Misc constructor caching
Cache trait look-ups in constructor for various other traits and activities.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user