Implement Cargo Console (#413)
* Implement Cargo Console Add to CargoConsoleComponent GalacticBank information for syncing Bank Account Balance. Implement CargoOrderDatabase on the server side and a list of orders in the CargoOrderDatabaseComponent on the client side. This makes it easier to change data on the server side but also utilize the state syncing between components. Implement GalacticMarketComponent. Only productIds get sent. Both client and server create their lists from YAML. Implement basic spawning of items from approved orders in CargoOrderDatabase. * Finish Cargo Console Add validation to make sure Order Amount is one or more. Implement approve and cancel buttons to CargoConsoleMenu orders list row. Add price to CargoConsoleMenu product list row. Implement CargoOrderDataManager to consolidate CargoOrder lists. Refactor CargoOrderDatabaseComponent to use CargoOrderDataManager instead of storing duplicate lists. Implement canceling orders. Implement approving orders. Fix sprite links. Implement Cargo Request Console.
This commit is contained in:
committed by
Pieter-Jan Briers
parent
58709d2d26
commit
1580750606
34
Content.Shared/Prototypes/Cargo/CargoOrderData.cs
Normal file
34
Content.Shared/Prototypes/Cargo/CargoOrderData.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using Robust.Shared.Serialization;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Content.Shared.Prototypes.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
111
Content.Shared/Prototypes/Cargo/CargoProductPrototype.cs
Normal file
111
Content.Shared/Prototypes/Cargo/CargoProductPrototype.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
using System;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Shared.Prototypes.Cargo
|
||||
{
|
||||
[NetSerializable, Serializable, Prototype("cargoProduct")]
|
||||
public class CargoProductPrototype : IPrototype, IIndexedPrototype
|
||||
{
|
||||
private string _id;
|
||||
private string _name;
|
||||
private string _description;
|
||||
private SpriteSpecifier _icon;
|
||||
private string _product;
|
||||
private int _pointCost;
|
||||
private string _category;
|
||||
private string _group;
|
||||
|
||||
[ViewVariables]
|
||||
public string ID => _id;
|
||||
|
||||
/// <summary>
|
||||
/// Product name.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_name.Trim().Length != 0)
|
||||
return _name;
|
||||
var protoMan = IoCManager.Resolve<IPrototypeManager>();
|
||||
if (protoMan == null)
|
||||
return _name;
|
||||
protoMan.TryIndex(_product, out EntityPrototype prototype);
|
||||
if (prototype?.Name != null)
|
||||
_name = prototype.Name;
|
||||
return _name;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Short description of the product.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public string Description
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_description.Trim().Length != 0)
|
||||
return _description;
|
||||
var protoMan = IoCManager.Resolve<IPrototypeManager>();
|
||||
if (protoMan == null)
|
||||
return _description;
|
||||
protoMan.TryIndex(_product, out EntityPrototype prototype);
|
||||
if (prototype?.Description != null)
|
||||
_description = prototype.Description;
|
||||
return _description;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Texture path used in the CargoConsole GUI.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public SpriteSpecifier Icon => _icon;
|
||||
|
||||
/// <summary>
|
||||
/// The prototype name of the product.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public string Product => _product;
|
||||
|
||||
/// <summary>
|
||||
/// The point cost of the product.
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public int PointCost => _pointCost;
|
||||
|
||||
/// <summary>
|
||||
/// The prototype category of the product. (e.g. Engineering, Medical)
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public string Category => _category;
|
||||
|
||||
/// <summary>
|
||||
/// The prototype group of the product. (e.g. Contraband)
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public string Group => _group;
|
||||
|
||||
public void LoadFrom(YamlMappingNode mapping)
|
||||
{
|
||||
var serializer = YamlObjectSerializer.NewReader(mapping);
|
||||
|
||||
serializer.DataField(ref _name, "name", string.Empty);
|
||||
serializer.DataField(ref _id, "id", string.Empty);
|
||||
serializer.DataField(ref _description, "description", string.Empty);
|
||||
serializer.DataField(ref _icon, "icon", SpriteSpecifier.Invalid);
|
||||
serializer.DataField(ref _product, "product", null);
|
||||
serializer.DataField(ref _pointCost, "cost", 0);
|
||||
serializer.DataField(ref _category, "category", string.Empty);
|
||||
serializer.DataField(ref _group, "group", string.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user