Actor properties consistency improved
This commit is contained in:
@@ -23,20 +23,33 @@ namespace OpenRA
|
||||
{
|
||||
public class Actor : IScriptBindable, IScriptNotifyBind, ILuaTableBinding, ILuaEqualityBinding, ILuaToStringBinding, IEquatable<Actor>
|
||||
{
|
||||
public readonly ActorInfo Info;
|
||||
[Sync] public Player Owner;
|
||||
|
||||
public readonly ActorInfo Info;
|
||||
public readonly World World;
|
||||
public readonly uint ActorID;
|
||||
public Lazy<Rectangle> Bounds;
|
||||
|
||||
Lazy<IOccupySpace> occupySpace;
|
||||
public bool IsInWorld { get; internal set; }
|
||||
public bool Destroyed { get; private set; }
|
||||
|
||||
Activity currentActivity;
|
||||
|
||||
public Group Group;
|
||||
public int Generation;
|
||||
|
||||
Lazy<Rectangle> bounds;
|
||||
Lazy<IFacing> facing;
|
||||
Lazy<Health> health;
|
||||
Lazy<IOccupySpace> occupySpace;
|
||||
Lazy<IEffectiveOwner> effectiveOwner;
|
||||
|
||||
public Rectangle Bounds { get { return bounds.Value; } }
|
||||
public IOccupySpace OccupiesSpace { get { return occupySpace.Value; } }
|
||||
public IEffectiveOwner EffectiveOwner { get { return effectiveOwner.Value; } }
|
||||
|
||||
public bool IsIdle { get { return currentActivity == null; } }
|
||||
public bool IsDead { get { return Destroyed || (health.Value == null ? false : health.Value.IsDead); } }
|
||||
|
||||
public CPos Location { get { return occupySpace.Value.TopLeft; } }
|
||||
public WPos CenterPosition { get { return occupySpace.Value.CenterPosition; } }
|
||||
|
||||
@@ -50,12 +63,6 @@ namespace OpenRA
|
||||
}
|
||||
}
|
||||
|
||||
[Sync] public Player Owner;
|
||||
|
||||
Activity currentActivity;
|
||||
public Group Group;
|
||||
public int Generation;
|
||||
|
||||
internal Actor(World world, string name, TypeDictionary initDict)
|
||||
{
|
||||
var init = new ActorInitializer(this, initDict);
|
||||
@@ -69,10 +76,12 @@ namespace OpenRA
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
if (!world.Map.Rules.Actors.ContainsKey(name.ToLowerInvariant()))
|
||||
throw new NotImplementedException("No rules definition for unit {0}".F(name.ToLowerInvariant()));
|
||||
name = name.ToLowerInvariant();
|
||||
|
||||
Info = world.Map.Rules.Actors[name.ToLowerInvariant()];
|
||||
if (!world.Map.Rules.Actors.ContainsKey(name))
|
||||
throw new NotImplementedException("No rules definition for unit " + name);
|
||||
|
||||
Info = world.Map.Rules.Actors[name];
|
||||
foreach (var trait in Info.TraitsInConstructOrder())
|
||||
AddTrait(trait.Create(init));
|
||||
}
|
||||
@@ -81,7 +90,7 @@ namespace OpenRA
|
||||
health = Exts.Lazy(() => TraitOrDefault<Health>());
|
||||
effectiveOwner = Exts.Lazy(() => TraitOrDefault<IEffectiveOwner>());
|
||||
|
||||
Bounds = Exts.Lazy(() =>
|
||||
bounds = Exts.Lazy(() =>
|
||||
{
|
||||
var si = Info.Traits.GetOrDefault<SelectableInfo>();
|
||||
var size = (si != null && si.Bounds != null) ? new int2(si.Bounds[0], si.Bounds[1]) :
|
||||
@@ -99,16 +108,12 @@ namespace OpenRA
|
||||
{
|
||||
var wasIdle = IsIdle;
|
||||
currentActivity = Traits.Util.RunActivity(this, currentActivity);
|
||||
|
||||
if (!wasIdle && IsIdle)
|
||||
foreach (var n in TraitsImplementing<INotifyBecomingIdle>())
|
||||
n.OnBecomingIdle(this);
|
||||
}
|
||||
|
||||
public bool IsIdle
|
||||
{
|
||||
get { return currentActivity == null; }
|
||||
}
|
||||
|
||||
public IEnumerable<IRenderable> Render(WorldRenderer wr)
|
||||
{
|
||||
var renderables = Renderables(wr);
|
||||
@@ -124,8 +129,6 @@ namespace OpenRA
|
||||
yield return renderable;
|
||||
}
|
||||
|
||||
public bool IsInWorld { get; internal set; }
|
||||
|
||||
public void QueueActivity(bool queued, Activity nextActivity)
|
||||
{
|
||||
if (!queued)
|
||||
@@ -198,8 +201,6 @@ namespace OpenRA
|
||||
World.traitDict.AddTrait(this, trait);
|
||||
}
|
||||
|
||||
public bool Destroyed { get; private set; }
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
World.AddFrameEndTask(w =>
|
||||
@@ -239,19 +240,6 @@ namespace OpenRA
|
||||
});
|
||||
}
|
||||
|
||||
public bool IsDead()
|
||||
{
|
||||
if (Destroyed)
|
||||
return true;
|
||||
|
||||
return (health.Value == null) ? false : health.Value.IsDead;
|
||||
}
|
||||
|
||||
public bool IsDisguised()
|
||||
{
|
||||
return effectiveOwner.Value != null && effectiveOwner.Value.Disguised;
|
||||
}
|
||||
|
||||
public void Kill(Actor attacker)
|
||||
{
|
||||
if (health.Value == null)
|
||||
|
||||
@@ -81,7 +81,8 @@ namespace OpenRA.Graphics
|
||||
if (Game.Settings.Game.TeamHealthColors)
|
||||
{
|
||||
var isAlly = actor.Owner.IsAlliedWith(actor.World.LocalPlayer)
|
||||
|| (actor.IsDisguised() && actor.World.LocalPlayer.IsAlliedWith(actor.EffectiveOwner.Owner));
|
||||
|| (actor.EffectiveOwner != null && actor.EffectiveOwner.Disguised
|
||||
&& actor.World.LocalPlayer.IsAlliedWith(actor.EffectiveOwner.Owner));
|
||||
return isAlly ? Color.LimeGreen : actor.Owner.NonCombatant ? Color.Tan : Color.Red;
|
||||
}
|
||||
else
|
||||
@@ -137,13 +138,13 @@ namespace OpenRA.Graphics
|
||||
public void BeforeRender(WorldRenderer wr) {}
|
||||
public void Render(WorldRenderer wr)
|
||||
{
|
||||
if (!actor.IsInWorld || actor.IsDead())
|
||||
if (!actor.IsInWorld || actor.IsDead)
|
||||
return;
|
||||
|
||||
var health = actor.TraitOrDefault<Health>();
|
||||
|
||||
var screenPos = wr.ScreenPxPosition(pos);
|
||||
var bounds = actor.Bounds.Value;
|
||||
var bounds = actor.Bounds;
|
||||
bounds.Offset(screenPos.X, screenPos.Y);
|
||||
|
||||
var xy = new float2(bounds.Left, bounds.Top);
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA.Graphics
|
||||
readonly Color color;
|
||||
|
||||
public SelectionBoxRenderable(Actor actor, Color color)
|
||||
: this(actor.CenterPosition, actor.Bounds.Value, 1f, color) { }
|
||||
: this(actor.CenterPosition, actor.Bounds, 1f, color) { }
|
||||
|
||||
public SelectionBoxRenderable(WPos pos, Rectangle bounds, float scale, Color color)
|
||||
{
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenRA.Scripting
|
||||
protected override string MemberNotFoundError(string memberName)
|
||||
{
|
||||
var actorName = actor.Info.Name;
|
||||
if (actor.IsDead())
|
||||
if (actor.IsDead)
|
||||
actorName += " (dead)";
|
||||
|
||||
return "Actor '{0}' does not define a property '{1}'".F(actorName, memberName);
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace OpenRA
|
||||
return;
|
||||
}
|
||||
|
||||
var groupActors = controlGroups[group].Where(a => !a.IsDead());
|
||||
var groupActors = controlGroups[group].Where(a => !a.IsDead);
|
||||
|
||||
if (mods.HasModifier(Modifiers.Alt) || MultiTapCount >= 2)
|
||||
{
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace OpenRA.Traits
|
||||
foreach (var nd in self.TraitsImplementing<INotifyDamageStateChanged>())
|
||||
nd.DamageStateChanged(self, ai);
|
||||
|
||||
if (Info.NotifyAppliedDamage && repairer != null && repairer.IsInWorld && !repairer.IsDead())
|
||||
if (Info.NotifyAppliedDamage && repairer != null && repairer.IsInWorld && !repairer.IsDead)
|
||||
foreach (var nd in repairer.TraitsImplementing<INotifyAppliedDamage>()
|
||||
.Concat(repairer.Owner.PlayerActor.TraitsImplementing<INotifyAppliedDamage>()))
|
||||
nd.AppliedDamage(repairer, self, ai);
|
||||
@@ -141,7 +141,7 @@ namespace OpenRA.Traits
|
||||
foreach (var nd in self.TraitsImplementing<INotifyDamageStateChanged>())
|
||||
nd.DamageStateChanged(self, ai);
|
||||
|
||||
if (Info.NotifyAppliedDamage && attacker != null && attacker.IsInWorld && !attacker.IsDead())
|
||||
if (Info.NotifyAppliedDamage && attacker != null && attacker.IsInWorld && !attacker.IsDead)
|
||||
foreach (var nd in attacker.TraitsImplementing<INotifyAppliedDamage>()
|
||||
.Concat(attacker.Owner.PlayerActor.TraitsImplementing<INotifyAppliedDamage>()))
|
||||
nd.AppliedDamage(attacker, self, ai);
|
||||
|
||||
@@ -47,13 +47,13 @@ namespace OpenRA.Traits
|
||||
FootprintRegion = footprintRegion;
|
||||
|
||||
CenterPosition = self.CenterPosition;
|
||||
Bounds = self.Bounds.Value;
|
||||
Bounds = self.Bounds;
|
||||
}
|
||||
|
||||
public uint ID { get { return actor.ActorID; } }
|
||||
public bool IsValid { get { return Owner != null && HasRenderables; } }
|
||||
public ActorInfo Info { get { return actor.Info; } }
|
||||
public Actor Actor { get { return !actor.IsDead() ? actor : null; } }
|
||||
public Actor Actor { get { return !actor.IsDead ? actor : null; } }
|
||||
|
||||
int flashTicks;
|
||||
public void Tick(World world, Shroud shroud)
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Traits
|
||||
|
||||
IEnumerable<WPos> ActivityTargetPath()
|
||||
{
|
||||
if (!self.IsInWorld || self.IsDead())
|
||||
if (!self.IsInWorld || self.IsDead)
|
||||
yield break;
|
||||
|
||||
var activity = self.GetCurrentActivity();
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Traits
|
||||
if (!self.Owner.IsAlliedWith(self.World.RenderPlayer) && self.World.FogObscures(self))
|
||||
yield break;
|
||||
|
||||
var b = self.Bounds.Value;
|
||||
var b = self.Bounds;
|
||||
var pos = wr.ScreenPxPosition(self.CenterPosition);
|
||||
var tl = wr.Viewport.WorldToViewPx(pos + new int2(b.Left, b.Top));
|
||||
var bl = wr.Viewport.WorldToViewPx(pos + new int2(b.Left, b.Bottom));
|
||||
@@ -85,7 +85,7 @@ namespace OpenRA.Traits
|
||||
var pipxyBase = basePosition + new int2(1 - pipSize.X / 2, - (3 + pipSize.Y / 2));
|
||||
var pipxyOffset = new int2(0, 0);
|
||||
var pal = wr.Palette(Info.Palette);
|
||||
var width = self.Bounds.Value.Width;
|
||||
var width = self.Bounds.Width;
|
||||
|
||||
foreach (var pips in pipSources)
|
||||
{
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA.Traits
|
||||
if (type == TargetType.Actor)
|
||||
{
|
||||
// Actor is no longer in the world
|
||||
if (!actor.IsInWorld || actor.IsDead())
|
||||
if (!actor.IsInWorld || actor.IsDead)
|
||||
return TargetType.Invalid;
|
||||
|
||||
// Actor generation has changed (teleported or captured)
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace OpenRA.Traits
|
||||
public void Add(Actor a)
|
||||
{
|
||||
var pos = worldRenderer.ScreenPxPosition(a.CenterPosition);
|
||||
var bounds = a.Bounds.Value;
|
||||
var bounds = a.Bounds;
|
||||
bounds.Offset(pos.X, pos.Y);
|
||||
|
||||
var top = Math.Max(0, bounds.Top / info.BinSize);
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.Cnc
|
||||
case State.Dock:
|
||||
ru.PlayCustomAnimation(self, "dock", () => {
|
||||
ru.PlayCustomAnimRepeating(self, "dock-loop");
|
||||
if (proc.IsInWorld && !proc.IsDead())
|
||||
if (proc.IsInWorld && !proc.IsDead)
|
||||
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
|
||||
nd.Docked(proc, self);
|
||||
state = State.Loop;
|
||||
@@ -63,12 +63,12 @@ namespace OpenRA.Mods.Cnc
|
||||
state = State.Wait;
|
||||
return this;
|
||||
case State.Loop:
|
||||
if (!proc.IsInWorld || proc.IsDead() || harv.TickUnload(self, proc))
|
||||
if (!proc.IsInWorld || proc.IsDead || harv.TickUnload(self, proc))
|
||||
state = State.Undock;
|
||||
return this;
|
||||
case State.Undock:
|
||||
ru.PlayCustomAnimBackwards(self, "dock", () => state = State.DragOut);
|
||||
if (proc.IsInWorld && !proc.IsDead())
|
||||
if (proc.IsInWorld && !proc.IsDead)
|
||||
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
|
||||
nd.Undocked(proc, self);
|
||||
state = State.Wait;
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
a.QueueActivity(new Land(Target.FromActor(self)));
|
||||
a.QueueActivity(new CallFunc(() =>
|
||||
{
|
||||
if (!self.IsInWorld || self.IsDead())
|
||||
if (!self.IsInWorld || self.IsDead)
|
||||
return;
|
||||
|
||||
foreach (var cargo in self.TraitsImplementing<INotifyDelivery>())
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
if (!a.IsInWorld || a.IsDead() || !a.Trait<CanPowerDown>().Disabled)
|
||||
if (!a.IsInWorld || a.IsDead || !a.Trait<CanPowerDown>().Disabled)
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
|
||||
anim.Tick();
|
||||
|
||||
@@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Effects
|
||||
circles.Play("circles");
|
||||
}
|
||||
|
||||
if (!building.IsInWorld || building.IsDead())
|
||||
if (!building.IsInWorld || building.IsDead)
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
}
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ namespace OpenRA.Mods.Common.Power
|
||||
{
|
||||
var actors = self.World.ActorsWithTrait<AffectedByPowerOutage>()
|
||||
.Select(tp => tp.Actor)
|
||||
.Where(a => !a.IsDead() && a.IsInWorld && a.Owner == self.Owner);
|
||||
.Where(a => !a.IsDead && a.IsInWorld && a.Owner == self.Owner);
|
||||
|
||||
UpdateActors(actors);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common
|
||||
{
|
||||
if (claim.Claimer.Destroyed) return;
|
||||
if (!claim.Claimer.IsInWorld) return;
|
||||
if (claim.Claimer.IsDead()) return;
|
||||
if (claim.Claimer.IsDead) return;
|
||||
|
||||
claim.Claimer.Trait<INotifyResourceClaimLost>().OnNotifyResourceClaimLost(claim.Claimer, claim, claimer);
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ namespace OpenRA.Mods.RA.AI
|
||||
|
||||
List<Actor> FindEnemyConstructionYards()
|
||||
{
|
||||
return world.Actors.Where(a => p.Stances[a.Owner] == Stance.Enemy && !a.IsDead()
|
||||
return world.Actors.Where(a => p.Stances[a.Owner] == Stance.Enemy && !a.IsDead
|
||||
&& a.HasTrait<BaseBuilding>() && !a.HasTrait<Mobile>()).ToList();
|
||||
}
|
||||
|
||||
@@ -483,7 +483,7 @@ namespace OpenRA.Mods.RA.AI
|
||||
{
|
||||
squads.RemoveAll(s => !s.IsValid);
|
||||
foreach (var s in squads)
|
||||
s.units.RemoveAll(a => a.IsDead() || a.Owner != p);
|
||||
s.units.RemoveAll(a => a.IsDead || a.Owner != p);
|
||||
}
|
||||
|
||||
// Use of this function requires that one squad of this type. Hence it is a piece of shit
|
||||
@@ -506,8 +506,8 @@ namespace OpenRA.Mods.RA.AI
|
||||
void AssignRolesToIdleUnits(Actor self)
|
||||
{
|
||||
CleanSquads();
|
||||
activeUnits.RemoveAll(a => a.IsDead() || a.Owner != p);
|
||||
unitsHangingAroundTheBase.RemoveAll(a => a.IsDead() || a.Owner != p);
|
||||
activeUnits.RemoveAll(a => a.IsDead || a.Owner != p);
|
||||
unitsHangingAroundTheBase.RemoveAll(a => a.IsDead || a.Owner != p);
|
||||
|
||||
if (--rushTicks <= 0)
|
||||
{
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.RA.AI
|
||||
else
|
||||
{
|
||||
var enemies = owner.world.FindActorsInCircle(leader.CenterPosition, WRange.FromCells(12))
|
||||
.Where(a1 => !a1.Destroyed && !a1.IsDead()).ToList();
|
||||
.Where(a1 => !a1.Destroyed && !a1.IsDead).ToList();
|
||||
var enemynearby = enemies.Where(a1 => a1.HasTrait<ITargetable>() && leader.Owner.Stances[a1.Owner] == Stance.Enemy).ToList();
|
||||
if (enemynearby.Any())
|
||||
{
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
if (IsCanceled || self.IsDead())
|
||||
if (IsCanceled || self.IsDead)
|
||||
return NextActivity;
|
||||
|
||||
if (!isCalculated)
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
protected override void OnInside(Actor self)
|
||||
{
|
||||
if (actor.IsDead() || capturable.BeingCaptured)
|
||||
if (actor.IsDead || capturable.BeingCaptured)
|
||||
return;
|
||||
|
||||
var b = actor.TraitOrDefault<Building>();
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
if (b != null && b.Locked)
|
||||
b.Unlock();
|
||||
|
||||
if (actor.IsDead() || capturable.BeingCaptured)
|
||||
if (actor.IsDead || capturable.BeingCaptured)
|
||||
return;
|
||||
|
||||
var health = actor.Trait<Health>();
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
if (target.IsDead())
|
||||
if (target.IsDead)
|
||||
return;
|
||||
|
||||
for (var f = 0; f < flashes; f++)
|
||||
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
w.Add(new DelayedAction(delay, () =>
|
||||
{
|
||||
if (target.IsDead())
|
||||
if (target.IsDead)
|
||||
return;
|
||||
|
||||
var modifiers = target.TraitsImplementing<IDamageModifier>()
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
protected override void OnInside(Actor self)
|
||||
{
|
||||
if (target.IsDead())
|
||||
if (target.IsDead)
|
||||
return;
|
||||
|
||||
target.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(payload);
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
{
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
if (self.IsDead() || transport.IsDead() || !cargo.CanLoad(transport, self))
|
||||
if (self.IsDead || transport.IsDead || !cargo.CanLoad(transport, self))
|
||||
return;
|
||||
|
||||
cargo.Load(transport, self);
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
var capturable = target.Actor.Trait<ExternalCapturable>();
|
||||
|
||||
if (IsCanceled || !self.IsInWorld || self.IsDead() || !target.IsValidFor(self))
|
||||
if (IsCanceled || !self.IsInWorld || self.IsDead || !target.IsValidFor(self))
|
||||
{
|
||||
if (capturable.CaptureInProgress)
|
||||
capturable.EndCapture();
|
||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
if (target.Actor.IsDead())
|
||||
if (target.Actor.IsDead)
|
||||
return;
|
||||
|
||||
var oldOwner = target.Actor.Owner;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
public Hunt(Actor self)
|
||||
{
|
||||
var attack = self.Trait<AttackBase>();
|
||||
targets = self.World.Actors.Where(a => self != a && !a.IsDead() && a.IsInWorld && a.AppearsHostileTo(self)
|
||||
targets = self.World.Actors.Where(a => self != a && !a.IsDead && a.IsInWorld && a.AppearsHostileTo(self)
|
||||
&& a.HasTrait<Huntable>() && attack.HasAnyValidWeapons(Target.FromActor(a)));
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
protected override void OnInside(Actor self)
|
||||
{
|
||||
if (target.IsDead() || target.Owner == self.Owner)
|
||||
if (target.IsDead || target.Owner == self.Owner)
|
||||
return;
|
||||
|
||||
foreach (var t in target.TraitsImplementing<INotifyInfiltrated>())
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA
|
||||
case State.Dock:
|
||||
ru.PlayCustomAnimation(self, "dock", () => {
|
||||
ru.PlayCustomAnimRepeating(self, "dock-loop");
|
||||
if (proc.IsInWorld && !proc.IsDead())
|
||||
if (proc.IsInWorld && !proc.IsDead)
|
||||
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
|
||||
nd.Docked(proc, self);
|
||||
state = State.Loop;
|
||||
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.RA
|
||||
state = State.Wait;
|
||||
return this;
|
||||
case State.Loop:
|
||||
if (!proc.IsInWorld || proc.IsDead() || harv.TickUnload(self, proc))
|
||||
if (!proc.IsInWorld || proc.IsDead || harv.TickUnload(self, proc))
|
||||
state = State.Undock;
|
||||
return this;
|
||||
case State.Undock:
|
||||
@@ -65,7 +65,7 @@ namespace OpenRA.Mods.RA
|
||||
case State.Complete:
|
||||
harv.LastLinkedProc = harv.LinkedProc;
|
||||
harv.LinkProc(self, null);
|
||||
if (proc.IsInWorld && !proc.IsDead())
|
||||
if (proc.IsInWorld && !proc.IsDead)
|
||||
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
|
||||
nd.Undocked(proc, self);
|
||||
return NextActivity;
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace OpenRA.Mods.RA.Activities
|
||||
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
if (self.IsDead())
|
||||
if (self.IsDead)
|
||||
return;
|
||||
|
||||
foreach (var nt in self.TraitsImplementing<INotifyTransform>())
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA
|
||||
if (stance == Stance.Ally)
|
||||
return true;
|
||||
|
||||
if (self.IsDisguised() && !toActor.HasTrait<IgnoresDisguise>())
|
||||
if (self.EffectiveOwner != null && self.EffectiveOwner.Disguised && !toActor.HasTrait<IgnoresDisguise>())
|
||||
return toActor.Owner.Stances[self.EffectiveOwner.Owner] == Stance.Ally;
|
||||
|
||||
return stance == Stance.Ally;
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA
|
||||
if (stance == Stance.Ally)
|
||||
return false; /* otherwise, we'll hate friendly disguised spies */
|
||||
|
||||
if (self.IsDisguised() && !toActor.HasTrait<IgnoresDisguise>())
|
||||
if (self.EffectiveOwner != null && self.EffectiveOwner.Disguised && !toActor.HasTrait<IgnoresDisguise>())
|
||||
return toActor.Owner.Stances[self.EffectiveOwner.Owner] == Stance.Enemy;
|
||||
|
||||
return stance == Stance.Enemy;
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
var target = inRange
|
||||
.Where(a => a != self && a.AppearsFriendlyTo(self))
|
||||
.Where(a => a.IsInWorld && !a.IsDead())
|
||||
.Where(a => a.IsInWorld && !a.IsDead)
|
||||
.Where(a => a.GetDamageState() > DamageState.Undamaged)
|
||||
.Where(a => attack.HasAnyValidWeapons(Target.FromActor(a)))
|
||||
.ClosestTo(self);
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
if (!self.IsDead())
|
||||
if (!self.IsDead)
|
||||
w.Add(new RepairIndicator(self, Info.IndicatorPalettePrefix));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA.Mods.RA.Crates
|
||||
{
|
||||
foreach (var a in actorsInRange.Append(collector))
|
||||
{
|
||||
if (!a.IsInWorld || a.IsDead())
|
||||
if (!a.IsInWorld || a.IsDead)
|
||||
continue;
|
||||
|
||||
var um = a.TraitOrDefault<UpgradeManager>();
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
|
||||
show = false;
|
||||
if (!self.IsInWorld || self.IsDead() || self.World.RenderPlayer == null)
|
||||
if (!self.IsInWorld || self.IsDead || self.World.RenderPlayer == null)
|
||||
return;
|
||||
|
||||
var gps = watcher[self.World.RenderPlayer];
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
if (self.IsDead())
|
||||
if (self.IsDead)
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
else
|
||||
anim.Tick();
|
||||
@@ -44,7 +44,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
if (!self.IsInWorld)
|
||||
yield break;
|
||||
|
||||
if (self.IsDead())
|
||||
if (self.IsDead)
|
||||
yield break;
|
||||
|
||||
if (!self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
||||
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
yield break;
|
||||
|
||||
var pos = wr.ScreenPxPosition(self.CenterPosition);
|
||||
var bounds = self.Bounds.Value;
|
||||
var bounds = self.Bounds;
|
||||
bounds.Offset(pos.X, pos.Y);
|
||||
|
||||
var palette = wr.Palette(paletteName);
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.RA.Effects
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
if (!building.IsInWorld || building.IsDead() ||
|
||||
if (!building.IsInWorld || building.IsDead ||
|
||||
rb == null || !rb.Repairers.Any())
|
||||
world.AddFrameEndTask(w => w.Remove(this));
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (Captor != null && (!Captor.IsInWorld || Captor.IsDead()))
|
||||
if (Captor != null && (!Captor.IsInWorld || Captor.IsDead))
|
||||
EndCapture();
|
||||
|
||||
if (!CaptureInProgress)
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
if (!self.IsDead())
|
||||
if (!self.IsDead)
|
||||
w.Add(new Rank(self, info.ChevronPalette));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
var target = FriendlyGuardableUnits(world, mi).FirstOrDefault();
|
||||
|
||||
if (target == null || subjects.All(s => s.IsDead()))
|
||||
if (target == null || subjects.All(s => s.IsDead))
|
||||
yield break;
|
||||
|
||||
foreach (var subject in subjects)
|
||||
@@ -74,7 +74,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
if (subjects.All(s => s.IsDead() || !s.HasTrait<Guard>()))
|
||||
if (subjects.All(s => s.IsDead || !s.HasTrait<Guard>()))
|
||||
world.CancelInputMode();
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace OpenRA.Mods.RA
|
||||
static IEnumerable<Actor> FriendlyGuardableUnits(World world, MouseInput mi)
|
||||
{
|
||||
return world.ScreenMap.ActorsAt(mi)
|
||||
.Where(a => !world.FogObscures(a) && !a.IsDead() &&
|
||||
.Where(a => !world.FogObscures(a) && !a.IsDead &&
|
||||
a.AppearsFriendlyTo(world.LocalPlayer.PlayerActor) &&
|
||||
a.HasTrait<Guardable>());
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
void Kill()
|
||||
{
|
||||
if (self.IsDead())
|
||||
if (self.IsDead)
|
||||
return;
|
||||
|
||||
if (info.RemoveInstead || !self.HasTrait<Health>())
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
if (!minelayer.IsInWorld || minelayer.IsDead())
|
||||
if (!minelayer.IsInWorld || minelayer.IsDead)
|
||||
world.CancelInputMode();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,14 +76,14 @@ namespace OpenRA.Mods.RA
|
||||
preventDock = true;
|
||||
|
||||
// Cancel the dock sequence
|
||||
if (dockedHarv != null && !dockedHarv.IsDead())
|
||||
if (dockedHarv != null && !dockedHarv.IsDead)
|
||||
dockedHarv.CancelActivity();
|
||||
}
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
// Harvester was killed while unloading
|
||||
if (dockedHarv != null && dockedHarv.IsDead())
|
||||
if (dockedHarv != null && dockedHarv.IsDead)
|
||||
{
|
||||
self.Trait<RenderBuilding>().CancelCustomAnim(self);
|
||||
dockedHarv = null;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
var prevItems = GetNumBuildables(self.Owner);
|
||||
|
||||
if (order.TargetActor.IsDead())
|
||||
if (order.TargetActor.IsDead)
|
||||
return;
|
||||
|
||||
var unit = self.World.Map.Rules.Actors[order.TargetString];
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
var total = (double)world.Map.Bounds.Width * world.Map.Bounds.Height;
|
||||
MapControl = world.Actors
|
||||
.Where(a => !a.IsDead() && a.IsInWorld && a.Owner == player && a.HasTrait<RevealsShroud>())
|
||||
.Where(a => !a.IsDead && a.IsInWorld && a.Owner == player && a.HasTrait<RevealsShroud>())
|
||||
.SelectMany(a => world.Map.FindTilesInCircle(
|
||||
a.Location,
|
||||
a.Trait<RevealsShroud>().Range.Clamp(WRange.Zero, WRange.FromCells(Map.MaxTilesInCircleRange)).Range / 1024))
|
||||
|
||||
@@ -372,7 +372,7 @@ namespace OpenRA.Mods.RA
|
||||
protected virtual bool BuildUnit(string name)
|
||||
{
|
||||
// Cannot produce if i'm dead
|
||||
if (!self.IsInWorld || self.IsDead())
|
||||
if (!self.IsInWorld || self.IsDead)
|
||||
{
|
||||
CancelProduction(name, 1);
|
||||
return true;
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
// Add all actors that provide prerequisites
|
||||
var prerequisites = player.World.ActorsWithTrait<ITechTreePrerequisite>()
|
||||
.Where(a => a.Actor.Owner == player && a.Actor.IsInWorld && !a.Actor.IsDead());
|
||||
.Where(a => a.Actor.Owner == player && a.Actor.IsInWorld && !a.Actor.IsDead);
|
||||
|
||||
foreach (var b in prerequisites)
|
||||
{
|
||||
@@ -96,7 +96,7 @@ namespace OpenRA.Mods.RA
|
||||
.Where(a =>
|
||||
a.Actor.Owner == player &&
|
||||
a.Actor.IsInWorld &&
|
||||
!a.Actor.IsDead() &&
|
||||
!a.Actor.IsDead &&
|
||||
!ret.ContainsKey(a.Actor.Info.Name) &&
|
||||
a.Actor.Info.Traits.Get<BuildableInfo>().BuildLimit > 0)
|
||||
.Do(b => ret[b.Actor.Info.Name].Add(b.Actor));
|
||||
|
||||
@@ -164,7 +164,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public void Tick(World world)
|
||||
{
|
||||
if (!self.IsInWorld || self.IsDead())
|
||||
if (!self.IsInWorld || self.IsDead)
|
||||
world.CancelInputMode();
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace OpenRA.Mods.RA
|
||||
public Production(ProductionInfo info, Actor self)
|
||||
{
|
||||
Info = info;
|
||||
rp = Exts.Lazy(() => self.IsDead() ? null : self.TraitOrDefault<RallyPoint>());
|
||||
rp = Exts.Lazy(() => self.IsDead ? null : self.TraitOrDefault<RallyPoint>());
|
||||
}
|
||||
|
||||
public void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo, string raceVariant)
|
||||
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
newUnit.SetTargetLine(target, rp.Value != null ? Color.Red : Color.Green, false);
|
||||
|
||||
if (!self.IsDead())
|
||||
if (!self.IsDead)
|
||||
foreach (var t in self.TraitsImplementing<INotifyProduction>())
|
||||
t.UnitProduced(self, newUnit, exit);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
public IEnumerable<IRenderable> Render(Actor self, WorldRenderer wr)
|
||||
{
|
||||
var pos = wr.ScreenPxPosition(self.CenterPosition);
|
||||
var bounds = self.Bounds.Value;
|
||||
var bounds = self.Bounds;
|
||||
bounds.Offset(pos.X, pos.Y);
|
||||
var spaceBuffer = (int)(10 / wr.Viewport.Zoom);
|
||||
var effectPos = wr.Position(new int2(pos.X, bounds.Y - spaceBuffer));
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace OpenRA.Mods.RA.Render
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
var isFlying = movement.IsMoving && !self.IsDead();
|
||||
var isFlying = movement.IsMoving && !self.IsDead;
|
||||
if (isFlying ^ (rotorAnim.CurrentSequence.Name != info.Sequence))
|
||||
return;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
}
|
||||
|
||||
[Desc("Specifies whether the actor is alive or dead.")]
|
||||
public bool IsDead { get { return self.IsDead(); } }
|
||||
public bool IsDead { get { return self.IsDead; } }
|
||||
|
||||
[Desc("Specifies whether the actor is idle (not performing any activities).")]
|
||||
public bool IsIdle { get { return self.IsIdle; } }
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
public Actor[] GetGroundAttackers()
|
||||
{
|
||||
return player.World.ActorsWithTrait<AttackBase>().Select(a => a.Actor)
|
||||
.Where(a => a.Owner == player && !a.IsDead() && a.IsInWorld && a.HasTrait<Mobile>())
|
||||
.Where(a => a.Owner == player && !a.IsDead && a.IsInWorld && a.HasTrait<Mobile>())
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
if (squad.Count >= squadSize)
|
||||
{
|
||||
using (func)
|
||||
using (var luaSquad = squad.Where(u => !u.IsDead()).ToArray().ToLuaValue(context))
|
||||
using (var luaSquad = squad.Where(u => !u.IsDead).ToArray().ToLuaValue(context))
|
||||
func.Call(luaSquad).Dispose();
|
||||
|
||||
triggers.OnProducedInternal -= productionHandler;
|
||||
@@ -230,7 +230,7 @@ namespace OpenRA.Mods.RA.Scripting
|
||||
if (squad.Count >= squadSize)
|
||||
{
|
||||
using (func)
|
||||
using (var luaSquad = squad.Where(u => !u.IsDead()).ToArray().ToLuaValue(context))
|
||||
using (var luaSquad = squad.Where(u => !u.IsDead).ToArray().ToLuaValue(context))
|
||||
func.Call(luaSquad).Dispose();
|
||||
|
||||
foreach (var q in queueTypes)
|
||||
|
||||
@@ -60,7 +60,7 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
public void Tick(Actor self)
|
||||
{
|
||||
if (self.IsDead() || disabled)
|
||||
if (self.IsDead || disabled)
|
||||
return;
|
||||
|
||||
if (health.HP >= info.HealIfBelow * health.MaxHP)
|
||||
|
||||
@@ -95,7 +95,7 @@ namespace OpenRA.Mods.RA.Traits
|
||||
return WVec.Zero;
|
||||
|
||||
return self.World.FindActorsInCircle(self.CenterPosition, info.IdealSeparation)
|
||||
.Where(a => !a.IsDead() && a.HasTrait<Aircraft>())
|
||||
.Where(a => !a.IsDead && a.HasTrait<Aircraft>())
|
||||
.Select(GetRepulsionForce)
|
||||
.Aggregate(WVec.Zero, (a, b) => a + b);
|
||||
}
|
||||
|
||||
@@ -244,11 +244,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
|
||||
var assets = template.Get<LabelWidget>("ASSETS");
|
||||
assets.GetText = () => "$" + world.Actors
|
||||
.Where(a => a.Owner == player && !a.IsDead() && a.Info.Traits.WithInterface<ValuedInfo>().Any())
|
||||
.Where(a => a.Owner == player && !a.IsDead && a.Info.Traits.WithInterface<ValuedInfo>().Any())
|
||||
.Sum(a => a.Info.Traits.WithInterface<ValuedInfo>().First().Cost);
|
||||
|
||||
var harvesters = template.Get<LabelWidget>("HARVESTERS");
|
||||
harvesters.GetText = () => world.Actors.Count(a => a.Owner == player && !a.IsDead() && a.HasTrait<Harvester>()).ToString();
|
||||
harvesters.GetText = () => world.Actors.Count(a => a.Owner == player && !a.IsDead && a.HasTrait<Harvester>()).ToString();
|
||||
|
||||
return template;
|
||||
}
|
||||
@@ -282,7 +282,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
{
|
||||
return ScrollItemWidget.Setup(template, () => false, () =>
|
||||
{
|
||||
var playerBase = world.Actors.FirstOrDefault(a => !a.IsDead() && a.HasTrait<BaseBuilding>() && a.Owner == player);
|
||||
var playerBase = world.Actors.FirstOrDefault(a => !a.IsDead && a.HasTrait<BaseBuilding>() && a.Owner == player);
|
||||
if (playerBase != null)
|
||||
worldRenderer.Viewport.Center(playerBase.CenterPosition);
|
||||
});
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA.Widgets
|
||||
public SupportPowerTimerWidget(World world)
|
||||
{
|
||||
powers = world.ActorsWithTrait<SupportPowerManager>()
|
||||
.Where(p => !p.Actor.IsDead() && !p.Actor.Owner.NonCombatant)
|
||||
.Where(p => !p.Actor.IsDead && !p.Actor.Owner.NonCombatant)
|
||||
.SelectMany(s => s.Trait.Powers.Values)
|
||||
.Where(p => p.Instances.Any() && p.Info.DisplayTimer && !p.Disabled);
|
||||
}
|
||||
|
||||
@@ -43,18 +43,18 @@ namespace OpenRA.Mods.TS
|
||||
state = State.Dock;
|
||||
return Util.SequenceActivities(new Turn(self, 160), this);
|
||||
case State.Dock:
|
||||
if (proc.IsInWorld && !proc.IsDead())
|
||||
if (proc.IsInWorld && !proc.IsDead)
|
||||
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
|
||||
nd.Docked(proc, self);
|
||||
state = State.Loop;
|
||||
body.Docked = true;
|
||||
return this;
|
||||
case State.Loop:
|
||||
if (!proc.IsInWorld || proc.IsDead() || harv.TickUnload(self, proc))
|
||||
if (!proc.IsInWorld || proc.IsDead || harv.TickUnload(self, proc))
|
||||
state = State.Undock;
|
||||
return this;
|
||||
case State.Undock:
|
||||
if (proc.IsInWorld && !proc.IsDead())
|
||||
if (proc.IsInWorld && !proc.IsDead)
|
||||
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
|
||||
nd.Undocked(proc, self);
|
||||
body.Docked = false;
|
||||
|
||||
Reference in New Issue
Block a user