Update trivial components to use auto comp states (#20539)
This commit is contained in:
@@ -6,7 +6,8 @@ namespace Content.Shared.Shuttles.Components;
|
||||
/// <summary>
|
||||
/// Handles what a grid should look like on radar.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, Access(typeof(SharedShuttleSystem))]
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
[Access(typeof(SharedShuttleSystem))]
|
||||
public sealed partial class IFFComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
@@ -19,13 +20,13 @@ public sealed partial class IFFComponent : Component
|
||||
/// </summary>
|
||||
public static readonly Color IFFColor = Color.Aquamarine;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("flags")]
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
||||
public IFFFlags Flags = IFFFlags.None;
|
||||
|
||||
/// <summary>
|
||||
/// Color for this to show up on IFF.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("color")]
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField, AutoNetworkedField]
|
||||
public Color Color = IFFColor;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,8 @@ using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Shuttles.Components;
|
||||
|
||||
[RegisterComponent, NetworkedComponent, Access(typeof(SharedRadarConsoleSystem))]
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
[Access(typeof(SharedRadarConsoleSystem))]
|
||||
public sealed partial class RadarConsoleComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
@@ -16,6 +17,6 @@ public sealed partial class RadarConsoleComponent : Component
|
||||
.SetRange(Owner, value, this);
|
||||
}
|
||||
|
||||
[DataField("maxRange")]
|
||||
[DataField, AutoNetworkedField]
|
||||
public float MaxRange = 256f;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Shuttles.Systems;
|
||||
|
||||
@@ -9,29 +7,6 @@ public abstract class SharedRadarConsoleSystem : EntitySystem
|
||||
public const float DefaultMinRange = 64f;
|
||||
public const float DefaultMaxRange = 256f;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<RadarConsoleComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<RadarConsoleComponent, ComponentHandleState>(OnHandleState);
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, RadarConsoleComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not RadarConsoleComponentState state)
|
||||
return;
|
||||
|
||||
component.MaxRange = state.Range;
|
||||
}
|
||||
|
||||
private void OnGetState(EntityUid uid, RadarConsoleComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new RadarConsoleComponentState()
|
||||
{
|
||||
Range = component.MaxRange
|
||||
};
|
||||
}
|
||||
|
||||
protected virtual void UpdateState(EntityUid uid, RadarConsoleComponent component)
|
||||
{
|
||||
}
|
||||
@@ -45,10 +20,4 @@ public abstract class SharedRadarConsoleSystem : EntitySystem
|
||||
Dirty(uid, component);
|
||||
UpdateState(uid, component);
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
protected sealed class RadarConsoleComponentState : ComponentState
|
||||
{
|
||||
public float Range;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Shuttles.Systems;
|
||||
|
||||
@@ -11,12 +9,6 @@ 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>
|
||||
@@ -61,29 +53,4 @@ public abstract partial class SharedShuttleSystem
|
||||
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,11 +2,6 @@ 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