Add power selling price (#11395)
This commit is contained in:
@@ -29,6 +29,13 @@ namespace Content.Server.Power.Components
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[ViewVariables] public bool IsFullyCharged => MathHelper.CloseToPercent(CurrentCharge, MaxCharge);
|
[ViewVariables] public bool IsFullyCharged => MathHelper.CloseToPercent(CurrentCharge, MaxCharge);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The price per one joule. Default is 1 credit for 10kJ.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("pricePerJoule")]
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public float PricePerJoule = 0.0001f;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If sufficient charge is avaiable on the battery, use it. Otherwise, don't.
|
/// If sufficient charge is avaiable on the battery, use it. Otherwise, don't.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Content.Server.Cargo.Systems;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
@@ -12,6 +13,7 @@ namespace Content.Server.Power.EntitySystems
|
|||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
SubscribeLocalEvent<ExaminableBatteryComponent, ExaminedEvent>(OnExamine);
|
SubscribeLocalEvent<ExaminableBatteryComponent, ExaminedEvent>(OnExamine);
|
||||||
|
SubscribeLocalEvent<BatteryComponent, PriceCalculationEvent>(CalculateBatteryPrice);
|
||||||
|
|
||||||
SubscribeLocalEvent<NetworkBatteryPreSync>(PreSync);
|
SubscribeLocalEvent<NetworkBatteryPreSync>(PreSync);
|
||||||
SubscribeLocalEvent<NetworkBatteryPostSync>(PostSync);
|
SubscribeLocalEvent<NetworkBatteryPostSync>(PostSync);
|
||||||
@@ -64,5 +66,13 @@ namespace Content.Server.Power.EntitySystems
|
|||||||
batt.CurrentCharge += comp.AutoRechargeRate * frameTime;
|
batt.CurrentCharge += comp.AutoRechargeRate * frameTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the price for the power contained in an entity's battery.
|
||||||
|
/// </summary>
|
||||||
|
private void CalculateBatteryPrice(EntityUid uid, BatteryComponent component, ref PriceCalculationEvent args)
|
||||||
|
{
|
||||||
|
args.Price += component.CurrentCharge * component.PricePerJoule;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
parent: BaseItem
|
parent: BaseItem
|
||||||
components:
|
components:
|
||||||
- type: Battery
|
- type: Battery
|
||||||
|
pricePerJoule: 0.15
|
||||||
- type: PowerCell
|
- type: PowerCell
|
||||||
- type: Explosive
|
- type: Explosive
|
||||||
explosionType: Default
|
explosionType: Default
|
||||||
@@ -28,8 +29,6 @@
|
|||||||
- DroneUsable
|
- DroneUsable
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
- type: PowerCellVisuals
|
- type: PowerCellVisuals
|
||||||
- type: StaticPrice
|
|
||||||
price: 100
|
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
name: potato battery
|
name: potato battery
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
- type: PowerSink
|
- type: PowerSink
|
||||||
- type: Battery
|
- type: Battery
|
||||||
maxCharge: 7500000
|
maxCharge: 7500000
|
||||||
|
pricePerJoule: 0.0003
|
||||||
- type: ExaminableBattery
|
- type: ExaminableBattery
|
||||||
- type: PowerConsumer
|
- type: PowerConsumer
|
||||||
voltage: High
|
voltage: High
|
||||||
|
|||||||
@@ -60,8 +60,6 @@
|
|||||||
- type: Machine
|
- type: Machine
|
||||||
board: SMESMachineCircuitboard
|
board: SMESMachineCircuitboard
|
||||||
- type: StationInfiniteBatteryTarget
|
- type: StationInfiniteBatteryTarget
|
||||||
- type: StaticPrice
|
|
||||||
price: 750
|
|
||||||
|
|
||||||
# SMES' in use
|
# SMES' in use
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user