Revert "Revert "epic Respiration Rework"" (#6527)

This commit is contained in:
Leon Friedrich
2022-02-10 17:53:10 +13:00
committed by GitHub
parent b417c022bf
commit 706ac6af40
32 changed files with 596 additions and 586 deletions

View 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);
}
}
}
}

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

View 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);
}
}
}