Files
OldThink/Content.Shared/Shuttles/Systems/SharedRadarConsoleSystem.cs

55 lines
1.5 KiB
C#
Raw Normal View History

using Content.Shared.Shuttles.Components;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.Shuttles.Systems;
public abstract class SharedRadarConsoleSystem : EntitySystem
{
2023-03-23 16:10:49 +11:00
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)
{
2023-07-08 09:02:17 -07:00
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
};
}
2023-07-08 09:02:17 -07:00
protected virtual void UpdateState(EntityUid uid, RadarConsoleComponent component)
{
}
2023-07-08 09:02:17 -07:00
public void SetRange(EntityUid uid, float value, RadarConsoleComponent component)
{
2023-07-08 09:02:17 -07:00
if (component.MaxRange.Equals(value))
return;
component.MaxRange = value;
2023-07-08 09:02:17 -07:00
Dirty(uid, component);
UpdateState(uid, component);
}
[Serializable, NetSerializable]
protected sealed class RadarConsoleComponentState : ComponentState
{
public float Range;
}
}