Re-organize all projects (#4166)
This commit is contained in:
31
Content.Shared/Cargo/CargoOrderData.cs
Normal file
31
Content.Shared/Cargo/CargoOrderData.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Cargo
|
||||
{
|
||||
[NetSerializable, Serializable]
|
||||
public class CargoOrderData
|
||||
{
|
||||
public int OrderNumber;
|
||||
public string Requester;
|
||||
// public String RequesterRank; // TODO Figure out how to get Character ID card data
|
||||
// public int RequesterId;
|
||||
public string Reason;
|
||||
public string ProductId;
|
||||
public int Amount;
|
||||
public int PayingAccountId;
|
||||
public bool Approved;
|
||||
|
||||
public CargoOrderData(int orderNumber, string requester, string reason, string productId, int amount, int payingAccountId)
|
||||
{
|
||||
OrderNumber = orderNumber;
|
||||
Requester = requester;
|
||||
Reason = reason;
|
||||
ProductId = productId;
|
||||
Amount = amount;
|
||||
PayingAccountId = payingAccountId;
|
||||
Approved = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
98
Content.Shared/Cargo/CargoProductPrototype.cs
Normal file
98
Content.Shared/Cargo/CargoProductPrototype.cs
Normal file
@@ -0,0 +1,98 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
namespace Content.Shared.Cargo
|
||||
{
|
||||
[NetSerializable, Serializable, Prototype("cargoProduct")]
|
||||
public class CargoProductPrototype : IPrototype
|
||||
{
|
||||
[DataField("name")] private string _name = string.Empty;
|
||||
|
||||
[DataField("description")] private string _description = string.Empty;
|
||||
|
||||
[ViewVariables]
|
||||
[DataField("id", required: true)]
|
||||
public string ID { get; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Product name.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_name.Trim().Length != 0)
|
||||
return _name;
|
||||
|
||||
if (IoCManager.Resolve<IPrototypeManager>().TryIndex(Product, out EntityPrototype? prototype))
|
||||
{
|
||||
_name = prototype.Name;
|
||||
}
|
||||
|
||||
return _name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Short description of the product.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_description.Trim().Length != 0)
|
||||
return _description;
|
||||
|
||||
if (IoCManager.Resolve<IPrototypeManager>().TryIndex(Product, out EntityPrototype? prototype))
|
||||
{
|
||||
_description = prototype.Description;
|
||||
}
|
||||
|
||||
return _description;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Texture path used in the CargoConsole GUI.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField("icon")]
|
||||
public SpriteSpecifier Icon { get; } = SpriteSpecifier.Invalid;
|
||||
|
||||
/// <summary>
|
||||
/// The prototype name of the product.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField("product")]
|
||||
public string Product { get; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The point cost of the product.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField("cost")]
|
||||
public int PointCost { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The prototype category of the product. (e.g. Engineering, Medical)
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField("category")]
|
||||
public string Category { get; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The prototype group of the product. (e.g. Contraband)
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
[DataField("group")]
|
||||
public string Group { get; } = string.Empty;
|
||||
}
|
||||
}
|
||||
100
Content.Shared/Cargo/Components/SharedCargoConsoleComponent.cs
Normal file
100
Content.Shared/Cargo/Components/SharedCargoConsoleComponent.cs
Normal file
@@ -0,0 +1,100 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Cargo.Components
|
||||
{
|
||||
public class SharedCargoConsoleComponent : Component
|
||||
{
|
||||
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
|
||||
|
||||
public sealed override string Name => "CargoConsole";
|
||||
|
||||
/// <summary>
|
||||
/// Sends away or requests shuttle
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public class CargoConsoleShuttleMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public CargoConsoleShuttleMessage()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add order to database.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public 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 class CargoConsoleRemoveOrderMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public int OrderNumber;
|
||||
|
||||
public CargoConsoleRemoveOrderMessage(int orderNumber)
|
||||
{
|
||||
OrderNumber = orderNumber;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set order in database as approved.
|
||||
/// </summary>
|
||||
[Serializable, NetSerializable]
|
||||
public class CargoConsoleApproveOrderMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public int OrderNumber;
|
||||
|
||||
public CargoConsoleApproveOrderMessage(int orderNumber)
|
||||
{
|
||||
OrderNumber = orderNumber;
|
||||
}
|
||||
}
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public enum CargoConsoleUiKey
|
||||
{
|
||||
Key
|
||||
}
|
||||
}
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.NetIDs;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Cargo.Components
|
||||
{
|
||||
public class SharedCargoOrderDatabaseComponent : Component
|
||||
{
|
||||
public sealed override string Name => "CargoOrderDatabase";
|
||||
public sealed override uint? NetID => ContentNetIDs.CARGO_ORDER_DATABASE;
|
||||
}
|
||||
|
||||
[NetSerializable, Serializable]
|
||||
public class CargoOrderDatabaseState : ComponentState
|
||||
{
|
||||
public readonly List<CargoOrderData>? Orders;
|
||||
|
||||
public CargoOrderDatabaseState(List<CargoOrderData>? orders) : base(ContentNetIDs.CARGO_ORDER_DATABASE)
|
||||
{
|
||||
Orders = orders;
|
||||
}
|
||||
}
|
||||
}
|
||||
106
Content.Shared/Cargo/Components/SharedGalacticMarketComponent.cs
Normal file
106
Content.Shared/Cargo/Components/SharedGalacticMarketComponent.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.NetIDs;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Shared.Cargo.Components
|
||||
{
|
||||
public class SharedGalacticMarketComponent : Component, IEnumerable<CargoProductPrototype>, ISerializationHooks
|
||||
{
|
||||
public sealed override string Name => "GalacticMarket";
|
||||
public sealed override uint? NetID => ContentNetIDs.GALACTIC_MARKET;
|
||||
|
||||
[DataField("products")]
|
||||
protected List<string> _productIds = new();
|
||||
|
||||
protected readonly List<CargoProductPrototype> _products = new();
|
||||
|
||||
/// <summary>
|
||||
/// A read-only list of products.
|
||||
/// </summary>
|
||||
public IReadOnlyList<CargoProductPrototype> Products => _products;
|
||||
|
||||
void ISerializationHooks.AfterDeserialization()
|
||||
{
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
|
||||
_products.Clear();
|
||||
|
||||
foreach (var id in _productIds)
|
||||
{
|
||||
if (!prototypeManager.TryIndex(id, out CargoProductPrototype? product))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_products.Add(product);
|
||||
}
|
||||
}
|
||||
|
||||
void ISerializationHooks.BeforeSerialization()
|
||||
{
|
||||
_productIds.Clear();
|
||||
|
||||
foreach (var product in _products)
|
||||
{
|
||||
_productIds.Add(product.ID);
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerator<CargoProductPrototype> GetEnumerator()
|
||||
{
|
||||
return _products.GetEnumerator();
|
||||
}
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator()
|
||||
{
|
||||
return GetEnumerator();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a product from the string id;
|
||||
/// </summary>
|
||||
/// <returns>Product</returns>
|
||||
public CargoProductPrototype? GetProduct(string productId)
|
||||
{
|
||||
var prototypeManager = IoCManager.Resolve<IPrototypeManager>();
|
||||
if (!prototypeManager.TryIndex(productId, out CargoProductPrototype? product) || !_products.Contains(product))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return product;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list with the IDs of all products.
|
||||
/// </summary>
|
||||
/// <returns>A list of product IDs</returns>
|
||||
public List<string> GetProductIdList()
|
||||
{
|
||||
var productIds = new List<string>();
|
||||
|
||||
foreach (var product in _products)
|
||||
{
|
||||
productIds.Add(product.ID);
|
||||
}
|
||||
|
||||
return productIds;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class GalacticMarketState : ComponentState
|
||||
{
|
||||
public List<string> Products;
|
||||
public GalacticMarketState(List<string> technologies) : base(ContentNetIDs.GALACTIC_MARKET)
|
||||
{
|
||||
Products = technologies;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user