Merge pull request #9981 from teees/gates-trait
Added gates to Tiberian Sun
This commit is contained in:
@@ -373,6 +373,28 @@ namespace OpenRA
|
||||
|
||||
return InvalidValueAction(value, fieldType, fieldName);
|
||||
}
|
||||
else if (fieldType == typeof(CVec[]))
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
var parts = value.Split(',');
|
||||
|
||||
if (parts.Length % 2 != 0)
|
||||
return InvalidValueAction(value, fieldType, fieldName);
|
||||
|
||||
var vecs = new CVec[parts.Length / 2];
|
||||
for (var i = 0; i < vecs.Length; i++)
|
||||
{
|
||||
int rx, ry;
|
||||
if (int.TryParse(parts[2 * i], out rx) && int.TryParse(parts[2 * i + 1], out ry))
|
||||
vecs[i] = new CVec(rx, ry);
|
||||
}
|
||||
|
||||
return vecs;
|
||||
}
|
||||
|
||||
return InvalidValueAction(value, fieldType, fieldName);
|
||||
}
|
||||
else if (fieldType.IsEnum)
|
||||
{
|
||||
try
|
||||
|
||||
@@ -284,6 +284,13 @@ namespace OpenRA.Traits
|
||||
bool CanEnterTargetNow(Actor self, Target target);
|
||||
}
|
||||
|
||||
[RequireExplicitImplementation]
|
||||
public interface ITemporaryBlocker
|
||||
{
|
||||
bool CanRemoveBlockage(Actor self, Actor blocking);
|
||||
bool IsBlocking(Actor self, CPos cell);
|
||||
}
|
||||
|
||||
public interface INotifyBlockingMove { void OnNotifyBlockingMove(Actor self, Actor blocking); }
|
||||
|
||||
public interface IFacing
|
||||
|
||||
@@ -37,6 +37,23 @@ namespace OpenRA
|
||||
a => (a.CenterPosition - origin).HorizontalLengthSquared <= r.LengthSquared);
|
||||
}
|
||||
|
||||
public static bool ContainsTemporaryBlocker(this World world, CPos cell, Actor ignoreActor = null)
|
||||
{
|
||||
var temporaryBlockers = world.ActorMap.GetActorsAt(cell);
|
||||
foreach (var temporaryBlocker in temporaryBlockers)
|
||||
{
|
||||
if (temporaryBlocker == ignoreActor)
|
||||
continue;
|
||||
|
||||
var temporaryBlockerTraits = temporaryBlocker.TraitsImplementing<ITemporaryBlocker>();
|
||||
foreach (var temporaryBlockerTrait in temporaryBlockerTraits)
|
||||
if (temporaryBlockerTrait.IsBlocking(temporaryBlocker, cell))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void DoTimed<T>(this IEnumerable<T> e, Action<T> a, string text)
|
||||
{
|
||||
// PERF: This is a hot path and must run with minimal added overhead.
|
||||
|
||||
Reference in New Issue
Block a user