Thrusters (shuttle go nyoom) (#5352)
This commit is contained in:
66
Content.Shared/Shuttles/Components/PilotComponent.cs
Normal file
66
Content.Shared/Shuttles/Components/PilotComponent.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Log;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.Shuttles.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores what shuttle this entity is currently piloting.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[NetworkedComponent]
|
||||
public sealed class PilotComponent : Component
|
||||
{
|
||||
public override string Name => "Pilot";
|
||||
[ViewVariables] public SharedShuttleConsoleComponent? Console { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Where we started piloting from to check if we should break from moving too far.
|
||||
/// </summary>
|
||||
[ViewVariables] public EntityCoordinates? Position { get; set; }
|
||||
|
||||
public const float BreakDistance = 0.25f;
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
base.HandleComponentState(curState, nextState);
|
||||
if (curState is not PilotComponentState state) return;
|
||||
|
||||
if (state.Console == null)
|
||||
{
|
||||
Console = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Owner.EntityManager.TryGetEntity(state.Console.Value, out var consoleEnt) ||
|
||||
!consoleEnt.TryGetComponent(out SharedShuttleConsoleComponent? shuttleConsoleComponent))
|
||||
{
|
||||
Logger.Warning($"Unable to set Helmsman console to {state.Console.Value}");
|
||||
return;
|
||||
}
|
||||
|
||||
Console = shuttleConsoleComponent;
|
||||
}
|
||||
|
||||
public override ComponentState GetComponentState(ICommonSession player)
|
||||
{
|
||||
return new PilotComponentState(Console?.OwnerUid);
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class PilotComponentState : ComponentState
|
||||
{
|
||||
public EntityUid? Console { get; }
|
||||
|
||||
public PilotComponentState(EntityUid? uid)
|
||||
{
|
||||
Console = uid;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
17
Content.Shared/Shuttles/Components/SharedDockingComponent.cs
Normal file
17
Content.Shared/Shuttles/Components/SharedDockingComponent.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.Shuttles.Components
|
||||
{
|
||||
public abstract class SharedDockingComponent : Component
|
||||
{
|
||||
// Yes I left this in for now because there's no overhead and we'll need a client one later anyway
|
||||
// and I was too lazy to delete it.
|
||||
public override string Name => "Docking";
|
||||
|
||||
[ViewVariables]
|
||||
public bool Enabled = false;
|
||||
|
||||
public abstract bool Docked { get; }
|
||||
}
|
||||
}
|
||||
22
Content.Shared/Shuttles/Components/SharedShuttleComponent.cs
Normal file
22
Content.Shared/Shuttles/Components/SharedShuttleComponent.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.Shuttles.Components
|
||||
{
|
||||
public abstract class SharedShuttleComponent : Component
|
||||
{
|
||||
public override string Name => "Shuttle";
|
||||
|
||||
[ViewVariables]
|
||||
public virtual bool Enabled { get; set; } = true;
|
||||
|
||||
[ViewVariables]
|
||||
public ShuttleMode Mode { get; set; } = ShuttleMode.Cruise;
|
||||
}
|
||||
|
||||
public enum ShuttleMode : byte
|
||||
{
|
||||
Docking,
|
||||
Cruise,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Shuttles.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// Interact with to start piloting a shuttle.
|
||||
/// </summary>
|
||||
[NetworkedComponent()]
|
||||
public abstract class SharedShuttleConsoleComponent : Component
|
||||
{
|
||||
public override string Name => "ShuttleConsole";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Shuttles.Components
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public enum ThrusterVisualState : byte
|
||||
{
|
||||
State,
|
||||
Thrusting,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user