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