stasis bed machine part scaling (#11773)

This commit is contained in:
Nemanja
2022-10-15 17:39:30 -04:00
committed by GitHub
parent 8f6f5ba236
commit a03ab2c087
3 changed files with 36 additions and 13 deletions

View File

@@ -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;
}
}
}