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

@@ -24,7 +24,7 @@ namespace Content.Client.Atmos.Visualizers
{
base.OnChangeData(component);
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(((IComponent) component).Owner, out SpriteComponent? sprite))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out SpriteComponent? sprite))
{
return;
}

View File

@@ -14,7 +14,7 @@ namespace Content.Client.Atmos.Visualizers
{
base.OnChangeData(component);
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(((IComponent) component).Owner, out SpriteComponent? sprite))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out SpriteComponent? sprite))
return;
if (component.TryGetData(PipeColorVisuals.Color, out Color color))

View File

@@ -319,7 +319,7 @@ namespace Content.Client.Instruments
foreach (var instrument in EntityManager.EntityQuery<InstrumentComponent>(true))
{
if (instrument.DirtyRenderer && instrument.Renderer != null)
UpdateRenderer(((IComponent) instrument).Owner, instrument);
UpdateRenderer(instrument.Owner, instrument);
if (!instrument.IsMidiOpen && !instrument.IsInputOpen)
continue;
@@ -366,7 +366,7 @@ namespace Content.Client.Instruments
if (eventCount == 0)
continue;
RaiseNetworkEvent(new InstrumentMidiEventEvent(((IComponent) instrument).Owner, events));
RaiseNetworkEvent(new InstrumentMidiEventEvent(instrument.Owner, events));
instrument.SentWithinASec += eventCount;

View File

@@ -104,7 +104,7 @@ namespace Content.Client.Instruments.UI
await Task.WhenAll(Timer.Delay(100), file.CopyToAsync(memStream));
if (_owner.Instrument is not {} instrument
|| !EntitySystem.Get<InstrumentSystem>().OpenMidi(((IComponent) instrument).Owner, memStream.GetBuffer().AsSpan(0, (int) memStream.Length), instrument))
|| !EntitySystem.Get<InstrumentSystem>().OpenMidi(instrument.Owner, memStream.GetBuffer().AsSpan(0, (int) memStream.Length), instrument))
return;
MidiPlaybackSetButtonsDisabled(false);
@@ -123,10 +123,10 @@ namespace Content.Client.Instruments.UI
MidiStopButtonOnPressed(null);
if(_owner.Instrument is {} instrument)
instrumentSystem.OpenInput(((IComponent) instrument).Owner, instrument);
instrumentSystem.OpenInput(instrument.Owner, instrument);
}
else if(_owner.Instrument is {} instrument)
instrumentSystem.CloseInput(((IComponent) instrument).Owner, false, instrument);
instrumentSystem.CloseInput(instrument.Owner, false, instrument);
}
private bool PlayCheck()
@@ -162,7 +162,7 @@ namespace Content.Client.Instruments.UI
if (_owner.Instrument is not { } instrument)
return;
EntitySystem.Get<InstrumentSystem>().CloseMidi(((IComponent) instrument).Owner, false, instrument);
EntitySystem.Get<InstrumentSystem>().CloseMidi(instrument.Owner, false, instrument);
}
private void MidiLoopButtonOnOnToggled(ButtonToggledEventArgs obj)
@@ -179,14 +179,14 @@ namespace Content.Client.Instruments.UI
// Do not seek while still grabbing.
if (PlaybackSlider.Grabbed || _owner.Instrument is not {} instrument) return;
EntitySystem.Get<InstrumentSystem>().SetPlayerTick(((IComponent) instrument).Owner, (int)Math.Ceiling(PlaybackSlider.Value), instrument);
EntitySystem.Get<InstrumentSystem>().SetPlayerTick(instrument.Owner, (int)Math.Ceiling(PlaybackSlider.Value), instrument);
}
private void PlaybackSliderKeyUp(GUIBoundKeyEventArgs args)
{
if (args.Function != EngineKeyFunctions.UIClick || _owner.Instrument is not {} instrument) return;
EntitySystem.Get<InstrumentSystem>().SetPlayerTick(((IComponent) instrument).Owner, (int)Math.Ceiling(PlaybackSlider.Value), instrument);
EntitySystem.Get<InstrumentSystem>().SetPlayerTick(instrument.Owner, (int)Math.Ceiling(PlaybackSlider.Value), instrument);
}
protected override void FrameUpdate(FrameEventArgs args)

View File

@@ -24,7 +24,7 @@ namespace Content.Client.Mining
{
base.OnChangeData(component);
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(((IComponent) component).Owner, out SpriteComponent? sprite))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out SpriteComponent? sprite))
{
return;
}

View File

@@ -25,7 +25,7 @@ namespace Content.Client.Singularity.Visualizers
{
base.OnChangeData(component);
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(((IComponent) component).Owner, out SpriteComponent? sprite))
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out SpriteComponent? sprite))
{
return;
}

View File

@@ -50,11 +50,11 @@ namespace Content.Server.Animals.Systems
continue;
}
if (!_solutionContainerSystem.TryGetSolution(((IComponent) udder).Owner, udder.TargetSolutionName, out var solution))
if (!_solutionContainerSystem.TryGetSolution(udder.Owner, udder.TargetSolutionName, out var solution))
continue;
//TODO: toxins from bloodstream !?
_solutionContainerSystem.TryAddReagent(((IComponent) udder).Owner, solution, udder.ReagentId, udder.QuantityPerUpdate, out var accepted);
_solutionContainerSystem.TryAddReagent(udder.Owner, solution, udder.ReagentId, udder.QuantityPerUpdate, out var accepted);
udder.AccumulatedFrameTime = 0;
}
}

View File

@@ -79,7 +79,7 @@ namespace Content.Server.Atmos.EntitySystems
{
airtight.AirBlocked = airblocked;
UpdatePosition(airtight);
RaiseLocalEvent(((IComponent) airtight).Owner, new AirtightChanged(airtight));
RaiseLocalEvent((airtight).Owner, new AirtightChanged(airtight));
}
public void UpdatePosition(AirtightComponent airtight)

View File

@@ -200,9 +200,9 @@ namespace Content.Server.Atmos.EntitySystems
var fireStackDelta = fireStackMod - flammable.FireStacks;
if (fireStackDelta > 0)
{
AdjustFireStacks(((IComponent) flammable).Owner, fireStackDelta, flammable);
AdjustFireStacks((flammable).Owner, fireStackDelta, flammable);
}
Ignite(((IComponent) flammable).Owner, flammable);
Ignite((flammable).Owner, flammable);
}
_fireEvents.Clear();

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

View File

@@ -190,7 +190,7 @@ namespace Content.Server.Chemistry.Components
EntitySystem.Get<SolutionContainerSystem>().SplitSolution(user, targetBloodstream.Solution, realTransferAmount);
var bloodstreamSys = EntitySystem.Get<BloodstreamSystem>();
bloodstreamSys.TryAddToBloodstream(((IComponent) targetBloodstream).Owner, removedSolution, targetBloodstream);
bloodstreamSys.TryAddToBloodstream((targetBloodstream).Owner, removedSolution, targetBloodstream);
removedSolution.DoEntityReaction(targetBloodstream.Owner, ReactionMethod.Injection);

View File

@@ -38,7 +38,7 @@ namespace Content.Server.Chemistry.EntitySystems
var solToInject = solRemoved.SplitSolution(solRemovedVol * component.TransferEfficiency);
_bloodstreamSystem.TryAddToBloodstream(((IComponent) args.OtherFixture.Body).Owner, solToInject, bloodstream);
_bloodstreamSystem.TryAddToBloodstream((args.OtherFixture.Body).Owner, solToInject, bloodstream);
}
}
}

View File

@@ -32,7 +32,7 @@ namespace Content.Server.Disposal.Tube.Components
EntitySystem.Get<AtmosphereSystem>().Merge(holderComponent.Air, from.Air);
from.Air.Clear();
return EntitySystem.Get<DisposableSystem>().EnterTube(((IComponent) holderComponent).Owner, Owner, holderComponent, null, this);
return EntitySystem.Get<DisposableSystem>().EnterTube((holderComponent).Owner, Owner, holderComponent, null, this);
}
protected override Direction[] ConnectableDirections()

View File

@@ -93,7 +93,7 @@ namespace Content.Server.Disposal.Tube.Components
continue;
}
EntitySystem.Get<DisposableSystem>().ExitDisposals(((IComponent) holder).Owner);
EntitySystem.Get<DisposableSystem>().ExitDisposals((holder).Owner);
}
}

View File

@@ -59,7 +59,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
if (duc != null)
{
// Insert into disposal unit
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates = new EntityCoordinates(((IComponent) duc).Owner, Vector2.Zero);
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates = new EntityCoordinates((duc).Owner, Vector2.Zero);
duc.Container.Insert(entity);
}
else
@@ -154,7 +154,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
var currentTube = holder.CurrentTube;
if (currentTube == null || currentTube.Deleted)
{
ExitDisposals(((IComponent) holder).Owner);
ExitDisposals((holder).Owner);
break;
}
@@ -178,12 +178,12 @@ namespace Content.Server.Disposal.Unit.EntitySystems
var nextTube = _disposalTubeSystem.NextTubeFor(currentTube.Owner, holder.CurrentDirection);
if (nextTube == null || nextTube.Deleted)
{
ExitDisposals(((IComponent) holder).Owner);
ExitDisposals((holder).Owner);
break;
}
// Perform remainder of entry process
if (!EnterTube(((IComponent) holder).Owner, nextTube.Owner, holder, null, nextTube, null))
if (!EnterTube((holder).Owner, nextTube.Owner, holder, null, nextTube, null))
{
break;
}

View File

@@ -112,7 +112,7 @@ namespace Content.Server.Fluids.Components
}
if (!_entities.TryGetComponent(target, out PuddleComponent? puddleComponent) ||
!solutionSystem.TryGetSolution(((IComponent) puddleComponent).Owner, puddleComponent.SolutionName, out var puddleSolution))
!solutionSystem.TryGetSolution((puddleComponent).Owner, puddleComponent.SolutionName, out var puddleSolution))
return false;
// So if the puddle has 20 units we mop in 2 seconds. Don't just store CurrentVolume given it can change so need to re-calc it anyway.

View File

@@ -154,7 +154,7 @@ public sealed partial class InstrumentSystem : SharedInstrumentSystem
&& instrument.InstrumentPlayer != null && instrument.RespectMidiLimits)
{
// Just in case
Clean(((IComponent) instrument).Owner);
Clean((instrument).Owner);
instrument.UserInterface?.CloseAll();
if (instrument.InstrumentPlayer.AttachedEntity is {Valid: true} mob)

View File

@@ -44,10 +44,10 @@ public class GrowingKudzuSystem : EntitySystem
kudzu.GrowthLevel += 1;
if (kudzu.GrowthLevel == 3 &&
EntityManager.TryGetComponent<SpreaderComponent>(((IComponent) kudzu).Owner, out var spreader))
EntityManager.TryGetComponent<SpreaderComponent>((kudzu).Owner, out var spreader))
{
// why cache when you can simply cease to be? Also saves a bit of memory/time.
EntityManager.RemoveComponent<GrowingKudzuComponent>(((IComponent) kudzu).Owner);
EntityManager.RemoveComponent<GrowingKudzuComponent>((kudzu).Owner);
}
appearance.SetData(KudzuVisuals.GrowthLevel, kudzu.GrowthLevel);

View File

@@ -35,7 +35,7 @@ public class SpreaderSystem : EntitySystem
private void OnAirtightChanged(AirtightChanged e)
{
UpdateNearbySpreaders(((IComponent) e.Airtight).Owner, e.Airtight);
UpdateNearbySpreaders((e.Airtight).Owner, e.Airtight);
}
private void SpreaderAddHandler(EntityUid uid, SpreaderComponent component, ComponentAdd args)

View File

@@ -67,7 +67,7 @@ namespace Content.Server.Nuke
var consoles = EntityManager.EntityQuery<CommunicationsConsoleComponent>();
foreach (var console in consoles)
{
if (!EntityManager.TryGetComponent(((IComponent) console).Owner, out TransformComponent? transform))
if (!EntityManager.TryGetComponent((console).Owner, out TransformComponent? transform))
continue;
var consolePos = transform.MapPosition;

View File

@@ -215,13 +215,13 @@ namespace Content.Server.Nutrition.EntitySystems
public void UpdateAppearance(DrinkComponent component)
{
if (!EntityManager.TryGetComponent(((IComponent) component).Owner, out AppearanceComponent? appearance) ||
!EntityManager.HasComponent<SolutionContainerManagerComponent>(((IComponent) component).Owner))
if (!EntityManager.TryGetComponent((component).Owner, out AppearanceComponent? appearance) ||
!EntityManager.HasComponent<SolutionContainerManagerComponent>((component).Owner))
{
return;
}
var drainAvailable = _solutionContainerSystem.DrainAvailable(((IComponent) component).Owner);
var drainAvailable = _solutionContainerSystem.DrainAvailable((component).Owner);
appearance.SetData(FoodVisuals.Visual, drainAvailable.Float());
appearance.SetData(DrinkCanStateVisual.Opened, component.Opened);
}
@@ -245,7 +245,7 @@ namespace Content.Server.Nutrition.EntitySystems
if (!EntityManager.TryGetComponent(userUid, out SharedBodyComponent? body))
return false;
if (!_solutionContainerSystem.TryGetDrainableSolution(((IComponent) drink).Owner, out var drinkSolution) ||
if (!_solutionContainerSystem.TryGetDrainableSolution((drink).Owner, out var drinkSolution) ||
drinkSolution.DrainAvailable <= 0)
{
_popupSystem.PopupEntity(Loc.GetString("drink-component-try-use-drink-is-empty",
@@ -271,7 +271,7 @@ namespace Content.Server.Nutrition.EntitySystems
var transferAmount = FixedPoint2.Min(drink.TransferAmount, drinkSolution.DrainAvailable);
var drain = _solutionContainerSystem.Drain(uid, drinkSolution, transferAmount);
var firstStomach = stomachs.FirstOrNull(
stomach => _stomachSystem.CanTransferSolution(((IComponent) stomach.Comp).Owner, drain));
stomach => _stomachSystem.CanTransferSolution((stomach.Comp).Owner, drain));
// All stomach are full or can't handle whatever solution we have.
if (firstStomach == null)
@@ -296,7 +296,7 @@ namespace Content.Server.Nutrition.EntitySystems
Filter.Pvs(userUid));
drain.DoEntityReaction(userUid, ReactionMethod.Ingestion);
_stomachSystem.TryTransferSolution(((IComponent) firstStomach.Value.Comp).Owner, drain, firstStomach.Value.Comp);
_stomachSystem.TryTransferSolution((firstStomach.Value.Comp).Owner, drain, firstStomach.Value.Comp);
return true;
}
@@ -372,7 +372,7 @@ namespace Content.Server.Nutrition.EntitySystems
{
args.Drink.InUse = false;
var transferAmount = FixedPoint2.Min(args.Drink.TransferAmount, args.DrinkSolution.DrainAvailable);
var drained = _solutionContainerSystem.Drain(((IComponent) args.Drink).Owner, args.DrinkSolution, transferAmount);
var drained = _solutionContainerSystem.Drain((args.Drink).Owner, args.DrinkSolution, transferAmount);
if (!_bodySystem.TryGetComponentsOnMechanisms<StomachComponent>(uid, out var stomachs, body))
{
@@ -384,7 +384,7 @@ namespace Content.Server.Nutrition.EntitySystems
}
var firstStomach = stomachs.FirstOrNull(
stomach => _stomachSystem.CanTransferSolution(((IComponent) stomach.Comp).Owner, drained));
stomach => _stomachSystem.CanTransferSolution((stomach.Comp).Owner, drained));
// All stomach are full or can't handle whatever solution we have.
if (firstStomach == null)
@@ -411,7 +411,7 @@ namespace Content.Server.Nutrition.EntitySystems
SoundSystem.Play(Filter.Pvs(uid), args.Drink.UseSound.GetSound(), uid, AudioParams.Default.WithVolume(-2f));
drained.DoEntityReaction(uid, ReactionMethod.Ingestion);
_stomachSystem.TryTransferSolution(((IComponent) firstStomach.Value.Comp).Owner, drained, firstStomach.Value.Comp);
_stomachSystem.TryTransferSolution((firstStomach.Value.Comp).Owner, drained, firstStomach.Value.Comp);
}
private void OnForceDrinkCancelled(ForceDrinkCancelledEvent args)

View File

@@ -156,7 +156,7 @@ namespace Content.Server.Nutrition.EntitySystems
var transferAmount = food.TransferAmount != null ? FixedPoint2.Min((FixedPoint2) food.TransferAmount, solution.CurrentVolume) : solution.CurrentVolume;
var split = _solutionContainerSystem.SplitSolution(uid, solution, transferAmount);
var firstStomach = stomachs.FirstOrNull(
stomach => _stomachSystem.CanTransferSolution(((IComponent) stomach.Comp).Owner, split));
stomach => _stomachSystem.CanTransferSolution((stomach.Comp).Owner, split));
if (firstStomach == null)
{
@@ -167,7 +167,7 @@ namespace Content.Server.Nutrition.EntitySystems
// TODO: Account for partial transfer.
split.DoEntityReaction(user, ReactionMethod.Ingestion);
_stomachSystem.TryTransferSolution(((IComponent) firstStomach.Value.Comp).Owner, split, firstStomach.Value.Comp);
_stomachSystem.TryTransferSolution((firstStomach.Value.Comp).Owner, split, firstStomach.Value.Comp);
SoundSystem.Play(Filter.Pvs(user), food.UseSound.GetSound(), user, AudioParams.Default.WithVolume(-1f));
_popupSystem.PopupEntity(Loc.GetString(food.EatMessage, ("food", food.Owner)), user, Filter.Entities(user));
@@ -175,7 +175,7 @@ namespace Content.Server.Nutrition.EntitySystems
// Try to break all used utensils
foreach (var utensil in usedUtensils)
{
_utensilSystem.TryBreak(((IComponent) utensil).Owner, user);
_utensilSystem.TryBreak((utensil).Owner, user);
}
if (food.UsesRemaining > 0)
@@ -184,7 +184,7 @@ namespace Content.Server.Nutrition.EntitySystems
}
if (string.IsNullOrEmpty(food.TrashPrototype))
EntityManager.QueueDeleteEntity(((IComponent) food).Owner);
EntityManager.QueueDeleteEntity((food).Owner);
else
DeleteAndSpawnTrash(food, user);
@@ -202,7 +202,7 @@ namespace Content.Server.Nutrition.EntitySystems
EntityManager.TryGetComponent(user.Value, out HandsComponent? handsComponent) &&
handsComponent.IsHolding(component.Owner))
{
EntityManager.DeleteEntity(((IComponent) component).Owner);
EntityManager.DeleteEntity((component).Owner);
// Put the trash in the user's hand
if (EntityManager.TryGetComponent(finisher, out ItemComponent? item) &&
@@ -213,7 +213,7 @@ namespace Content.Server.Nutrition.EntitySystems
return;
}
EntityManager.QueueDeleteEntity(((IComponent) component).Owner);
EntityManager.QueueDeleteEntity((component).Owner);
}
private void AddEatVerb(EntityUid uid, FoodComponent component, GetInteractionVerbsEvent ev)
@@ -310,9 +310,9 @@ namespace Content.Server.Nutrition.EntitySystems
? FixedPoint2.Min((FixedPoint2) args.Food.TransferAmount, args.FoodSolution.CurrentVolume)
: args.FoodSolution.CurrentVolume;
var split = _solutionContainerSystem.SplitSolution(((IComponent) args.Food).Owner, args.FoodSolution, transferAmount);
var split = _solutionContainerSystem.SplitSolution((args.Food).Owner, args.FoodSolution, transferAmount);
var firstStomach = stomachs.FirstOrNull(
stomach => _stomachSystem.CanTransferSolution(((IComponent) stomach.Comp).Owner, split));
stomach => _stomachSystem.CanTransferSolution((stomach.Comp).Owner, split));
if (firstStomach == null)
{
@@ -322,7 +322,7 @@ namespace Content.Server.Nutrition.EntitySystems
}
split.DoEntityReaction(uid, ReactionMethod.Ingestion);
_stomachSystem.TryTransferSolution(((IComponent) firstStomach.Value.Comp).Owner, split, firstStomach.Value.Comp);
_stomachSystem.TryTransferSolution((firstStomach.Value.Comp).Owner, split, firstStomach.Value.Comp);
EntityManager.TryGetComponent(uid, out MetaDataComponent? targetMeta);
var targetName = targetMeta?.EntityName ?? string.Empty;
@@ -341,14 +341,14 @@ namespace Content.Server.Nutrition.EntitySystems
// Try to break all used utensils
foreach (var utensil in args.Utensils)
{
_utensilSystem.TryBreak(((IComponent) utensil).Owner, args.User);
_utensilSystem.TryBreak((utensil).Owner, args.User);
}
if (args.Food.UsesRemaining > 0)
return;
if (string.IsNullOrEmpty(args.Food.TrashPrototype))
EntityManager.QueueDeleteEntity(((IComponent) args.Food).Owner);
EntityManager.QueueDeleteEntity((args.Food).Owner);
else
DeleteAndSpawnTrash(args.Food, args.User);
}

View File

@@ -107,7 +107,7 @@ namespace Content.Server.Physics.Controllers
// then do the movement input once for it.
foreach (var (shuttle, pilots) in _shuttlePilots)
{
if (shuttle.Paused || !EntityManager.TryGetComponent(((IComponent) shuttle).Owner, out PhysicsComponent? body)) continue;
if (shuttle.Paused || !EntityManager.TryGetComponent((shuttle).Owner, out PhysicsComponent? body)) continue;
// Collate movement linear and angular inputs together
var linearInput = Vector2.Zero;
@@ -130,7 +130,7 @@ namespace Content.Server.Physics.Controllers
if (sprint.Equals(Vector2.Zero)) continue;
var offsetRotation = EntityManager.GetComponent<TransformComponent>(((IComponent) console).Owner).LocalRotation;
var offsetRotation = EntityManager.GetComponent<TransformComponent>((console).Owner).LocalRotation;
linearInput += offsetRotation.RotateVec(new Vector2(0f, sprint.Y));
angularInput += sprint.X;
@@ -152,7 +152,7 @@ namespace Content.Server.Physics.Controllers
if (sprint.Equals(Vector2.Zero)) continue;
var offsetRotation = EntityManager.GetComponent<TransformComponent>(((IComponent) console).Owner).LocalRotation;
var offsetRotation = EntityManager.GetComponent<TransformComponent>((console).Owner).LocalRotation;
sprint = offsetRotation.RotateVec(sprint);
linearInput += sprint;
@@ -179,7 +179,7 @@ namespace Content.Server.Physics.Controllers
var angle = linearInput.ToWorldAngle();
var linearDir = angle.GetDir();
var dockFlag = linearDir.AsFlag();
var shuttleNorth = EntityManager.GetComponent<TransformComponent>(((IComponent) body).Owner).WorldRotation.ToWorldVec();
var shuttleNorth = EntityManager.GetComponent<TransformComponent>((body).Owner).WorldRotation.ToWorldVec();
// Won't just do cardinal directions.
foreach (DirectionFlag dir in Enum.GetValues(typeof(DirectionFlag)))

View File

@@ -175,7 +175,7 @@ namespace Content.Server.PneumaticCannon
if (storage.StoredEntities == null) return;
if (storage.StoredEntities.Count == 0)
{
SoundSystem.Play(Filter.Pvs(((IComponent) comp).Owner), "/Audio/Weapons/click.ogg", ((IComponent) comp).Owner, AudioParams.Default);
SoundSystem.Play(Filter.Pvs((comp).Owner), "/Audio/Weapons/click.ogg", ((IComponent) comp).Owner, AudioParams.Default);
return;
}

View File

@@ -68,7 +68,7 @@ namespace Content.Server.Power.EntitySystems
{
// No point resetting what the receiver is doing if it's deleting, plus significant perf savings
// in not doing needless lookups
if (EntityManager.GetComponent<MetaDataComponent>(((IComponent) receiver).Owner).EntityLifeStage >
if (EntityManager.GetComponent<MetaDataComponent>((receiver).Owner).EntityLifeStage >
EntityLifeStage.MapInitialized) continue;
TryFindAndSetProvider(receiver);

View File

@@ -110,7 +110,7 @@ namespace Content.Server.Shuttles.EntitySystems
if (dockingFixture == null)
{
DebugTools.Assert(false);
Logger.ErrorS("docking", $"Found null fixture on {((IComponent) body).Owner}");
Logger.ErrorS("docking", $"Found null fixture on {(body).Owner}");
return null;
}
@@ -181,7 +181,7 @@ namespace Content.Server.Shuttles.EntitySystems
if (dockB == null || dockA.DockJoint == null)
{
DebugTools.Assert(false);
Logger.Error("docking", $"Tried to cleanup {((IComponent) dockA).Owner} but not docked?");
Logger.Error("docking", $"Tried to cleanup {(dockA).Owner} but not docked?");
dockA.DockedWith = null;
if (dockA.DockJoint != null)
@@ -200,8 +200,8 @@ namespace Content.Server.Shuttles.EntitySystems
dockA.DockedWith = null;
// If these grids are ever invalid then need to look at fixing ordering for unanchored events elsewhere.
var gridAUid = _mapManager.GetGrid(EntityManager.GetComponent<TransformComponent>(((IComponent) dockA).Owner).GridID).GridEntityId;
var gridBUid = _mapManager.GetGrid(EntityManager.GetComponent<TransformComponent>(((IComponent) dockB).Owner).GridID).GridEntityId;
var gridAUid = _mapManager.GetGrid(EntityManager.GetComponent<TransformComponent>((dockA).Owner).GridID).GridEntityId;
var gridBUid = _mapManager.GetGrid(EntityManager.GetComponent<TransformComponent>((dockB).Owner).GridID).GridEntityId;
var msg = new UndockEvent
{
@@ -211,8 +211,8 @@ namespace Content.Server.Shuttles.EntitySystems
GridBUid = gridBUid,
};
EntityManager.EventBus.RaiseLocalEvent(((IComponent) dockA).Owner, msg, false);
EntityManager.EventBus.RaiseLocalEvent(((IComponent) dockB).Owner, msg, false);
EntityManager.EventBus.RaiseLocalEvent((dockA).Owner, msg, false);
EntityManager.EventBus.RaiseLocalEvent((dockB).Owner, msg, false);
EntityManager.EventBus.RaiseEvent(EventSource.Local, msg);
}
@@ -308,8 +308,8 @@ namespace Content.Server.Shuttles.EntitySystems
// We could also potentially use a prismatic joint? Depending if we want clamps that can extend or whatever
var dockAXform = EntityManager.GetComponent<TransformComponent>(((IComponent) dockA).Owner);
var dockBXform = EntityManager.GetComponent<TransformComponent>(((IComponent) dockB).Owner);
var dockAXform = EntityManager.GetComponent<TransformComponent>((dockA).Owner);
var dockBXform = EntityManager.GetComponent<TransformComponent>((dockB).Owner);
var gridA = _mapManager.GetGrid(dockAXform.GridID).GridEntityId;
var gridB = _mapManager.GetGrid(dockBXform.GridID).GridEntityId;
@@ -324,7 +324,7 @@ namespace Content.Server.Shuttles.EntitySystems
// These need playing around with
// Could also potentially have collideconnected false and stiffness 0 but it was a bit more suss???
var joint = _jointSystem.CreateWeldJoint(gridA, gridB, DockingJoint + ((IComponent) dockA).Owner);
var joint = _jointSystem.CreateWeldJoint(gridA, gridB, DockingJoint + (dockA).Owner);
var gridAXform = EntityManager.GetComponent<TransformComponent>(gridA);
var gridBXform = EntityManager.GetComponent<TransformComponent>(gridB);
@@ -344,13 +344,13 @@ namespace Content.Server.Shuttles.EntitySystems
dockA.DockJoint = joint;
dockB.DockJoint = joint;
if (EntityManager.TryGetComponent(((IComponent) dockA).Owner, out ServerDoorComponent? doorA))
if (EntityManager.TryGetComponent((dockA).Owner, out ServerDoorComponent? doorA))
{
doorA.ChangeAirtight = false;
doorA.Open();
}
if (EntityManager.TryGetComponent(((IComponent) dockB).Owner, out ServerDoorComponent? doorB))
if (EntityManager.TryGetComponent((dockB).Owner, out ServerDoorComponent? doorB))
{
doorB.ChangeAirtight = false;
doorB.Open();
@@ -364,8 +364,8 @@ namespace Content.Server.Shuttles.EntitySystems
GridBUid = gridB,
};
EntityManager.EventBus.RaiseLocalEvent(((IComponent) dockA).Owner, msg, false);
EntityManager.EventBus.RaiseLocalEvent(((IComponent) dockB).Owner, msg, false);
EntityManager.EventBus.RaiseLocalEvent((dockA).Owner, msg, false);
EntityManager.EventBus.RaiseLocalEvent((dockB).Owner, msg, false);
EntityManager.EventBus.RaiseEvent(EventSource.Local, msg);
}
@@ -374,8 +374,8 @@ namespace Content.Server.Shuttles.EntitySystems
/// </summary>
private void TryDock(DockingComponent dockA, DockingComponent dockB)
{
if (!EntityManager.TryGetComponent(((IComponent) dockA).Owner, out PhysicsComponent? bodyA) ||
!EntityManager.TryGetComponent(((IComponent) dockB).Owner, out PhysicsComponent? bodyB) ||
if (!EntityManager.TryGetComponent((dockA).Owner, out PhysicsComponent? bodyA) ||
!EntityManager.TryGetComponent((dockB).Owner, out PhysicsComponent? bodyB) ||
!dockA.Enabled ||
!dockB.Enabled)
{
@@ -421,17 +421,17 @@ namespace Content.Server.Shuttles.EntitySystems
if (dock.DockedWith == null)
{
DebugTools.Assert(false);
Logger.ErrorS("docking", $"Tried to undock {((IComponent) dock).Owner} but not docked with anything?");
Logger.ErrorS("docking", $"Tried to undock {(dock).Owner} but not docked with anything?");
return;
}
if (EntityManager.TryGetComponent(((IComponent) dock).Owner, out ServerDoorComponent? doorA))
if (EntityManager.TryGetComponent((dock).Owner, out ServerDoorComponent? doorA))
{
doorA.ChangeAirtight = true;
doorA.Close();
}
if (EntityManager.TryGetComponent(((IComponent) dock.DockedWith).Owner, out ServerDoorComponent? doorB))
if (EntityManager.TryGetComponent((dock.DockedWith).Owner, out ServerDoorComponent? doorB))
{
doorB.ChangeAirtight = true;
doorB.Close();

View File

@@ -39,7 +39,7 @@ namespace Content.Server.Shuttles.EntitySystems
{
if (comp.Console == null) continue;
if (!_blocker.CanInteract(((IComponent) comp).Owner))
if (!_blocker.CanInteract((comp).Owner))
{
toRemove.Add(comp);
}

View File

@@ -397,14 +397,14 @@ namespace Content.Server.Shuttles.EntitySystems
if (args.OurFixture.ID != BurnFixture) return;
_activeThrusters.Add(component);
component.Colliding.Add(((IComponent) args.OtherFixture.Body).Owner);
component.Colliding.Add((args.OtherFixture.Body).Owner);
}
private void OnEndCollide(EntityUid uid, ThrusterComponent component, EndCollideEvent args)
{
if (args.OurFixture.ID != BurnFixture) return;
component.Colliding.Remove(((IComponent) args.OtherFixture.Body).Owner);
component.Colliding.Remove((args.OtherFixture.Body).Owner);
if (component.Colliding.Count == 0)
{
@@ -425,7 +425,7 @@ namespace Content.Server.Shuttles.EntitySystems
foreach (var comp in component.LinearThrusters[index])
{
if (!EntityManager.TryGetComponent(((IComponent) comp).Owner, out AppearanceComponent? appearanceComponent))
if (!EntityManager.TryGetComponent((comp).Owner, out AppearanceComponent? appearanceComponent))
continue;
comp.Firing = true;
@@ -446,7 +446,7 @@ namespace Content.Server.Shuttles.EntitySystems
foreach (var comp in component.LinearThrusters[index])
{
if (!EntityManager.TryGetComponent(((IComponent) comp).Owner, out AppearanceComponent? appearanceComponent))
if (!EntityManager.TryGetComponent((comp).Owner, out AppearanceComponent? appearanceComponent))
continue;
comp.Firing = false;
@@ -470,7 +470,7 @@ namespace Content.Server.Shuttles.EntitySystems
{
foreach (var comp in component.AngularThrusters)
{
if (!EntityManager.TryGetComponent(((IComponent) comp).Owner, out AppearanceComponent? appearanceComponent))
if (!EntityManager.TryGetComponent((comp).Owner, out AppearanceComponent? appearanceComponent))
continue;
comp.Firing = true;
@@ -481,7 +481,7 @@ namespace Content.Server.Shuttles.EntitySystems
{
foreach (var comp in component.AngularThrusters)
{
if (!EntityManager.TryGetComponent(((IComponent) comp).Owner, out AppearanceComponent? appearanceComponent))
if (!EntityManager.TryGetComponent((comp).Owner, out AppearanceComponent? appearanceComponent))
continue;
comp.Firing = false;

View File

@@ -112,17 +112,19 @@ namespace Content.Server.Solar.EntitySystems
else
{
TotalPanelPower = 0;
foreach (var panel in EntityManager.EntityQuery<SolarPanelComponent>())
foreach (var (panel, xform) in EntityManager.EntityQuery<SolarPanelComponent, TransformComponent>())
{
TotalPanelPower += panel.MaxSupply * panel.Coverage;
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(panel.Owner).WorldRotation = TargetPanelRotation;
xform.WorldRotation = TargetPanelRotation;
_updateQueue.Enqueue(panel);
}
}
}
private void UpdatePanelCoverage(SolarPanelComponent panel) {
private void UpdatePanelCoverage(SolarPanelComponent panel)
{
EntityUid entity = panel.Owner;
var xform = EntityManager.GetComponent<TransformComponent>(entity);
// So apparently, and yes, I *did* only find this out later,
// this is just a really fancy way of saying "Lambert's law of cosines".
@@ -136,7 +138,7 @@ namespace Content.Server.Solar.EntitySystems
// directly downwards (abs(theta) = pi) = coverage -1
// as TowardsSun + = CCW,
// panelRelativeToSun should - = CW
var panelRelativeToSun = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).WorldRotation - TowardsSun;
var panelRelativeToSun = xform.WorldRotation - TowardsSun;
// essentially, given cos = X & sin = Y & Y is 'downwards',
// then for the first 90 degrees of rotation in either direction,
// this plots the lower-right quadrant of a circle.
@@ -154,19 +156,19 @@ namespace Content.Server.Solar.EntitySystems
if (coverage > 0)
{
// Determine if the solar panel is occluded, and zero out coverage if so.
var ray = new CollisionRay(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).WorldPosition, TowardsSun.ToWorldVec(), (int) CollisionGroup.Opaque);
var ray = new CollisionRay(xform.WorldPosition, TowardsSun.ToWorldVec(), (int) CollisionGroup.Opaque);
var rayCastResults = _physicsSystem.IntersectRayWithPredicate(
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).MapID,
xform.MapID,
ray,
SunOcclusionCheckDistance,
e => !IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(e).Anchored || e == entity);
e => !xform.Anchored || e == entity);
if (rayCastResults.Any())
coverage = 0;
}
// Total coverage calculated; apply it to the panel.
panel.Coverage = coverage;
UpdateSupply(((IComponent) panel).Owner, panel);
UpdateSupply((panel).Owner, panel);
}
public void UpdateSupply(

View File

@@ -71,7 +71,7 @@ namespace Content.Server.StationEvents.Events
var possibleTargets = _entityManager.EntityQuery<StationComponent>()
.Where(x => x.Station == _target).ToArray();
StationComponent tempQualifier = _robustRandom.Pick(possibleTargets);
var stationEnt = ((IComponent) tempQualifier).Owner;
var stationEnt = (tempQualifier).Owner;
if (!_entityManager.TryGetComponent<IMapGridComponent>(stationEnt, out var grid))
return;

View File

@@ -103,7 +103,7 @@ namespace Content.Server.Tabletop
return;
};
var gamerUid = ((IComponent) gamer).Owner;
var gamerUid = (gamer).Owner;
if (actor.PlayerSession.Status > SessionStatus.Connected || CanSeeTable(gamerUid, gamer.Tabletop)
|| !StunnedOrNoHands(gamerUid))

View File

@@ -59,7 +59,7 @@ namespace Content.Server.Temperature.Systems
if (comp.Deleted || comp.Paused)
continue;
ChangeDamage(((IComponent) comp).Owner, comp);
ChangeDamage((comp).Owner, comp);
}
ShouldUpdateDamage.Clear();

View File

@@ -83,10 +83,10 @@ namespace Content.Server.UserInterface
// If we've gotten this far, fire a cancellable event that indicates someone is about to activate this.
// This is so that stuff can require further conditions (like power).
var oae = new ActivatableUIOpenAttemptEvent(user);
RaiseLocalEvent(((IComponent) aui).Owner, oae, false);
RaiseLocalEvent((aui).Owner, oae, false);
if (oae.Cancelled) return false;
SetCurrentSingleUser(((IComponent) aui).Owner, actor.PlayerSession, aui);
SetCurrentSingleUser((aui).Owner, actor.PlayerSession, aui);
ui.Toggle(actor.PlayerSession);
return true;
}

View File

@@ -278,7 +278,7 @@ namespace Content.Server.Weapon.Melee
foreach (var bloodstream in hitBloodstreams)
{
var individualInjection = solutionToInject.SplitSolution(volPerBloodstream);
_bloodstreamSystem.TryAddToBloodstream(((IComponent) bloodstream).Owner, individualInjection, bloodstream);
_bloodstreamSystem.TryAddToBloodstream((bloodstream).Owner, individualInjection, bloodstream);
}
}

View File

@@ -191,7 +191,7 @@ namespace Content.Shared.Body.Components
{
// TODO BODY SYSTEM KILL : Find a more elegant way of killing em than just dumping bloodloss damage.
var damage = new DamageSpecifier(_prototypeManager.Index<DamageTypePrototype>("Bloodloss"), 300);
EntitySystem.Get<DamageableSystem>().TryChangeDamage(((IComponent) part).Owner, damage);
EntitySystem.Get<DamageableSystem>().TryChangeDamage(part.Owner, damage);
}
OnBodyChanged();
@@ -468,7 +468,7 @@ namespace Content.Shared.Body.Components
var i = 0;
foreach (var (part, slot) in SlotParts)
{
parts[i] = (slot.Id, Owner: ((IComponent) part).Owner);
parts[i] = (slot.Id, Owner: part.Owner);
i++;
}

View File

@@ -304,7 +304,7 @@ namespace Content.Shared.Body.Components
foreach (var mechanism in _mechanisms)
{
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) mechanism).Owner, new AddedToBodyEvent(body));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(mechanism.Owner, new AddedToBodyEvent(body));
}
}
@@ -319,7 +319,7 @@ namespace Content.Shared.Body.Components
foreach (var mechanism in _mechanisms)
{
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(((IComponent) mechanism).Owner, new RemovedFromBodyEvent(old));
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(mechanism.Owner, new RemovedFromBodyEvent(old));
}
}

View File

@@ -75,9 +75,9 @@ namespace Content.Shared.Chemistry
if (component.ModifierTimer > currentTime) continue;
_components.RemoveAt(i);
EntityManager.RemoveComponent<MovespeedModifierMetabolismComponent>(((IComponent) component).Owner);
EntityManager.RemoveComponent<MovespeedModifierMetabolismComponent>(component.Owner);
_movespeed.RefreshMovementSpeedModifiers(((IComponent) component).Owner);
_movespeed.RefreshMovementSpeedModifiers(component.Owner);
}
}
}

View File

@@ -128,9 +128,9 @@ namespace Content.Shared.Damage
SetTotalDamage(component, component.Damage.Total, logChange);
component.Dirty();
if (EntityManager.TryGetComponent<AppearanceComponent>(((IComponent) component).Owner, out var appearance) && damageDelta != null)
if (EntityManager.TryGetComponent<AppearanceComponent>(component.Owner, out var appearance) && damageDelta != null)
appearance.SetData(DamageVisualizerKeys.DamageUpdateGroups, damageDelta.GetDamagePerGroup().Keys.ToList());
RaiseLocalEvent(((IComponent) component).Owner, new DamageChangedEvent(component, damageDelta, interruptsDoAfters), false);
RaiseLocalEvent(component.Owner, new DamageChangedEvent(component, damageDelta, interruptsDoAfters), false);
}
/// <summary>

View File

@@ -56,7 +56,7 @@ namespace Content.Shared.Friction
if (body.Deleted ||
prediction && !body.Predict ||
body.BodyStatus == BodyStatus.InAir ||
Mover.UseMobMovement(((IComponent) body).Owner)) continue;
Mover.UseMobMovement(body.Owner)) continue;
var surfaceFriction = GetTileFriction(body);
var bodyModifier = IoCManager.Resolve<IEntityManager>().GetComponentOrNull<SharedTileFrictionModifier>(body.Owner)?.Modifier ?? 1.0f;

View File

@@ -36,7 +36,7 @@ public class SlowContactsSystem : EntitySystem
foreach (var colliding in _physics.GetCollidingEntities(physicsComponent))
{
var ent = ((IComponent) colliding).Owner;
var ent = colliding.Owner;
if (!EntityManager.TryGetComponent<SlowContactsComponent>(ent, out var slowContactsComponent))
continue;
@@ -49,7 +49,7 @@ public class SlowContactsSystem : EntitySystem
private void OnEntityExit(EntityUid uid, SlowContactsComponent component, EndCollideEvent args)
{
var otherUid = ((IComponent) args.OtherFixture.Body).Owner;
var otherUid = args.OtherFixture.Body.Owner;
if (!EntityManager.HasComponent<MovementSpeedModifierComponent>(otherUid)
|| !EntityManager.HasComponent<SlowsOnContactComponent>(otherUid))
return;
@@ -64,7 +64,7 @@ public class SlowContactsSystem : EntitySystem
private void OnEntityEnter(EntityUid uid, SlowContactsComponent component, StartCollideEvent args)
{
var otherUid = ((IComponent) args.OtherFixture.Body).Owner;
var otherUid = args.OtherFixture.Body.Owner;
if (!EntityManager.HasComponent<MovementSpeedModifierComponent>(otherUid))
return;
if (!_statusCapableInContact.ContainsKey(otherUid))

View File

@@ -167,7 +167,7 @@ namespace Content.Shared.Movement
IoCManager.Resolve<IEntityManager>().HasComponent<MobStateComponent>(body.Owner) &&
// If we're being pulled then don't mess with our velocity.
(!IoCManager.Resolve<IEntityManager>().TryGetComponent(body.Owner, out SharedPullableComponent? pullable) || !pullable.BeingPulled) &&
_blocker.CanMove(((IComponent) body).Owner);
_blocker.CanMove((body).Owner);
}
/// <summary>

View File

@@ -47,7 +47,7 @@ namespace Content.Shared.Pulling.Systems
if (args.Puller.Owner != uid)
return;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out SharedAlertsComponent? alerts))
if (EntityManager.TryGetComponent(component.Owner, out SharedAlertsComponent? alerts))
alerts.ShowAlert(AlertType.Pulling);
RefreshMovementSpeed(component);
@@ -61,7 +61,7 @@ namespace Content.Shared.Pulling.Systems
if (args.Puller.Owner != uid)
return;
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out SharedAlertsComponent? alerts))
if (EntityManager.TryGetComponent(component.Owner, out SharedAlertsComponent? alerts))
alerts.ClearAlert(AlertType.Pulling);
RefreshMovementSpeed(component);
@@ -74,7 +74,7 @@ namespace Content.Shared.Pulling.Systems
private void RefreshMovementSpeed(SharedPullerComponent component)
{
_movementSpeedModifierSystem.RefreshMovementSpeedModifiers(((IComponent) component).Owner);
_movementSpeedModifierSystem.RefreshMovementSpeedModifiers((component).Owner);
}
}
}

View File

@@ -36,14 +36,14 @@ namespace Content.Shared.Pulling
// They do not expect to be cancellable.
private void ForceDisconnect(SharedPullerComponent puller, SharedPullableComponent pullable)
{
var pullerPhysics = IoCManager.Resolve<IEntityManager>().GetComponent<PhysicsComponent>(puller.Owner);
var pullablePhysics = IoCManager.Resolve<IEntityManager>().GetComponent<PhysicsComponent>(pullable.Owner);
var pullerPhysics = EntityManager.GetComponent<PhysicsComponent>(puller.Owner);
var pullablePhysics = EntityManager.GetComponent<PhysicsComponent>(pullable.Owner);
// MovingTo shutdown
ForceSetMovingTo(pullable, null);
// Joint shutdown
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<JointComponent?>(puller.Owner, out var jointComp))
if (EntityManager.TryGetComponent<JointComponent?>(puller.Owner, out var jointComp))
{
if (jointComp.GetJoints.Contains(pullable.PullJoint!))
{
@@ -59,10 +59,10 @@ namespace Content.Shared.Pulling
// Messaging
var message = new PullStoppedMessage(pullerPhysics, pullablePhysics);
RaiseLocalEvent(((IComponent) puller).Owner, message, broadcast: false);
RaiseLocalEvent(puller.Owner, message, broadcast: false);
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(pullable.Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(pullable.Owner).EntityLifeStage) <= EntityLifeStage.MapInitialized)
RaiseLocalEvent(((IComponent) pullable).Owner, message);
if ((!EntityManager.EntityExists(pullable.Owner) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(pullable.Owner).EntityLifeStage) <= EntityLifeStage.MapInitialized)
RaiseLocalEvent(pullable.Owner, message);
// Networking
puller.Dirty();
@@ -81,22 +81,22 @@ namespace Content.Shared.Pulling
var pullableOldPullerE = pullable?.Puller;
if (pullableOldPullerE != null)
{
ForceDisconnect(IoCManager.Resolve<IEntityManager>().GetComponent<SharedPullerComponent>(pullableOldPullerE.Value), pullable!);
ForceDisconnect(EntityManager.GetComponent<SharedPullerComponent>(pullableOldPullerE.Value), pullable!);
}
// Continue with the puller.
var pullerOldPullableE = puller?.Pulling;
if (pullerOldPullableE != null)
{
ForceDisconnect(puller!, IoCManager.Resolve<IEntityManager>().GetComponent<SharedPullableComponent>(pullerOldPullableE.Value));
ForceDisconnect(puller!, EntityManager.GetComponent<SharedPullableComponent>(pullerOldPullableE.Value));
}
// And now for the actual connection (if any).
if ((puller != null) && (pullable != null))
{
var pullerPhysics = IoCManager.Resolve<IEntityManager>().GetComponent<PhysicsComponent>(puller.Owner);
var pullablePhysics = IoCManager.Resolve<IEntityManager>().GetComponent<PhysicsComponent>(pullable.Owner);
var pullerPhysics = EntityManager.GetComponent<PhysicsComponent>(puller.Owner);
var pullablePhysics = EntityManager.GetComponent<PhysicsComponent>(pullable.Owner);
// State startup
puller.Pulling = pullable.Owner;
@@ -106,7 +106,7 @@ namespace Content.Shared.Pulling
var union = pullerPhysics.GetWorldAABB().Union(pullablePhysics.GetWorldAABB());
var length = Math.Max(union.Size.X, union.Size.Y) * 0.75f;
pullable.PullJoint = _jointSystem.CreateDistanceJoint(((IComponent) pullablePhysics).Owner, pullerPhysics.Owner, id:$"pull-joint-{pullablePhysics.Owner}");
pullable.PullJoint = _jointSystem.CreateDistanceJoint(pullablePhysics.Owner, pullerPhysics.Owner, id:$"pull-joint-{pullablePhysics.Owner}");
pullable.PullJoint.CollideConnected = false;
// This maximum has to be there because if the object is constrained too closely, the clamping goes backwards and asserts.
pullable.PullJoint.MaxLength = Math.Max(1.0f, length);
@@ -117,8 +117,8 @@ namespace Content.Shared.Pulling
// Messaging
var message = new PullStartedMessage(pullerPhysics, pullablePhysics);
RaiseLocalEvent(((IComponent) puller).Owner, message, broadcast: false);
RaiseLocalEvent(((IComponent) pullable).Owner, message);
RaiseLocalEvent(puller.Owner, message, broadcast: false);
RaiseLocalEvent(pullable.Owner, message);
// Networking
puller.Dirty();

View File

@@ -29,7 +29,7 @@ namespace Content.Shared.Pulling
public bool CanPull(EntityUid puller, EntityUid pulled)
{
if (!IoCManager.Resolve<IEntityManager>().HasComponent<SharedPullerComponent>(puller))
if (!EntityManager.HasComponent<SharedPullerComponent>(puller))
{
return false;
}
@@ -39,7 +39,7 @@ namespace Content.Shared.Pulling
return false;
}
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<IPhysBody?>(pulled, out var _physics))
if (!EntityManager.TryGetComponent<IPhysBody?>(pulled, out var _physics))
{
return false;
}
@@ -59,7 +59,7 @@ namespace Content.Shared.Pulling
return false;
}
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<SharedBuckleComponent?>(puller, out var buckle))
if (EntityManager.TryGetComponent<SharedBuckleComponent?>(puller, out var buckle))
{
// Prevent people pulling the chair they're on, etc.
if (buckle.Buckled && (buckle.LastEntityBuckledTo == pulled))
@@ -92,7 +92,7 @@ namespace Content.Shared.Pulling
}
var msg = new StopPullingEvent(user);
RaiseLocalEvent(((IComponent) pullable).Owner, msg);
RaiseLocalEvent(pullable.Owner, msg);
if (msg.Cancelled) return false;
@@ -173,14 +173,14 @@ namespace Content.Shared.Pulling
var pullAttempt = new PullAttemptMessage(pullerPhysics, pullablePhysics);
RaiseLocalEvent(((IComponent) puller).Owner, pullAttempt, broadcast: false);
RaiseLocalEvent(puller.Owner, pullAttempt, broadcast: false);
if (pullAttempt.Cancelled)
{
return false;
}
RaiseLocalEvent(((IComponent) pullable).Owner, pullAttempt);
RaiseLocalEvent(pullable.Owner, pullAttempt);
if (pullAttempt.Cancelled)
{
@@ -198,7 +198,7 @@ namespace Content.Shared.Pulling
return false;
}
if (!IoCManager.Resolve<IEntityManager>().HasComponent<PhysicsComponent>(pullable.Owner))
if (!EntityManager.HasComponent<PhysicsComponent>(pullable.Owner))
{
return false;
}

View File

@@ -164,7 +164,7 @@ namespace Content.Shared.Pulling
// The pulled object may have already been deleted.
// TODO: Work out why. Monkey + meat spike is a good test for this,
// assuming you're still pulling the monkey when it gets gibbed.
if ((!EntityManager.EntityExists(pulled.Value) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(pulled.Value).EntityLifeStage) >= EntityLifeStage.Deleted)
if ((!EntityManager.EntityExists(pulled.Value) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(pulled.Value).EntityLifeStage) >= EntityLifeStage.Deleted)
{
return;
}
@@ -249,16 +249,18 @@ namespace Content.Shared.Pulling
private void UpdatePulledRotation(EntityUid puller, EntityUid pulled)
{
// TODO: update once ComponentReference works with directed event bus.
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(pulled, out RotatableComponent? rotatable))
if (!EntityManager.TryGetComponent(pulled, out RotatableComponent? rotatable))
return;
if (!rotatable.RotateWhilePulling)
return;
var dir = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(puller).WorldPosition - IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(pulled).WorldPosition;
var pulledXform = EntityManager.GetComponent<TransformComponent>(pulled);
var dir = EntityManager.GetComponent<TransformComponent>(puller).WorldPosition - pulledXform.WorldPosition;
if (dir.LengthSquared > ThresholdRotDistance * ThresholdRotDistance)
{
var oldAngle = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(pulled).WorldRotation;
var oldAngle = pulledXform.WorldRotation;
var newAngle = Angle.FromWorldVec(dir);
var diff = newAngle - oldAngle;
@@ -268,10 +270,10 @@ namespace Content.Shared.Pulling
// Otherwise PIANO DOOR STUCK! happens.
// But it also needs to work with station rotation / align to the local parent.
// So...
var baseRotation = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(pulled).Parent?.WorldRotation ?? 0f;
var baseRotation = pulledXform.Parent?.WorldRotation ?? 0f;
var localRotation = newAngle - baseRotation;
var localRotationSnapped = Angle.FromDegrees(Math.Floor((localRotation.Degrees / ThresholdRotAngle) + 0.5f) * ThresholdRotAngle);
IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(pulled).LocalRotation = localRotationSnapped;
pulledXform.LocalRotation = localRotationSnapped;
}
}
}

View File

@@ -32,7 +32,7 @@ namespace Content.Shared.Slippery
private void HandleCollide(EntityUid uid, SlipperyComponent component, StartCollideEvent args)
{
var otherUid = ((IComponent) args.OtherFixture.Body).Owner;
var otherUid = args.OtherFixture.Body.Owner;
if (!CanSlip(component, otherUid)) return;

View File

@@ -21,7 +21,7 @@ namespace Content.Shared.Storage.EntitySystems
private void CounterEntityInserted(EntityUid uid, ItemCounterComponent itemCounter,
EntInsertedIntoContainerMessage args)
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(itemCounter.Owner, out AppearanceComponent? appearanceComponent)) return;
if (!EntityManager.TryGetComponent(itemCounter.Owner, out AppearanceComponent? appearanceComponent)) return;
var count = GetCount(args, itemCounter);
if (count == null)
@@ -36,7 +36,7 @@ namespace Content.Shared.Storage.EntitySystems
private void CounterEntityRemoved(EntityUid uid, ItemCounterComponent itemCounter,
EntRemovedFromContainerMessage args)
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(itemCounter.Owner, out AppearanceComponent? appearanceComponent)) return;
if (!EntityManager.TryGetComponent(itemCounter.Owner, out AppearanceComponent? appearanceComponent)) return;
var count = GetCount(args, itemCounter);
if (count == null)

View File

@@ -21,7 +21,7 @@ namespace Content.Shared.Storage.EntitySystems
private void InitLayers(EntityUid uid, ItemMapperComponent component, ComponentInit args)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out AppearanceComponent? appearanceComponent))
if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearanceComponent))
{
var list = new List<string>(component.MapLayers.Keys);
appearanceComponent.SetData(StorageMapVisuals.InitLayers, new ShowLayerData(list));
@@ -31,7 +31,7 @@ namespace Content.Shared.Storage.EntitySystems
private void MapperEntityRemoved(EntityUid uid, ItemMapperComponent itemMapper,
EntRemovedFromContainerMessage args)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(itemMapper.Owner, out AppearanceComponent? appearanceComponent)
if (EntityManager.TryGetComponent(itemMapper.Owner, out AppearanceComponent? appearanceComponent)
&& TryGetLayers(args, itemMapper, out var containedLayers))
{
appearanceComponent.SetData(StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers));
@@ -41,7 +41,7 @@ namespace Content.Shared.Storage.EntitySystems
private void MapperEntityInserted(EntityUid uid, ItemMapperComponent itemMapper,
EntInsertedIntoContainerMessage args)
{
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(itemMapper.Owner, out AppearanceComponent? appearanceComponent)
if (EntityManager.TryGetComponent(itemMapper.Owner, out AppearanceComponent? appearanceComponent)
&& TryGetLayers(args, itemMapper, out var containedLayers))
{
appearanceComponent.SetData(StorageMapVisuals.LayerChanged, new ShowLayerData(containedLayers));

View File

@@ -54,7 +54,7 @@ namespace Content.Shared.Throwing
private void ThrowItem(EntityUid uid, ThrownItemComponent component, ThrownEvent args)
{
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out PhysicsComponent? physicsComponent) ||
if (!EntityManager.TryGetComponent(component.Owner, out PhysicsComponent? physicsComponent) ||
physicsComponent.Fixtures.Count != 1) return;
if (_fixtures.GetFixtureOrNull(physicsComponent, ThrowingFixture) != null)
@@ -114,13 +114,13 @@ namespace Content.Shared.Throwing
public void LandComponent(ThrownItemComponent thrownItem)
{
if (thrownItem.Deleted || (!IoCManager.Resolve<IEntityManager>().EntityExists(thrownItem.Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(thrownItem.Owner).EntityLifeStage) >= EntityLifeStage.Deleted || _containerSystem.IsEntityInContainer(thrownItem.Owner)) return;
if (thrownItem.Deleted || (!EntityManager.EntityExists(thrownItem.Owner) ? EntityLifeStage.Deleted : EntityManager.GetComponent<MetaDataComponent>(thrownItem.Owner).EntityLifeStage) >= EntityLifeStage.Deleted || _containerSystem.IsEntityInContainer(thrownItem.Owner)) return;
var landing = thrownItem.Owner;
// Unfortunately we can't check for hands containers as they have specific names.
if (thrownItem.Owner.TryGetContainerMan(out var containerManager) &&
IoCManager.Resolve<IEntityManager>().HasComponent<SharedHandsComponent>(containerManager.Owner))
EntityManager.HasComponent<SharedHandsComponent>(containerManager.Owner))
{
EntityManager.RemoveComponent(landing, thrownItem);
return;