IFF console (#10504)
* IFF console * Silly * Color * a * Const bool default * Full stealth as well coz dork. * Infiltrator update
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Shuttles.BUIStates;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class IFFConsoleBoundUserInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public IFFFlags AllowedFlags;
|
||||
public IFFFlags Flags;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum IFFConsoleUiKey : byte
|
||||
{
|
||||
Key,
|
||||
}
|
||||
49
Content.Shared/Shuttles/Components/IFFComponent.cs
Normal file
49
Content.Shared/Shuttles/Components/IFFComponent.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using Content.Shared.Shuttles.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Shuttles.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Handles what a grid should look like on radar.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, Access(typeof(SharedShuttleSystem))]
|
||||
public sealed class IFFComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Should we show IFF by default?
|
||||
/// </summary>
|
||||
public const bool ShowIFFDefault = true;
|
||||
|
||||
/// <summary>
|
||||
/// Default color to use for IFF if no component is found.
|
||||
/// </summary>
|
||||
public static readonly Color IFFColor = Color.Aquamarine;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("flags")]
|
||||
public IFFFlags Flags = IFFFlags.None;
|
||||
|
||||
/// <summary>
|
||||
/// Color for this to show up on IFF.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("color")]
|
||||
public Color Color = IFFColor;
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum IFFFlags : byte
|
||||
{
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Should the label for this grid be hidden at all ranges.
|
||||
/// </summary>
|
||||
HideLabel,
|
||||
|
||||
/// <summary>
|
||||
/// Should the grid hide entirely (AKA full stealth).
|
||||
/// Will also hide the label if that is not set.
|
||||
/// </summary>
|
||||
Hide,
|
||||
|
||||
// TODO: Need one that hides its outline, just replace it with a bunch of triangles or lines or something.
|
||||
}
|
||||
12
Content.Shared/Shuttles/Events/IFFShowIFFMessage.cs
Normal file
12
Content.Shared/Shuttles/Events/IFFShowIFFMessage.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Shuttles.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Raised on a client IFF console when it wishes to show IFF.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class IFFShowIFFMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public bool Show;
|
||||
}
|
||||
9
Content.Shared/Shuttles/Events/IFFShowVesselMessage.cs
Normal file
9
Content.Shared/Shuttles/Events/IFFShowVesselMessage.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Shuttles.Events;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class IFFShowVesselMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public bool Show;
|
||||
}
|
||||
89
Content.Shared/Shuttles/Systems/SharedShuttleSystem.IFF.cs
Normal file
89
Content.Shared/Shuttles/Systems/SharedShuttleSystem.IFF.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Shuttles.Systems;
|
||||
|
||||
public abstract partial class SharedShuttleSystem
|
||||
{
|
||||
/*
|
||||
* Handles the label visibility on radar controls. This can be hiding the label or applying other effects.
|
||||
*/
|
||||
|
||||
private void InitializeIFF()
|
||||
{
|
||||
SubscribeLocalEvent<IFFComponent, ComponentGetState>(OnIFFGetState);
|
||||
SubscribeLocalEvent<IFFComponent, ComponentHandleState>(OnIFFHandleState);
|
||||
}
|
||||
|
||||
protected virtual void UpdateIFFInterfaces(EntityUid gridUid, IFFComponent component) {}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the color for this grid to appear as on radar.
|
||||
/// </summary>
|
||||
[PublicAPI]
|
||||
public void SetIFFColor(EntityUid gridUid, Color color, IFFComponent? component = null)
|
||||
{
|
||||
component ??= EnsureComp<IFFComponent>(gridUid);
|
||||
|
||||
if (component.Color.Equals(color))
|
||||
return;
|
||||
|
||||
component.Color = color;
|
||||
Dirty(component);
|
||||
UpdateIFFInterfaces(gridUid, component);
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public void AddIFFFlag(EntityUid gridUid, IFFFlags flags, IFFComponent? component = null)
|
||||
{
|
||||
component ??= EnsureComp<IFFComponent>(gridUid);
|
||||
|
||||
if ((component.Flags & flags) == flags)
|
||||
return;
|
||||
|
||||
component.Flags |= flags;
|
||||
Dirty(component);
|
||||
UpdateIFFInterfaces(gridUid, component);
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public void RemoveIFFFlag(EntityUid gridUid, IFFFlags flags, IFFComponent? component = null)
|
||||
{
|
||||
if (!Resolve(gridUid, ref component, false))
|
||||
return;
|
||||
|
||||
if ((component.Flags & flags) == 0x0)
|
||||
return;
|
||||
|
||||
component.Flags &= ~flags;
|
||||
Dirty(component);
|
||||
UpdateIFFInterfaces(gridUid, component);
|
||||
}
|
||||
|
||||
private void OnIFFHandleState(EntityUid uid, IFFComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not IFFComponentState state)
|
||||
return;
|
||||
|
||||
component.Flags = state.Flags;
|
||||
component.Color = state.Color;
|
||||
}
|
||||
|
||||
private void OnIFFGetState(EntityUid uid, IFFComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new IFFComponentState()
|
||||
{
|
||||
Flags = component.Flags,
|
||||
Color = component.Color,
|
||||
};
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class IFFComponentState : ComponentState
|
||||
{
|
||||
public IFFFlags Flags;
|
||||
public Color Color;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,11 @@ namespace Content.Shared.Shuttles.Systems;
|
||||
|
||||
public abstract partial class SharedShuttleSystem : EntitySystem
|
||||
{
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
InitializeIFF();
|
||||
}
|
||||
}
|
||||
|
||||
[Flags]
|
||||
|
||||
Reference in New Issue
Block a user