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
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Shuttles.BUIStates;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
[Virtual]
|
||||
public class RadarConsoleBoundInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public readonly float MaxRange;
|
||||
public readonly EntityUid? Entity;
|
||||
public readonly List<DockingInterfaceState> Docks;
|
||||
|
||||
public RadarConsoleBoundInterfaceState(
|
||||
float maxRange,
|
||||
EntityUid? entity,
|
||||
List<DockingInterfaceState> docks)
|
||||
{
|
||||
MaxRange = maxRange;
|
||||
Entity = entity;
|
||||
Docks = docks;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// State of each individual docking port for interface purposes
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class DockingInterfaceState
|
||||
{
|
||||
public EntityCoordinates Coordinates;
|
||||
public Angle Angle;
|
||||
public EntityUid Entity;
|
||||
public bool Connected;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum RadarConsoleUiKey : byte
|
||||
{
|
||||
Key
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Shuttles.BUIStates;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ShuttleConsoleBoundInterfaceState : RadarConsoleBoundInterfaceState
|
||||
{
|
||||
public readonly ShuttleMode Mode;
|
||||
|
||||
public ShuttleConsoleBoundInterfaceState(
|
||||
ShuttleMode mode,
|
||||
float maxRange,
|
||||
EntityUid? entity,
|
||||
List<DockingInterfaceState> docks) : base(maxRange, entity, docks)
|
||||
{
|
||||
Mode = mode;
|
||||
}
|
||||
}
|
||||
21
Content.Shared/Shuttles/Components/RadarConsoleComponent.cs
Normal file
21
Content.Shared/Shuttles/Components/RadarConsoleComponent.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Content.Shared.Shuttles.Systems;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Shuttles.Components;
|
||||
|
||||
[RegisterComponent, NetworkedComponent, Access(typeof(SharedRadarConsoleSystem))]
|
||||
public sealed class RadarConsoleComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float RangeVV
|
||||
{
|
||||
get => MaxRange;
|
||||
set => IoCManager
|
||||
.Resolve<IEntitySystemManager>()
|
||||
.GetEntitySystem<SharedRadarConsoleSystem>()
|
||||
.SetRange(this, value);
|
||||
}
|
||||
|
||||
[ViewVariables, DataField("maxRange")]
|
||||
public float MaxRange = 120f;
|
||||
}
|
||||
@@ -1,17 +1,8 @@
|
||||
namespace Content.Shared.Shuttles.Components
|
||||
{
|
||||
public abstract class SharedShuttleComponent : Component
|
||||
{
|
||||
[ViewVariables]
|
||||
public virtual bool Enabled { get; set; } = true;
|
||||
|
||||
[ViewVariables]
|
||||
public ShuttleMode Mode { get; set; } = ShuttleMode.Cruise;
|
||||
}
|
||||
|
||||
public enum ShuttleMode : byte
|
||||
{
|
||||
Docking,
|
||||
Strafing,
|
||||
Cruise,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,20 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Shuttles.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Interact with to start piloting a shuttle.
|
||||
/// </summary>
|
||||
[NetworkedComponent()]
|
||||
[NetworkedComponent]
|
||||
public abstract class SharedShuttleConsoleComponent : Component
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum ShuttleConsoleUiKey : byte
|
||||
{
|
||||
Key,
|
||||
}
|
||||
}
|
||||
|
||||
12
Content.Shared/Shuttles/Events/AutodockRequestMessage.cs
Normal file
12
Content.Shared/Shuttles/Events/AutodockRequestMessage.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Shuttles.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Raised on the client when it's viewing a particular docking port to try and dock it automatically.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class AutodockRequestMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public EntityUid Entity;
|
||||
}
|
||||
13
Content.Shared/Shuttles/Events/ShuttleModeRequestMessage.cs
Normal file
13
Content.Shared/Shuttles/Events/ShuttleModeRequestMessage.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Shuttles.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Raised by the client to request the server change a particular shuttle's mode.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ShuttleModeRequestMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public ShuttleMode Mode;
|
||||
}
|
||||
12
Content.Shared/Shuttles/Events/StopAutodockRequestMessage.cs
Normal file
12
Content.Shared/Shuttles/Events/StopAutodockRequestMessage.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Shuttles.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Raised on a client when it is no longer viewing a dock.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class StopAutodockRequestMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public EntityUid Entity;
|
||||
}
|
||||
12
Content.Shared/Shuttles/Events/UndockRequestMessage.cs
Normal file
12
Content.Shared/Shuttles/Events/UndockRequestMessage.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Shuttles.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Raised on the client when it wishes to not have 2 docking ports docked.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class UndockRequestMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public EntityUid Entity;
|
||||
}
|
||||
45
Content.Shared/Shuttles/Systems/SharedRadarConsoleSystem.cs
Normal file
45
Content.Shared/Shuttles/Systems/SharedRadarConsoleSystem.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
using Content.Shared.ActionBlocker;
|
||||
using Content.Shared.Movement;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Shuttles
|
||||
namespace Content.Shared.Shuttles.Systems
|
||||
{
|
||||
public abstract class SharedShuttleConsoleSystem : EntitySystem
|
||||
{
|
||||
@@ -16,38 +15,10 @@ namespace Content.Shared.Shuttles
|
||||
SubscribeLocalEvent<PilotComponent, UpdateCanMoveEvent>(HandleMovementBlock);
|
||||
SubscribeLocalEvent<PilotComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<PilotComponent, ComponentShutdown>(HandlePilotShutdown);
|
||||
SubscribeLocalEvent<PilotComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<PilotComponent, ComponentHandleState>(OnHandleState);
|
||||
}
|
||||
|
||||
private void OnGetState(EntityUid uid, PilotComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new PilotComponentState(component.Console?.Owner);
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, PilotComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not PilotComponentState state) return;
|
||||
|
||||
var console = state.Console.GetValueOrDefault();
|
||||
if (!console.IsValid())
|
||||
{
|
||||
component.Console = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!TryComp<SharedShuttleConsoleComponent>(console, out var shuttleConsoleComponent))
|
||||
{
|
||||
Logger.Warning($"Unable to set Helmsman console to {console}");
|
||||
return;
|
||||
}
|
||||
|
||||
component.Console = shuttleConsoleComponent;
|
||||
ActionBlockerSystem.UpdateCanMove(uid);
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class PilotComponentState : ComponentState
|
||||
protected sealed class PilotComponentState : ComponentState
|
||||
{
|
||||
public EntityUid? Console { get; }
|
||||
|
||||
Reference in New Issue
Block a user