Files
tbd-station-14/Content.Server/Buckle/Systems/AntiRotOnBuckleSystem.cs
metalgearsloth a89d4c750b Power stuff (#31314)
* Power stuff

- Add shared IsPowered
- Add shared ResolveApc
- Move PowerChangedEvent to shared for now
- Add SlimPoweredLight that actually functions how you'd expect a PoweredLight to function it id didn't have a bunch of bloat on it.

* big update

* boing
2024-08-25 22:18:42 +10:00

31 lines
1.0 KiB
C#

using Content.Server.Power.Components;
using Content.Shared.Atmos.Rotting;
using Content.Shared.Buckle.Components;
using Content.Shared.Power;
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;
}
}