Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mirror: Trading Outpost now has half buy-only and half sell-only pallets #191

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion Content.Server/Cargo/Components/CargoPalletComponent.cs
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 1 addition & 1 deletion Content.Server/Cargo/Systems/CargoSystem.Orders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private void OnApproveOrderMessage(EntityUid uid, CargoOrderConsoleComponent com
// 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);
Expand Down
15 changes: 12 additions & 3 deletions Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,16 @@ private List<CargoOrderData> GetProjectedOrders(
/// </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))
Expand All @@ -214,7 +217,13 @@ private int GetCargoSpace(EntityUid gridUid)
continue;
}

if ((requestType & comp.PalletType) == 0)
{
continue;
}

_pads.Add((uid, comp, compXform));

}

return _pads;
Expand Down Expand Up @@ -274,7 +283,7 @@ private void GetPalletGoods(EntityUid gridUid, out HashSet<EntityUid> toSell, ou
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();
Expand Down
263 changes: 145 additions & 118 deletions Resources/Maps/Shuttles/trading_outpost.yml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
mask:
- MachineMask
- type: CargoPallet
palletType: All
- type: StaticPrice
price: 100
- type: Sprite
Expand Down Expand Up @@ -53,3 +54,33 @@
- type: GuideHelp
guides:
- Cargo

- type: entity
id: CargoPalletSell
name: cargo selling pallet
description: Designates valid items to sell with a selling computer, or to CentCom when a shuttle is recalled.
parent: CargoPallet
components:
- type: CargoPallet
palletType: sell
- type: Sprite
drawdepth: FloorTiles
layers:
- sprite: Structures/cargo_pallets.rsi
state: cargo_pallet_sell


- type: entity
id: CargoPalletBuy
name: cargo buying pallet
description: Designates where orders will appear when purchased.
parent: CargoPallet
components:
- type: CargoPallet
palletType: buy
- type: Sprite
drawdepth: FloorTiles
layers:
- sprite: Structures/cargo_pallets.rsi
state: cargo_pallet_buy

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions Resources/Textures/Structures/cargo_pallets.rsi/meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"version": 1,
"license": "CC-BY-SA-3.0",
"copyright": "Created by TheShuEd (github) for Space Station 14)",
"size": {
"x": 32,
"y": 32
},
"states": [
{
"name": "cargo_pallet_buy"
},
{
"name": "cargo_pallet_sell"
}
]
}
Loading