Trading Outpost now has half buy-only and half sell-only pallets (#25955)
* Added new Buy & Sell specific cargo pallets * Remapped trading outpost with new pallets, tweaked texture * Removed debug message * Fixed/Compacted conditional checking to let old pallets still work for backwards compatability * Update Content.Server/Cargo/Components/CargoPalletComponent.cs Alright, updating all the references to it. Co-authored-by: Tayrtahn <tayrtahn@gmail.com> * Changed textures, changed to enum instead of string for pallet type check * Few minor code tweaks/formatting fixes * Missed the prototype change * Update Content.Server/Cargo/Components/CargoPalletComponent.cs * Update Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs --------- Co-authored-by: Tayrtahn <tayrtahn@gmail.com> Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -1,7 +1,26 @@
|
||||
namespace Content.Server.Cargo.Components;
|
||||
using Content.Shared.Actions;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations;
|
||||
|
||||
/// <summary>
|
||||
/// Any entities intersecting when a shuttle is recalled will be sold.
|
||||
/// </summary>
|
||||
|
||||
[Flags]
|
||||
public enum BuySellType : byte
|
||||
{
|
||||
Buy = 1 << 0,
|
||||
Sell = 1 << 1,
|
||||
All = Buy | Sell
|
||||
}
|
||||
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class CargoPalletComponent : Component {}
|
||||
public sealed partial class CargoPalletComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Whether the pad is a buy pad, a sell pad, or all.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public BuySellType PalletType;
|
||||
}
|
||||
|
||||
@@ -205,7 +205,7 @@ namespace Content.Server.Cargo.Systems
|
||||
// Try to fulfill from any station where possible, if the pad is not occupied.
|
||||
foreach (var trade in _listEnts)
|
||||
{
|
||||
var tradePads = GetCargoPallets(trade);
|
||||
var tradePads = GetCargoPallets(trade, BuySellType.Buy);
|
||||
_random.Shuffle(tradePads);
|
||||
|
||||
var freePads = GetFreeCargoPallets(trade, tradePads);
|
||||
|
||||
@@ -173,13 +173,16 @@ public sealed partial class CargoSystem
|
||||
/// </summary>
|
||||
private int GetCargoSpace(EntityUid gridUid)
|
||||
{
|
||||
var space = GetCargoPallets(gridUid).Count;
|
||||
var space = GetCargoPallets(gridUid, BuySellType.Buy).Count;
|
||||
return space;
|
||||
}
|
||||
|
||||
private List<(EntityUid Entity, CargoPalletComponent Component, TransformComponent PalletXform)> GetCargoPallets(EntityUid gridUid)
|
||||
/// GetCargoPallets(gridUid, BuySellType.Sell) to return only Sell pads
|
||||
/// GetCargoPallets(gridUid, BuySellType.Buy) to return only Buy pads
|
||||
private List<(EntityUid Entity, CargoPalletComponent Component, TransformComponent PalletXform)> GetCargoPallets(EntityUid gridUid, BuySellType requestType = BuySellType.All)
|
||||
{
|
||||
_pads.Clear();
|
||||
|
||||
var query = AllEntityQuery<CargoPalletComponent, TransformComponent>();
|
||||
|
||||
while (query.MoveNext(out var uid, out var comp, out var compXform))
|
||||
@@ -190,7 +193,13 @@ public sealed partial class CargoSystem
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((requestType & comp.PalletType) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
_pads.Add((uid, comp, compXform));
|
||||
|
||||
}
|
||||
|
||||
return _pads;
|
||||
@@ -250,7 +259,7 @@ public sealed partial class CargoSystem
|
||||
amount = 0;
|
||||
toSell = new HashSet<EntityUid>();
|
||||
|
||||
foreach (var (palletUid, _, _) in GetCargoPallets(gridUid))
|
||||
foreach (var (palletUid, _, _) in GetCargoPallets(gridUid, BuySellType.Sell))
|
||||
{
|
||||
// Containers should already get the sell price of their children so can skip those.
|
||||
_setEnts.Clear();
|
||||
|
||||
Reference in New Issue
Block a user