constructable rechargers (#16367)
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using Content.Shared.Construction.Prototypes;
|
||||
using Content.Shared.Power;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Power.Components
|
||||
{
|
||||
@@ -8,8 +10,32 @@ namespace Content.Server.Power.Components
|
||||
[ViewVariables]
|
||||
public CellChargerStatus Status;
|
||||
|
||||
/// <summary>
|
||||
/// The charge rate of the charger, in watts
|
||||
/// </summary>
|
||||
|
||||
[DataField("chargeRate")]
|
||||
public int ChargeRate = 20;
|
||||
public float ChargeRate = 20.0f;
|
||||
|
||||
/// <summary>
|
||||
/// The charge rate with no machine upgrades
|
||||
/// </summary>
|
||||
|
||||
[DataField("baseChargeRate")]
|
||||
public float BaseChargeRate = 20.0f;
|
||||
|
||||
/// <summary>
|
||||
/// The machine part that affects the charge rate multiplier of the charger
|
||||
/// </summary>
|
||||
[DataField("machinePartChargeRateModifier", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
|
||||
public string MachinePartChargeRateModifier = "Capacitor";
|
||||
|
||||
/// <summary>
|
||||
/// A value used to scale the charge rate multiplier
|
||||
/// with the corresponding part rating.
|
||||
/// </summary>
|
||||
[DataField("partRatingChargeRateModifier")]
|
||||
public float PartRatingChargeRateModifier = 1.5f;
|
||||
|
||||
[DataField("slotId", required: true)]
|
||||
public string SlotId = string.Empty;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
using Content.Server.Construction;
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Server.PowerCell;
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Content.Shared.Examine;
|
||||
using Content.Shared.Power;
|
||||
using Content.Shared.PowerCell.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Containers;
|
||||
using Content.Shared.Power;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Content.Server.Power.EntitySystems;
|
||||
@@ -20,6 +21,8 @@ internal sealed class ChargerSystem : EntitySystem
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<ChargerComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<ChargerComponent, RefreshPartsEvent>(OnRefreshParts);
|
||||
SubscribeLocalEvent<ChargerComponent, UpgradeExamineEvent>(OnUpgradeExamine);
|
||||
SubscribeLocalEvent<ChargerComponent, PowerChangedEvent>(OnPowerChanged);
|
||||
SubscribeLocalEvent<ChargerComponent, EntInsertedIntoContainerMessage>(OnInserted);
|
||||
SubscribeLocalEvent<ChargerComponent, EntRemovedFromContainerMessage>(OnRemoved);
|
||||
@@ -51,6 +54,17 @@ internal sealed class ChargerSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRefreshParts(EntityUid uid, ChargerComponent component, RefreshPartsEvent args)
|
||||
{
|
||||
var modifierRating = args.PartRatings[component.MachinePartChargeRateModifier];
|
||||
component.ChargeRate = component.BaseChargeRate * MathF.Pow(component.PartRatingChargeRateModifier, modifierRating - 1);
|
||||
}
|
||||
|
||||
private void OnUpgradeExamine(EntityUid uid, ChargerComponent component, UpgradeExamineEvent args)
|
||||
{
|
||||
args.AddPercentageUpgrade("charger-component-charge-rate", component.ChargeRate / component.BaseChargeRate);
|
||||
}
|
||||
|
||||
private void OnPowerChanged(EntityUid uid, ChargerComponent component, ref PowerChangedEvent args)
|
||||
{
|
||||
UpdateStatus(uid, component);
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
charger-examine = Charges [color={$color}]{$chargeRate}W[/color] per second.
|
||||
charger-component-charge-rate = Charge rate
|
||||
|
||||
@@ -450,6 +450,38 @@
|
||||
requirements:
|
||||
Capacitor: 5
|
||||
|
||||
- type: entity
|
||||
id: CellRechargerCircuitboard
|
||||
parent: BaseMachineCircuitboard
|
||||
name: cell recharger machine board
|
||||
description: A machine printed circuit board for a cell recharger.
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Objects/Misc/module.rsi
|
||||
state: charger_APC
|
||||
- type: MachineBoard
|
||||
prototype: PowerCellRecharger
|
||||
requirements:
|
||||
Capacitor: 2
|
||||
materialRequirements:
|
||||
Cable: 5
|
||||
|
||||
- type: entity
|
||||
id: WeaponCapacitorRechargerCircuitboard
|
||||
parent: BaseMachineCircuitboard
|
||||
name: recharger machine board
|
||||
description: A machine printed circuit board for a recharger.
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Objects/Misc/module.rsi
|
||||
state: charger_APC
|
||||
- type: MachineBoard
|
||||
prototype: WeaponCapacitorRecharger
|
||||
requirements:
|
||||
Capacitor: 2
|
||||
materialRequirements:
|
||||
CableMV: 5
|
||||
|
||||
- type: entity
|
||||
id: SubstationMachineCircuitboard
|
||||
parent: BaseMachineCircuitboard
|
||||
|
||||
@@ -109,6 +109,8 @@
|
||||
- APCElectronics
|
||||
- SMESMachineCircuitboard
|
||||
- SubstationMachineCircuitboard
|
||||
- CellRechargerCircuitboard
|
||||
- WeaponCapacitorRechargerCircuitboard
|
||||
- type: StaticPrice
|
||||
price: 800
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
- type: entity
|
||||
name: cell recharger
|
||||
id: PowerCellRecharger
|
||||
parent: ConstructibleMachine
|
||||
placement:
|
||||
mode: SnapgridCenter
|
||||
components:
|
||||
- type: Transform
|
||||
anchored: true
|
||||
- type: Sprite
|
||||
netsync: false
|
||||
sprite: Structures/Power/cell_recharger.rsi
|
||||
drawdepth: SmallObjects
|
||||
snapCardinals: true
|
||||
@@ -21,6 +21,8 @@
|
||||
slotId: charger_slot
|
||||
- type: ApcPowerReceiver
|
||||
- type: ExtensionCableReceiver
|
||||
- type: Machine
|
||||
board: CellRechargerCircuitboard
|
||||
- type: Appearance
|
||||
- type: PowerChargerVisuals
|
||||
- type: Anchorable
|
||||
@@ -70,6 +72,8 @@
|
||||
- type: ContainerContainer
|
||||
containers:
|
||||
charger_slot: !type:ContainerSlot
|
||||
machine_board: !type:Container
|
||||
machine_parts: !type:Container
|
||||
|
||||
- type: entity
|
||||
name: recharger
|
||||
@@ -78,6 +82,8 @@
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Structures/Power/recharger.rsi
|
||||
- type: Machine
|
||||
board: WeaponCapacitorRechargerCircuitboard
|
||||
- type: Charger
|
||||
slotId: charger_slot
|
||||
- type: ItemSlots
|
||||
@@ -93,10 +99,77 @@
|
||||
- type: entity
|
||||
name: wall recharger
|
||||
id: WallWeaponCapacitorRecharger
|
||||
parent: WeaponCapacitorRecharger
|
||||
placement:
|
||||
mode: SnapgridCenter
|
||||
components:
|
||||
- type: Sprite
|
||||
sprite: Structures/Power/wall_recharger.rsi
|
||||
drawdepth: SmallObjects
|
||||
snapCardinals: true
|
||||
layers:
|
||||
- map: ["enum.PowerChargerVisualLayers.Base"]
|
||||
state: "empty"
|
||||
- map: ["enum.PowerChargerVisualLayers.Light"]
|
||||
state: "light-off"
|
||||
shader: "unshaded"
|
||||
- type: WallMount
|
||||
- type: Charger
|
||||
chargeRate: 25
|
||||
slotId: charger_slot
|
||||
- type: Transform
|
||||
anchored: true
|
||||
- type: ApcPowerReceiver
|
||||
- type: ExtensionCableReceiver
|
||||
- type: Appearance
|
||||
- type: PowerChargerVisuals
|
||||
- type: Anchorable
|
||||
- type: Pullable
|
||||
- type: Clickable
|
||||
- type: InteractionOutline
|
||||
- type: Damageable
|
||||
damageContainer: Inorganic
|
||||
damageModifierSet: Metallic
|
||||
- type: Destructible
|
||||
thresholds:
|
||||
- trigger:
|
||||
!type:DamageTrigger
|
||||
damage: 80
|
||||
behaviors:
|
||||
- !type:DoActsBehavior
|
||||
acts: [ "Destruction" ]
|
||||
- trigger:
|
||||
!type:DamageTrigger
|
||||
damage: 40
|
||||
behaviors:
|
||||
- !type:EmptyAllContainersBehaviour
|
||||
- !type:DoActsBehavior
|
||||
acts: [ "Destruction" ]
|
||||
- !type:PlaySoundBehavior
|
||||
sound:
|
||||
path: /Audio/Effects/metalbreak.ogg
|
||||
- type: Physics
|
||||
bodyType: Static
|
||||
- type: Fixtures
|
||||
fixtures:
|
||||
fix1:
|
||||
shape:
|
||||
!type:PhysShapeAabb
|
||||
bounds: "-0.10,-0.10,0.10,0.10"
|
||||
density: 500
|
||||
mask:
|
||||
- TabletopMachineMask
|
||||
- type: ItemSlots
|
||||
slots:
|
||||
charger_slot:
|
||||
ejectOnInteract: true
|
||||
whitelist:
|
||||
components:
|
||||
- HitscanBatteryAmmoProvider
|
||||
- ProjectileBatteryAmmoProvider
|
||||
- Stunbaton
|
||||
- type: ContainerContainer
|
||||
containers:
|
||||
charger_slot: !type:ContainerSlot
|
||||
machine_board: !type:Container
|
||||
machine_parts: !type:Container
|
||||
|
||||
|
||||
@@ -14,6 +14,22 @@
|
||||
Steel: 50
|
||||
Plastic: 300
|
||||
|
||||
- type: latheRecipe
|
||||
id: CellRechargerCircuitboard
|
||||
result: CellRechargerCircuitboard
|
||||
completetime: 2
|
||||
materials:
|
||||
Steel: 50
|
||||
Plastic: 50
|
||||
|
||||
- type: latheRecipe
|
||||
id: WeaponCapacitorRechargerCircuitboard
|
||||
result: WeaponCapacitorRechargerCircuitboard
|
||||
completetime: 2
|
||||
materials:
|
||||
Steel: 50
|
||||
Plastic: 50
|
||||
|
||||
- type: latheRecipe
|
||||
id: DoorElectronics
|
||||
result: DoorElectronics
|
||||
|
||||
Reference in New Issue
Block a user