Remove 700 usages of Component.Owner (#21100)
This commit is contained in:
@@ -81,7 +81,7 @@ public sealed class InternalsSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
var tank = FindBestGasTank(uid ,internals);
|
||||
var tank = FindBestGasTank(uid, internals);
|
||||
|
||||
if (tank == null)
|
||||
{
|
||||
@@ -95,7 +95,7 @@ public sealed class InternalsSystem : EntitySystem
|
||||
return;
|
||||
}
|
||||
|
||||
_gasTank.ConnectToInternals(tank);
|
||||
_gasTank.ConnectToInternals(tank.Value);
|
||||
}
|
||||
|
||||
private void StartToggleInternalsDoAfter(EntityUid user, EntityUid target, InternalsComponent internals)
|
||||
@@ -139,34 +139,36 @@ public sealed class InternalsSystem : EntitySystem
|
||||
if (AreInternalsWorking(component))
|
||||
{
|
||||
var gasTank = Comp<GasTankComponent>(component.GasTankEntity!.Value);
|
||||
args.Gas = _gasTank.RemoveAirVolume(gasTank, Atmospherics.BreathVolume);
|
||||
args.Gas = _gasTank.RemoveAirVolume((component.GasTankEntity.Value, gasTank), Atmospherics.BreathVolume);
|
||||
// TODO: Should listen to gas tank updates instead I guess?
|
||||
_alerts.ShowAlert(uid, AlertType.Internals, GetSeverity(component));
|
||||
}
|
||||
}
|
||||
public void DisconnectBreathTool(InternalsComponent component)
|
||||
public void DisconnectBreathTool(Entity<InternalsComponent> ent)
|
||||
{
|
||||
var (owner, component) = ent;
|
||||
var old = component.BreathToolEntity;
|
||||
component.BreathToolEntity = null;
|
||||
|
||||
if (TryComp(old, out BreathToolComponent? breathTool) )
|
||||
{
|
||||
_atmos.DisconnectInternals(breathTool);
|
||||
DisconnectTank(component);
|
||||
DisconnectTank(ent);
|
||||
}
|
||||
|
||||
_alerts.ShowAlert(component.Owner, AlertType.Internals, GetSeverity(component));
|
||||
_alerts.ShowAlert(owner, AlertType.Internals, GetSeverity(component));
|
||||
}
|
||||
|
||||
public void ConnectBreathTool(InternalsComponent component, EntityUid toolEntity)
|
||||
public void ConnectBreathTool(Entity<InternalsComponent> ent, EntityUid toolEntity)
|
||||
{
|
||||
var (owner, component) = ent;
|
||||
if (TryComp(component.BreathToolEntity, out BreathToolComponent? tool))
|
||||
{
|
||||
_atmos.DisconnectInternals(tool);
|
||||
}
|
||||
|
||||
component.BreathToolEntity = toolEntity;
|
||||
_alerts.ShowAlert(component.Owner, AlertType.Internals, GetSeverity(component));
|
||||
_alerts.ShowAlert(owner, AlertType.Internals, GetSeverity(component));
|
||||
}
|
||||
|
||||
public void DisconnectTank(InternalsComponent? component)
|
||||
@@ -175,22 +177,23 @@ public sealed class InternalsSystem : EntitySystem
|
||||
return;
|
||||
|
||||
if (TryComp(component.GasTankEntity, out GasTankComponent? tank))
|
||||
_gasTank.DisconnectFromInternals(tank);
|
||||
_gasTank.DisconnectFromInternals((component.GasTankEntity.Value, tank));
|
||||
|
||||
component.GasTankEntity = null;
|
||||
_alerts.ShowAlert(component.Owner, AlertType.Internals, GetSeverity(component));
|
||||
}
|
||||
|
||||
public bool TryConnectTank(InternalsComponent component, EntityUid tankEntity)
|
||||
public bool TryConnectTank(Entity<InternalsComponent> ent, EntityUid tankEntity)
|
||||
{
|
||||
var component = ent.Comp;
|
||||
if (component.BreathToolEntity == null)
|
||||
return false;
|
||||
|
||||
if (TryComp(component.GasTankEntity, out GasTankComponent? tank))
|
||||
_gasTank.DisconnectFromInternals(tank);
|
||||
_gasTank.DisconnectFromInternals((component.GasTankEntity.Value, tank));
|
||||
|
||||
component.GasTankEntity = tankEntity;
|
||||
_alerts.ShowAlert(component.Owner, AlertType.Internals, GetSeverity(component));
|
||||
_alerts.ShowAlert(ent, AlertType.Internals, GetSeverity(component));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -213,7 +216,7 @@ public sealed class InternalsSystem : EntitySystem
|
||||
return 1;
|
||||
}
|
||||
|
||||
public GasTankComponent? FindBestGasTank(EntityUid internalsOwner, InternalsComponent component)
|
||||
public Entity<GasTankComponent>? FindBestGasTank(EntityUid internalsOwner, InternalsComponent component)
|
||||
{
|
||||
// Prioritise
|
||||
// 1. back equipped tanks
|
||||
@@ -227,27 +230,27 @@ public sealed class InternalsSystem : EntitySystem
|
||||
TryComp<GasTankComponent>(backEntity, out var backGasTank) &&
|
||||
_gasTank.CanConnectToInternals(backGasTank))
|
||||
{
|
||||
return backGasTank;
|
||||
return (backEntity.Value, backGasTank);
|
||||
}
|
||||
|
||||
if (_inventory.TryGetSlotEntity(internalsOwner, "suitstorage", out var entity, inventory, containerManager) &&
|
||||
TryComp<GasTankComponent>(entity, out var gasTank) &&
|
||||
_gasTank.CanConnectToInternals(gasTank))
|
||||
{
|
||||
return gasTank;
|
||||
return (entity.Value, gasTank);
|
||||
}
|
||||
|
||||
var tanks = new List<GasTankComponent>();
|
||||
var tanks = new List<Entity<GasTankComponent>>();
|
||||
|
||||
foreach (var hand in _hands.EnumerateHands(internalsOwner))
|
||||
{
|
||||
if (TryComp(hand.HeldEntity, out gasTank) && _gasTank.CanConnectToInternals(gasTank))
|
||||
tanks.Add(gasTank);
|
||||
tanks.Add((hand.HeldEntity.Value, gasTank));
|
||||
}
|
||||
|
||||
if (tanks.Count > 0)
|
||||
{
|
||||
tanks.Sort((x, y) => y.Air.TotalMoles.CompareTo(x.Air.TotalMoles));
|
||||
tanks.Sort((x, y) => y.Comp.Air.TotalMoles.CompareTo(x.Comp.Air.TotalMoles));
|
||||
return tanks[0];
|
||||
}
|
||||
|
||||
@@ -258,12 +261,12 @@ public sealed class InternalsSystem : EntitySystem
|
||||
while (enumerator.MoveNext(out var container))
|
||||
{
|
||||
if (TryComp(container.ContainedEntity, out gasTank) && _gasTank.CanConnectToInternals(gasTank))
|
||||
tanks.Add(gasTank);
|
||||
tanks.Add((container.ContainedEntity.Value, gasTank));
|
||||
}
|
||||
|
||||
if (tanks.Count > 0)
|
||||
{
|
||||
tanks.Sort((x, y) => y.Air.TotalMoles.CompareTo(x.Air.TotalMoles));
|
||||
tanks.Sort((x, y) => y.Comp.Air.TotalMoles.CompareTo(x.Comp.Air.TotalMoles));
|
||||
return tanks[0];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public sealed class LungSystem : EntitySystem
|
||||
if (TryComp(args.Equipee, out InternalsComponent? internals))
|
||||
{
|
||||
component.ConnectedInternalsEntity = args.Equipee;
|
||||
_internals.ConnectBreathTool(internals, uid);
|
||||
_internals.ConnectBreathTool((args.Equipee, internals), uid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@ using Content.Shared.Damage;
|
||||
using Content.Shared.Database;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Timing;
|
||||
|
||||
namespace Content.Server.Body.Systems
|
||||
@@ -41,10 +40,9 @@ namespace Content.Server.Body.Systems
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
foreach (var (respirator, body) in EntityManager.EntityQuery<RespiratorComponent, BodyComponent>())
|
||||
var query = EntityQueryEnumerator<RespiratorComponent, BodyComponent>();
|
||||
while (query.MoveNext(out var uid, out var respirator, out var body))
|
||||
{
|
||||
var uid = respirator.Owner;
|
||||
|
||||
if (_mobState.IsDead(uid))
|
||||
{
|
||||
continue;
|
||||
@@ -55,7 +53,7 @@ namespace Content.Server.Body.Systems
|
||||
if (respirator.AccumulatedFrametime < respirator.CycleDelay)
|
||||
continue;
|
||||
respirator.AccumulatedFrametime -= respirator.CycleDelay;
|
||||
UpdateSaturation(respirator.Owner, -respirator.CycleDelay, respirator);
|
||||
UpdateSaturation(uid, -respirator.CycleDelay, respirator);
|
||||
|
||||
if (!_mobState.IsIncapacitated(uid)) // cannot breathe in crit.
|
||||
{
|
||||
@@ -99,7 +97,7 @@ namespace Content.Server.Body.Systems
|
||||
|
||||
// Inhale gas
|
||||
var ev = new InhaleLocationEvent();
|
||||
RaiseLocalEvent(uid, ev, false);
|
||||
RaiseLocalEvent(uid, ev);
|
||||
|
||||
ev.Gas ??= _atmosSys.GetContainingMixture(uid, false, true);
|
||||
|
||||
|
||||
@@ -20,7 +20,8 @@ namespace Content.Server.Body.Systems
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
foreach (var (stomach, organ, sol)in EntityManager.EntityQuery<StomachComponent, OrganComponent, SolutionContainerManagerComponent>())
|
||||
var query = EntityQueryEnumerator<StomachComponent, OrganComponent, SolutionContainerManagerComponent>();
|
||||
while (query.MoveNext(out var uid, out var stomach, out var organ, out var sol))
|
||||
{
|
||||
stomach.AccumulatedFrameTime += frameTime;
|
||||
|
||||
@@ -30,7 +31,7 @@ namespace Content.Server.Body.Systems
|
||||
stomach.AccumulatedFrameTime -= stomach.UpdateInterval;
|
||||
|
||||
// Get our solutions
|
||||
if (!_solutionContainerSystem.TryGetSolution(stomach.Owner, DefaultSolutionName,
|
||||
if (!_solutionContainerSystem.TryGetSolution(uid, DefaultSolutionName,
|
||||
out var stomachSolution, sol))
|
||||
continue;
|
||||
|
||||
@@ -50,7 +51,7 @@ namespace Content.Server.Body.Systems
|
||||
if (reagent.Quantity > delta.ReagentQuantity.Quantity)
|
||||
reagent = new(reagent.Reagent, delta.ReagentQuantity.Quantity);
|
||||
|
||||
_solutionContainerSystem.RemoveReagent((stomach).Owner, stomachSolution, reagent);
|
||||
_solutionContainerSystem.RemoveReagent(uid, stomachSolution, reagent);
|
||||
transferSolution.AddReagent(reagent);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,14 +12,15 @@ public sealed class ThermalRegulatorSystem : EntitySystem
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
foreach (var regulator in EntityManager.EntityQuery<ThermalRegulatorComponent>())
|
||||
var query = EntityQueryEnumerator<ThermalRegulatorComponent>();
|
||||
while (query.MoveNext(out var uid, out var regulator))
|
||||
{
|
||||
regulator.AccumulatedFrametime += frameTime;
|
||||
if (regulator.AccumulatedFrametime < 1)
|
||||
continue;
|
||||
|
||||
regulator.AccumulatedFrametime -= 1;
|
||||
ProcessThermalRegulation(regulator.Owner, regulator);
|
||||
ProcessThermalRegulation(uid, regulator);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user