mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 10:21:18 +03:00
* Everything except the YAML slop... * She solution on my manager till I sajfslkahfsjakfhaskjfshajksafhfsakhfasjfas * another 1000 lines * fix chem dispenser size * go my shnelf * Implicit ass * rider is being mean for some reason * dasdas * borger * better formatting go! * clothes/bloodstream * Cartons * cups and bottles * mmm soder * bar drinks * Spray bottles and some size tweaks with hindsight * 99 bottles of beer on the wall I hate YAML * push that shit * mmm burger * Sneed * sheets * condiments * mmm yummy * fridge yummyfood * meat... * sub 300 * burger... * bready * let them eat cake * does she know how to make a grilled cheese? * pizza pie! * misc shit * soup or salad * Food and drinks, vanquished * the cubes!!! * Almost free from YAML... * fix test fails and some yaml issues * fix prediction, almost done * fix all test fails * remove master merge artifacts and undo autonetworking * review and compatibility * graaah * unfuck master merge I hate github * merg conflicts * sfsa * ehoop * sadas * afsafsaasf * merge conflicts * fucked up the merge conflicts * merge conflict is fucked I might need to completely redo this branch * test fail * no calcium???? --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
92 lines
3.2 KiB
C#
92 lines
3.2 KiB
C#
using Content.Shared.Atmos;
|
|
using Content.Shared.Atmos.Components;
|
|
using Content.Shared.Atmos.EntitySystems;
|
|
using Content.Shared.Body.Components;
|
|
using Content.Shared.Chemistry.Components;
|
|
using Content.Shared.Chemistry.EntitySystems;
|
|
using Content.Shared.Inventory.Events;
|
|
using Robust.Shared.Prototypes;
|
|
using BreathToolComponent = Content.Shared.Atmos.Components.BreathToolComponent;
|
|
using InternalsComponent = Content.Shared.Body.Components.InternalsComponent;
|
|
|
|
namespace Content.Shared.Body.Systems;
|
|
|
|
public sealed class LungSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedAtmosphereSystem _atmos = default!;
|
|
[Dependency] private readonly SharedInternalsSystem _internals = default!;
|
|
[Dependency] private readonly SharedSolutionContainerSystem _solutionContainerSystem = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
SubscribeLocalEvent<LungComponent, MapInitEvent>(OnMapInit);
|
|
SubscribeLocalEvent<BreathToolComponent, GotEquippedEvent>(OnGotEquipped);
|
|
SubscribeLocalEvent<BreathToolComponent, GotUnequippedEvent>(OnGotUnequipped);
|
|
}
|
|
|
|
private void OnGotUnequipped(Entity<BreathToolComponent> ent, ref GotUnequippedEvent args)
|
|
{
|
|
_atmos.DisconnectInternals(ent);
|
|
}
|
|
|
|
private void OnGotEquipped(Entity<BreathToolComponent> ent, ref GotEquippedEvent args)
|
|
{
|
|
if ((args.SlotFlags & ent.Comp.AllowedSlots) == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (TryComp(args.EquipTarget, out InternalsComponent? internals))
|
|
{
|
|
ent.Comp.ConnectedInternalsEntity = args.EquipTarget;
|
|
_internals.ConnectBreathTool((args.EquipTarget, internals), ent);
|
|
}
|
|
}
|
|
|
|
private void OnMapInit(Entity<LungComponent> entity, ref MapInitEvent args)
|
|
{
|
|
_solutionContainerSystem.EnsureSolution(entity.Owner, entity.Comp.SolutionName, out var solution);
|
|
|
|
solution.Comp.Solution.MaxVolume = 100.0f;
|
|
solution.Comp.Solution.CanReact = false; // No dexalin lungs
|
|
}
|
|
|
|
// TODO: JUST METABOLIZE GASES DIRECTLY DON'T CONVERT TO REAGENTS!!! (Needs Metabolism refactor :B)
|
|
public void GasToReagent(EntityUid uid, LungComponent lung)
|
|
{
|
|
if (!_solutionContainerSystem.ResolveSolution(uid, lung.SolutionName, ref lung.Solution, out var solution))
|
|
return;
|
|
|
|
GasToReagent(lung.Air, solution);
|
|
_solutionContainerSystem.UpdateChemicals(lung.Solution.Value);
|
|
}
|
|
|
|
/* This should really be moved to somewhere in the atmos system and modernized,
|
|
so that other systems, like CondenserSystem, can use it.
|
|
*/
|
|
private void GasToReagent(GasMixture gas, Solution solution)
|
|
{
|
|
foreach (var gasId in Enum.GetValues<Gas>())
|
|
{
|
|
var i = (int) gasId;
|
|
var moles = gas[i];
|
|
if (moles <= 0)
|
|
continue;
|
|
|
|
var reagent = _atmos.GasReagents[i];
|
|
if (reagent is null)
|
|
continue;
|
|
|
|
var amount = moles * Atmospherics.BreathMolesToReagentMultiplier;
|
|
solution.AddReagent(reagent, amount);
|
|
}
|
|
}
|
|
|
|
public Solution GasToReagent(GasMixture gas)
|
|
{
|
|
var solution = new Solution();
|
|
GasToReagent(gas, solution);
|
|
return solution;
|
|
}
|
|
}
|