Turbo Recharger (#23723)

turbo charger
This commit is contained in:
Nemanja
2024-01-08 02:15:13 -05:00
committed by GitHub
parent b3e695cbfc
commit c861b66a47
14 changed files with 125 additions and 41 deletions

View File

@@ -1,7 +1,5 @@
using Content.Shared.Construction.Prototypes;
using Content.Shared.Power;
using Content.Shared.Whitelist;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Server.Power.Components
{
@@ -17,25 +15,6 @@ namespace Content.Server.Power.Components
[DataField("chargeRate")]
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;
/// <summary>
/// The container ID that is holds the entities being charged.
/// </summary>

View File

@@ -1,4 +1,3 @@
using Content.Server.Construction;
using Content.Server.Power.Components;
using Content.Server.PowerCell;
using Content.Shared.Examine;
@@ -23,8 +22,6 @@ 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);
@@ -61,17 +58,6 @@ 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);