Mark cells that have changed MovementType as dirty

This commit is contained in:
teinarss
2019-09-29 11:50:45 +02:00
committed by abcdefg30
parent ad02adff3e
commit 9bfc324c04
4 changed files with 15 additions and 2 deletions

View File

@@ -90,12 +90,12 @@ namespace OpenRA.Mods.Common.Traits
protected override void TraitEnabled(Actor self)
{
self.World.ActorMap.UpdatePosition(self, self.OccupiesSpace);
self.World.ActorMap.UpdateOccupiedCells(self.OccupiesSpace);
}
protected override void TraitDisabled(Actor self)
{
self.World.ActorMap.UpdatePosition(self, self.OccupiesSpace);
self.World.ActorMap.UpdateOccupiedCells(self.OccupiesSpace);
}
}
}

View File

@@ -159,8 +159,11 @@ namespace OpenRA.Mods.Common.Traits
var oldValue = movementTypes;
movementTypes = value;
if (value != oldValue)
{
self.World.ActorMap.UpdateOccupiedCells(self.OccupiesSpace);
foreach (var n in notifyMoving)
n.MovementTypeChanged(self, value);
}
}
}
#endregion

View File

@@ -410,6 +410,15 @@ namespace OpenRA.Mods.Common.Traits
influenceNode = influenceNode.Next;
}
public void UpdateOccupiedCells(IOccupySpace ios)
{
if (CellUpdated == null)
return;
foreach (var c in ios.OccupiedCells())
CellUpdated(c.First);
}
void ITick.Tick(Actor self)
{
// Position updates are done in one pass