Thrusters (shuttle go nyoom) (#5352)
This commit is contained in:
21
Content.Server/Shuttles/Components/DockingComponent.cs
Normal file
21
Content.Server/Shuttles/Components/DockingComponent.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using Content.Shared.Shuttles;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Physics.Dynamics.Joints;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Shuttles.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class DockingComponent : SharedDockingComponent
|
||||
{
|
||||
[ViewVariables]
|
||||
public DockingComponent? DockedWith;
|
||||
|
||||
[ViewVariables]
|
||||
public Joint? DockJoint;
|
||||
|
||||
[ViewVariables]
|
||||
public override bool Docked => DockedWith != null;
|
||||
}
|
||||
}
|
||||
37
Content.Server/Shuttles/Components/ShuttleComponent.cs
Normal file
37
Content.Server/Shuttles/Components/ShuttleComponent.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Shuttles.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class ShuttleComponent : SharedShuttleComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// The cached impulse available for each cardinal direction
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public readonly float[] LinearThrusterImpulse = new float[4];
|
||||
|
||||
/// <summary>
|
||||
/// The thrusters contributing to each direction for impulse.
|
||||
/// </summary>
|
||||
public readonly List<ThrusterComponent>[] LinearThrusters = new List<ThrusterComponent>[4];
|
||||
|
||||
/// <summary>
|
||||
/// The thrusters contributing to the angular impulse of the shuttle.
|
||||
/// </summary>
|
||||
public readonly List<ThrusterComponent> AngularThrusters = new List<ThrusterComponent>();
|
||||
|
||||
[ViewVariables]
|
||||
public float AngularThrust = 0f;
|
||||
|
||||
/// <summary>
|
||||
/// A bitmask of all the directions we are considered thrusting.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public DirectionFlag ThrustDirections = DirectionFlag.None;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Shuttles;
|
||||
using Content.Shared.Shuttles.Components;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Shuttles.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[ComponentReference(typeof(SharedShuttleConsoleComponent))]
|
||||
internal sealed class ShuttleConsoleComponent : SharedShuttleConsoleComponent
|
||||
{
|
||||
[ViewVariables]
|
||||
public List<PilotComponent> SubscribedPilots = new();
|
||||
|
||||
/// <summary>
|
||||
/// Whether the console can be used to pilot. Toggled whenever it gets powered / unpowered.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public bool Enabled { get; set; } = false;
|
||||
}
|
||||
}
|
||||
86
Content.Server/Shuttles/Components/ThrusterComponent.cs
Normal file
86
Content.Server/Shuttles/Components/ThrusterComponent.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Shuttles.EntitySystems;
|
||||
using Content.Shared.Damage;
|
||||
using Robust.Shared.Analyzers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Physics.Collision.Shapes;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Server.Shuttles.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
[Friend(typeof(ThrusterSystem))]
|
||||
public sealed class ThrusterComponent : Component
|
||||
{
|
||||
public override string Name => "Thruster";
|
||||
|
||||
/// <summary>
|
||||
/// Whether the thruster has been force to be enabled / disable (e.g. VV, interaction, etc.)
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("enabled")]
|
||||
public bool Enabled
|
||||
{
|
||||
get => _enabled;
|
||||
set
|
||||
{
|
||||
if (_enabled == value) return;
|
||||
_enabled = value;
|
||||
|
||||
var system = EntitySystem.Get<ThrusterSystem>();
|
||||
|
||||
if (!_enabled)
|
||||
{
|
||||
system.DisableThruster(OwnerUid, this);
|
||||
}
|
||||
else if (system.CanEnable(OwnerUid, this))
|
||||
{
|
||||
system.EnableThruster(OwnerUid, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _enabled = true;
|
||||
|
||||
/// <summary>
|
||||
/// This determines whether the thruster is actually enabled for the purposes of thrust
|
||||
/// </summary>
|
||||
public bool IsOn;
|
||||
|
||||
[ViewVariables]
|
||||
[DataField("impulse")]
|
||||
public float Impulse = 5f;
|
||||
|
||||
[ViewVariables]
|
||||
[DataField("thrusterType")]
|
||||
public ThrusterType Type = ThrusterType.Linear;
|
||||
|
||||
[DataField("burnShape")] public List<Vector2> BurnPoly = new()
|
||||
{
|
||||
new Vector2(-0.4f, 0.5f),
|
||||
new Vector2(-0.1f, 1.2f),
|
||||
new Vector2(0.1f, 1.2f),
|
||||
new Vector2(0.4f, 0.5f)
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// How much damage is done per second to anything colliding with our thrust.
|
||||
/// </summary>
|
||||
[ViewVariables] [DataField("damage")] public DamageSpecifier? Damage = new();
|
||||
|
||||
// Used for burns
|
||||
|
||||
public List<EntityUid> Colliding = new();
|
||||
|
||||
public bool Firing = false;
|
||||
}
|
||||
|
||||
public enum ThrusterType
|
||||
{
|
||||
Linear,
|
||||
// Angular meaning rotational.
|
||||
Angular,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user