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:
@@ -101,7 +101,7 @@ public sealed class RottingSystem : EntitySystem
|
|||||||
var ev = new IsRottingEvent();
|
var ev = new IsRottingEvent();
|
||||||
RaiseLocalEvent(uid, ref ev);
|
RaiseLocalEvent(uid, ref ev);
|
||||||
|
|
||||||
return ev.Handled;
|
return !ev.Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool IsRotten(EntityUid uid, RottingComponent? rotting = null)
|
public bool IsRotten(EntityUid uid, RottingComponent? rotting = null)
|
||||||
@@ -154,7 +154,7 @@ public sealed class RottingSystem : EntitySystem
|
|||||||
{
|
{
|
||||||
if (args.Handled)
|
if (args.Handled)
|
||||||
return;
|
return;
|
||||||
args.Handled = component.CurrentTemperature > Atmospherics.T0C + 0.85f;
|
args.Handled = component.CurrentTemperature < Atmospherics.T0C + 0.85f;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update(float frameTime)
|
public override void Update(float frameTime)
|
||||||
|
|||||||
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
22
Content.Shared/Atmos/Rotting/AntiRotOnBuckleComponent.cs
Normal file
22
Content.Shared/Atmos/Rotting/AntiRotOnBuckleComponent.cs
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
|
namespace Content.Shared.Atmos.Rotting;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Perishable entities buckled to an entity with this component will stop rotting.
|
||||||
|
/// </summary>
|
||||||
|
[RegisterComponent, NetworkedComponent]
|
||||||
|
public sealed partial class AntiRotOnBuckleComponent : Component
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Does this component require power to function.
|
||||||
|
/// </summary>
|
||||||
|
[DataField("requiresPower"), ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public bool RequiresPower = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether this component is active or not.
|
||||||
|
/// </summarY>
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public bool Enabled = true;
|
||||||
|
}
|
||||||
@@ -2,10 +2,11 @@
|
|||||||
id: StasisBed
|
id: StasisBed
|
||||||
name: stasis bed
|
name: stasis bed
|
||||||
parent: [ BaseMachinePowered, ConstructibleMachine ]
|
parent: [ BaseMachinePowered, ConstructibleMachine ]
|
||||||
description: A bed that massively slows down the patient's metabolism, allowing more time to administer a proper treatment for stabilization.
|
description: A bed that massively slows down the patient's metabolism and prevents bodily decay, allowing more time to administer a proper treatment for stabilization.
|
||||||
components:
|
components:
|
||||||
- type: StasisBed
|
- type: StasisBed
|
||||||
baseMultiplier: 10
|
baseMultiplier: 10
|
||||||
|
- type: AntiRotOnBuckle
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
sprite: Structures/Machines/stasis_bed.rsi
|
sprite: Structures/Machines/stasis_bed.rsi
|
||||||
noRot: true
|
noRot: true
|
||||||
|
|||||||
Reference in New Issue
Block a user