constructable rechargers (#16367)
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
|
using Content.Shared.Construction.Prototypes;
|
||||||
using Content.Shared.Power;
|
using Content.Shared.Power;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
|
|
||||||
namespace Content.Server.Power.Components
|
namespace Content.Server.Power.Components
|
||||||
{
|
{
|
||||||
@@ -8,8 +10,32 @@ namespace Content.Server.Power.Components
|
|||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
public CellChargerStatus Status;
|
public CellChargerStatus Status;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The charge rate of the charger, in watts
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
[DataField("chargeRate")]
|
[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)]
|
[DataField("slotId", required: true)]
|
||||||
public string SlotId = string.Empty;
|
public string SlotId = string.Empty;
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
|
using Content.Server.Construction;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
using Content.Server.PowerCell;
|
using Content.Server.PowerCell;
|
||||||
using Content.Shared.Containers.ItemSlots;
|
using Content.Shared.Containers.ItemSlots;
|
||||||
using Content.Shared.Examine;
|
using Content.Shared.Examine;
|
||||||
|
using Content.Shared.Power;
|
||||||
using Content.Shared.PowerCell.Components;
|
using Content.Shared.PowerCell.Components;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Content.Shared.Power;
|
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
|
|
||||||
namespace Content.Server.Power.EntitySystems;
|
namespace Content.Server.Power.EntitySystems;
|
||||||
@@ -20,6 +21,8 @@ internal sealed class ChargerSystem : EntitySystem
|
|||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
SubscribeLocalEvent<ChargerComponent, ComponentStartup>(OnStartup);
|
SubscribeLocalEvent<ChargerComponent, ComponentStartup>(OnStartup);
|
||||||
|
SubscribeLocalEvent<ChargerComponent, RefreshPartsEvent>(OnRefreshParts);
|
||||||
|
SubscribeLocalEvent<ChargerComponent, UpgradeExamineEvent>(OnUpgradeExamine);
|
||||||
SubscribeLocalEvent<ChargerComponent, PowerChangedEvent>(OnPowerChanged);
|
SubscribeLocalEvent<ChargerComponent, PowerChangedEvent>(OnPowerChanged);
|
||||||
SubscribeLocalEvent<ChargerComponent, EntInsertedIntoContainerMessage>(OnInserted);
|
SubscribeLocalEvent<ChargerComponent, EntInsertedIntoContainerMessage>(OnInserted);
|
||||||
SubscribeLocalEvent<ChargerComponent, EntRemovedFromContainerMessage>(OnRemoved);
|
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)
|
private void OnPowerChanged(EntityUid uid, ChargerComponent component, ref PowerChangedEvent args)
|
||||||
{
|
{
|
||||||
UpdateStatus(uid, component);
|
UpdateStatus(uid, component);
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
charger-examine = Charges [color={$color}]{$chargeRate}W[/color] per second.
|
charger-examine = Charges [color={$color}]{$chargeRate}W[/color] per second.
|
||||||
|
charger-component-charge-rate = Charge rate
|
||||||
|
|||||||
@@ -450,6 +450,38 @@
|
|||||||
requirements:
|
requirements:
|
||||||
Capacitor: 5
|
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
|
- type: entity
|
||||||
id: SubstationMachineCircuitboard
|
id: SubstationMachineCircuitboard
|
||||||
parent: BaseMachineCircuitboard
|
parent: BaseMachineCircuitboard
|
||||||
|
|||||||
@@ -109,6 +109,8 @@
|
|||||||
- APCElectronics
|
- APCElectronics
|
||||||
- SMESMachineCircuitboard
|
- SMESMachineCircuitboard
|
||||||
- SubstationMachineCircuitboard
|
- SubstationMachineCircuitboard
|
||||||
|
- CellRechargerCircuitboard
|
||||||
|
- WeaponCapacitorRechargerCircuitboard
|
||||||
- type: StaticPrice
|
- type: StaticPrice
|
||||||
price: 800
|
price: 800
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
- type: entity
|
- type: entity
|
||||||
name: cell recharger
|
name: cell recharger
|
||||||
id: PowerCellRecharger
|
id: PowerCellRecharger
|
||||||
|
parent: ConstructibleMachine
|
||||||
placement:
|
placement:
|
||||||
mode: SnapgridCenter
|
mode: SnapgridCenter
|
||||||
components:
|
components:
|
||||||
- type: Transform
|
- type: Transform
|
||||||
anchored: true
|
anchored: true
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
netsync: false
|
|
||||||
sprite: Structures/Power/cell_recharger.rsi
|
sprite: Structures/Power/cell_recharger.rsi
|
||||||
drawdepth: SmallObjects
|
drawdepth: SmallObjects
|
||||||
snapCardinals: true
|
snapCardinals: true
|
||||||
@@ -21,6 +21,8 @@
|
|||||||
slotId: charger_slot
|
slotId: charger_slot
|
||||||
- type: ApcPowerReceiver
|
- type: ApcPowerReceiver
|
||||||
- type: ExtensionCableReceiver
|
- type: ExtensionCableReceiver
|
||||||
|
- type: Machine
|
||||||
|
board: CellRechargerCircuitboard
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
- type: PowerChargerVisuals
|
- type: PowerChargerVisuals
|
||||||
- type: Anchorable
|
- type: Anchorable
|
||||||
@@ -70,6 +72,8 @@
|
|||||||
- type: ContainerContainer
|
- type: ContainerContainer
|
||||||
containers:
|
containers:
|
||||||
charger_slot: !type:ContainerSlot
|
charger_slot: !type:ContainerSlot
|
||||||
|
machine_board: !type:Container
|
||||||
|
machine_parts: !type:Container
|
||||||
|
|
||||||
- type: entity
|
- type: entity
|
||||||
name: recharger
|
name: recharger
|
||||||
@@ -78,6 +82,8 @@
|
|||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Structures/Power/recharger.rsi
|
sprite: Structures/Power/recharger.rsi
|
||||||
|
- type: Machine
|
||||||
|
board: WeaponCapacitorRechargerCircuitboard
|
||||||
- type: Charger
|
- type: Charger
|
||||||
slotId: charger_slot
|
slotId: charger_slot
|
||||||
- type: ItemSlots
|
- type: ItemSlots
|
||||||
@@ -93,10 +99,77 @@
|
|||||||
- type: entity
|
- type: entity
|
||||||
name: wall recharger
|
name: wall recharger
|
||||||
id: WallWeaponCapacitorRecharger
|
id: WallWeaponCapacitorRecharger
|
||||||
parent: WeaponCapacitorRecharger
|
placement:
|
||||||
|
mode: SnapgridCenter
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Structures/Power/wall_recharger.rsi
|
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: WallMount
|
||||||
- type: Charger
|
- type: Charger
|
||||||
chargeRate: 25
|
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
|
Steel: 50
|
||||||
Plastic: 300
|
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
|
- type: latheRecipe
|
||||||
id: DoorElectronics
|
id: DoorElectronics
|
||||||
result: DoorElectronics
|
result: DoorElectronics
|
||||||
|
|||||||
Reference in New Issue
Block a user