Misc constructor caching

Cache trait look-ups in constructor for various other traits and
activities.
This commit is contained in:
reaperrr
2015-03-14 04:00:39 +01:00
parent 1e9d1a6cb7
commit b52d055eec
11 changed files with 70 additions and 48 deletions

View File

@@ -30,6 +30,7 @@ namespace OpenRA.Mods.Common.Traits
class ScaredyCat : ITick, INotifyIdle, INotifyDamage, INotifyAttack, ISpeedModifier, ISync, IRenderInfantrySequenceModifier
{
readonly ScaredyCatInfo info;
readonly Mobile mobile;
[Sync] readonly Actor self;
[Sync] int panicStartedTick;
bool Panicking { get { return panicStartedTick > 0; } }
@@ -41,6 +42,7 @@ namespace OpenRA.Mods.Common.Traits
{
this.self = self;
this.info = info;
mobile = self.Trait<Mobile>();
}
public void Panic()
@@ -68,7 +70,7 @@ namespace OpenRA.Mods.Common.Traits
if (!Panicking)
return;
self.Trait<Mobile>().Nudge(self, self, true);
mobile.Nudge(self, self, true);
}
public void Damaged(Actor self, AttackInfo e)