Files
tbd-station-14/Content.Shared/Shuttles/Systems/SharedRadarConsoleSystem.cs
metalgearsloth 1e82d0c7ed Add docking window to shuttle consoles (#8756)
* lewd

* A

* Realtime

* Sleepy dork

* Draw radar position

* Accurate infiltrator

* experiments

* Better drawing

* Labels

* I need aan adult

* Cleanup

* Show toggles

* display I guess

* A

* fix

* fix

* cleanupsies

* Bit more polish

* Make sure mass scanners actually work

* Remove dummy state

* fren

* opposite

* aghost crash

* comment

* What's in a name

* woops

* Show docking ports

* Dock highlighting

* Drawing dock

* Shitty docks

* Lots of docking drawing

* Autodock working

* dork

* More graceful shutdown

* zoomies

* Lines and distance change

* revert

* Good enough

* cleanup

* Fix default range

* Dock UI and loc update

* Update on undock

* Loc fixes
2022-06-16 15:28:16 +10:00

46 lines
1.4 KiB
C#

using Content.Shared.Shuttles.Components;
using Robust.Shared.GameStates;
using Robust.Shared.Serialization;
namespace Content.Shared.Shuttles.Systems;
public abstract class SharedRadarConsoleSystem : EntitySystem
{
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(RadarConsoleComponent component) {}
public void SetRange(RadarConsoleComponent component, float value)
{
if (component.MaxRange.Equals(value)) return;
component.MaxRange = value;
Dirty(component);
UpdateState(component);
}
[Serializable, NetSerializable]
protected sealed class RadarConsoleComponentState : ComponentState
{
public float Range;
}
}