Body code cleanup (#24946)

* Fix test

* Kill float accumulators

* Use entity proxy methods

* DataField auto name generation where possible

* Kill comp properties

* Clean up server comps

* Make events record structs

* Clean up shared body code

* Clean up server body code

* Rename organ events to be same names as in med refactor
This commit is contained in:
0x6273
2024-03-28 01:48:37 +01:00
committed by GitHub
parent 527c2c42ed
commit 37b8d78dac
32 changed files with 916 additions and 820 deletions

View File

@@ -1,4 +1,4 @@
using Content.Server.Atmos.Components;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Body.Components;
using Content.Server.Chemistry.Containers.EntitySystems;
@@ -26,21 +26,24 @@ public sealed class LungSystem : EntitySystem
SubscribeLocalEvent<BreathToolComponent, ItemMaskToggledEvent>(OnMaskToggled);
}
private void OnGotUnequipped(EntityUid uid, BreathToolComponent component, GotUnequippedEvent args)
private void OnGotUnequipped(Entity<BreathToolComponent> ent, ref GotUnequippedEvent args)
{
_atmosphereSystem.DisconnectInternals(component);
_atmosphereSystem.DisconnectInternals(ent);
}
private void OnGotEquipped(EntityUid uid, BreathToolComponent component, GotEquippedEvent args)
private void OnGotEquipped(Entity<BreathToolComponent> ent, ref GotEquippedEvent args)
{
if ((args.SlotFlags & ent.Comp.AllowedSlots) == 0)
{
return;
}
if ((args.SlotFlags & component.AllowedSlots) == 0) return;
component.IsFunctional = true;
ent.Comp.IsFunctional = true;
if (TryComp(args.Equipee, out InternalsComponent? internals))
{
component.ConnectedInternalsEntity = args.Equipee;
_internals.ConnectBreathTool((args.Equipee, internals), uid);
ent.Comp.ConnectedInternalsEntity = args.Equipee;
_internals.ConnectBreathTool((args.Equipee, internals), ent);
}
}
@@ -81,7 +84,7 @@ public sealed class LungSystem : EntitySystem
if (moles <= 0)
continue;
var reagent = _atmosphereSystem.GasReagents[i];
if (reagent == null) continue;
if (reagent is null) continue;
var amount = moles * Atmospherics.BreathMolesToReagentMultiplier;
solution.AddReagent(reagent, amount);