Skip to content

Commit

Permalink
Cargo Depot finagling
Browse files Browse the repository at this point in the history
  • Loading branch information
whatston3 committed Feb 2, 2025
1 parent b06e7af commit 2294a89
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 65 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Content.Server.Cargo.Systems;
using Content.Shared.Stacks;
using Content.Shared.Whitelist;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;

namespace Content.Server.Cargo.Components;
Expand All @@ -16,4 +17,10 @@ public sealed partial class CargoPalletConsoleComponent : Component
// Can be modified individually when mapping, so that consoles have a further reach
[DataField("palletDistance")]
public int PalletDistance = 8;

// The distance in a radius around the console to check for cargo pallets
// Can be modified individually when mapping, so that consoles have a further reach
[DataField]
public EntityWhitelist? Whitelist;
// End Frontier
}
30 changes: 19 additions & 11 deletions Content.Server/Cargo/Systems/CargoSystem.Shuttle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Robust.Shared.Map;
using Robust.Shared.Random;
using Robust.Shared.Audio;
using Content.Shared.Whitelist; // Frontier
using Content.Server._NF.Cargo.Components; // Frontier
using Content.Shared._NF.Bank.Components; // Frontier
using Content.Shared.Mobs; // Frontier
Expand All @@ -20,6 +21,8 @@ public sealed partial class CargoSystem
* Handles cargo shuttle / trade mechanics.
*/

[Dependency] EntityWhitelistSystem _whitelist = default!; // Frontier

// Frontier addition:
// The maximum distance from the console to look for pallets.
private const int DefaultPalletDistance = 8;
Expand Down Expand Up @@ -59,29 +62,29 @@ private void UpdateCargoShuttleConsoles(EntityUid shuttleUid, CargoShuttleCompon
}
}

private void UpdatePalletConsoleInterface(EntityUid uid)
private void UpdatePalletConsoleInterface(Entity<CargoPalletConsoleComponent> uid) // Frontier: EntityUid<Entity
{
if (Transform(uid).GridUid is not EntityUid gridUid)
{
_uiSystem.SetUiState(uid, CargoPalletConsoleUiKey.Sale,
_uiSystem.SetUiState(uid.Owner, CargoPalletConsoleUiKey.Sale, // Frontier: uid<uid.Owner
new CargoPalletConsoleInterfaceState(0, 0, false));
return;
}
GetPalletGoods(uid, gridUid, out var toSell, out var amount, out var noModAmount); // Frontier: add noModAmount
// Frontier
// Frontier: per-object market modification
GetPalletGoods(uid, gridUid, out var toSell, out var amount, out var noModAmount);
if (TryComp<MarketModifierComponent>(uid, out var priceMod))
{
amount *= priceMod.Mod;
}
amount += noModAmount;
// End Frontier
_uiSystem.SetUiState(uid, CargoPalletConsoleUiKey.Sale,
_uiSystem.SetUiState(uid.Owner, CargoPalletConsoleUiKey.Sale, // Frontier: uid<uid.Owner
new CargoPalletConsoleInterfaceState((int) amount, toSell.Count, true));
}

private void OnPalletUIOpen(EntityUid uid, CargoPalletConsoleComponent component, BoundUIOpenedEvent args)
{
UpdatePalletConsoleInterface(uid);
UpdatePalletConsoleInterface((uid, component)); // Frontier: EntityUid<Entity
}

/// <summary>
Expand All @@ -94,7 +97,7 @@ private void OnPalletUIOpen(EntityUid uid, CargoPalletConsoleComponent component

private void OnPalletAppraise(EntityUid uid, CargoPalletConsoleComponent component, CargoPalletAppraiseMessage args)
{
UpdatePalletConsoleInterface(uid);
UpdatePalletConsoleInterface((uid, component)); // Frontier: EntityUid<Entity
}

private void OnCargoShuttleConsoleStartup(EntityUid uid, CargoShuttleConsoleComponent component, ComponentStartup args)
Expand Down Expand Up @@ -262,7 +265,7 @@ public static double CalculateDistance(EntityCoordinates point1, EntityCoordinat

#region Station

private bool SellPallets(EntityUid consoleUid, EntityUid gridUid, out double amount, out double noMultiplierAmount) // Frontier: add noMultiplierAmount
private bool SellPallets(Entity<CargoPalletConsoleComponent> consoleUid, EntityUid gridUid, out double amount, out double noMultiplierAmount) // Frontier: first arg to Entity, add noMultiplierAmount
{
GetPalletGoods(consoleUid, gridUid, out var toSell, out amount, out noMultiplierAmount); // Frontier: add noMultiplierAmount

Expand All @@ -283,7 +286,7 @@ private bool SellPallets(EntityUid consoleUid, EntityUid gridUid, out double amo
return true;
}

private void GetPalletGoods(EntityUid consoleUid, EntityUid gridUid, out HashSet<EntityUid> toSell, out double amount, out double noMultiplierAmount) // Frontier: add noMultiplierAmount
private void GetPalletGoods(Entity<CargoPalletConsoleComponent> consoleUid, EntityUid gridUid, out HashSet<EntityUid> toSell, out double amount, out double noMultiplierAmount) // Frontier: first arg to Entity, add noMultiplierAmount
{
amount = 0;
noMultiplierAmount = 0;
Expand All @@ -310,6 +313,11 @@ private void GetPalletGoods(EntityUid consoleUid, EntityUid gridUid, out HashSet
continue;
}

// Frontier: whitelisted consoles
if (_whitelist.IsWhitelistFail(consoleUid.Comp.Whitelist, ent))
continue;
// End Frontier

if (_blacklistQuery.HasComponent(ent))
continue;

Expand Down Expand Up @@ -366,7 +374,7 @@ private void OnPalletSale(EntityUid uid, CargoPalletConsoleComponent component,
return;
}

if (!SellPallets(uid, gridUid, out var price, out var noMultiplierPrice)) // Frontier: add noMultiplierPrice
if (!SellPallets((uid, component), gridUid, out var price, out var noMultiplierPrice)) // Frontier: convert first arg to Entity, add noMultiplierPrice
return;

// Frontier: market modifiers & immune objects
Expand All @@ -379,7 +387,7 @@ private void OnPalletSale(EntityUid uid, CargoPalletConsoleComponent component,
var stackPrototype = _protoMan.Index<StackPrototype>(component.CashType);
_stack.Spawn((int) price, stackPrototype, xform.Coordinates);
_audio.PlayPvs(ApproveSound, uid);
UpdatePalletConsoleInterface(uid);
UpdatePalletConsoleInterface((uid, component)); // Frontier: EntityUid<Entity
}

#endregion
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/_NF/CCVar/NFCCVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public sealed class NFCCVars
/// The number of Cargo Depots to spawn in every round
/// </summary>
public static readonly CVarDef<int> CargoDepots =
CVarDef.Create("nf14.worldgen.cargo_depots", 2, CVar.SERVERONLY);
CVarDef.Create("nf14.worldgen.cargo_depots", 4, CVar.SERVERONLY);

/// <summary>
/// The number of Optional Points Of Interest to spawn in every round
Expand Down
23 changes: 1 addition & 22 deletions Resources/Maps/_NF/POI/cargodepot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ entities:
264: 5,2
265: 5,-2
266: 5,-4
289: -1,0
- node:
angle: 1.5707963267948966 rad
color: '#FFFFFFFF'
Expand All @@ -369,7 +368,6 @@ entities:
260: -5,2
261: -5,-2
262: -5,-4
290: 1,0
- node:
color: '#A4610696'
id: MiniTileCheckerAOverlay
Expand Down Expand Up @@ -3467,18 +3465,7 @@ entities:
- type: Transform
pos: 4.5,10.5
parent: 10
- proto: ComputerMarketConsoleNFHigh
entities:
- uid: 466
components:
- type: Transform
pos: 0.5,-0.5
parent: 10
- type: ContainerContainer
containers:
board: !type:Container
ents: []
- proto: ComputerPalletConsoleNFHighMarket
- proto: ComputerPalletConsoleNFNormalTradeCrate
entities:
- uid: 7
components:
Expand Down Expand Up @@ -3655,14 +3642,6 @@ entities:
rot: 1.5707963267948966 rad
pos: 9.5,-1.5
parent: 10
- proto: CrateMachine
entities:
- uid: 465
components:
- type: Transform
rot: -1.5707963267948966 rad
pos: 0.5,0.5
parent: 10
- proto: d6Dice
entities:
- uid: 1056
Expand Down
22 changes: 1 addition & 21 deletions Resources/Maps/_NF/POI/cargodepotalt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,6 @@ entities:
270: 5,2
271: 5,-2
272: 5,-4
393: -1,0
- node:
angle: 1.5707963267948966 rad
color: '#FFFFFFFF'
Expand All @@ -438,7 +437,6 @@ entities:
266: -5,2
267: -5,-2
268: -5,-4
394: 1,0
- node:
color: '#A4610696'
id: MiniTileCheckerAOverlay
Expand Down Expand Up @@ -3530,18 +3528,7 @@ entities:
- type: Transform
pos: 4.5,10.5
parent: 10
- proto: ComputerMarketConsoleNFHigh
entities:
- uid: 483
components:
- type: Transform
pos: 0.5,-0.5
parent: 10
- type: ContainerContainer
containers:
board: !type:Container
ents: []
- proto: ComputerPalletConsoleNFHighMarket
- proto: ComputerPalletConsoleNFNormalTradeCrate
entities:
- uid: 7
components:
Expand Down Expand Up @@ -3718,13 +3705,6 @@ entities:
rot: 1.5707963267948966 rad
pos: 9.5,-1.5
parent: 10
- proto: CrateMachine
entities:
- uid: 484
components:
- type: Transform
pos: 0.5,0.5
parent: 10
- proto: DisposalUnit
entities:
- uid: 1059
Expand Down
4 changes: 2 additions & 2 deletions Resources/Maps/_NF/POI/trade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10884,7 +10884,7 @@ entities:
- OrderSender: OrderReceiver
4372:
- OrderSender: OrderReceiver
- proto: ComputerTabletopMarketConsoleNFLow
- proto: ComputerTabletopMarketConsoleNFNormal
entities:
- uid: 237
components:
Expand All @@ -10909,7 +10909,7 @@ entities:
rot: -1.5707963267948966 rad
pos: -20.5,9.5
parent: 1
- proto: ComputerTabletopPalletConsoleNFLowMarket
- proto: ComputerTabletopPalletConsoleNFNormalMarket
entities:
- uid: 96
components:
Expand Down
4 changes: 2 additions & 2 deletions Resources/Maps/_NF/POI/trademall.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19215,7 +19215,7 @@ entities:
rot: -1.5707963267948966 rad
pos: 29.5,11.5
parent: 1
- proto: ComputerTabletopMarketConsoleNFLow
- proto: ComputerTabletopMarketConsoleNFNormal
entities:
- uid: 27
components:
Expand All @@ -19234,7 +19234,7 @@ entities:
rot: 1.5707963267948966 rad
pos: 58.5,-3.5
parent: 1
- proto: ComputerTabletopPalletConsoleNFLowMarket
- proto: ComputerTabletopPalletConsoleNFNormalMarket
entities:
- uid: 632
components:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@
- type: MarketModifier
mod: 0.50

- type: entity
parent: ComputerPalletConsoleNFNormalMarket
id: ComputerPalletConsoleNFNormalTradeCrate
name: trade crate sale computer
suffix: Trade Crates, Normal
description: Used to sell trade crates loaded onto cargo pallets.
components:
- type: CargoPalletConsole
whitelist:
components:
- TradeCrate

- type: entity
name: contraband exchange computer
parent: [BaseStructureDisableToolUse, BaseStructureIndestructible, BaseComputer]
Expand Down Expand Up @@ -210,6 +222,15 @@
- type: MarketModifier
mod: 4

- type: entity
name: cargo market computer
parent: ComputerMarketConsoleNFBase
id: ComputerMarketConsoleNFNormal
suffix: Normal
components:
- type: MarketModifier
mod: 6

- type: entity
name: cargo market computer
parent: ComputerMarketConsoleNFBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,15 @@
sprite: Structures/Machines/computers.rsi
state: tech_key

- type: entity
parent: [BaseStructureComputerTabletop, ComputerMarketConsoleNFNormal]
id: ComputerTabletopMarketConsoleNFNormal
suffix: Normal, Tabletop
components:
- type: Sprite
drawdepth: SmallObjects
layers: *cargoMarketSprite

- type: entity
parent: [BaseStructureComputerTabletop, ComputerMarketConsoleNFHigh]
id: ComputerTabletopMarketConsoleNFHigh
Expand Down Expand Up @@ -581,6 +590,15 @@
drawdepth: SmallObjects
layers: *cargoPalletSprite

- type: entity
parent: [BaseStructureIndestructible, BaseStructureComputerTabletop, ComputerPalletConsoleNFNormalTradeCrate]
id: ComputerTabletopPalletConsoleNFNormalTradeCrate
suffix: Trade Crates, Normal, Tabletop
components:
- type: Sprite
drawdepth: SmallObjects
layers: *cargoPalletSprite

- type: entity
parent: [BaseStructureIndestructible, BaseStructureComputerTabletop, ComputerPalletConsoleNFLowMarket]
id: ComputerTabletopPalletConsoleNFLowMarket
Expand Down
12 changes: 6 additions & 6 deletions Resources/Prototypes/_NF/PointsOfInterest/depots.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
id: CargoDepot
parent: BasePOI
name: Cargo Depot
minimumDistance: 4500
maximumDistance: 6000
minimumDistance: 4000
maximumDistance: 5000
spawnGroup: CargoDepot
gridPath: /Maps/_NF/POI/cargodepot.yml
addComponents:
Expand All @@ -26,8 +26,8 @@
id: CargoDepotAlt
parent: BasePOI
name: Cargo Depot
minimumDistance: 4500
maximumDistance: 6000
minimumDistance: 4000
maximumDistance: 5000
spawnGroup: CargoDepot
gridPath: /Maps/_NF/POI/cargodepotalt.yml
addComponents:
Expand All @@ -43,7 +43,7 @@
minPlayers: 0
stations:
CargoDepot:
stationProto: MarketFrontierOutpost
stationProto: StandardFrontierOutpost
components:
- type: StationNameSetup
mapNameTemplate: 'Cargo Depot' # Has a letter appended in PointOfInterestSystem
Expand All @@ -57,7 +57,7 @@
minPlayers: 0
stations:
CargoDepotAlt:
stationProto: MarketFrontierOutpost
stationProto: StandardFrontierOutpost
components:
- type: StationNameSetup
mapNameTemplate: 'Cargo Depot' # Has a letter appended in PointOfInterestSystem
Expand Down

0 comments on commit 2294a89

Please sign in to comment.