More (IComponent) shenanigans and also some contaminated IoCManager.Resolve<IEntityManager>() very long yes calls

This commit is contained in:
metalgearsloth
2021-12-07 22:22:34 +11:00
parent 373b5988d7
commit 8af335097f
55 changed files with 176 additions and 172 deletions

View File

@@ -56,7 +56,7 @@ namespace Content.Server.Body.Systems
foreach (var (part, _) in body.Parts)
foreach (var mechanism in part.Mechanisms)
{
if (EntityManager.TryGetComponent<T>(((IComponent) mechanism).Owner, out var comp))
if (EntityManager.TryGetComponent<T>((mechanism).Owner, out var comp))
yield return (comp, mechanism);
}
}

View File

@@ -14,12 +14,12 @@ namespace Content.Server.Body.Systems
{
base.Initialize();
SubscribeLocalEvent<BrainComponent, AddedToBodyEvent>((uid, component, args) => HandleMind(((IComponent) args.Body).Owner, uid));
SubscribeLocalEvent<BrainComponent, AddedToPartEvent>((uid, component, args) => HandleMind(((IComponent) args.Part).Owner, uid));
SubscribeLocalEvent<BrainComponent, AddedToPartInBodyEvent>((uid, component, args) => HandleMind(((IComponent) args.Body).Owner, uid));
SubscribeLocalEvent<BrainComponent, AddedToBodyEvent>((uid, component, args) => HandleMind((args.Body).Owner, uid));
SubscribeLocalEvent<BrainComponent, AddedToPartEvent>((uid, component, args) => HandleMind((args.Part).Owner, uid));
SubscribeLocalEvent<BrainComponent, AddedToPartInBodyEvent>((uid, component, args) => HandleMind((args.Body).Owner, uid));
SubscribeLocalEvent<BrainComponent, RemovedFromBodyEvent>(OnRemovedFromBody);
SubscribeLocalEvent<BrainComponent, RemovedFromPartEvent>((uid, component, args) => HandleMind(uid, ((IComponent) args.Old).Owner));
SubscribeLocalEvent<BrainComponent, RemovedFromPartInBodyEvent>((uid, component, args) => HandleMind(((IComponent) args.OldBody).Owner, uid));
SubscribeLocalEvent<BrainComponent, RemovedFromPartEvent>((uid, component, args) => HandleMind(uid, (args.Old).Owner));
SubscribeLocalEvent<BrainComponent, RemovedFromPartInBodyEvent>((uid, component, args) => HandleMind((args.OldBody).Owner, uid));
}
private void OnRemovedFromBody(EntityUid uid, BrainComponent component, RemovedFromBodyEvent args)
@@ -28,7 +28,7 @@ namespace Content.Server.Body.Systems
if (!EntityManager.TryGetComponent(uid, out MechanismComponent mech))
return;
HandleMind(((IComponent) mech.Part!).Owner, ((IComponent) args.Old).Owner);
HandleMind((mech.Part!).Owner, (args.Old).Owner);
}
private void HandleMind(EntityUid newEntity, EntityUid oldEntity)

View File

@@ -57,7 +57,7 @@ public class LungSystem : EntitySystem
if (!Resolve(uid, ref lung, ref mech))
return;
if (mech.Body != null && EntityManager.TryGetComponent(((IComponent) mech.Body).Owner, out MobStateComponent? mobState) && mobState.IsCritical())
if (mech.Body != null && EntityManager.TryGetComponent((mech.Body).Owner, out MobStateComponent? mobState) && mobState.IsCritical())
{
return;
}
@@ -111,7 +111,7 @@ public class LungSystem : EntitySystem
// TODO Jesus Christ make this event based.
if (mech.Body != null &&
EntityManager.TryGetComponent(((IComponent) mech.Body).Owner, out InternalsComponent? internals) &&
EntityManager.TryGetComponent((mech.Body).Owner, out InternalsComponent? internals) &&
internals.BreathToolEntity != null &&
internals.GasTankEntity != null &&
IoCManager.Resolve<IEntityManager>().TryGetComponent(internals.BreathToolEntity, out BreathToolComponent? breathTool) &&
@@ -148,7 +148,7 @@ public class LungSystem : EntitySystem
if (mech.Body == null)
return;
if (!EntityManager.TryGetComponent(((IComponent) mech.Body).Owner, out BloodstreamComponent? bloodstream))
if (!EntityManager.TryGetComponent((mech.Body).Owner, out BloodstreamComponent? bloodstream))
return;
var to = bloodstream.Air;
@@ -189,10 +189,10 @@ public class LungSystem : EntitySystem
if (mech.Body == null)
return;
if (!EntityManager.TryGetComponent(((IComponent) mech.Body).Owner, out BloodstreamComponent? bloodstream))
if (!EntityManager.TryGetComponent((mech.Body).Owner, out BloodstreamComponent? bloodstream))
return;
_bloodstreamSystem.PumpToxins(((IComponent) mech.Body).Owner, lung.Air, bloodstream);
_bloodstreamSystem.PumpToxins((mech.Body).Owner, lung.Air, bloodstream);
var lungRemoved = lung.Air.RemoveRatio(0.5f);
_atmosSys.Merge(to, lungRemoved);

View File

@@ -43,7 +43,7 @@ namespace Content.Server.Body.Systems
{
if (mech.Body != null)
{
_solutionContainerSystem.EnsureSolution(((IComponent) mech.Body).Owner, component.SolutionName);
_solutionContainerSystem.EnsureSolution((mech.Body).Owner, component.SolutionName);
}
}
}
@@ -61,7 +61,7 @@ namespace Content.Server.Body.Systems
if (metab.AccumulatedFrametime >= metab.UpdateFrequency)
{
metab.AccumulatedFrametime -= metab.UpdateFrequency;
TryMetabolize(((IComponent) metab).Owner, metab);
TryMetabolize((metab).Owner, metab);
}
}
}
@@ -86,9 +86,9 @@ namespace Content.Server.Body.Systems
if (body != null)
{
if (!Resolve(((IComponent) body).Owner, ref manager, false))
if (!Resolve((body).Owner, ref manager, false))
return;
_solutionContainerSystem.TryGetSolution(((IComponent) body).Owner, meta.SolutionName, out solution, manager);
_solutionContainerSystem.TryGetSolution((body).Owner, meta.SolutionName, out solution, manager);
solutionEntityUid = body.Owner;
}
}
@@ -152,7 +152,7 @@ namespace Content.Server.Body.Systems
continue;
}
var args = new ReagentEffectArgs(solutionEntityUid.Value, ((IComponent) meta).Owner, solution, proto, entry.MetabolismRate,
var args = new ReagentEffectArgs(solutionEntityUid.Value, (meta).Owner, solution, proto, entry.MetabolismRate,
EntityManager, null);
// do all effects, if conditions apply

View File

@@ -32,7 +32,7 @@ namespace Content.Server.Body.Systems
foreach (var (respirator, blood, body) in
EntityManager.EntityQuery<RespiratorComponent, BloodstreamComponent, SharedBodyComponent>())
{
var uid = ((IComponent) respirator).Owner;
var uid = (respirator).Owner;
if (!EntityManager.TryGetComponent<MobStateComponent>(uid, out var state) ||
state.IsDead())
{
@@ -144,7 +144,7 @@ namespace Content.Server.Body.Systems
foreach (var (lung, mech) in lungs)
{
_lungSystem.UpdateLung(((IComponent) lung).Owner, frameTime, lung, mech);
_lungSystem.UpdateLung((lung).Owner, frameTime, lung, mech);
}
foreach (var (gas, amountNeeded) in needs)
@@ -159,7 +159,7 @@ namespace Content.Server.Body.Systems
// Panic inhale
foreach (var (lung, mech) in lungs)
{
_lungSystem.Gasp(((IComponent) lung).Owner, lung, mech);
_lungSystem.Gasp((lung).Owner, lung, mech);
}
}

View File

@@ -35,11 +35,11 @@ namespace Content.Server.Body.Systems
stomach.AccumulatedFrameTime -= stomach.UpdateInterval;
// Get our solutions
if (!_solutionContainerSystem.TryGetSolution(((IComponent) stomach).Owner, DefaultSolutionName,
if (!_solutionContainerSystem.TryGetSolution((stomach).Owner, DefaultSolutionName,
out var stomachSolution, sol))
continue;
if (!_solutionContainerSystem.TryGetSolution(((IComponent) mech.Body).Owner, stomach.BodySolutionName,
if (!_solutionContainerSystem.TryGetSolution((mech.Body).Owner, stomach.BodySolutionName,
out var bodySolution))
continue;
@@ -56,7 +56,7 @@ namespace Content.Server.Body.Systems
if (quant > delta.Quantity)
quant = delta.Quantity;
_solutionContainerSystem.TryRemoveReagent(((IComponent) stomach).Owner, stomachSolution,
_solutionContainerSystem.TryRemoveReagent((stomach).Owner, stomachSolution,
delta.ReagentId, quant);
transferSolution.AddReagent(delta.ReagentId, quant);
}
@@ -71,7 +71,7 @@ namespace Content.Server.Body.Systems
}
// Transfer everything to the body solution!
_solutionContainerSystem.TryAddSolution(((IComponent) mech.Body).Owner, bodySolution, transferSolution);
_solutionContainerSystem.TryAddSolution((mech.Body).Owner, bodySolution, transferSolution);
}
}

View File

@@ -22,7 +22,7 @@ public class ThermalRegulatorSystem : EntitySystem
continue;
regulator.AccumulatedFrametime -= 1;
ProcessThermalRegulation(((IComponent) regulator).Owner, regulator);
ProcessThermalRegulation(regulator.Owner, regulator);
}
}