Move MaskComponent to shared and add toggle events (#22395)
* Move MaskComponent to shared and add toggle events * Datafield and network IsToggled * Add missing dirty
This commit is contained in:
@@ -3,12 +3,14 @@ using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Chemistry.EntitySystems;
|
||||
using Content.Shared.Clothing;
|
||||
using Content.Shared.Inventory.Events;
|
||||
|
||||
namespace Content.Server.Body.Systems;
|
||||
|
||||
public sealed class LungSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly AtmosphereSystem _atmos = default!;
|
||||
[Dependency] private readonly InternalsSystem _internals = default!;
|
||||
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
|
||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||
@@ -21,6 +23,7 @@ public sealed class LungSystem : EntitySystem
|
||||
SubscribeLocalEvent<LungComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<BreathToolComponent, GotEquippedEvent>(OnGotEquipped);
|
||||
SubscribeLocalEvent<BreathToolComponent, GotUnequippedEvent>(OnGotUnequipped);
|
||||
SubscribeLocalEvent<BreathToolComponent, ItemMaskToggledEvent>(OnMaskToggled);
|
||||
}
|
||||
|
||||
private void OnGotUnequipped(EntityUid uid, BreathToolComponent component, GotUnequippedEvent args)
|
||||
@@ -48,6 +51,28 @@ public sealed class LungSystem : EntitySystem
|
||||
component.LungSolution.CanReact = false; // No dexalin lungs
|
||||
}
|
||||
|
||||
private void OnMaskToggled(Entity<BreathToolComponent> ent, ref ItemMaskToggledEvent args)
|
||||
{
|
||||
// toggle breath tool connection (skip during equip since that is handled in LungSystem)
|
||||
if (args.IsEquip)
|
||||
{
|
||||
if (args.IsToggled)
|
||||
{
|
||||
_atmos.DisconnectInternals(ent.Comp);
|
||||
}
|
||||
else
|
||||
{
|
||||
ent.Comp.IsFunctional = true;
|
||||
|
||||
if (TryComp(args.Wearer, out InternalsComponent? internals))
|
||||
{
|
||||
ent.Comp.ConnectedInternalsEntity = args.Wearer;
|
||||
_internals.ConnectBreathTool((args.Wearer, internals), ent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void GasToReagent(EntityUid uid, LungComponent lung)
|
||||
{
|
||||
foreach (var gas in Enum.GetValues<Gas>())
|
||||
|
||||
Reference in New Issue
Block a user