IFF console (#10504)
* IFF console * Silly * Color * a * Const bool default * Full stealth as well coz dork. * Infiltrator update
This commit is contained in:
91
Content.Server/Shuttles/Systems/ShuttleSystem.IFF.cs
Normal file
91
Content.Server/Shuttles/Systems/ShuttleSystem.IFF.cs
Normal file
@@ -0,0 +1,91 @@
|
||||
using Content.Server.Shuttles.Components;
|
||||
using Content.Shared.Shuttles.BUIStates;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Content.Shared.Shuttles.Events;
|
||||
|
||||
namespace Content.Server.Shuttles.Systems;
|
||||
|
||||
public sealed partial class ShuttleSystem
|
||||
{
|
||||
private void InitializeIFF()
|
||||
{
|
||||
SubscribeLocalEvent<IFFConsoleComponent, AnchorStateChangedEvent>(OnIFFConsoleAnchor);
|
||||
SubscribeLocalEvent<IFFConsoleComponent, IFFShowIFFMessage>(OnIFFShow);
|
||||
SubscribeLocalEvent<IFFConsoleComponent, IFFShowVesselMessage>(OnIFFShowVessel);
|
||||
}
|
||||
|
||||
private void OnIFFShow(EntityUid uid, IFFConsoleComponent component, IFFShowIFFMessage args)
|
||||
{
|
||||
if (!TryComp<TransformComponent>(uid, out var xform) || xform.GridUid == null ||
|
||||
(component.AllowedFlags & IFFFlags.HideLabel) == 0x0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.Show)
|
||||
{
|
||||
AddIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnIFFShowVessel(EntityUid uid, IFFConsoleComponent component, IFFShowVesselMessage args)
|
||||
{
|
||||
if (!TryComp<TransformComponent>(uid, out var xform) || xform.GridUid == null ||
|
||||
(component.AllowedFlags & IFFFlags.Hide) == 0x0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!args.Show)
|
||||
{
|
||||
AddIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
|
||||
}
|
||||
else
|
||||
{
|
||||
RemoveIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnIFFConsoleAnchor(EntityUid uid, IFFConsoleComponent component, ref AnchorStateChangedEvent args)
|
||||
{
|
||||
// If we anchor / re-anchor then make sure flags up to date.
|
||||
if (!args.Anchored ||
|
||||
!TryComp<TransformComponent>(uid, out var xform) ||
|
||||
!TryComp<IFFComponent>(xform.GridUid, out var iff))
|
||||
{
|
||||
_uiSystem.TrySetUiState(uid, IFFConsoleUiKey.Key, new IFFConsoleBoundUserInterfaceState()
|
||||
{
|
||||
AllowedFlags = component.AllowedFlags,
|
||||
Flags = IFFFlags.None,
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
_uiSystem.TrySetUiState(uid, IFFConsoleUiKey.Key, new IFFConsoleBoundUserInterfaceState()
|
||||
{
|
||||
AllowedFlags = component.AllowedFlags,
|
||||
Flags = iff.Flags,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override void UpdateIFFInterfaces(EntityUid gridUid, IFFComponent component)
|
||||
{
|
||||
base.UpdateIFFInterfaces(gridUid, component);
|
||||
foreach (var (comp, xform) in EntityQuery<IFFConsoleComponent, TransformComponent>(true))
|
||||
{
|
||||
if (xform.GridUid != gridUid)
|
||||
continue;
|
||||
|
||||
_uiSystem.TrySetUiState(comp.Owner, IFFConsoleUiKey.Key, new IFFConsoleBoundUserInterfaceState()
|
||||
{
|
||||
AllowedFlags = comp.AllowedFlags,
|
||||
Flags = component.Flags,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user