Fix icon smoothing not applying after entities are deleted.

This commit is contained in:
Pieter-Jan Briers
2019-10-14 17:09:45 +02:00
parent def32d80dd
commit 7de97eeb2c
2 changed files with 6 additions and 4 deletions

View File

@@ -200,10 +200,10 @@ namespace Content.Client.GameObjects.Components.IconSmoothing
/// <inheritdoc /> /// <inheritdoc />
protected override void Shutdown() protected override void Shutdown()
{ {
base.Shutdown();
SnapGrid.OnPositionChanged -= SnapGridOnPositionChanged; SnapGrid.OnPositionChanged -= SnapGridOnPositionChanged;
Owner.EntityManager.RaiseEvent(Owner, new IconSmoothDirtyEvent(_lastPosition, SnapGrid.Offset, Mode)); Owner.EntityManager.RaiseEvent(Owner, new IconSmoothDirtyEvent(_lastPosition, SnapGrid.Offset, Mode));
base.Shutdown();
} }
private void SnapGridOnPositionChanged() private void SnapGridOnPositionChanged()

View File

@@ -64,7 +64,8 @@ namespace Content.Client.GameObjects.EntitySystems
// Yes, we updates ALL smoothing entities surrounding us even if they would never smooth with us. // Yes, we updates ALL smoothing entities surrounding us even if they would never smooth with us.
// This is simpler to implement. If you want to optimize it be my guest. // This is simpler to implement. If you want to optimize it be my guest.
if (sender is IEntity senderEnt && senderEnt.IsValid() && if (sender is IEntity senderEnt && senderEnt.IsValid() &&
senderEnt.HasComponent<IconSmoothComponent>()) senderEnt.TryGetComponent(out IconSmoothComponent iconSmooth)
&& iconSmooth.Running)
{ {
var snapGrid = senderEnt.GetComponent<SnapGridComponent>(); var snapGrid = senderEnt.GetComponent<SnapGridComponent>();
@@ -82,7 +83,8 @@ namespace Content.Client.GameObjects.EntitySystems
AddValidEntities(snapGrid.GetInDir(Direction.NorthWest)); AddValidEntities(snapGrid.GetInDir(Direction.NorthWest));
} }
} }
else if (ev.LastPosition.HasValue)
if (ev.LastPosition.HasValue)
{ {
// Entity is no longer valid, update around the last position it was at. // Entity is no longer valid, update around the last position it was at.
var grid = _mapManager.GetGrid(ev.LastPosition.Value.grid); var grid = _mapManager.GetGrid(ev.LastPosition.Value.grid);