Files
tbd-station-14/Content.Shared/Atmos/EntitySystems/SharedAtmosphereSystem.BreathTool.cs
metalgearsloth bd69fc612a Predicted internals (#33800)
* Predicted gas pumps

I wanted to try out atmos and first thing I found.

* a

* Atmos device prediction

- Canisters
- Tanks
- Internals

AirMixes aren't predicted so nothing on that front but all the UIs should be a lot closer.

* Remove details range

* Gas tank prediction

* Even more sweeping changes

* Alerts

* rehg

* Popup fix

* Fix merge conflicts

* Fix

* Review
2025-05-02 18:22:29 +10:00

52 lines
1.5 KiB
C#

using Content.Shared.Atmos.Components;
using Content.Shared.Body.Components;
using Content.Shared.Clothing;
namespace Content.Shared.Atmos.EntitySystems;
public abstract partial class SharedAtmosphereSystem
{
private void InitializeBreathTool()
{
SubscribeLocalEvent<BreathToolComponent, ComponentShutdown>(OnBreathToolShutdown);
SubscribeLocalEvent<BreathToolComponent, ItemMaskToggledEvent>(OnMaskToggled);
}
private void OnBreathToolShutdown(Entity<BreathToolComponent> entity, ref ComponentShutdown args)
{
DisconnectInternals(entity);
}
public void DisconnectInternals(Entity<BreathToolComponent> entity, bool forced = false)
{
var old = entity.Comp.ConnectedInternalsEntity;
if (old == null)
return;
entity.Comp.ConnectedInternalsEntity = null;
if (_internalsQuery.TryComp(old, out var internalsComponent))
{
_internals.DisconnectBreathTool((old.Value, internalsComponent), entity.Owner, forced: forced);
}
Dirty(entity);
}
private void OnMaskToggled(Entity<BreathToolComponent> ent, ref ItemMaskToggledEvent args)
{
if (args.Mask.Comp.IsToggled)
{
DisconnectInternals(ent, forced: true);
}
else
{
if (_internalsQuery.TryComp(args.Wearer, out var internals))
{
_internals.ConnectBreathTool((args.Wearer.Value, internals), ent);
}
}
}
}