Cache trait look-ups in the constructor where possible for Air activities/traits

This commit is contained in:
reaperrr
2015-03-14 03:59:37 +01:00
parent 9a780ba07d
commit 1e9d1a6cb7
22 changed files with 160 additions and 93 deletions

View File

@@ -59,16 +59,16 @@ namespace OpenRA.Mods.Cnc.Traits
return;
var altitude = self.World.Map.Rules.Actors[actorType].Traits.Get<PlaneInfo>().CruiseAltitude;
var a = w.CreateActor(actorType, new TypeDictionary
var actor = w.CreateActor(actorType, new TypeDictionary
{
new CenterPositionInit(w.Map.CenterOfCell(startPos) + new WVec(WRange.Zero, WRange.Zero, altitude)),
new OwnerInit(owner),
new FacingInit(64)
});
a.QueueActivity(new Fly(a, Target.FromCell(w, self.Location + new CVec(9, 0))));
a.QueueActivity(new Land(Target.FromActor(self)));
a.QueueActivity(new CallFunc(() =>
actor.QueueActivity(new Fly(actor, Target.FromCell(w, self.Location + new CVec(9, 0))));
actor.QueueActivity(new Land(actor, Target.FromActor(self)));
actor.QueueActivity(new CallFunc(() =>
{
if (!self.IsInWorld || self.IsDead)
return;
@@ -80,8 +80,8 @@ namespace OpenRA.Mods.Cnc.Traits
Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.ReadyAudio, self.Owner.Country.Race);
}));
a.QueueActivity(new Fly(a, Target.FromCell(w, endPos)));
a.QueueActivity(new RemoveSelf());
actor.QueueActivity(new Fly(actor, Target.FromCell(w, endPos)));
actor.QueueActivity(new RemoveSelf());
});
return true;