Add cargo shuttle (#8686)
This commit is contained in:
22
Content.Shared/Cargo/BUI/CargoConsoleInterfaceState.cs
Normal file
22
Content.Shared/Cargo/BUI/CargoConsoleInterfaceState.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Cargo.BUI;
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public sealed class CargoConsoleInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public string Name;
|
||||
public int Count;
|
||||
public int Capacity;
|
||||
public int Balance;
|
||||
public List<CargoOrderData> Orders;
|
||||
|
||||
public CargoConsoleInterfaceState(string name, int count, int capacity, int balance, List<CargoOrderData> orders)
|
||||
{
|
||||
Name = name;
|
||||
Count = count;
|
||||
Capacity = capacity;
|
||||
Balance = balance;
|
||||
Orders = orders;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Cargo.BUI;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class CargoShuttleConsoleBoundUserInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public string AccountName;
|
||||
public string ShuttleName;
|
||||
|
||||
// Unfortunately shuttles have essentially 3 states so can't just use a nullable var for it:
|
||||
// 1. stowed
|
||||
// 2. called but not recallable
|
||||
// 3. called and recallable
|
||||
// The reason we have 2 is so people don't spam the recall button in the UI.
|
||||
public bool CanRecall;
|
||||
|
||||
/// <summary>
|
||||
/// When the shuttle is expected to be usable.
|
||||
/// </summary>
|
||||
public TimeSpan? ShuttleETA;
|
||||
|
||||
/// <summary>
|
||||
/// List of orders expected on the delivery.
|
||||
/// </summary>
|
||||
public List<CargoOrderData> Orders;
|
||||
|
||||
public CargoShuttleConsoleBoundUserInterfaceState(
|
||||
string accountName,
|
||||
string shuttleName,
|
||||
bool canRecall,
|
||||
TimeSpan? shuttleETA,
|
||||
List<CargoOrderData> orders)
|
||||
{
|
||||
AccountName = accountName;
|
||||
ShuttleName = shuttleName;
|
||||
CanRecall = canRecall;
|
||||
ShuttleETA = shuttleETA;
|
||||
Orders = orders;
|
||||
}
|
||||
}
|
||||
@@ -12,18 +12,16 @@ namespace Content.Shared.Cargo
|
||||
public string Reason;
|
||||
public string ProductId;
|
||||
public int Amount;
|
||||
public int PayingAccountId;
|
||||
public bool Approved;
|
||||
public string Approver = string.Empty;
|
||||
|
||||
public CargoOrderData(int orderNumber, string requester, string reason, string productId, int amount, int payingAccountId)
|
||||
public CargoOrderData(int orderNumber, string requester, string reason, string productId, int amount)
|
||||
{
|
||||
OrderNumber = orderNumber;
|
||||
Requester = requester;
|
||||
Reason = reason;
|
||||
ProductId = productId;
|
||||
Amount = amount;
|
||||
PayingAccountId = payingAccountId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
31
Content.Shared/Cargo/Components/CargoShuttleComponent.cs
Normal file
31
Content.Shared/Cargo/Components/CargoShuttleComponent.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using Robust.Shared.Map;
|
||||
|
||||
namespace Content.Shared.Cargo.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Present on cargo shuttles to provide metadata such as preventing spam calling.
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(SharedCargoSystem))]
|
||||
public sealed class CargoShuttleComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("nextCall")]
|
||||
public TimeSpan? NextCall;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("cooldown")]
|
||||
public float Cooldown = 45f;
|
||||
|
||||
[ViewVariables]
|
||||
public bool CanRecall;
|
||||
|
||||
/// <summary>
|
||||
/// The shuttle's assigned coordinates on the cargo map.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public EntityCoordinates Coordinates;
|
||||
|
||||
/// <summary>
|
||||
/// The assigned station for this cargo shuttle.
|
||||
/// </summary>
|
||||
[ViewVariables, DataField("station")]
|
||||
public EntityUid? Station;
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Cargo.Components
|
||||
{
|
||||
[Virtual]
|
||||
public class SharedCargoConsoleComponent : Component
|
||||
{
|
||||
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Sends away or requests shuttle
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class CargoConsoleShuttleMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public CargoConsoleShuttleMessage()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add order to database.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class CargoConsoleAddOrderMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public string Requester;
|
||||
public string Reason;
|
||||
public string ProductId;
|
||||
public int Amount;
|
||||
|
||||
public CargoConsoleAddOrderMessage(string requester, string reason, string productId, int amount)
|
||||
{
|
||||
Requester = requester;
|
||||
Reason = reason;
|
||||
ProductId = productId;
|
||||
Amount = amount;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove order from database.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class CargoConsoleRemoveOrderMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public int OrderNumber;
|
||||
|
||||
public CargoConsoleRemoveOrderMessage(int orderNumber)
|
||||
{
|
||||
OrderNumber = orderNumber;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set order in database as approved.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class CargoConsoleApproveOrderMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public int OrderNumber;
|
||||
|
||||
public CargoConsoleApproveOrderMessage(int orderNumber)
|
||||
{
|
||||
OrderNumber = orderNumber;
|
||||
}
|
||||
}
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public enum CargoConsoleUiKey
|
||||
{
|
||||
Key
|
||||
}
|
||||
}
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public sealed class CargoConsoleInterfaceState : BoundUserInterfaceState
|
||||
{
|
||||
public readonly bool RequestOnly;
|
||||
public readonly int BankId;
|
||||
public readonly string BankName;
|
||||
public readonly int BankBalance;
|
||||
public readonly (int CurrentCapacity, int MaxCapacity) ShuttleCapacity;
|
||||
|
||||
public CargoConsoleInterfaceState(bool requestOnly, int bankId, string bankName, int bankBalance, (int CurrentCapacity, int MaxCapacity) shuttleCapacity)
|
||||
{
|
||||
RequestOnly = requestOnly;
|
||||
BankId = bankId;
|
||||
BankName = bankName;
|
||||
BankBalance = bankBalance;
|
||||
ShuttleCapacity = shuttleCapacity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Cargo.Components
|
||||
{
|
||||
[NetworkedComponent()]
|
||||
public abstract class SharedCargoOrderDatabaseComponent : Component
|
||||
{
|
||||
}
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public sealed class CargoOrderDatabaseState : ComponentState
|
||||
{
|
||||
public readonly List<CargoOrderData>? Orders;
|
||||
|
||||
public CargoOrderDatabaseState(List<CargoOrderData>? orders)
|
||||
{
|
||||
Orders = orders;
|
||||
}
|
||||
}
|
||||
}
|
||||
12
Content.Shared/Cargo/Events/CargoCallShuttleMessage.cs
Normal file
12
Content.Shared/Cargo/Events/CargoCallShuttleMessage.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Cargo.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Raised on a cargo console requesting the cargo shuttle.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class CargoCallShuttleMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
|
||||
}
|
||||
23
Content.Shared/Cargo/Events/CargoConsoleAddOrderMessage.cs
Normal file
23
Content.Shared/Cargo/Events/CargoConsoleAddOrderMessage.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Cargo.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Add order to database.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class CargoConsoleAddOrderMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public string Requester;
|
||||
public string Reason;
|
||||
public string ProductId;
|
||||
public int Amount;
|
||||
|
||||
public CargoConsoleAddOrderMessage(string requester, string reason, string productId, int amount)
|
||||
{
|
||||
Requester = requester;
|
||||
Reason = reason;
|
||||
ProductId = productId;
|
||||
Amount = amount;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Cargo.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Set order in database as approved.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class CargoConsoleApproveOrderMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public int OrderNumber;
|
||||
|
||||
public CargoConsoleApproveOrderMessage(int orderNumber)
|
||||
{
|
||||
OrderNumber = orderNumber;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Cargo.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Remove order from database.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class CargoConsoleRemoveOrderMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public int OrderNumber;
|
||||
|
||||
public CargoConsoleRemoveOrderMessage(int orderNumber)
|
||||
{
|
||||
OrderNumber = orderNumber;
|
||||
}
|
||||
}
|
||||
12
Content.Shared/Cargo/Events/CargoRecallShuttleMessage.cs
Normal file
12
Content.Shared/Cargo/Events/CargoRecallShuttleMessage.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Cargo.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Raised on a client request cargo shuttle recall
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class CargoRecallShuttleMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@ using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Cargo
|
||||
namespace Content.Shared.Cargo.Prototypes
|
||||
{
|
||||
[NetSerializable, Serializable, Prototype("cargoProduct")]
|
||||
public sealed class CargoProductPrototype : IPrototype
|
||||
@@ -13,7 +13,7 @@ namespace Content.Shared.Cargo
|
||||
[DataField("description")] private string _description = string.Empty;
|
||||
|
||||
[ViewVariables]
|
||||
[IdDataFieldAttribute]
|
||||
[IdDataField]
|
||||
public string ID { get; } = default!;
|
||||
|
||||
/// <summary>
|
||||
20
Content.Shared/Cargo/Prototypes/CargoShuttlePrototype.cs
Normal file
20
Content.Shared/Cargo/Prototypes/CargoShuttlePrototype.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Content.Shared.Dataset;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Cargo.Prototypes;
|
||||
|
||||
[Prototype("cargoShuttle")]
|
||||
public sealed class CargoShuttlePrototype : IPrototype
|
||||
{
|
||||
[ViewVariables]
|
||||
[IdDataField]
|
||||
public string ID { get; } = default!;
|
||||
|
||||
[ViewVariables, DataField("path")]
|
||||
public ResourcePath Path = default!;
|
||||
|
||||
[ViewVariables, DataField("nameDataset", customTypeSerializer:typeof(PrototypeIdSerializer<DatasetPrototype>))]
|
||||
public string NameDataset = "CargoShuttleNames";
|
||||
}
|
||||
@@ -2,6 +2,14 @@ using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Cargo;
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public enum CargoConsoleUiKey : byte
|
||||
{
|
||||
Orders,
|
||||
Shuttle,
|
||||
Telepad
|
||||
}
|
||||
|
||||
public abstract class SharedCargoSystem : EntitySystem {}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
|
||||
Reference in New Issue
Block a user