* 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>
59 lines
1.6 KiB
C#
59 lines
1.6 KiB
C#
#nullable enable
|
|
using Content.Server.Atmos;
|
|
using Content.Server.GameObjects.EntitySystems;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.GameObjects.Systems;
|
|
|
|
namespace Content.Server.GameObjects.Components.Atmos.Piping
|
|
{
|
|
/// <summary>
|
|
/// 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>
|
|
[RegisterComponent]
|
|
public class PipeNetDeviceComponent : Component
|
|
{
|
|
public override string Name => "PipeNetDevice";
|
|
|
|
private IGridAtmosphereComponent? JoinedGridAtmos { get; set; }
|
|
|
|
private PipeNetUpdateMessage _cachedUpdateMessage = new();
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
JoinGridAtmos();
|
|
}
|
|
|
|
public override void OnRemove()
|
|
{
|
|
base.OnRemove();
|
|
LeaveGridAtmos();
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
SendMessage(_cachedUpdateMessage);
|
|
}
|
|
|
|
private void JoinGridAtmos()
|
|
{
|
|
var gridAtmos = EntitySystem.Get<AtmosphereSystem>()
|
|
.GetGridAtmosphere(Owner.Transform.GridID);
|
|
JoinedGridAtmos = gridAtmos;
|
|
JoinedGridAtmos.AddPipeNetDevice(this);
|
|
}
|
|
|
|
private void LeaveGridAtmos()
|
|
{
|
|
JoinedGridAtmos?.RemovePipeNetDevice(this);
|
|
JoinedGridAtmos = null;
|
|
}
|
|
}
|
|
|
|
public class PipeNetUpdateMessage : ComponentMessage
|
|
{
|
|
|
|
}
|
|
}
|