diff --git a/Content.Client/IconSmoothing/IconSmoothComponent.cs b/Content.Client/IconSmoothing/IconSmoothComponent.cs index eb84e7c68a..d1de5616ad 100644 --- a/Content.Client/IconSmoothing/IconSmoothComponent.cs +++ b/Content.Client/IconSmoothing/IconSmoothComponent.cs @@ -26,6 +26,7 @@ namespace Content.Client.IconSmoothing [RegisterComponent] public class IconSmoothComponent : Component { + [Dependency] private readonly IEntityManager _entMan = default!; [Dependency] private readonly IMapManager _mapManager = default!; [DataField("mode")] @@ -63,7 +64,7 @@ namespace Content.Client.IconSmoothing { base.Initialize(); - Sprite = IoCManager.Resolve().GetComponent(Owner); + Sprite = _entMan.GetComponent(Owner); } /// @@ -71,12 +72,12 @@ namespace Content.Client.IconSmoothing { base.Startup(); - if (IoCManager.Resolve().GetComponent(Owner).Anchored) + if (_entMan.GetComponent(Owner).Anchored) { // ensures lastposition initial value is populated on spawn. Just calling // the hook here would cause a dirty event to fire needlessly UpdateLastPosition(); - IoCManager.Resolve().EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, null, Mode)); + _entMan.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, null, Mode)); } if (Sprite != null && Mode == IconSmoothingMode.Corners) @@ -95,9 +96,9 @@ namespace Content.Client.IconSmoothing private void UpdateLastPosition() { - if (_mapManager.TryGetGrid(IoCManager.Resolve().GetComponent(Owner).GridID, out var grid)) + if (_mapManager.TryGetGrid(_entMan.GetComponent(Owner).GridID, out var grid)) { - _lastPosition = (IoCManager.Resolve().GetComponent(Owner).GridID, grid.TileIndicesFor(IoCManager.Resolve().GetComponent(Owner).Coordinates)); + _lastPosition = (_entMan.GetComponent(Owner).GridID, grid.TileIndicesFor(_entMan.GetComponent(Owner).Coordinates)); } else { @@ -109,9 +110,9 @@ namespace Content.Client.IconSmoothing internal virtual void CalculateNewSprite() { - if (!_mapManager.TryGetGrid(IoCManager.Resolve().GetComponent(Owner).GridID, out var grid)) + if (!_mapManager.TryGetGrid(_entMan.GetComponent(Owner).GridID, out var grid)) { - Logger.Error($"Failed to calculate IconSmoothComponent sprite in {Owner} because grid {IoCManager.Resolve().GetComponent(Owner).GridID} was missing."); + Logger.Error($"Failed to calculate IconSmoothComponent sprite in {Owner} because grid {_entMan.GetComponent(Owner).GridID} was missing."); return; } CalculateNewSprite(grid); @@ -136,14 +137,14 @@ namespace Content.Client.IconSmoothing private void CalculateNewSpriteCardinal(IMapGrid grid) { - if (!IoCManager.Resolve().GetComponent(Owner).Anchored || Sprite == null) + if (!_entMan.GetComponent(Owner).Anchored || Sprite == null) { return; } var dirs = CardinalConnectDirs.None; - var position = IoCManager.Resolve().GetComponent(Owner).Coordinates; + var position = _entMan.GetComponent(Owner).Coordinates; if (MatchingEntity(grid.GetInDir(position, Direction.North))) dirs |= CardinalConnectDirs.North; if (MatchingEntity(grid.GetInDir(position, Direction.South))) @@ -173,12 +174,12 @@ namespace Content.Client.IconSmoothing protected (CornerFill ne, CornerFill nw, CornerFill sw, CornerFill se) CalculateCornerFill(IMapGrid grid) { - if (!IoCManager.Resolve().GetComponent(Owner).Anchored) + if (!_entMan.GetComponent(Owner).Anchored) { return (CornerFill.None, CornerFill.None, CornerFill.None, CornerFill.None); } - var position = IoCManager.Resolve().GetComponent(Owner).Coordinates; + var position = _entMan.GetComponent(Owner).Coordinates; var n = MatchingEntity(grid.GetInDir(position, Direction.North)); var ne = MatchingEntity(grid.GetInDir(position, Direction.NorthEast)); var e = MatchingEntity(grid.GetInDir(position, Direction.East)); @@ -240,7 +241,7 @@ namespace Content.Client.IconSmoothing } // Local is fine as we already know it's parented to the grid (due to the way anchoring works). - switch (IoCManager.Resolve().GetComponent(Owner).LocalRotation.GetCardinalDir()) + switch (_entMan.GetComponent(Owner).LocalRotation.GetCardinalDir()) { case Direction.North: return (cornerSW, cornerSE, cornerNE, cornerNW); @@ -258,17 +259,17 @@ namespace Content.Client.IconSmoothing { base.Shutdown(); - if (IoCManager.Resolve().GetComponent(Owner).Anchored) + if (_entMan.GetComponent(Owner).Anchored) { - IoCManager.Resolve().EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, Mode)); + _entMan.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, Mode)); } } public void AnchorStateChanged() { - if (IoCManager.Resolve().GetComponent(Owner).Anchored) + if (_entMan.GetComponent(Owner).Anchored) { - IoCManager.Resolve().EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, Mode)); + _entMan.EventBus.RaiseEvent(EventSource.Local, new IconSmoothDirtyEvent(Owner, _lastPosition, Mode)); UpdateLastPosition(); } } @@ -278,7 +279,7 @@ namespace Content.Client.IconSmoothing { foreach (var entity in candidates) { - if (!IoCManager.Resolve().TryGetComponent(entity, out IconSmoothComponent? other)) + if (!_entMan.TryGetComponent(entity, out IconSmoothComponent? other)) { continue; } diff --git a/Content.Server/Construction/Components/MachineFrameComponent.cs b/Content.Server/Construction/Components/MachineFrameComponent.cs index d1854a7516..8b4eccb4d8 100644 --- a/Content.Server/Construction/Components/MachineFrameComponent.cs +++ b/Content.Server/Construction/Components/MachineFrameComponent.cs @@ -15,6 +15,7 @@ namespace Content.Server.Construction.Components [RegisterComponent] public class MachineFrameComponent : Component, IInteractUsing { + [Dependency] private readonly IEntityManager _entMan = default!; [Dependency] private readonly IComponentFactory _componentFactory = default!; public const string PartContainer = "machine_parts"; @@ -121,7 +122,7 @@ namespace Content.Server.Construction.Components RegenerateProgress(); - if (IoCManager.Resolve().TryGetComponent(Owner, out var construction)) + if (_entMan.TryGetComponent(Owner, out var construction)) { // Attempt to set pathfinding to the machine node... EntitySystem.Get().SetPathfindingTarget(Owner, "machine", construction); @@ -167,7 +168,7 @@ namespace Content.Server.Construction.Components if (!HasBoard) { - if (IoCManager.Resolve().TryGetComponent(Owner, out appearance)) + if (_entMan.TryGetComponent(Owner, out appearance)) { appearance.SetData(MachineFrameVisuals.State, 1); } @@ -186,10 +187,10 @@ namespace Content.Server.Construction.Components var board = _boardContainer.ContainedEntities[0]; - if (!IoCManager.Resolve().TryGetComponent(board, out var machineBoard)) + if (!_entMan.TryGetComponent(board, out var machineBoard)) return; - if (IoCManager.Resolve().TryGetComponent(Owner, out appearance)) + if (_entMan.TryGetComponent(Owner, out appearance)) { appearance.SetData(MachineFrameVisuals.State, 2); } @@ -198,7 +199,7 @@ namespace Content.Server.Construction.Components foreach (var part in _partContainer.ContainedEntities) { - if (IoCManager.Resolve().TryGetComponent(part, out var machinePart)) + if (_entMan.TryGetComponent(part, out var machinePart)) { // Check this is part of the requirements... if (!Requirements.ContainsKey(machinePart.PartType)) @@ -210,7 +211,7 @@ namespace Content.Server.Construction.Components _progress[machinePart.PartType]++; } - if (IoCManager.Resolve().TryGetComponent(part, out var stack)) + if (_entMan.TryGetComponent(part, out var stack)) { var type = stack.StackTypeId; // Check this is part of the requirements... @@ -228,7 +229,7 @@ namespace Content.Server.Construction.Components { var registration = _componentFactory.GetRegistration(compName); - if (!IoCManager.Resolve().HasComponent(part, registration.Type)) + if (!_entMan.HasComponent(part, registration.Type)) continue; if (!_componentProgress.ContainsKey(compName)) @@ -253,7 +254,7 @@ namespace Content.Server.Construction.Components async Task IInteractUsing.InteractUsing(InteractUsingEventArgs eventArgs) { - if (!HasBoard && IoCManager.Resolve().TryGetComponent(eventArgs.Using, out var machineBoard)) + if (!HasBoard && _entMan.TryGetComponent(eventArgs.Using, out var machineBoard)) { if (eventArgs.Using.TryRemoveFromContainer()) { @@ -263,12 +264,12 @@ namespace Content.Server.Construction.Components // Setup requirements and progress... ResetProgressAndRequirements(machineBoard); - if (IoCManager.Resolve().TryGetComponent(Owner, out var appearance)) + if (_entMan.TryGetComponent(Owner, out var appearance)) { appearance.SetData(MachineFrameVisuals.State, 2); } - if (IoCManager.Resolve().TryGetComponent(Owner, out ConstructionComponent? construction)) + if (_entMan.TryGetComponent(Owner, out ConstructionComponent? construction)) { // So prying the components off works correctly. EntitySystem.Get().ResetEdge(Owner, construction); @@ -279,7 +280,7 @@ namespace Content.Server.Construction.Components } else if (HasBoard) { - if (IoCManager.Resolve().TryGetComponent(eventArgs.Using, out var machinePart)) + if (_entMan.TryGetComponent(eventArgs.Using, out var machinePart)) { if (!Requirements.ContainsKey(machinePart.PartType)) return false; @@ -292,7 +293,7 @@ namespace Content.Server.Construction.Components } } - if (IoCManager.Resolve().TryGetComponent(eventArgs.Using, out var stack)) + if (_entMan.TryGetComponent(eventArgs.Using, out var stack)) { var type = stack.StackTypeId; if (!MaterialRequirements.ContainsKey(type)) @@ -313,7 +314,7 @@ namespace Content.Server.Construction.Components return true; } - var splitStack = EntitySystem.Get().Split(eventArgs.Using, needed, IoCManager.Resolve().GetComponent(Owner).Coordinates, stack); + var splitStack = EntitySystem.Get().Split(eventArgs.Using, needed, _entMan.GetComponent(Owner).Coordinates, stack); if (splitStack == null) return false; @@ -332,7 +333,7 @@ namespace Content.Server.Construction.Components var registration = _componentFactory.GetRegistration(compName); - if (!IoCManager.Resolve().HasComponent(eventArgs.Using, registration.Type)) + if (!_entMan.HasComponent(eventArgs.Using, registration.Type)) continue; if (!eventArgs.Using.TryRemoveFromContainer() || !_partContainer.Insert(eventArgs.Using)) continue; diff --git a/Content.Server/Light/EntitySystems/PoweredLightSystem.cs b/Content.Server/Light/EntitySystems/PoweredLightSystem.cs index a443c9eca1..04e2861252 100644 --- a/Content.Server/Light/EntitySystems/PoweredLightSystem.cs +++ b/Content.Server/Light/EntitySystems/PoweredLightSystem.cs @@ -73,7 +73,7 @@ namespace Content.Server.Light.EntitySystems _ => throw new ArgumentOutOfRangeException() }; - var entity = EntityManager.SpawnEntity(prototype, IoCManager.Resolve().GetComponent(light.Owner).Coordinates); + var entity = EntityManager.SpawnEntity(prototype, EntityManager.GetComponent(light.Owner).Coordinates); light.LightBulbContainer.Insert(entity); } @@ -336,7 +336,7 @@ namespace Content.Server.Light.EntitySystems light.IsBlinking = isNowBlinking; - if (!IoCManager.Resolve().TryGetComponent(light.Owner, out AppearanceComponent? appearance)) + if (!EntityManager.TryGetComponent(light.Owner, out AppearanceComponent? appearance)) return; appearance.SetData(PoweredLightVisuals.Blinking, isNowBlinking); } diff --git a/Content.Shared/Singularity/SharedSingularitySystem.cs b/Content.Shared/Singularity/SharedSingularitySystem.cs index 8fbcb87f1b..25c4c14a6e 100644 --- a/Content.Shared/Singularity/SharedSingularitySystem.cs +++ b/Content.Shared/Singularity/SharedSingularitySystem.cs @@ -55,7 +55,7 @@ namespace Content.Shared.Singularity value = Math.Clamp(value, 0, 6); - var physics = IoCManager.Resolve().GetComponentOrNull(singularity.Owner); + var physics = EntityManager.GetComponentOrNull(singularity.Owner); if (singularity.Level > 1 && value <= 1) { @@ -68,12 +68,12 @@ namespace Content.Shared.Singularity singularity.Level = value; - if (IoCManager.Resolve().TryGetComponent(singularity.Owner, out SharedRadiationPulseComponent? pulse)) + if (EntityManager.TryGetComponent(singularity.Owner, out SharedRadiationPulseComponent? pulse)) { pulse.RadsPerSecond = 10 * value; } - if (IoCManager.Resolve().TryGetComponent(singularity.Owner, out AppearanceComponent? appearance)) + if (EntityManager.TryGetComponent(singularity.Owner, out AppearanceComponent? appearance)) { appearance.SetData(SingularityVisuals.Level, value); } @@ -83,7 +83,7 @@ namespace Content.Shared.Singularity circle.Radius = value - 0.5f; } - if (IoCManager.Resolve().TryGetComponent(singularity.Owner, out SingularityDistortionComponent? distortion)) + if (EntityManager.TryGetComponent(singularity.Owner, out SingularityDistortionComponent? distortion)) { distortion.Falloff = GetFalloff(value); distortion.Intensity = GetIntensity(value); @@ -102,8 +102,8 @@ namespace Content.Shared.Singularity { var other = args.BodyB.Owner; - if ((!IoCManager.Resolve().HasComponent(other) && - !IoCManager.Resolve().HasComponent(other)) || + if ((!EntityManager.HasComponent(other) && + !EntityManager.HasComponent(other)) || component.Level >= 4) { args.Cancel();