Welders now use EntityQuery to update instead of subscriptions.
This commit is contained in:
@@ -162,7 +162,6 @@ namespace Content.Server.GameObjects.Components.Interactable
|
|||||||
if (_pointLightComponent != null) _pointLightComponent.Enabled = false;
|
if (_pointLightComponent != null) _pointLightComponent.Enabled = false;
|
||||||
|
|
||||||
PlaySoundCollection("WelderOff", -5);
|
PlaySoundCollection("WelderOff", -5);
|
||||||
_welderSystem.Unsubscribe(this);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +178,6 @@ namespace Content.Server.GameObjects.Components.Interactable
|
|||||||
if (_pointLightComponent != null) _pointLightComponent.Enabled = true;
|
if (_pointLightComponent != null) _pointLightComponent.Enabled = true;
|
||||||
|
|
||||||
PlaySoundCollection("WelderOn", -5);
|
PlaySoundCollection("WelderOn", -5);
|
||||||
_welderSystem.Subscribe(this);
|
|
||||||
|
|
||||||
Owner.Transform.GridPosition
|
Owner.Transform.GridPosition
|
||||||
.GetTileAtmosphere()?.HotspotExpose(700f, 50f, true);
|
.GetTileAtmosphere()?.HotspotExpose(700f, 50f, true);
|
||||||
@@ -212,7 +210,7 @@ namespace Content.Server.GameObjects.Components.Interactable
|
|||||||
|
|
||||||
public void OnUpdate(float frameTime)
|
public void OnUpdate(float frameTime)
|
||||||
{
|
{
|
||||||
if (!HasQuality(ToolQuality.Welding) || !WelderLit || Owner.Deleted)
|
if (!HasQuality(ToolQuality.Welding) || !WelderLit)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_solutionComponent?.TryRemoveReagent("chem.WeldingFuel", ReagentUnit.New(FuelLossRate * frameTime));
|
_solutionComponent?.TryRemoveReagent("chem.WeldingFuel", ReagentUnit.New(FuelLossRate * frameTime));
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Content.Server.GameObjects.Components.Interactable;
|
using Content.Server.GameObjects.Components.Interactable;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.GameObjects.Systems;
|
using Robust.Shared.GameObjects.Systems;
|
||||||
|
|
||||||
namespace Content.Server.GameObjects.EntitySystems
|
namespace Content.Server.GameObjects.EntitySystems
|
||||||
@@ -10,23 +11,12 @@ namespace Content.Server.GameObjects.EntitySystems
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class WelderSystem : EntitySystem
|
public class WelderSystem : EntitySystem
|
||||||
{
|
{
|
||||||
private readonly HashSet<WelderComponent> _activeWelders = new HashSet<WelderComponent>();
|
|
||||||
|
|
||||||
public bool Subscribe(WelderComponent welder)
|
|
||||||
{
|
|
||||||
return _activeWelders.Add(welder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Unsubscribe(WelderComponent welder)
|
|
||||||
{
|
|
||||||
return _activeWelders.Remove(welder);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
{
|
{
|
||||||
foreach (var tool in _activeWelders.ToArray())
|
foreach (var welder in EntityManager.ComponentManager.EntityQuery<WelderComponent>())
|
||||||
{
|
{
|
||||||
tool.OnUpdate(frameTime);
|
if(welder.WelderLit && !welder.Owner.Deleted)
|
||||||
|
welder.OnUpdate(frameTime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user