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
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user