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