Make Saltern driveable (#4257)

* Broadphase refactor (content)

* Shuttle jank

* Fixes

* Testing jank

* Features and things

* Balance stuffsies

* AHHHHHHHHHHHHHHHH

* Mass and stuff working

* Fix drops

* Another balance pass

* Balance AGEN

* Add in stuff for rotating shuttles for debugging

* Nothing to see here

* Testbed stuffsies

* Fix some tests

* Fixen test

* Try fixing map

* Shuttle movement balance pass

* lasaggne

* Basic Helmsman console working

* Slight docking cleanup

* Helmsman requires power

* Basic shuttle test

* Stuff

* Fix computations

* Add shuttle console to saltern

* Rename helmsman to shuttleconsole

* Final stretch

* More tweaks

* Fix piloting prediction for now.
This commit is contained in:
metalgearsloth
2021-07-21 21:15:12 +10:00
committed by GitHub
parent 55087a6f16
commit 500b9cb1ea
44 changed files with 1042 additions and 1601 deletions

View File

@@ -0,0 +1,58 @@
using System;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Log;
using Robust.Shared.Players;
using Robust.Shared.Serialization;
using Robust.Shared.ViewVariables;
namespace Content.Shared.Shuttles
{
/// <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; }
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?.Owner.Uid);
}
[Serializable, NetSerializable]
private sealed class PilotComponentState : ComponentState
{
public EntityUid? Console { get; }
public PilotComponentState(EntityUid? uid)
{
Console = uid;
}
}
}
}

View File

@@ -0,0 +1,28 @@
using Robust.Shared.GameObjects;
using Robust.Shared.ViewVariables;
namespace Content.Shared.Shuttles
{
public abstract class SharedShuttleComponent : Component
{
public override string Name => "Shuttle";
[ViewVariables]
public virtual bool Enabled { get; set; } = true;
/// <summary>
/// How much our linear impulse is multiplied by.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
public float SpeedMultipler { get; set; } = 200.0f;
[ViewVariables]
public ShuttleMode Mode { get; set; } = ShuttleMode.Docking;
}
public enum ShuttleMode : byte
{
Docking,
Cruise,
}
}

View File

@@ -0,0 +1,14 @@
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
namespace Content.Shared.Shuttles
{
/// <summary>
/// Interact with to start piloting a shuttle.
/// </summary>
[NetworkedComponent()]
public abstract class SharedShuttleConsoleComponent : Component
{
public override string Name => "ShuttleConsole";
}
}

View File

@@ -0,0 +1,20 @@
using Content.Shared.Movement;
using Robust.Shared.GameObjects;
namespace Content.Shared.Shuttles
{
public abstract class SharedShuttleConsoleSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<PilotComponent, MovementAttemptEvent>(HandleMovementBlock);
}
private void HandleMovementBlock(EntityUid uid, PilotComponent component, MovementAttemptEvent args)
{
if (component.Console == null) return;
args.Cancel();
}
}
}