Powered stasis bed prevents body decay (#23520)
* Powered stasis bed prevents body decay * Update following CR comments * Remove unused import * Simplify if-statements * Change implementation following CR suggestions * Add comment & remove explicit get/set
This commit is contained in:
29
Content.Server/Buckle/Systems/AntiRotOnBuckleSystem.cs
Normal file
29
Content.Server/Buckle/Systems/AntiRotOnBuckleSystem.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using Content.Server.Power.Components;
|
||||
using Content.Shared.Atmos.Rotting;
|
||||
using Content.Shared.Buckle.Components;
|
||||
|
||||
namespace Content.Server.Buckle.Systems;
|
||||
|
||||
public sealed class AntiRotOnBuckleSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<BuckleComponent, IsRottingEvent>(OnIsRotting);
|
||||
SubscribeLocalEvent<AntiRotOnBuckleComponent, PowerChangedEvent>(OnPowerChanged);
|
||||
}
|
||||
|
||||
private void OnIsRotting(EntityUid uid, BuckleComponent buckle, ref IsRottingEvent args)
|
||||
{
|
||||
if (args.Handled)
|
||||
return;
|
||||
args.Handled = buckle is { Buckled: true, BuckledTo: not null } &&
|
||||
TryComp<AntiRotOnBuckleComponent>(buckle.BuckledTo.Value, out var antiRot) &&
|
||||
antiRot.Enabled;
|
||||
}
|
||||
|
||||
private void OnPowerChanged(EntityUid uid, AntiRotOnBuckleComponent component, ref PowerChangedEvent args)
|
||||
{
|
||||
component.Enabled = !component.RequiresPower || args.Powered;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user