Add prices for gas canisters (#10129)
This commit is contained in:
@@ -3,6 +3,7 @@ using Content.Server.Atmos.Components;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Atmos.Piping.Components;
|
||||
using Content.Server.Atmos.Piping.Unary.Components;
|
||||
using Content.Server.Cargo.Systems;
|
||||
using Content.Server.NodeContainer;
|
||||
using Content.Server.NodeContainer.NodeGroups;
|
||||
using Content.Server.NodeContainer.Nodes;
|
||||
@@ -23,6 +24,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
[Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!;
|
||||
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
|
||||
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
|
||||
[Dependency] private readonly PricingSystem _pricing = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
|
||||
public override void Initialize()
|
||||
@@ -36,6 +38,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
SubscribeLocalEvent<GasCanisterComponent, InteractUsingEvent>(OnCanisterInteractUsing);
|
||||
SubscribeLocalEvent<GasCanisterComponent, EntInsertedIntoContainerMessage>(OnCanisterContainerInserted);
|
||||
SubscribeLocalEvent<GasCanisterComponent, EntRemovedFromContainerMessage>(OnCanisterContainerRemoved);
|
||||
SubscribeLocalEvent<GasCanisterComponent, PriceCalculationEvent>(CalculateCanisterPrice);
|
||||
// Bound UI subscriptions
|
||||
SubscribeLocalEvent<GasCanisterComponent, GasCanisterHoldingTankEjectMessage>(OnHoldingTankEjectMessage);
|
||||
SubscribeLocalEvent<GasCanisterComponent, GasCanisterChangeReleasePressureMessage>(OnCanisterChangeReleasePressure);
|
||||
@@ -292,5 +295,25 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems
|
||||
_atmosphereSystem.Merge(containerAir, buffer);
|
||||
containerAir.Multiply(containerAir.Volume / buffer.Volume);
|
||||
}
|
||||
|
||||
private void CalculateCanisterPrice(EntityUid uid, GasCanisterComponent component, ref PriceCalculationEvent args)
|
||||
{
|
||||
float basePrice = 0; // moles of gas * price/mole
|
||||
float totalMoles = 0; // total number of moles in can
|
||||
float maxComponent = 0; // moles of the dominant gas
|
||||
for (var i = 0; i < Atmospherics.TotalNumberOfGases; i++)
|
||||
{
|
||||
basePrice += component.Air.Moles[i] * _atmosphereSystem.GetGas(i).PricePerMole;
|
||||
totalMoles += component.Air.Moles[i];
|
||||
maxComponent = Math.Max(maxComponent, component.Air.Moles[i]);
|
||||
}
|
||||
|
||||
// Pay more for gas canisters that are more pure
|
||||
float purity = 1;
|
||||
if (totalMoles > 0) {
|
||||
purity = maxComponent / totalMoles;
|
||||
}
|
||||
args.Price += basePrice * purity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,5 +80,8 @@ namespace Content.Shared.Atmos.Prototypes
|
||||
public string? Reagent { get; } = default!;
|
||||
|
||||
[DataField("color")] public string Color { get; } = string.Empty;
|
||||
|
||||
[DataField("pricePerMole")]
|
||||
public float PricePerMole { get; set; } = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
molarMass: 32
|
||||
color: 2887E8
|
||||
reagent: Oxygen
|
||||
pricePerMole: 0.3
|
||||
|
||||
- type: gas
|
||||
id: 1
|
||||
@@ -15,6 +16,7 @@
|
||||
molarMass: 28
|
||||
color: DA1010
|
||||
reagent: Nitrogen
|
||||
pricePerMole: 0.6
|
||||
|
||||
- type: gas
|
||||
id: 2
|
||||
@@ -24,6 +26,7 @@
|
||||
molarMass: 44
|
||||
color: 4e4e4e
|
||||
reagent: CarbonDioxide
|
||||
pricePerMole: 0.4
|
||||
|
||||
- type: gas
|
||||
id: 3
|
||||
@@ -35,6 +38,7 @@
|
||||
gasOverlayState: plasma
|
||||
color: FF3300
|
||||
reagent: Plasma
|
||||
pricePerMole: 2.5
|
||||
|
||||
- type: gas
|
||||
id: 4
|
||||
@@ -46,6 +50,7 @@
|
||||
gasOverlayState: tritium
|
||||
color: 13FF4B
|
||||
reagent: Tritium
|
||||
pricePerMole: 5
|
||||
|
||||
- type: gas
|
||||
id: 5
|
||||
@@ -57,6 +62,7 @@
|
||||
gasOverlayState: water_vapor
|
||||
color: bffffd
|
||||
reagent: Water
|
||||
pricePerMole: 0.4
|
||||
|
||||
- type: gas
|
||||
id: 6
|
||||
@@ -70,6 +76,7 @@
|
||||
gasVisbilityFactor: 3.5
|
||||
color: 56941E
|
||||
reagent: Miasma
|
||||
pricePerMole: 0.15
|
||||
|
||||
- type: gas
|
||||
id: 7
|
||||
@@ -79,6 +86,7 @@
|
||||
molarMass: 44
|
||||
color: 2887E8
|
||||
reagent: NitrousOxide
|
||||
pricePerMole: 2.5
|
||||
|
||||
- type: gas
|
||||
id: 8
|
||||
@@ -91,3 +99,4 @@
|
||||
gasMolesVisible: 0.6
|
||||
color: 3a758c
|
||||
reagent: Frezon
|
||||
pricePerMole: 7.5
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
sprite: Structures/Storage/canister.rsi
|
||||
state: grey
|
||||
product: AirCanister
|
||||
cost: 1000
|
||||
cost: 2700
|
||||
category: Atmospherics
|
||||
group: market
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
sprite: Structures/Storage/canister.rsi
|
||||
state: blue
|
||||
product: OxygenCanister
|
||||
cost: 1000
|
||||
cost: 2300
|
||||
category: Atmospherics
|
||||
group: market
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
sprite: Structures/Storage/canister.rsi
|
||||
state: red
|
||||
product: NitrogenCanister
|
||||
cost: 1000
|
||||
cost: 3200
|
||||
category: Atmospherics
|
||||
group: market
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
sprite: Structures/Storage/canister.rsi
|
||||
state: black
|
||||
product: CarbonDioxideCanister
|
||||
cost: 1000
|
||||
cost: 2600
|
||||
category: Atmospherics
|
||||
group: market
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
# sprite: Structures/Storage/canister.rsi
|
||||
# state: water_vapor
|
||||
# product: WaterVaporCanister
|
||||
# cost: 1000
|
||||
# cost: 2600
|
||||
# category: Atmospherics
|
||||
# group: market
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
# sprite: Structures/Storage/canister.rsi
|
||||
# state: orange
|
||||
# product: PlasmaCanister
|
||||
# cost: 2000
|
||||
# cost: 8500
|
||||
# category: Atmospherics
|
||||
# group: market
|
||||
|
||||
@@ -78,6 +78,6 @@
|
||||
# sprite: Structures/Storage/canister.rsi
|
||||
# state: green
|
||||
# product: TritiumCanister
|
||||
# cost: 2000
|
||||
# cost: 15500
|
||||
# category: Atmospherics
|
||||
# group: market
|
||||
|
||||
@@ -80,6 +80,8 @@
|
||||
volume: 1
|
||||
- type: GasPortable
|
||||
- type: GasCanister
|
||||
- type: StaticPrice
|
||||
price: 1000
|
||||
|
||||
- type: entity
|
||||
parent: GasCanister
|
||||
|
||||
Reference in New Issue
Block a user