PipeNetDeviceComponent refactor (#2912)

* Removes inheritance of PipeNetDeviceComponent

* Enables nullable in piping

* Piping error messages report the prototype

* Moves PipeNetDevice updating to ComponentMessage

* Build fix

* Review fixes

* review fix 2

Co-authored-by: py01 <pyronetics01@gmail.com>
This commit is contained in:
py01
2021-01-07 00:37:17 -06:00
committed by GitHub
parent 2b195fccb9
commit 8fa8de36ed
5 changed files with 180 additions and 109 deletions

View File

@@ -1,4 +1,5 @@
using Content.Server.Atmos;
#nullable enable
using Content.Server.Atmos;
using Content.Server.GameObjects.EntitySystems;
using Robust.Shared.GameObjects;
using Robust.Shared.GameObjects.Systems;
@@ -9,11 +10,14 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
/// Adds itself to a <see cref="IGridAtmosphereComponent"/> to be updated by.
/// TODO: Make compatible with unanchoring/anchoring. Currently assumes that the Owner does not move.
/// </summary>
public abstract class PipeNetDeviceComponent : Component
[RegisterComponent]
public class PipeNetDeviceComponent : Component
{
public abstract void Update();
public override string Name => "PipeNetDevice";
protected IGridAtmosphereComponent JoinedGridAtmos { get; private set; }
private IGridAtmosphereComponent? JoinedGridAtmos { get; set; }
private PipeNetUpdateMessage _cachedUpdateMessage = new();
public override void Initialize()
{
@@ -27,6 +31,11 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
LeaveGridAtmos();
}
public void Update()
{
SendMessage(_cachedUpdateMessage);
}
private void JoinGridAtmos()
{
var gridAtmos = EntitySystem.Get<AtmosphereSystem>()
@@ -41,4 +50,9 @@ namespace Content.Server.GameObjects.Components.Atmos.Piping
JoinedGridAtmos = null;
}
}
public class PipeNetUpdateMessage : ComponentMessage
{
}
}