stasis bed machine part scaling (#11773)
This commit is contained in:
parent
8f6f5ba236
commit
a03ab2c087
|
|
@ -10,8 +10,8 @@ using Content.Server.Bed.Sleep;
|
|||
using Content.Server.Power.Components;
|
||||
using Content.Server.Power.EntitySystems;
|
||||
using Content.Shared.Emag.Systems;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Server.Actions;
|
||||
using Content.Server.Construction;
|
||||
using Content.Server.MobState;
|
||||
using Content.Shared.Actions.ActionTypes;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
|
@ -24,6 +24,7 @@ namespace Content.Server.Bed
|
|||
[Dependency] private readonly ActionsSystem _actionsSystem = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly SleepingSystem _sleepingSystem = default!;
|
||||
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
|
||||
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
|
||||
public override void Initialize()
|
||||
{
|
||||
|
|
@ -32,6 +33,7 @@ namespace Content.Server.Bed
|
|||
SubscribeLocalEvent<StasisBedComponent, BuckleChangeEvent>(OnBuckleChange);
|
||||
SubscribeLocalEvent<StasisBedComponent, PowerChangedEvent>(OnPowerChanged);
|
||||
SubscribeLocalEvent<StasisBedComponent, GotEmaggedEvent>(OnEmagged);
|
||||
SubscribeLocalEvent<StasisBedComponent, RefreshPartsEvent>(OnRefreshParts);
|
||||
}
|
||||
|
||||
private void ManageUpdateList(EntityUid uid, HealOnBuckleComponent component, BuckleChangeEvent args)
|
||||
|
|
@ -46,7 +48,7 @@ namespace Content.Server.Bed
|
|||
}
|
||||
|
||||
if (sleepAction != null)
|
||||
_actionsSystem.RemoveAction(args.BuckledEntity, sleepAction, null);
|
||||
_actionsSystem.RemoveAction(args.BuckledEntity, sleepAction);
|
||||
|
||||
_sleepingSystem.TryWaking(args.BuckledEntity);
|
||||
RemComp<HealOnBuckleHealingComponent>(uid);
|
||||
|
|
@ -85,25 +87,22 @@ namespace Content.Server.Bed
|
|||
|
||||
private void UpdateAppearance(EntityUid uid, bool isOn)
|
||||
{
|
||||
if (!TryComp<AppearanceComponent>(uid, out var appearance))
|
||||
return;
|
||||
|
||||
appearance.SetData(StasisBedVisuals.IsOn, isOn);
|
||||
_appearance.SetData(uid, StasisBedVisuals.IsOn, isOn);
|
||||
}
|
||||
|
||||
private void OnBuckleChange(EntityUid uid, StasisBedComponent component, BuckleChangeEvent args)
|
||||
{
|
||||
// In testing this also received an unbuckle event when the bed is destroyed
|
||||
// So don't worry about that
|
||||
if (!TryComp<SharedBodyComponent>(args.BuckledEntity, out var body))
|
||||
if (!HasComp<SharedBodyComponent>(args.BuckledEntity))
|
||||
return;
|
||||
|
||||
if (!this.IsPowered(uid, EntityManager))
|
||||
return;
|
||||
|
||||
var metabolicEvent = new ApplyMetabolicMultiplierEvent()
|
||||
var metabolicEvent = new ApplyMetabolicMultiplierEvent
|
||||
{Uid = args.BuckledEntity, Multiplier = component.Multiplier, Apply = args.Buckling};
|
||||
RaiseLocalEvent(args.BuckledEntity, metabolicEvent, false);
|
||||
RaiseLocalEvent(args.BuckledEntity, metabolicEvent);
|
||||
}
|
||||
|
||||
private void OnPowerChanged(EntityUid uid, StasisBedComponent component, ref PowerChangedEvent args)
|
||||
|
|
@ -129,11 +128,19 @@ namespace Content.Server.Bed
|
|||
|
||||
foreach (var buckledEntity in strap.BuckledEntities)
|
||||
{
|
||||
var metabolicEvent = new ApplyMetabolicMultiplierEvent()
|
||||
var metabolicEvent = new ApplyMetabolicMultiplierEvent
|
||||
{Uid = buckledEntity, Multiplier = component.Multiplier, Apply = shouldApply};
|
||||
RaiseLocalEvent(buckledEntity, metabolicEvent, false);
|
||||
RaiseLocalEvent(buckledEntity, metabolicEvent);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnRefreshParts(EntityUid uid, StasisBedComponent component, RefreshPartsEvent args)
|
||||
{
|
||||
var metabolismRating = args.PartRatings[component.MachinePartMetabolismModifier];
|
||||
component.Multiplier = component.BaseMultiplier * metabolismRating; //linear scaling so it's not OP
|
||||
if (component.Emagged)
|
||||
component.Multiplier = 1f / component.Multiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,29 @@
|
|||
using Content.Shared.Construction.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Bed.Components
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class StasisBedComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Stores whether or not the stasis bed has been emagged,
|
||||
/// which causes the multiplier to speed up rather than
|
||||
/// slow down. Needs to be stored for machine upgrades.
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public bool Emagged = false;
|
||||
|
||||
[DataField("baseMultiplier", required: true), ViewVariables(VVAccess.ReadWrite)]
|
||||
public float BaseMultiplier = 10f;
|
||||
|
||||
/// <summary>
|
||||
/// What the metabolic update rate will be multiplied by (higher = slower metabolism)
|
||||
/// </summary>
|
||||
[DataField("multiplier", required: true)]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
public float Multiplier = 10f;
|
||||
|
||||
[DataField("machinePartMetabolismModifier", customTypeSerializer: typeof(PrototypeIdSerializer<MachinePartPrototype>))]
|
||||
public string MachinePartMetabolismModifier = "Manipulator";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
description: A bed that massively slows down the patient's metabolism, allowing more time to administer a proper treatment for stabilization.
|
||||
components:
|
||||
- type: StasisBed
|
||||
multiplier: 10
|
||||
baseMultiplier: 10
|
||||
- type: Sprite
|
||||
sprite: Structures/Machines/stasis_bed.rsi
|
||||
netsync: false
|
||||
|
|
|
|||
Loading…
Reference in New Issue