Cleanup internals (#12719)

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
metalgearsloth
2022-11-23 19:26:51 +11:00
committed by GitHub
parent 8cb1226476
commit 32ba8e4f9d
2 changed files with 66 additions and 103 deletions

View File

@@ -19,35 +19,7 @@ public sealed class ToggleInternals : IAlertClick
{
public void AlertClicked(EntityUid player)
{
var entManager = IoCManager.Resolve<IEntityManager>();
if (!entManager.TryGetComponent<InternalsComponent>(player, out var internals)) return;
var popups = entManager.EntitySysManager.GetEntitySystem<PopupSystem>();
var internalsSystem = entManager.EntitySysManager.GetEntitySystem<InternalsSystem>();
// Toggle off if they're on
if (internalsSystem.AreInternalsWorking(internals))
{
internalsSystem.DisconnectTank(internals);
return;
}
// If they're not on then check if we have a mask to use
if (internals.BreathToolEntity == null)
{
popups.PopupEntity(Loc.GetString("internals-no-breath-tool"), player, Filter.Entities(player));
return;
}
var tank = internalsSystem.FindBestGasTank(internals);
if (tank == null)
{
popups.PopupEntity(Loc.GetString("internals-no-tank"), player, Filter.Entities(player));
return;
}
entManager.EntitySysManager.GetEntitySystem<GasTankSystem>().ConnectToInternals(tank);
var internalsSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<InternalsSystem>();
internalsSystem.ToggleInternals(player, player, false);
}
}