SubscribeLocalEvent<BreathToolComponent, ComponentShutdown>(OnBreathToolShutdown);
}
- private void OnBreathToolShutdown(EntityUid uid, BreathToolComponent component, ComponentShutdown args)
+ private void OnBreathToolShutdown(Entity<BreathToolComponent> entity, ref ComponentShutdown args)
{
- DisconnectInternals(component);
+ DisconnectInternals(entity);
}
- public void DisconnectInternals(BreathToolComponent component)
+ public void DisconnectInternals(Entity<BreathToolComponent> entity)
{
- var old = component.ConnectedInternalsEntity;
- component.ConnectedInternalsEntity = null;
+ var old = entity.Comp.ConnectedInternalsEntity;
+ entity.Comp.ConnectedInternalsEntity = null;
if (TryComp<InternalsComponent>(old, out var internalsComponent))
{
- _internals.DisconnectBreathTool((old.Value, internalsComponent));
+ _internals.DisconnectBreathTool((old.Value, internalsComponent), entity.Owner);
}
- component.IsFunctional = false;
+ entity.Comp.IsFunctional = false;
}
}
private void OnStartingGear(EntityUid uid, InternalsComponent component, ref StartingGearEquippedEvent args)
{
- if (component.BreathToolEntity == null)
+ if (component.BreathTools.Count == 0)
return;
if (component.GasTankEntity != null)
}
// If they're not on then check if we have a mask to use
- if (internals.BreathToolEntity is null)
+ if (internals.BreathTools.Count == 0)
{
_popupSystem.PopupEntity(Loc.GetString("internals-no-breath-tool"), uid, user);
return;
_alerts.ShowAlert(ent, ent.Comp.InternalsAlert, GetSeverity(ent));
}
}
- public void DisconnectBreathTool(Entity<InternalsComponent> ent)
+ public void DisconnectBreathTool(Entity<InternalsComponent> ent, EntityUid toolEntity)
{
- var old = ent.Comp.BreathToolEntity;
- ent.Comp.BreathToolEntity = null;
+ ent.Comp.BreathTools.Remove(toolEntity);
- if (TryComp(old, out BreathToolComponent? breathTool))
- {
- _atmos.DisconnectInternals(breathTool);
+ if (TryComp(toolEntity, out BreathToolComponent? breathTool))
+ _atmos.DisconnectInternals((toolEntity, breathTool));
+
+ if (ent.Comp.BreathTools.Count == 0)
DisconnectTank(ent);
- }
_alerts.ShowAlert(ent, ent.Comp.InternalsAlert, GetSeverity(ent));
}
public void ConnectBreathTool(Entity<InternalsComponent> ent, EntityUid toolEntity)
{
- if (TryComp(ent.Comp.BreathToolEntity, out BreathToolComponent? tool))
- {
- _atmos.DisconnectInternals(tool);
- }
+ if (!ent.Comp.BreathTools.Add(toolEntity))
+ return;
- ent.Comp.BreathToolEntity = toolEntity;
_alerts.ShowAlert(ent, ent.Comp.InternalsAlert, GetSeverity(ent));
}
public bool TryConnectTank(Entity<InternalsComponent> ent, EntityUid tankEntity)
{
- if (ent.Comp.BreathToolEntity is null)
+ if (ent.Comp.BreathTools.Count == 0)
return false;
if (TryComp(ent.Comp.GasTankEntity, out GasTankComponent? tank))
public bool AreInternalsWorking(InternalsComponent component)
{
- return TryComp(component.BreathToolEntity, out BreathToolComponent? breathTool)
+ return TryComp(component.BreathTools.FirstOrNull(), out BreathToolComponent? breathTool)
&& breathTool.IsFunctional
&& HasComp<GasTankComponent>(component.GasTankEntity);
}
private short GetSeverity(InternalsComponent component)
{
- if (component.BreathToolEntity is null || !AreInternalsWorking(component))
+ if (component.BreathTools.Count == 0 || !AreInternalsWorking(component))
return 2;
// If pressure in the tank is below low pressure threshold, flash warning on internals UI