epic Respiration Rework (#6022)
This commit is contained in:
46
Content.Server/Chemistry/ReagentEffects/AdjustAlert.cs
Normal file
46
Content.Server/Chemistry/ReagentEffects/AdjustAlert.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects;
|
||||
|
||||
public class AdjustAlert : ReagentEffect
|
||||
{
|
||||
[DataField("alertType", required: true)]
|
||||
public AlertType Type;
|
||||
|
||||
[DataField("clear")]
|
||||
public bool Clear;
|
||||
|
||||
[DataField("cooldown")]
|
||||
public bool Cooldown;
|
||||
|
||||
[DataField("time")]
|
||||
public float Time;
|
||||
|
||||
public override void Effect(ReagentEffectArgs args)
|
||||
{
|
||||
var alertSys = EntitySystem.Get<AlertsSystem>();
|
||||
if (args.EntityManager.HasComponent<AlertsComponent>(args.SolutionEntity))
|
||||
{
|
||||
if (Clear)
|
||||
{
|
||||
alertSys.ClearAlert(args.SolutionEntity, Type);
|
||||
}
|
||||
else
|
||||
{
|
||||
(TimeSpan, TimeSpan)? cooldown = null;
|
||||
if (Cooldown)
|
||||
{
|
||||
var timing = IoCManager.Resolve<IGameTiming>();
|
||||
cooldown = (timing.CurTime, timing.CurTime + TimeSpan.FromSeconds(Time));
|
||||
}
|
||||
alertSys.ShowAlert(args.SolutionEntity, Type, cooldown: cooldown);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
24
Content.Server/Chemistry/ReagentEffects/ModifyLungGas.cs
Normal file
24
Content.Server/Chemistry/ReagentEffects/ModifyLungGas.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Shared.Atmos;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects;
|
||||
|
||||
public class ModifyLungGas : ReagentEffect
|
||||
{
|
||||
[DataField("ratios", required: true)]
|
||||
private Dictionary<Gas, float> _ratios = default!;
|
||||
|
||||
public override void Effect(ReagentEffectArgs args)
|
||||
{
|
||||
if (args.EntityManager.TryGetComponent<LungComponent>(args.OrganEntity, out var lung))
|
||||
{
|
||||
foreach (var (gas, ratio) in _ratios)
|
||||
{
|
||||
lung.Air.Moles[(int) gas] += (ratio * args.Quantity.Float()) / Atmospherics.BreathMolesToReagentMultiplier;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Content.Server/Chemistry/ReagentEffects/Oxygenate.cs
Normal file
22
Content.Server/Chemistry/ReagentEffects/Oxygenate.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Content.Server.Body.Components;
|
||||
using Content.Server.Body.Systems;
|
||||
using Content.Shared.Chemistry.Reagent;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Server.Chemistry.ReagentEffects;
|
||||
|
||||
public class Oxygenate : ReagentEffect
|
||||
{
|
||||
[DataField("factor")]
|
||||
public float Factor = 1f;
|
||||
|
||||
public override void Effect(ReagentEffectArgs args)
|
||||
{
|
||||
if (args.EntityManager.TryGetComponent<RespiratorComponent>(args.SolutionEntity, out var resp))
|
||||
{
|
||||
var respSys = EntitySystem.Get<RespiratorSystem>();
|
||||
respSys.UpdateSaturation(resp.Owner, args.Quantity.Float() * Factor, resp);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user