From a815b50f6df58a1767e24a3d6068fa090c547169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Aguilera=20Puerto?= Date: Sat, 15 Aug 2020 00:02:17 +0200 Subject: [PATCH] Welders now use EntityQuery to update instead of subscriptions. --- .../Components/Interactable/WelderComponent.cs | 4 +--- .../GameObjects/EntitySystems/WelderSystem.cs | 18 ++++-------------- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs b/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs index 3f2e07206d..5148071820 100644 --- a/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs +++ b/Content.Server/GameObjects/Components/Interactable/WelderComponent.cs @@ -162,7 +162,6 @@ namespace Content.Server.GameObjects.Components.Interactable if (_pointLightComponent != null) _pointLightComponent.Enabled = false; PlaySoundCollection("WelderOff", -5); - _welderSystem.Unsubscribe(this); return true; } @@ -179,7 +178,6 @@ namespace Content.Server.GameObjects.Components.Interactable if (_pointLightComponent != null) _pointLightComponent.Enabled = true; PlaySoundCollection("WelderOn", -5); - _welderSystem.Subscribe(this); Owner.Transform.GridPosition .GetTileAtmosphere()?.HotspotExpose(700f, 50f, true); @@ -212,7 +210,7 @@ namespace Content.Server.GameObjects.Components.Interactable public void OnUpdate(float frameTime) { - if (!HasQuality(ToolQuality.Welding) || !WelderLit || Owner.Deleted) + if (!HasQuality(ToolQuality.Welding) || !WelderLit) return; _solutionComponent?.TryRemoveReagent("chem.WeldingFuel", ReagentUnit.New(FuelLossRate * frameTime)); diff --git a/Content.Server/GameObjects/EntitySystems/WelderSystem.cs b/Content.Server/GameObjects/EntitySystems/WelderSystem.cs index 411e3546fc..d8b9081e2a 100644 --- a/Content.Server/GameObjects/EntitySystems/WelderSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/WelderSystem.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Linq; using Content.Server.GameObjects.Components.Interactable; +using Robust.Shared.GameObjects; using Robust.Shared.GameObjects.Systems; namespace Content.Server.GameObjects.EntitySystems @@ -10,23 +11,12 @@ namespace Content.Server.GameObjects.EntitySystems /// public class WelderSystem : EntitySystem { - private readonly HashSet _activeWelders = new HashSet(); - - public bool Subscribe(WelderComponent welder) - { - return _activeWelders.Add(welder); - } - - public bool Unsubscribe(WelderComponent welder) - { - return _activeWelders.Remove(welder); - } - public override void Update(float frameTime) { - foreach (var tool in _activeWelders.ToArray()) + foreach (var welder in EntityManager.ComponentManager.EntityQuery()) { - tool.OnUpdate(frameTime); + if(welder.WelderLit && !welder.Owner.Deleted) + welder.OnUpdate(frameTime); } } }