Gas tank internals alerts (#9567)
This commit is contained in:
@@ -1,68 +1,12 @@
|
||||
using Content.Server.Atmos.Components;
|
||||
|
||||
namespace Content.Server.Body.Components
|
||||
namespace Content.Server.Body.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Handles hooking up a mask (breathing tool) / gas tank together and allowing the Owner to breathe through it.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
public sealed class InternalsComponent : Component
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _entMan = default!;
|
||||
|
||||
[ViewVariables] public EntityUid? GasTankEntity { get; set; }
|
||||
[ViewVariables] public EntityUid? BreathToolEntity { get; set; }
|
||||
|
||||
public void DisconnectBreathTool()
|
||||
{
|
||||
var old = BreathToolEntity;
|
||||
BreathToolEntity = null;
|
||||
|
||||
if (_entMan.TryGetComponent(old, out BreathToolComponent? breathTool) )
|
||||
{
|
||||
breathTool.DisconnectInternals();
|
||||
DisconnectTank();
|
||||
}
|
||||
}
|
||||
|
||||
public void ConnectBreathTool(EntityUid toolEntity)
|
||||
{
|
||||
if (_entMan.TryGetComponent(BreathToolEntity, out BreathToolComponent? tool))
|
||||
{
|
||||
tool.DisconnectInternals();
|
||||
}
|
||||
|
||||
BreathToolEntity = toolEntity;
|
||||
}
|
||||
|
||||
public void DisconnectTank()
|
||||
{
|
||||
if (_entMan.TryGetComponent(GasTankEntity, out GasTankComponent? tank))
|
||||
{
|
||||
tank.DisconnectFromInternals(Owner);
|
||||
}
|
||||
|
||||
GasTankEntity = null;
|
||||
}
|
||||
|
||||
public bool TryConnectTank(EntityUid tankEntity)
|
||||
{
|
||||
if (BreathToolEntity == null)
|
||||
return false;
|
||||
|
||||
if (_entMan.TryGetComponent(GasTankEntity, out GasTankComponent? tank))
|
||||
{
|
||||
tank.DisconnectFromInternals(Owner);
|
||||
}
|
||||
|
||||
GasTankEntity = tankEntity;
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool AreInternalsWorking()
|
||||
{
|
||||
return _entMan.TryGetComponent(BreathToolEntity, out BreathToolComponent? breathTool) &&
|
||||
breathTool.IsFunctional &&
|
||||
_entMan.TryGetComponent(GasTankEntity, out GasTankComponent? gasTank) &&
|
||||
gasTank.Air != null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user