From 7de97eeb2c333646a4cd48993d19da280a031dec Mon Sep 17 00:00:00 2001 From: Pieter-Jan Briers Date: Mon, 14 Oct 2019 17:09:45 +0200 Subject: [PATCH] Fix icon smoothing not applying after entities are deleted. --- .../Components/IconSmoothing/IconSmoothComponent.cs | 4 ++-- .../GameObjects/EntitySystems/IconSmoothSystem.cs | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Content.Client/GameObjects/Components/IconSmoothing/IconSmoothComponent.cs b/Content.Client/GameObjects/Components/IconSmoothing/IconSmoothComponent.cs index 31265c593a..3eced3afde 100644 --- a/Content.Client/GameObjects/Components/IconSmoothing/IconSmoothComponent.cs +++ b/Content.Client/GameObjects/Components/IconSmoothing/IconSmoothComponent.cs @@ -200,10 +200,10 @@ namespace Content.Client.GameObjects.Components.IconSmoothing /// protected override void Shutdown() { + base.Shutdown(); + SnapGrid.OnPositionChanged -= SnapGridOnPositionChanged; Owner.EntityManager.RaiseEvent(Owner, new IconSmoothDirtyEvent(_lastPosition, SnapGrid.Offset, Mode)); - - base.Shutdown(); } private void SnapGridOnPositionChanged() diff --git a/Content.Client/GameObjects/EntitySystems/IconSmoothSystem.cs b/Content.Client/GameObjects/EntitySystems/IconSmoothSystem.cs index 9b7851360a..09152b5c66 100644 --- a/Content.Client/GameObjects/EntitySystems/IconSmoothSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/IconSmoothSystem.cs @@ -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. // This is simpler to implement. If you want to optimize it be my guest. if (sender is IEntity senderEnt && senderEnt.IsValid() && - senderEnt.HasComponent()) + senderEnt.TryGetComponent(out IconSmoothComponent iconSmooth) + && iconSmooth.Running) { var snapGrid = senderEnt.GetComponent(); @@ -82,7 +83,8 @@ namespace Content.Client.GameObjects.EntitySystems 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. var grid = _mapManager.GetGrid(ev.LastPosition.Value.grid);