Skip to content

Commit

Permalink
Update locomotor cache when Crushable is enabled/disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
teinarss committed Aug 5, 2019
1 parent 8046a0c commit b25f0c8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions OpenRA.Game/Traits/TraitsInterfaces.cs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ public interface IActorMap
WDist LargestBlockingActorRadius { get; }

event Action<CPos> UpdateCell;
void MarkAsDirty(IOccupySpace selfOccupiesSpace);
}

[RequireExplicitImplementation]
Expand Down
10 changes: 10 additions & 0 deletions OpenRA.Mods.Common/Traits/Crushable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,15 @@ bool CrushableInner(BitSet<CrushClass> crushClasses, Player crushOwner)

return Info.CrushClasses.Overlaps(crushClasses);
}

protected override void TraitEnabled(Actor self)
{
self.World.ActorMap.MarkAsDirty(self.OccupiesSpace);
}

protected override void TraitDisabled(Actor self)
{
self.World.ActorMap.MarkAsDirty(self.OccupiesSpace);
}
}
}
7 changes: 7 additions & 0 deletions OpenRA.Mods.Common/Traits/World/ActorMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,13 @@ static void RemoveInfluenceInner(ref InfluenceNode influenceNode, Actor toRemove
influenceNode = influenceNode.Next;
}

public void MarkAsDirty(IOccupySpace ios)
{
if (UpdateCell != null)
foreach (var c in ios.OccupiedCells())
UpdateCell(c.First);
}

void ITick.Tick(Actor self)
{
// Position updates are done in one pass
Expand Down

0 comments on commit b25f0c8

Please sign in to comment.