ActorMap, avoid IPositionable trait lookup.
This commit is contained in:
committed by
Matthias Mailänder
parent
d72b1ffd49
commit
7c0f6ead3a
@@ -107,7 +107,7 @@ namespace OpenRA.Mods.Cnc.Traits
|
||||
|
||||
protected override void Created(Actor self)
|
||||
{
|
||||
iPositionable = self.TraitOrDefault<IPositionable>();
|
||||
iPositionable = self.OccupiesSpace as IPositionable;
|
||||
base.Created(self);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
public Parachute(Actor self)
|
||||
{
|
||||
pos = self.TraitOrDefault<IPositionable>();
|
||||
|
||||
pos = self.OccupiesSpace as IPositionable;
|
||||
fallVector = new WVec(0, 0, self.Info.TraitInfo<ParachutableInfo>().FallRate);
|
||||
IsInterruptible = false;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
protected override void Created(Actor self)
|
||||
{
|
||||
facing = self.TraitOrDefault<IFacing>();
|
||||
positionable = self.TraitOrDefault<IPositionable>();
|
||||
positionable = self.OccupiesSpace as IPositionable;
|
||||
notifyAiming = self.TraitsImplementing<INotifyAiming>().ToArray();
|
||||
|
||||
getArmaments = InitializeGetArmaments(self);
|
||||
|
||||
@@ -65,8 +65,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!info.ValidTargets.Overlaps(collector.GetEnabledTargetTypes()))
|
||||
return false;
|
||||
|
||||
var positionable = collector.TraitOrDefault<IPositionable>();
|
||||
if (positionable == null)
|
||||
if (collector.OccupiesSpace is not IPositionable positionable)
|
||||
return false;
|
||||
|
||||
return collector.World.Map.FindTilesInCircle(collector.Location, info.MaxRadius)
|
||||
@@ -83,7 +82,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public override void Activate(Actor collector)
|
||||
{
|
||||
var positionable = collector.Trait<IPositionable>();
|
||||
var positionable = collector.OccupiesSpace as IPositionable;
|
||||
var candidateCells = collector.World.Map.FindTilesInCircle(collector.Location, info.MaxRadius)
|
||||
.Where(c => positionable.CanEnterCell(c)).Shuffle(collector.World.SharedRandom)
|
||||
.ToArray();
|
||||
|
||||
@@ -355,8 +355,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (checkTransient)
|
||||
return true;
|
||||
|
||||
var pos = i.Actor.TraitOrDefault<IPositionable>();
|
||||
if (pos == null || !pos.IsLeavingCell(a, i.SubCell))
|
||||
// PERF: Avoid trait lookup
|
||||
if (i.Actor.OccupiesSpace is not IPositionable pos || !pos.IsLeavingCell(a, i.SubCell))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user