diff --git a/Content.Server/AI/EntitySystems/AiFactionTagSystem.cs b/Content.Server/AI/EntitySystems/AiFactionTagSystem.cs index 0b590484be..3052b5b7dd 100644 --- a/Content.Server/AI/EntitySystems/AiFactionTagSystem.cs +++ b/Content.Server/AI/EntitySystems/AiFactionTagSystem.cs @@ -55,7 +55,7 @@ namespace Content.Server.AI.EntitySystems public Faction GetHostileFactions(Faction faction) => _hostileFactions.TryGetValue(faction, out var hostiles) ? hostiles : Faction.None; public Faction GetFactions(EntityUid entity) => - IoCManager.Resolve().TryGetComponent(entity, out AiFactionTagComponent? factionTags) + EntityManager.TryGetComponent(entity, out AiFactionTagComponent? factionTags) ? factionTags.Factions : Faction.None; @@ -72,9 +72,9 @@ namespace Content.Server.AI.EntitySystems { if ((component.Factions & hostile) == 0) continue; - if (IoCManager.Resolve().GetComponent(component.Owner).MapID != IoCManager.Resolve().GetComponent(entity).MapID) + if (EntityManager.GetComponent(component.Owner).MapID != EntityManager.GetComponent(entity).MapID) continue; - if (!IoCManager.Resolve().GetComponent(component.Owner).MapPosition.InRange(IoCManager.Resolve().GetComponent(entity).MapPosition, range)) + if (!EntityManager.GetComponent(component.Owner).MapPosition.InRange(EntityManager.GetComponent(entity).MapPosition, range)) continue; yield return component.Owner; diff --git a/Content.Server/AI/Pathfinding/Accessible/AiReachableSystem.cs b/Content.Server/AI/Pathfinding/Accessible/AiReachableSystem.cs index cefdd62620..cfc97c432c 100644 --- a/Content.Server/AI/Pathfinding/Accessible/AiReachableSystem.cs +++ b/Content.Server/AI/Pathfinding/Accessible/AiReachableSystem.cs @@ -214,7 +214,7 @@ namespace Content.Server.AI.Pathfinding.Accessible return false; } - var entityTile = _mapManager.GetGrid(EntityManager.GetComponent(entity).GridID).GetTileRef(IoCManager.Resolve().GetComponent(entity).Coordinates); + var entityTile = _mapManager.GetGrid(EntityManager.GetComponent(entity).GridID).GetTileRef(EntityManager.GetComponent(entity).Coordinates); var entityNode = _pathfindingSystem.GetNode(entityTile); var entityRegion = GetRegion(entityNode); var targetRegion = GetRegion(targetNode); @@ -424,12 +424,12 @@ namespace Content.Server.AI.Pathfinding.Accessible /// public PathfindingRegion? GetRegion(EntityUid entity) { - if (!IoCManager.Resolve().GetComponent(entity).GridID.IsValid()) + if (!EntityManager.GetComponent(entity).GridID.IsValid()) { return null; } - var entityTile = _mapManager.GetGrid(IoCManager.Resolve().GetComponent(entity).GridID).GetTileRef(IoCManager.Resolve().GetComponent(entity).Coordinates); + var entityTile = _mapManager.GetGrid(EntityManager.GetComponent(entity).GridID).GetTileRef(EntityManager.GetComponent(entity).Coordinates); var entityNode = _pathfindingSystem.GetNode(entityTile); return GetRegion(entityNode); } diff --git a/Content.Server/AI/Pathfinding/PathfindingSystem.cs b/Content.Server/AI/Pathfinding/PathfindingSystem.cs index bd3663af42..f7165e6aec 100644 --- a/Content.Server/AI/Pathfinding/PathfindingSystem.cs +++ b/Content.Server/AI/Pathfinding/PathfindingSystem.cs @@ -183,7 +183,7 @@ namespace Content.Server.AI.Pathfinding /// public PathfindingNode GetNode(EntityUid entity) { - var tile = _mapManager.GetGrid(IoCManager.Resolve().GetComponent(entity).GridID).GetTileRef(IoCManager.Resolve().GetComponent(entity).Coordinates); + var tile = _mapManager.GetGrid(EntityManager.GetComponent(entity).GridID).GetTileRef(EntityManager.GetComponent(entity).Coordinates); return GetNode(tile); } @@ -264,16 +264,16 @@ namespace Content.Server.AI.Pathfinding /// private void HandleEntityAdd(EntityUid entity) { - if ((!IoCManager.Resolve().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity).EntityLifeStage) >= EntityLifeStage.Deleted || + if ((!EntityManager.EntityExists(entity) ? EntityLifeStage.Deleted : EntityManager.GetComponent(entity).EntityLifeStage) >= EntityLifeStage.Deleted || _lastKnownPositions.ContainsKey(entity) || - !IoCManager.Resolve().TryGetComponent(entity, out IPhysBody? physics) || + !EntityManager.TryGetComponent(entity, out IPhysBody? physics) || !PathfindingNode.IsRelevant(entity, physics)) { return; } - var grid = _mapManager.GetGrid(IoCManager.Resolve().GetComponent(entity).GridID); - var tileRef = grid.GetTileRef(IoCManager.Resolve().GetComponent(entity).Coordinates); + var grid = _mapManager.GetGrid(EntityManager.GetComponent(entity).GridID); + var tileRef = grid.GetTileRef(EntityManager.GetComponent(entity).Coordinates); var chunk = GetChunk(tileRef); var node = chunk.GetNode(tileRef); @@ -304,8 +304,8 @@ namespace Content.Server.AI.Pathfinding private void HandleEntityMove(MoveEvent moveEvent) { // If we've moved to space or the likes then remove us. - if ((!IoCManager.Resolve().EntityExists(moveEvent.Sender) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(moveEvent.Sender).EntityLifeStage) >= EntityLifeStage.Deleted || - !IoCManager.Resolve().TryGetComponent(moveEvent.Sender, out IPhysBody? physics) || + if ((!EntityManager.EntityExists(moveEvent.Sender) ? EntityLifeStage.Deleted : EntityManager.GetComponent(moveEvent.Sender).EntityLifeStage) >= EntityLifeStage.Deleted || + !EntityManager.TryGetComponent(moveEvent.Sender, out IPhysBody? physics) || !PathfindingNode.IsRelevant(moveEvent.Sender, physics) || moveEvent.NewPosition.GetGridId(EntityManager) == GridId.Invalid) { @@ -314,9 +314,9 @@ namespace Content.Server.AI.Pathfinding } // Memory leak protection until grid parenting confirmed fix / you REALLY need the performance - var gridBounds = _mapManager.GetGrid(IoCManager.Resolve().GetComponent(moveEvent.Sender).GridID).WorldBounds; + var gridBounds = _mapManager.GetGrid(EntityManager.GetComponent(moveEvent.Sender).GridID).WorldBounds; - if (!gridBounds.Contains(IoCManager.Resolve().GetComponent(moveEvent.Sender).WorldPosition)) + if (!gridBounds.Contains(EntityManager.GetComponent(moveEvent.Sender).WorldPosition)) { HandleEntityRemove(moveEvent.Sender); return; @@ -370,7 +370,7 @@ namespace Content.Server.AI.Pathfinding public bool CanTraverse(EntityUid entity, PathfindingNode node) { - if (IoCManager.Resolve().TryGetComponent(entity, out IPhysBody? physics) && + if (EntityManager.TryGetComponent(entity, out IPhysBody? physics) && (physics.CollisionMask & node.BlockedCollisionMask) != 0) { return false; diff --git a/Content.Server/Access/Systems/IdCardSystem.cs b/Content.Server/Access/Systems/IdCardSystem.cs index 7e1141bede..3c363206cc 100644 --- a/Content.Server/Access/Systems/IdCardSystem.cs +++ b/Content.Server/Access/Systems/IdCardSystem.cs @@ -22,7 +22,7 @@ namespace Content.Server.Access.Systems private void OnInit(EntityUid uid, IdCardComponent id, ComponentInit args) { - id.OriginalOwnerName ??= IoCManager.Resolve().GetComponent(id.Owner).EntityName; + id.OriginalOwnerName ??= EntityManager.GetComponent(id.Owner).EntityName; UpdateEntityName(uid, id); } @@ -67,7 +67,7 @@ namespace Content.Server.Access.Systems if (string.IsNullOrWhiteSpace(id.FullName) && string.IsNullOrWhiteSpace(id.JobTitle)) { - IoCManager.Resolve().GetComponent(id.Owner).EntityName = id.OriginalOwnerName; + EntityManager.GetComponent(id.Owner).EntityName = id.OriginalOwnerName; return; } @@ -80,7 +80,7 @@ namespace Content.Server.Access.Systems : Loc.GetString("access-id-card-component-owner-full-name-job-title-text", ("fullName", id.FullName), ("jobSuffix", jobSuffix)); - IoCManager.Resolve().GetComponent(id.Owner).EntityName = val; + EntityManager.GetComponent(id.Owner).EntityName = val; } /// diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs index f944229e10..7e33c1a9d1 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.HighPressureDelta.cs @@ -33,7 +33,7 @@ namespace Content.Server.Atmos.EntitySystems foreach (var entity in _gridtileLookupSystem.GetEntitiesIntersecting(tile.GridIndex, tile.GridIndices)) { - if (!IoCManager.Resolve().TryGetComponent(entity, out IPhysBody? physics) + if (!EntityManager.TryGetComponent(entity, out IPhysBody? physics) || !entity.IsMovedByPressure(out var pressure) || entity.IsInContainer()) continue; diff --git a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs index 2cf7f858bc..f2dbd82d88 100644 --- a/Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs +++ b/Content.Server/Atmos/EntitySystems/AtmosphereSystem.cs @@ -75,9 +75,9 @@ namespace Content.Server.Atmos.EntitySystems { foreach (var exposed in EntityManager.EntityQuery()) { - var tile = GetTileMixture(IoCManager.Resolve().GetComponent(exposed.Owner).Coordinates); + var tile = GetTileMixture(EntityManager.GetComponent(exposed.Owner).Coordinates); if (tile == null) continue; - var updateEvent = new AtmosExposedUpdateEvent(IoCManager.Resolve().GetComponent(exposed.Owner).Coordinates, tile); + var updateEvent = new AtmosExposedUpdateEvent(EntityManager.GetComponent(exposed.Owner).Coordinates, tile); RaiseLocalEvent(exposed.Owner, ref updateEvent); } diff --git a/Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs b/Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs index 69061876bd..6850458c34 100644 --- a/Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs +++ b/Content.Server/Atmos/EntitySystems/BarotraumaSystem.cs @@ -86,7 +86,7 @@ namespace Content.Server.Atmos.EntitySystems var uid = barotrauma.Owner; - var status = IoCManager.Resolve().GetComponentOrNull(barotrauma.Owner); + var status = EntityManager.GetComponentOrNull(barotrauma.Owner); var pressure = 1f; diff --git a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs index c564504669..518dae272a 100644 --- a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs +++ b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs @@ -224,7 +224,7 @@ namespace Content.Server.Atmos.EntitySystems flammable.FireStacks = MathF.Min(0, flammable.FireStacks + 1); } - IoCManager.Resolve().TryGetComponent(flammable.Owner, out ServerAlertsComponent? status); + EntityManager.TryGetComponent(flammable.Owner, out ServerAlertsComponent? status); if (!flammable.OnFire) { diff --git a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs index b4256c1614..856d9acfc0 100644 --- a/Content.Server/Atmos/EntitySystems/GasTankSystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasTankSystem.cs @@ -24,7 +24,7 @@ namespace Content.Server.Atmos.EntitySystems private void AddOpenUIVerb(EntityUid uid, GasTankComponent component, GetActivationVerbsEvent args) { - if (!args.CanAccess || !IoCManager.Resolve().TryGetComponent(args.User, out var actor)) + if (!args.CanAccess || !EntityManager.TryGetComponent(args.User, out var actor)) return; Verb verb = new(); diff --git a/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs b/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs index 0f5a66645d..ac44b578f3 100644 --- a/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs +++ b/Content.Server/Atmos/EntitySystems/GasTileOverlaySystem.cs @@ -196,17 +196,17 @@ namespace Content.Server.Atmos.EntitySystems // This is the max in any direction that we can get a chunk (e.g. max 2 chunks away of data). var (maxXDiff, maxYDiff) = ((int) (_updateRange / ChunkSize) + 1, (int) (_updateRange / ChunkSize) + 1); - var worldBounds = Box2.CenteredAround(IoCManager.Resolve().GetComponent(entity).WorldPosition, + var worldBounds = Box2.CenteredAround(EntityManager.GetComponent(entity).WorldPosition, new Vector2(_updateRange, _updateRange)); - foreach (var grid in _mapManager.FindGridsIntersecting(IoCManager.Resolve().GetComponent(entity).MapID, worldBounds)) + foreach (var grid in _mapManager.FindGridsIntersecting(EntityManager.GetComponent(entity).MapID, worldBounds)) { if (!_overlay.TryGetValue(grid.Index, out var chunks)) { continue; } - var entityTile = grid.GetTileRef(IoCManager.Resolve().GetComponent(entity).Coordinates).GridIndices; + var entityTile = grid.GetTileRef(EntityManager.GetComponent(entity).Coordinates).GridIndices; for (var x = -maxXDiff; x <= maxXDiff; x++) { diff --git a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasDualPortVentPumpSystem.cs b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasDualPortVentPumpSystem.cs index d2febdb99b..00ad837a56 100644 --- a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasDualPortVentPumpSystem.cs +++ b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasDualPortVentPumpSystem.cs @@ -28,7 +28,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems private void OnGasDualPortVentPumpUpdated(EntityUid uid, GasDualPortVentPumpComponent vent, AtmosDeviceUpdateEvent args) { - var appearance = IoCManager.Resolve().GetComponentOrNull(vent.Owner); + var appearance = EntityManager.GetComponentOrNull(vent.Owner); if (vent.Welded) { @@ -45,7 +45,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems return; } - var environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve().GetComponent(vent.Owner).Coordinates, true); + var environment = _atmosphereSystem.GetTileMixture(EntityManager.GetComponent(vent.Owner).Coordinates, true); // We're in an air-blocked tile... Do nothing. if (environment == null) diff --git a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs index 34c897337e..374d69faed 100644 --- a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs +++ b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasPressurePumpSystem.cs @@ -38,7 +38,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems private void OnExamined(EntityUid uid, GasPressurePumpComponent pump, ExaminedEvent args) { - if (!IoCManager.Resolve().GetComponent(pump.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status. + if (!EntityManager.GetComponent(pump.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status. return; if (Loc.TryGetString("gas-pressure-pump-system-examined", out var str, @@ -50,7 +50,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems private void OnPumpUpdated(EntityUid uid, GasPressurePumpComponent pump, AtmosDeviceUpdateEvent args) { - var appearance = IoCManager.Resolve().GetComponentOrNull(pump.Owner); + var appearance = EntityManager.GetComponentOrNull(pump.Owner); if (!pump.Enabled || !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer) @@ -92,10 +92,10 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems private void OnPumpInteractHand(EntityUid uid, GasPressurePumpComponent component, InteractHandEvent args) { - if (!IoCManager.Resolve().TryGetComponent(args.User, out ActorComponent? actor)) + if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) return; - if (IoCManager.Resolve().GetComponent(component.Owner).Anchored) + if (EntityManager.GetComponent(component.Owner).Anchored) { _userInterfaceSystem.TryOpen(uid, GasPressurePumpUiKey.Key, actor.PlayerSession); DirtyUI(uid, component); @@ -127,7 +127,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems return; _userInterfaceSystem.TrySetUiState(uid, GasPressurePumpUiKey.Key, - new GasPressurePumpBoundUserInterfaceState(IoCManager.Resolve().GetComponent(pump.Owner).EntityName, pump.TargetPressure, pump.Enabled)); + new GasPressurePumpBoundUserInterfaceState(EntityManager.GetComponent(pump.Owner).EntityName, pump.TargetPressure, pump.Enabled)); } } } diff --git a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasValveSystem.cs b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasValveSystem.cs index 43693e4ad9..5d04f55d01 100644 --- a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasValveSystem.cs +++ b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasValveSystem.cs @@ -31,7 +31,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems private void OnExamined(EntityUid uid, GasValveComponent valve, ExaminedEvent args) { - if (!IoCManager.Resolve().GetComponent(valve.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status. + if (!EntityManager.GetComponent(valve.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status. return; if (Loc.TryGetString("gas-valve-system-examined", out var str, diff --git a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs index 82e632ba2e..b9e64a898d 100644 --- a/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs +++ b/Content.Server/Atmos/Piping/Binary/EntitySystems/GasVolumePumpSystem.cs @@ -39,7 +39,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems private void OnExamined(EntityUid uid, GasVolumePumpComponent pump, ExaminedEvent args) { - if (!IoCManager.Resolve().GetComponent(pump.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status. + if (!EntityManager.GetComponent(pump.Owner).Anchored || !args.IsInDetailsRange) // Not anchored? Out of range? No status. return; if (Loc.TryGetString("gas-volume-pump-system-examined", out var str, @@ -83,7 +83,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems // Some of the gas from the mixture leaks when overclocked. if (pump.Overclocked) { - var tile = _atmosphereSystem.GetTileMixture(IoCManager.Resolve().GetComponent(pump.Owner).Coordinates, true); + var tile = _atmosphereSystem.GetTileMixture(EntityManager.GetComponent(pump.Owner).Coordinates, true); if (tile != null) { @@ -97,10 +97,10 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems private void OnPumpInteractHand(EntityUid uid, GasVolumePumpComponent component, InteractHandEvent args) { - if (!IoCManager.Resolve().TryGetComponent(args.User, out ActorComponent? actor)) + if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) return; - if (IoCManager.Resolve().GetComponent(component.Owner).Anchored) + if (EntityManager.GetComponent(component.Owner).Anchored) { _userInterfaceSystem.TryOpen(uid, GasVolumePumpUiKey.Key, actor.PlayerSession); DirtyUI(uid, component); @@ -132,7 +132,7 @@ namespace Content.Server.Atmos.Piping.Binary.EntitySystems return; _userInterfaceSystem.TrySetUiState(uid, GasVolumePumpUiKey.Key, - new GasVolumePumpBoundUserInterfaceState(IoCManager.Resolve().GetComponent(pump.Owner).EntityName, pump.TransferRate, pump.Enabled)); + new GasVolumePumpBoundUserInterfaceState(EntityManager.GetComponent(pump.Owner).EntityName, pump.TransferRate, pump.Enabled)); } } } diff --git a/Content.Server/Atmos/Piping/EntitySystems/AtmosDeviceSystem.cs b/Content.Server/Atmos/Piping/EntitySystems/AtmosDeviceSystem.cs index 92a027a5c1..2d5bcca41a 100644 --- a/Content.Server/Atmos/Piping/EntitySystems/AtmosDeviceSystem.cs +++ b/Content.Server/Atmos/Piping/EntitySystems/AtmosDeviceSystem.cs @@ -32,7 +32,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems private bool CanJoinAtmosphere(AtmosDeviceComponent component) { - return !component.RequireAnchored || IoCManager.Resolve().GetComponent(component.Owner).Anchored; + return !component.RequireAnchored || EntityManager.GetComponent(component.Owner).Anchored; } public void JoinAtmosphere(AtmosDeviceComponent component) @@ -104,7 +104,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems if (!component.RequireAnchored) return; - if(IoCManager.Resolve().GetComponent(component.Owner).Anchored) + if(EntityManager.GetComponent(component.Owner).Anchored) JoinAtmosphere(component); else LeaveAtmosphere(component); diff --git a/Content.Server/Atmos/Piping/EntitySystems/AtmosUnsafeUnanchorSystem.cs b/Content.Server/Atmos/Piping/EntitySystems/AtmosUnsafeUnanchorSystem.cs index 3ba85fddd3..7997984658 100644 --- a/Content.Server/Atmos/Piping/EntitySystems/AtmosUnsafeUnanchorSystem.cs +++ b/Content.Server/Atmos/Piping/EntitySystems/AtmosUnsafeUnanchorSystem.cs @@ -31,7 +31,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems if (!component.Enabled || !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodes)) return; - if (_atmosphereSystem.GetTileMixture(IoCManager.Resolve().GetComponent(component.Owner).Coordinates) is not {} environment) + if (_atmosphereSystem.GetTileMixture(EntityManager.GetComponent(component.Owner).Coordinates) is not {} environment) return; foreach (var node in nodes.Nodes.Values) @@ -52,7 +52,7 @@ namespace Content.Server.Atmos.Piping.EntitySystems if (!component.Enabled || !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodes)) return; - if (_atmosphereSystem.GetTileMixture(IoCManager.Resolve().GetComponent(component.Owner).Coordinates, true) is not {} environment) + if (_atmosphereSystem.GetTileMixture(EntityManager.GetComponent(component.Owner).Coordinates, true) is not {} environment) environment = GasMixture.SpaceGas; var lost = 0f; diff --git a/Content.Server/Atmos/Piping/Other/EntitySystems/GasMinerSystem.cs b/Content.Server/Atmos/Piping/Other/EntitySystems/GasMinerSystem.cs index fe4ab565ab..3bcb4e602b 100644 --- a/Content.Server/Atmos/Piping/Other/EntitySystems/GasMinerSystem.cs +++ b/Content.Server/Atmos/Piping/Other/EntitySystems/GasMinerSystem.cs @@ -37,10 +37,10 @@ namespace Content.Server.Atmos.Piping.Other.EntitySystems private bool CheckMinerOperation(GasMinerComponent miner, [NotNullWhen(true)] out GasMixture? environment) { - environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve().GetComponent(miner.Owner).Coordinates, true); + environment = _atmosphereSystem.GetTileMixture(EntityManager.GetComponent(miner.Owner).Coordinates, true); // Space. - if (_atmosphereSystem.IsTileSpace(IoCManager.Resolve().GetComponent(miner.Owner).Coordinates)) + if (_atmosphereSystem.IsTileSpace(EntityManager.GetComponent(miner.Owner).Coordinates)) { miner.Broken = true; return false; diff --git a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs index 4a0da847db..8b770c282f 100644 --- a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs +++ b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasFilterSystem.cs @@ -38,7 +38,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems private void OnFilterUpdated(EntityUid uid, GasFilterComponent filter, AtmosDeviceUpdateEvent args) { - var appearance = IoCManager.Resolve().GetComponentOrNull(filter.Owner); + var appearance = EntityManager.GetComponentOrNull(filter.Owner); if (!filter.Enabled || !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer) @@ -81,10 +81,10 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems private void OnFilterInteractHand(EntityUid uid, GasFilterComponent component, InteractHandEvent args) { - if (!IoCManager.Resolve().TryGetComponent(args.User, out ActorComponent? actor)) + if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) return; - if (IoCManager.Resolve().GetComponent(component.Owner).Anchored) + if (EntityManager.GetComponent(component.Owner).Anchored) { _userInterfaceSystem.TryOpen(uid, GasFilterUiKey.Key, actor.PlayerSession); DirtyUI(uid, component); @@ -104,7 +104,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems return; _userInterfaceSystem.TrySetUiState(uid, GasFilterUiKey.Key, - new GasFilterBoundUserInterfaceState(IoCManager.Resolve().GetComponent(filter.Owner).EntityName, filter.TransferRate, filter.Enabled, filter.FilteredGas)); + new GasFilterBoundUserInterfaceState(EntityManager.GetComponent(filter.Owner).EntityName, filter.TransferRate, filter.Enabled, filter.FilteredGas)); } private void OnToggleStatusMessage(EntityUid uid, GasFilterComponent filter, GasFilterToggleStatusMessage args) diff --git a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs index 668f8e02b1..9a44d1f614 100644 --- a/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs +++ b/Content.Server/Atmos/Piping/Trinary/EntitySystems/GasMixerSystem.cs @@ -106,10 +106,10 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems private void OnMixerInteractHand(EntityUid uid, GasMixerComponent component, InteractHandEvent args) { - if (!IoCManager.Resolve().TryGetComponent(args.User, out ActorComponent? actor)) + if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) return; - if (IoCManager.Resolve().GetComponent(component.Owner).Anchored) + if (EntityManager.GetComponent(component.Owner).Anchored) { _userInterfaceSystem.TryOpen(uid, GasMixerUiKey.Key, actor.PlayerSession); DirtyUI(uid, component); @@ -128,7 +128,7 @@ namespace Content.Server.Atmos.Piping.Trinary.EntitySystems return; _userInterfaceSystem.TrySetUiState(uid, GasMixerUiKey.Key, - new GasMixerBoundUserInterfaceState(IoCManager.Resolve().GetComponent(mixer.Owner).EntityName, mixer.TargetPressure, mixer.Enabled, mixer.InletOneConcentration)); + new GasMixerBoundUserInterfaceState(EntityManager.GetComponent(mixer.Owner).EntityName, mixer.TargetPressure, mixer.Enabled, mixer.InletOneConcentration)); } private void OnToggleStatusMessage(EntityUid uid, GasMixerComponent mixer, GasMixerToggleStatusMessage args) diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasOutletInjectorSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasOutletInjectorSystem.cs index e07063f4d4..1074f84398 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasOutletInjectorSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasOutletInjectorSystem.cs @@ -35,7 +35,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems if (!nodeContainer.TryGetNode(injector.InletName, out PipeNode? inlet)) return; - var environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve().GetComponent(injector.Owner).Coordinates, true); + var environment = _atmosphereSystem.GetTileMixture(EntityManager.GetComponent(injector.Owner).Coordinates, true); if (environment == null) return; diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPassiveVentSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPassiveVentSystem.cs index 2935413f52..f214db1e84 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPassiveVentSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasPassiveVentSystem.cs @@ -25,7 +25,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems private void OnPassiveVentUpdated(EntityUid uid, GasPassiveVentComponent vent, AtmosDeviceUpdateEvent args) { - var environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve().GetComponent(vent.Owner).Coordinates, true); + var environment = _atmosphereSystem.GetTileMixture(EntityManager.GetComponent(vent.Owner).Coordinates, true); if (environment == null) return; diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasThermoMachineSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasThermoMachineSystem.cs index 98df062037..a7f7c90142 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasThermoMachineSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasThermoMachineSystem.cs @@ -25,7 +25,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems private void OnThermoMachineUpdated(EntityUid uid, GasThermoMachineComponent thermoMachine, AtmosDeviceUpdateEvent args) { - var appearance = IoCManager.Resolve().GetComponentOrNull(thermoMachine.Owner); + var appearance = EntityManager.GetComponentOrNull(thermoMachine.Owner); if (!thermoMachine.Enabled || !EntityManager.TryGetComponent(uid, out NodeContainerComponent? nodeContainer) diff --git a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs index 6df03c59a6..8f08c4c1f8 100644 --- a/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs +++ b/Content.Server/Atmos/Piping/Unary/EntitySystems/GasVentScrubberSystem.cs @@ -28,7 +28,7 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems private void OnVentScrubberUpdated(EntityUid uid, GasVentScrubberComponent scrubber, AtmosDeviceUpdateEvent args) { - var appearance = IoCManager.Resolve().GetComponentOrNull(scrubber.Owner); + var appearance = EntityManager.GetComponentOrNull(scrubber.Owner); if (scrubber.Welded) { @@ -44,14 +44,14 @@ namespace Content.Server.Atmos.Piping.Unary.EntitySystems return; } - var environment = _atmosphereSystem.GetTileMixture(IoCManager.Resolve().GetComponent(scrubber.Owner).Coordinates, true); + var environment = _atmosphereSystem.GetTileMixture(EntityManager.GetComponent(scrubber.Owner).Coordinates, true); Scrub(_atmosphereSystem, scrubber, appearance, environment, outlet); if (!scrubber.WideNet) return; // Scrub adjacent tiles too. - foreach (var adjacent in _atmosphereSystem.GetAdjacentTileMixtures(IoCManager.Resolve().GetComponent(scrubber.Owner).Coordinates, false, true)) + foreach (var adjacent in _atmosphereSystem.GetAdjacentTileMixtures(EntityManager.GetComponent(scrubber.Owner).Coordinates, false, true)) { Scrub(_atmosphereSystem, scrubber, null, adjacent, outlet); } diff --git a/Content.Server/BarSign/Systems/BarSignSystem.cs b/Content.Server/BarSign/Systems/BarSignSystem.cs index fb3ac2456e..0e05852114 100644 --- a/Content.Server/BarSign/Systems/BarSignSystem.cs +++ b/Content.Server/BarSign/Systems/BarSignSystem.cs @@ -67,9 +67,9 @@ namespace Content.Server.BarSign.Systems return; } - if (IoCManager.Resolve().TryGetComponent(component.Owner, out SpriteComponent? sprite)) + if (EntityManager.TryGetComponent(component.Owner, out SpriteComponent? sprite)) { - if (!IoCManager.Resolve().TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver) || !receiver.Powered) + if (!EntityManager.TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver) || !receiver.Powered) { sprite.LayerSetState(0, "empty"); sprite.LayerSetShader(0, "shaded"); @@ -83,15 +83,15 @@ namespace Content.Server.BarSign.Systems if (!string.IsNullOrEmpty(prototype.Name)) { - IoCManager.Resolve().GetComponent(component.Owner).EntityName = prototype.Name; + EntityManager.GetComponent(component.Owner).EntityName = prototype.Name; } else { string val = Loc.GetString("barsign-component-name"); - IoCManager.Resolve().GetComponent(component.Owner).EntityName = val; + EntityManager.GetComponent(component.Owner).EntityName = val; } - IoCManager.Resolve().GetComponent(component.Owner).EntityDescription = prototype.Description; + EntityManager.GetComponent(component.Owner).EntityDescription = prototype.Description; } } } diff --git a/Content.Server/Buckle/Systems/BuckleSystem.cs b/Content.Server/Buckle/Systems/BuckleSystem.cs index f7cdea8221..0135e3aea0 100644 --- a/Content.Server/Buckle/Systems/BuckleSystem.cs +++ b/Content.Server/Buckle/Systems/BuckleSystem.cs @@ -79,7 +79,7 @@ namespace Content.Server.Buckle.Systems return; } - var strapPosition = IoCManager.Resolve().GetComponent(strap.Owner).Coordinates.Offset(buckle.BuckleOffset); + var strapPosition = EntityManager.GetComponent(strap.Owner).Coordinates.Offset(buckle.BuckleOffset); if (ev.NewPosition.InRange(EntityManager, strapPosition, 0.2f)) { @@ -95,7 +95,7 @@ namespace Content.Server.Buckle.Systems // This fixes buckle offsets and draw depths. foreach (var buckledEntity in strap.BuckledEntities) { - if (!IoCManager.Resolve().TryGetComponent(buckledEntity, out BuckleComponent? buckled)) + if (!EntityManager.TryGetComponent(buckledEntity, out BuckleComponent? buckled)) { continue; } @@ -112,7 +112,7 @@ namespace Content.Server.Buckle.Systems { foreach (var buckledEntity in strap.BuckledEntities) { - if (!IoCManager.Resolve().TryGetComponent(buckledEntity, out BuckleComponent? buckled)) + if (!EntityManager.TryGetComponent(buckledEntity, out BuckleComponent? buckled)) { continue; } diff --git a/Content.Server/Chemistry/EntitySystems/RehydratableSystem.cs b/Content.Server/Chemistry/EntitySystems/RehydratableSystem.cs index 09b354fbfc..3ff87ae2b9 100644 --- a/Content.Server/Chemistry/EntitySystems/RehydratableSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/RehydratableSystem.cs @@ -39,12 +39,12 @@ namespace Content.Server.Chemistry.EntitySystems owner.PopupMessageEveryone(Loc.GetString("rehydratable-component-expands-message", ("owner", owner))); if (!string.IsNullOrEmpty(component.TargetPrototype)) { - var ent = IoCManager.Resolve().SpawnEntity(component.TargetPrototype, - IoCManager.Resolve().GetComponent(owner).Coordinates); - IoCManager.Resolve().GetComponent(ent).AttachToGridOrMap(); + var ent = EntityManager.SpawnEntity(component.TargetPrototype, + EntityManager.GetComponent(owner).Coordinates); + EntityManager.GetComponent(ent).AttachToGridOrMap(); } - IoCManager.Resolve().QueueDeleteEntity((EntityUid) owner); + EntityManager.QueueDeleteEntity((EntityUid) owner); } } } diff --git a/Content.Server/Chemistry/EntitySystems/SolutionContainerSystem.cs b/Content.Server/Chemistry/EntitySystems/SolutionContainerSystem.cs index fde645a7dd..a7b61f4bbc 100644 --- a/Content.Server/Chemistry/EntitySystems/SolutionContainerSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/SolutionContainerSystem.cs @@ -292,7 +292,7 @@ namespace Content.Server.Chemistry.EntitySystems { var reagentQuantity = FixedPoint2.New(0); if (EntityManager.EntityExists(owner) - && IoCManager.Resolve().TryGetComponent(owner, out SolutionContainerManagerComponent? managerComponent)) + && EntityManager.TryGetComponent(owner, out SolutionContainerManagerComponent? managerComponent)) { foreach (var solution in managerComponent.Solutions.Values) { diff --git a/Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs b/Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs index 7967a5b19b..e26ca86fac 100644 --- a/Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/SolutionInjectOnCollideSystem.cs @@ -30,7 +30,7 @@ namespace Content.Server.Chemistry.EntitySystems private void HandleInjection(EntityUid uid, SolutionInjectOnCollideComponent component, StartCollideEvent args) { - if (!IoCManager.Resolve().TryGetComponent(args.OtherFixture.Body.Owner, out var bloodstream) || + if (!EntityManager.TryGetComponent(args.OtherFixture.Body.Owner, out var bloodstream) || !_solutionsSystem.TryGetInjectableSolution(component.Owner, out var solution)) return; var solRemoved = solution.SplitSolution(component.TransferAmount); diff --git a/Content.Server/Chemistry/EntitySystems/SolutionTransferSystem.cs b/Content.Server/Chemistry/EntitySystems/SolutionTransferSystem.cs index 3c1e73ffc4..7208f76c49 100644 --- a/Content.Server/Chemistry/EntitySystems/SolutionTransferSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/SolutionTransferSystem.cs @@ -32,7 +32,7 @@ namespace Content.Server.Chemistry.EntitySystems if (!args.CanAccess || !args.CanInteract || !component.CanChangeTransferAmount) return; - if (!IoCManager.Resolve().TryGetComponent(args.User, out var actor)) + if (!EntityManager.TryGetComponent(args.User, out var actor)) return; // Custom transfer verb diff --git a/Content.Server/Chemistry/EntitySystems/TransformableContainerSystem.cs b/Content.Server/Chemistry/EntitySystems/TransformableContainerSystem.cs index 3541867bcc..ff3905dc31 100644 --- a/Content.Server/Chemistry/EntitySystems/TransformableContainerSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/TransformableContainerSystem.cs @@ -50,14 +50,14 @@ namespace Content.Server.Chemistry.EntitySystems var spriteSpec = new SpriteSpecifier.Rsi( new ResourcePath("Objects/Consumable/Drinks/" + proto.SpriteReplacementPath), "icon"); - if (IoCManager.Resolve().TryGetComponent(owner, out SpriteComponent? sprite)) + if (EntityManager.TryGetComponent(owner, out SpriteComponent? sprite)) { sprite?.LayerSetSprite(0, spriteSpec); } string val = proto.Name + " glass"; - IoCManager.Resolve().GetComponent(owner).EntityName = val; - IoCManager.Resolve().GetComponent(owner).EntityDescription = proto.Description; + EntityManager.GetComponent(owner).EntityName = val; + EntityManager.GetComponent(owner).EntityDescription = proto.Description; component.CurrentReagent = proto; component.Transformed = true; } @@ -68,14 +68,14 @@ namespace Content.Server.Chemistry.EntitySystems component.CurrentReagent = null; component.Transformed = false; - if (IoCManager.Resolve().TryGetComponent(component.Owner, out SpriteComponent? sprite) && + if (EntityManager.TryGetComponent(component.Owner, out SpriteComponent? sprite) && component.InitialSprite != null) { sprite.LayerSetSprite(0, component.InitialSprite); } - IoCManager.Resolve().GetComponent(component.Owner).EntityName = component.InitialName; - IoCManager.Resolve().GetComponent(component.Owner).EntityDescription = component.InitialDescription; + EntityManager.GetComponent(component.Owner).EntityName = component.InitialName; + EntityManager.GetComponent(component.Owner).EntityDescription = component.InitialDescription; } } } diff --git a/Content.Server/Chemistry/EntitySystems/VaporSystem.cs b/Content.Server/Chemistry/EntitySystems/VaporSystem.cs index 24691b8ccd..cebe2f846d 100644 --- a/Content.Server/Chemistry/EntitySystems/VaporSystem.cs +++ b/Content.Server/Chemistry/EntitySystems/VaporSystem.cs @@ -52,7 +52,7 @@ namespace Content.Server.Chemistry.EntitySystems vapor.Target = target; vapor.AliveTime = aliveTime; // Set Move - if (IoCManager.Resolve().TryGetComponent(vapor.Owner, out PhysicsComponent? physics)) + if (EntityManager.TryGetComponent(vapor.Owner, out PhysicsComponent? physics)) { physics.BodyStatus = BodyStatus.InAir; physics.ApplyLinearImpulse(dir * speed); @@ -97,12 +97,12 @@ namespace Content.Server.Chemistry.EntitySystems vapor.Timer += frameTime; vapor.ReactTimer += frameTime; - if (vapor.ReactTimer >= ReactTime && IoCManager.Resolve().GetComponent(vapor.Owner).GridID.IsValid()) + if (vapor.ReactTimer >= ReactTime && EntityManager.GetComponent(vapor.Owner).GridID.IsValid()) { vapor.ReactTimer = 0; - var mapGrid = _mapManager.GetGrid(IoCManager.Resolve().GetComponent(entity).GridID); + var mapGrid = _mapManager.GetGrid(EntityManager.GetComponent(entity).GridID); - var tile = mapGrid.GetTileRef(IoCManager.Resolve().GetComponent(entity).Coordinates.ToVector2i(EntityManager, _mapManager)); + var tile = mapGrid.GetTileRef(EntityManager.GetComponent(entity).Coordinates.ToVector2i(EntityManager, _mapManager)); foreach (var reagentQuantity in contents.Contents.ToArray()) { if (reagentQuantity.Quantity == FixedPoint2.Zero) continue; @@ -114,7 +114,7 @@ namespace Content.Server.Chemistry.EntitySystems // Check if we've reached our target. if (!vapor.Reached && - vapor.Target.TryDistance(EntityManager, IoCManager.Resolve().GetComponent(entity).Coordinates, out var distance) && + vapor.Target.TryDistance(EntityManager, EntityManager.GetComponent(entity).Coordinates, out var distance) && distance <= 0.5f) { vapor.Reached = true; @@ -123,7 +123,7 @@ namespace Content.Server.Chemistry.EntitySystems if (contents.CurrentVolume == 0 || vapor.Timer > vapor.AliveTime) { // Delete this - IoCManager.Resolve().QueueDeleteEntity(entity); + EntityManager.QueueDeleteEntity(entity); } } } diff --git a/Content.Server/Climbing/ClimbSystem.cs b/Content.Server/Climbing/ClimbSystem.cs index 41f4852867..9921bdb333 100644 --- a/Content.Server/Climbing/ClimbSystem.cs +++ b/Content.Server/Climbing/ClimbSystem.cs @@ -41,7 +41,7 @@ namespace Content.Server.Climbing return; // Check that the user climb. - if (!IoCManager.Resolve().TryGetComponent(args.User, out ClimbingComponent? climbingComponent) || + if (!EntityManager.TryGetComponent(args.User, out ClimbingComponent? climbingComponent) || climbingComponent.IsClimbing) return; diff --git a/Content.Server/Construction/ConstructionSystem.cs b/Content.Server/Construction/ConstructionSystem.cs index b4c9740239..9386cf1889 100644 --- a/Content.Server/Construction/ConstructionSystem.cs +++ b/Content.Server/Construction/ConstructionSystem.cs @@ -51,13 +51,13 @@ namespace Content.Server.Construction { if (GetCurrentGraph(uid, construction) is not {} graph) { - _sawmill.Warning($"Prototype {IoCManager.Resolve().GetComponent(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid graph specified."); + _sawmill.Warning($"Prototype {EntityManager.GetComponent(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid graph specified."); return; } if (GetNodeFromGraph(graph, construction.Node) is not {} node) { - _sawmill.Warning($"Prototype {IoCManager.Resolve().GetComponent(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid node specified."); + _sawmill.Warning($"Prototype {EntityManager.GetComponent(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid node specified."); return; } @@ -66,7 +66,7 @@ namespace Content.Server.Construction { if (GetEdgeFromNode(node, edgeIndex) is not {} currentEdge) { - _sawmill.Warning($"Prototype {IoCManager.Resolve().GetComponent(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid edge index specified."); + _sawmill.Warning($"Prototype {EntityManager.GetComponent(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid edge index specified."); return; } @@ -77,7 +77,7 @@ namespace Content.Server.Construction { if (GetNodeFromGraph(graph, targetNodeId) is not { } targetNode) { - _sawmill.Warning($"Prototype {IoCManager.Resolve().GetComponent(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid target node specified."); + _sawmill.Warning($"Prototype {EntityManager.GetComponent(construction.Owner).EntityPrototype?.ID}'s construction component has an invalid target node specified."); return; } diff --git a/Content.Server/Conveyor/ConveyorSystem.cs b/Content.Server/Conveyor/ConveyorSystem.cs index cef36ac6a3..95a3f378fb 100644 --- a/Content.Server/Conveyor/ConveyorSystem.cs +++ b/Content.Server/Conveyor/ConveyorSystem.cs @@ -40,9 +40,9 @@ namespace Content.Server.Conveyor private void UpdateAppearance(ConveyorComponent component) { - if (IoCManager.Resolve().TryGetComponent(component.Owner, out var appearance)) + if (EntityManager.TryGetComponent(component.Owner, out var appearance)) { - if (IoCManager.Resolve().TryGetComponent(component.Owner, out var receiver) && receiver.Powered) + if (EntityManager.TryGetComponent(component.Owner, out var receiver) && receiver.Powered) { appearance.SetData(ConveyorVisuals.State, component.State); } @@ -98,13 +98,13 @@ namespace Content.Server.Conveyor return false; } - if (IoCManager.Resolve().TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver) && + if (EntityManager.TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver) && !receiver.Powered) { return false; } - if (IoCManager.Resolve().HasComponent(component.Owner)) + if (EntityManager.HasComponent(component.Owner)) { return false; } @@ -124,7 +124,7 @@ namespace Content.Server.Conveyor var adjustment = component.State == ConveyorState.Reversed ? MathHelper.Pi/2 : -MathHelper.Pi/2; var radians = MathHelper.DegreesToRadians(component.Angle); - return new Angle(IoCManager.Resolve().GetComponent(component.Owner).LocalRotation.Theta + radians + adjustment); + return new Angle(EntityManager.GetComponent(component.Owner).LocalRotation.Theta + radians + adjustment); } public IEnumerable<(EntityUid, IPhysBody)> GetEntitiesToMove(ConveyorComponent comp) @@ -132,7 +132,7 @@ namespace Content.Server.Conveyor //todo uuuhhh cache this foreach (var entity in _entityLookup.GetEntitiesIntersecting(comp.Owner, flags: LookupFlags.Approximate)) { - if ((!IoCManager.Resolve().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity).EntityLifeStage) >= EntityLifeStage.Deleted) + if ((!EntityManager.EntityExists(entity) ? EntityLifeStage.Deleted : EntityManager.GetComponent(entity).EntityLifeStage) >= EntityLifeStage.Deleted) { continue; } @@ -142,13 +142,13 @@ namespace Content.Server.Conveyor continue; } - if (!IoCManager.Resolve().TryGetComponent(entity, out IPhysBody? physics) || + if (!EntityManager.TryGetComponent(entity, out IPhysBody? physics) || physics.BodyType == BodyType.Static || physics.BodyStatus == BodyStatus.InAir || entity.IsWeightless()) { continue; } - if (IoCManager.Resolve().HasComponent(entity)) + if (EntityManager.HasComponent(entity)) { continue; } diff --git a/Content.Server/Cuffs/CuffableSystem.cs b/Content.Server/Cuffs/CuffableSystem.cs index f16eb8839f..1ca61281d9 100644 --- a/Content.Server/Cuffs/CuffableSystem.cs +++ b/Content.Server/Cuffs/CuffableSystem.cs @@ -66,7 +66,7 @@ namespace Content.Server.Cuffs if (args.User == args.Target) { // This UncuffAttemptEvent check should probably be In MobStateSystem, not here? - if (IoCManager.Resolve().TryGetComponent(args.User, out var state)) + if (EntityManager.TryGetComponent(args.User, out var state)) { // Manually check this. if (state.IsIncapacitated()) @@ -101,11 +101,11 @@ namespace Content.Server.Cuffs { var owner = message.Sender; - if (!IoCManager.Resolve().TryGetComponent(owner, out CuffableComponent? cuffable) || + if (!EntityManager.TryGetComponent(owner, out CuffableComponent? cuffable) || !cuffable.Initialized) return; var dirty = false; - var handCount = IoCManager.Resolve().GetComponentOrNull(owner)?.Count ?? 0; + var handCount = EntityManager.GetComponentOrNull(owner)?.Count ?? 0; while (cuffable.CuffedHandCount > handCount && cuffable.CuffedHandCount > 0) { @@ -115,7 +115,7 @@ namespace Content.Server.Cuffs var entity = container.ContainedEntities[^1]; container.Remove(entity); - IoCManager.Resolve().GetComponent(entity).WorldPosition = IoCManager.Resolve().GetComponent(owner).WorldPosition; + EntityManager.GetComponent(entity).WorldPosition = EntityManager.GetComponent(owner).WorldPosition; } if (dirty) diff --git a/Content.Server/Damage/Systems/DamageOnToolInteractSystem.cs b/Content.Server/Damage/Systems/DamageOnToolInteractSystem.cs index 68b231ab05..3b0303f2ff 100644 --- a/Content.Server/Damage/Systems/DamageOnToolInteractSystem.cs +++ b/Content.Server/Damage/Systems/DamageOnToolInteractSystem.cs @@ -28,7 +28,7 @@ namespace Content.Server.Damage.Systems return; if (component.WeldingDamage is {} weldingDamage - && IoCManager.Resolve().TryGetComponent(args.Used, out var welder) + && EntityManager.TryGetComponent(args.Used, out var welder) && welder.Lit) { var dmg = _damageableSystem.TryChangeDamage(args.Target, weldingDamage); @@ -40,7 +40,7 @@ namespace Content.Server.Damage.Systems args.Handled = true; } else if (component.DefaultDamage is {} damage - && IoCManager.Resolve().TryGetComponent(args.Used, out var tool) + && EntityManager.TryGetComponent(args.Used, out var tool) && tool.Qualities.ContainsAny(component.Tools)) { var dmg = _damageableSystem.TryChangeDamage(args.Target, damage); diff --git a/Content.Server/DeviceNetwork/Systems/ApcNetworkSystem.cs b/Content.Server/DeviceNetwork/Systems/ApcNetworkSystem.cs index 6c2865ea5a..ee8278fbe1 100644 --- a/Content.Server/DeviceNetwork/Systems/ApcNetworkSystem.cs +++ b/Content.Server/DeviceNetwork/Systems/ApcNetworkSystem.cs @@ -36,7 +36,7 @@ namespace Content.Server.DeviceNetwork.Systems private void OnProviderConnected(EntityUid uid, ApcNetworkComponent component, ExtensionCableSystem.ProviderConnectedEvent args) { - if (!IoCManager.Resolve().TryGetComponent(args.Provider.Owner, out NodeContainerComponent? nodeContainer)) return; + if (!EntityManager.TryGetComponent(args.Provider.Owner, out NodeContainerComponent? nodeContainer)) return; if (nodeContainer.TryGetNode("power", out CableNode? node)) { diff --git a/Content.Server/Disposal/Tube/DisposalTubeSystem.cs b/Content.Server/Disposal/Tube/DisposalTubeSystem.cs index afe16e7e59..32b9546a2f 100644 --- a/Content.Server/Disposal/Tube/DisposalTubeSystem.cs +++ b/Content.Server/Disposal/Tube/DisposalTubeSystem.cs @@ -34,7 +34,7 @@ namespace Content.Server.Disposal.Tube if (!args.CanAccess || !args.CanInteract) return; - if (!IoCManager.Resolve().TryGetComponent(args.User, out var actor)) + if (!EntityManager.TryGetComponent(args.User, out var actor)) return; var player = actor.PlayerSession; @@ -50,7 +50,7 @@ namespace Content.Server.Disposal.Tube if (!args.CanAccess || !args.CanInteract) return; - if (!IoCManager.Resolve().TryGetComponent(args.User, out var actor)) + if (!EntityManager.TryGetComponent(args.User, out var actor)) return; var player = actor.PlayerSession; @@ -86,8 +86,8 @@ namespace Content.Server.Disposal.Tube return null; var oppositeDirection = nextDirection.GetOpposite(); - var grid = _mapManager.GetGrid(IoCManager.Resolve().GetComponent(targetTube.Owner).GridID); - var position = IoCManager.Resolve().GetComponent(targetTube.Owner).Coordinates; + var grid = _mapManager.GetGrid(EntityManager.GetComponent(targetTube.Owner).GridID); + var position = EntityManager.GetComponent(targetTube.Owner).Coordinates; foreach (var entity in grid.GetInDir(position, nextDirection)) { if (!EntityManager.TryGetComponent(entity, out IDisposalTubeComponent? tube)) diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs index 776c84cc47..867fee4dd4 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs @@ -47,24 +47,24 @@ namespace Content.Server.Disposal.Unit.EntitySystems foreach (var entity in holder.Container.ContainedEntities.ToArray()) { - if (IoCManager.Resolve().TryGetComponent(entity, out IPhysBody? physics)) + if (EntityManager.TryGetComponent(entity, out IPhysBody? physics)) { physics.CanCollide = true; } holder.Container.ForceRemove(entity); - if (IoCManager.Resolve().GetComponent(entity).Parent == holderTransform) + if (EntityManager.GetComponent(entity).Parent == holderTransform) { if (duc != null) { // Insert into disposal unit - IoCManager.Resolve().GetComponent(entity).Coordinates = new EntityCoordinates((duc).Owner, Vector2.Zero); + EntityManager.GetComponent(entity).Coordinates = new EntityCoordinates((duc).Owner, Vector2.Zero); duc.Container.Insert(entity); } else { - IoCManager.Resolve().GetComponent(entity).AttachParentToContainerOrGrid(); + EntityManager.GetComponent(entity).AttachParentToContainerOrGrid(); } } } @@ -161,11 +161,11 @@ namespace Content.Server.Disposal.Unit.EntitySystems if (holder.TimeLeft > 0) { var progress = 1 - holder.TimeLeft / holder.StartingTime; - var origin = IoCManager.Resolve().GetComponent(currentTube.Owner).Coordinates; + var origin = EntityManager.GetComponent(currentTube.Owner).Coordinates; var destination = holder.CurrentDirection.ToVec(); var newPosition = destination * progress; - IoCManager.Resolve().GetComponent(holder.Owner).Coordinates = origin.Offset(newPosition); + EntityManager.GetComponent(holder.Owner).Coordinates = origin.Offset(newPosition); continue; } diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs index ad6b660274..65d13c5495 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs @@ -172,7 +172,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems #region Eventbus Handlers private void HandleActivate(EntityUid uid, DisposalUnitComponent component, ActivateInWorldEvent args) { - if (!IoCManager.Resolve().TryGetComponent(args.User, out ActorComponent? actor)) + if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) { return; } @@ -187,7 +187,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems private void HandleInteractHand(EntityUid uid, DisposalUnitComponent component, InteractHandEvent args) { - if (!IoCManager.Resolve().TryGetComponent(args.User, out ActorComponent? actor)) return; + if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) return; // Duplicated code here, not sure how else to get actor inside to make UserInterface happy. @@ -198,7 +198,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems private void HandleInteractUsing(EntityUid uid, DisposalUnitComponent component, InteractUsingEvent args) { - if (!IoCManager.Resolve().TryGetComponent(args.User, out HandsComponent? hands)) + if (!EntityManager.TryGetComponent(args.User, out HandsComponent? hands)) { return; } @@ -238,7 +238,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems UpdateInterface(component, component.Powered); - if (!IoCManager.Resolve().HasComponent(component.Owner)) + if (!EntityManager.HasComponent(component.Owner)) { Logger.WarningS("VitalComponentMissing", $"Disposal unit {uid} is missing an {nameof(AnchorableComponent)}"); } @@ -302,7 +302,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems { var currentTime = GameTiming.CurTime; - if (!IoCManager.Resolve().TryGetComponent(args.Entity, out HandsComponent? hands) || + if (!EntityManager.TryGetComponent(args.Entity, out HandsComponent? hands) || hands.Count == 0 || currentTime < component.LastExitAttempt + ExitAttemptDelay) { @@ -351,7 +351,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems if (count > 0) { - if (!IoCManager.Resolve().TryGetComponent(component.Owner, out PhysicsComponent? disposalsBody)) + if (!EntityManager.TryGetComponent(component.Owner, out PhysicsComponent? disposalsBody)) { component.RecentlyEjected.Clear(); } @@ -395,7 +395,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems } // This popup message doesn't appear on clicks, even when code was seperate. Unsure why. - if (!IoCManager.Resolve().HasComponent(eventArgs.User)) + if (!EntityManager.HasComponent(eventArgs.User)) { eventArgs.Target.PopupMessage(eventArgs.User, Loc.GetString("ui-disposal-unit-is-valid-interaction-no-hands")); return false; @@ -444,8 +444,8 @@ namespace Content.Server.Disposal.Unit.EntitySystems return false; } - var grid = _mapManager.GetGrid(IoCManager.Resolve().GetComponent(component.Owner).GridID); - var coords = IoCManager.Resolve().GetComponent(component.Owner).Coordinates; + var grid = _mapManager.GetGrid(EntityManager.GetComponent(component.Owner).GridID); + var coords = EntityManager.GetComponent(component.Owner).Coordinates; var entry = grid.GetLocal(coords) .FirstOrDefault(entity => EntityManager.HasComponent(entity)); @@ -457,7 +457,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems var air = component.Air; var entryComponent = EntityManager.GetComponent(entry); - if (_atmosSystem.GetTileMixture(IoCManager.Resolve().GetComponent(component.Owner).Coordinates, true) is {Temperature: > 0} environment) + if (_atmosSystem.GetTileMixture(EntityManager.GetComponent(component.Owner).Coordinates, true) is {Temperature: > 0} environment) { var transferMoles = 0.1f * (0.05f * Atmospherics.OneAtmosphere * 1.01f - air.Pressure) * air.Volume / (environment.Temperature * Atmospherics.R); @@ -483,7 +483,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems public void UpdateInterface(DisposalUnitComponent component, bool powered) { var stateString = Loc.GetString($"{component.State}"); - var state = new SharedDisposalUnitComponent.DisposalUnitBoundUserInterfaceState(IoCManager.Resolve().GetComponent(component.Owner).EntityName, stateString, EstimatedFullPressure(component), powered, component.Engaged); + var state = new SharedDisposalUnitComponent.DisposalUnitBoundUserInterfaceState(EntityManager.GetComponent(component.Owner).EntityName, stateString, EstimatedFullPressure(component), powered, component.Engaged); component.UserInterface?.SetState(state); } @@ -504,12 +504,12 @@ namespace Content.Server.Disposal.Unit.EntitySystems public void UpdateVisualState(DisposalUnitComponent component, bool flush) { - if (!IoCManager.Resolve().TryGetComponent(component.Owner, out AppearanceComponent? appearance)) + if (!EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearance)) { return; } - if (!IoCManager.Resolve().GetComponent(component.Owner).Anchored) + if (!EntityManager.GetComponent(component.Owner).Anchored) { appearance.SetData(SharedDisposalUnitComponent.Visuals.VisualState, SharedDisposalUnitComponent.VisualState.UnAnchored); appearance.SetData(SharedDisposalUnitComponent.Visuals.Handle, SharedDisposalUnitComponent.HandleState.Normal); @@ -567,7 +567,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems public bool CanFlush(DisposalUnitComponent component) { - return component.State == SharedDisposalUnitComponent.PressureState.Ready && component.Powered && IoCManager.Resolve().GetComponent(component.Owner).Anchored; + return component.State == SharedDisposalUnitComponent.PressureState.Ready && component.Powered && EntityManager.GetComponent(component.Owner).Anchored; } public void Engage(DisposalUnitComponent component) @@ -633,7 +633,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems { TryQueueEngage(component); - if (IoCManager.Resolve().TryGetComponent(entity, out ActorComponent? actor)) + if (EntityManager.TryGetComponent(entity, out ActorComponent? actor)) { component.UserInterface?.Close(actor.PlayerSession); } diff --git a/Content.Server/Doors/Systems/AirlockSystem.cs b/Content.Server/Doors/Systems/AirlockSystem.cs index ef1b97f4e0..14ef8d6a95 100644 --- a/Content.Server/Doors/Systems/AirlockSystem.cs +++ b/Content.Server/Doors/Systems/AirlockSystem.cs @@ -88,7 +88,7 @@ namespace Content.Server.Doors.Systems private void OnDoorClickShouldActivate(EntityUid uid, AirlockComponent component, DoorClickShouldActivateEvent args) { if (component.WiresComponent != null && component.WiresComponent.IsPanelOpen && - IoCManager.Resolve().TryGetComponent(args.Args.User, out ActorComponent? actor)) + EntityManager.TryGetComponent(args.Args.User, out ActorComponent? actor)) { component.WiresComponent.OpenInterface(actor.PlayerSession); args.Handled = true; diff --git a/Content.Server/Doors/Systems/DoorSystem.cs b/Content.Server/Doors/Systems/DoorSystem.cs index 82913a3fee..54b781ec72 100644 --- a/Content.Server/Doors/Systems/DoorSystem.cs +++ b/Content.Server/Doors/Systems/DoorSystem.cs @@ -46,7 +46,7 @@ namespace Content.Server.Doors private void HandleCollide(EntityUid uid, ServerDoorComponent component, StartCollideEvent args) { - if (!IoCManager.Resolve().HasComponent(args.OtherFixture.Body.Owner)) + if (!EntityManager.HasComponent(args.OtherFixture.Body.Owner)) { return; } diff --git a/Content.Server/Electrocution/ElectrocutionSystem.cs b/Content.Server/Electrocution/ElectrocutionSystem.cs index 6c2893936c..72d2fe4f42 100644 --- a/Content.Server/Electrocution/ElectrocutionSystem.cs +++ b/Content.Server/Electrocution/ElectrocutionSystem.cs @@ -165,7 +165,7 @@ namespace Content.Server.Electrocution foreach (var entity in transform.Coordinates.GetEntitiesInTile( LookupFlags.Approximate | LookupFlags.IncludeAnchored, _entityLookup)) { - if (IoCManager.Resolve().HasComponent(entity)) + if (EntityManager.HasComponent(entity)) return false; } } @@ -285,10 +285,10 @@ namespace Content.Server.Electrocution var electrocutionEntity = EntityManager.SpawnEntity( $"VirtualElectrocutionLoad{node.NodeGroupID}", sourceTransform.Coordinates); - var electrocutionNode = IoCManager.Resolve().GetComponent(electrocutionEntity) + var electrocutionNode = EntityManager.GetComponent(electrocutionEntity) .GetNode("electrocution"); - var electrocutionComponent = IoCManager.Resolve().GetComponent(electrocutionEntity); + var electrocutionComponent = EntityManager.GetComponent(electrocutionEntity); electrocutionNode.CableEntity = sourceUid; electrocutionNode.NodeName = node.Name; diff --git a/Content.Server/Engineering/EntitySystems/DisassembleOnActivateSystem.cs b/Content.Server/Engineering/EntitySystems/DisassembleOnActivateSystem.cs index f29bcf7e54..cd12f721ad 100644 --- a/Content.Server/Engineering/EntitySystems/DisassembleOnActivateSystem.cs +++ b/Content.Server/Engineering/EntitySystems/DisassembleOnActivateSystem.cs @@ -41,18 +41,18 @@ namespace Content.Server.Engineering.EntitySystems component.TokenSource.Cancel(); } - if (component.Deleted || (!IoCManager.Resolve().EntityExists(component.Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(component.Owner).EntityLifeStage) >= EntityLifeStage.Deleted) + if (component.Deleted || (!EntityManager.EntityExists(component.Owner) ? EntityLifeStage.Deleted : EntityManager.GetComponent(component.Owner).EntityLifeStage) >= EntityLifeStage.Deleted) return; - var entity = EntityManager.SpawnEntity(component.Prototype, IoCManager.Resolve().GetComponent(component.Owner).Coordinates); + var entity = EntityManager.SpawnEntity(component.Prototype, EntityManager.GetComponent(component.Owner).Coordinates); - if (IoCManager.Resolve().TryGetComponent(args.User, out var hands) - && IoCManager.Resolve().TryGetComponent(entity, out var item)) + if (EntityManager.TryGetComponent(args.User, out var hands) + && EntityManager.TryGetComponent(entity, out var item)) { hands.PutInHandOrDrop(item); } - IoCManager.Resolve().DeleteEntity(component.Owner); + EntityManager.DeleteEntity(component.Owner); return; } diff --git a/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs b/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs index bcbcdc0da4..5434edf4c1 100644 --- a/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs +++ b/Content.Server/Engineering/EntitySystems/SpawnAfterInteractSystem.cs @@ -57,10 +57,10 @@ namespace Content.Server.Engineering.EntitySystems return; } - if (component.Deleted || (!IoCManager.Resolve().EntityExists(component.Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(component.Owner).EntityLifeStage) >= EntityLifeStage.Deleted) + if (component.Deleted || (!EntityManager.EntityExists(component.Owner) ? EntityLifeStage.Deleted : EntityManager.GetComponent(component.Owner).EntityLifeStage) >= EntityLifeStage.Deleted) return; - if (IoCManager.Resolve().TryGetComponent(component.Owner, out var stackComp) + if (EntityManager.TryGetComponent(component.Owner, out var stackComp) && component.RemoveOnInteract && !_stackSystem.Use(uid, 1, stackComp)) { return; @@ -68,8 +68,8 @@ namespace Content.Server.Engineering.EntitySystems EntityManager.SpawnEntity(component.Prototype, args.ClickLocation.SnapToGrid(grid)); - if (component.RemoveOnInteract && stackComp == null && !((!IoCManager.Resolve().EntityExists(component.Owner) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(component.Owner).EntityLifeStage) >= EntityLifeStage.Deleted)) - IoCManager.Resolve().DeleteEntity(component.Owner); + if (component.RemoveOnInteract && stackComp == null && !((!EntityManager.EntityExists(component.Owner) ? EntityLifeStage.Deleted : EntityManager.GetComponent(component.Owner).EntityLifeStage) >= EntityLifeStage.Deleted)) + EntityManager.DeleteEntity(component.Owner); } } } diff --git a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs index 00039ca069..a282d38b30 100644 --- a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs +++ b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs @@ -149,7 +149,7 @@ namespace Content.Server.Explosion.EntitySystems Timer.Spawn(delay, () => { - if ((!IoCManager.Resolve().EntityExists(triggered) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(triggered).EntityLifeStage) >= EntityLifeStage.Deleted) return; + if (Deleted(triggered)) return; Trigger(triggered, user); }); } diff --git a/Content.Server/Flash/FlashSystem.cs b/Content.Server/Flash/FlashSystem.cs index fb25b4844f..1471a5e2ec 100644 --- a/Content.Server/Flash/FlashSystem.cs +++ b/Content.Server/Flash/FlashSystem.cs @@ -61,7 +61,7 @@ namespace Content.Server.Flash return; } - if (IoCManager.Resolve().HasComponent(args.Entity)) + if (EntityManager.HasComponent(args.Entity)) { args.CanInteract = true; Flash(args.Entity, args.User, uid, comp.FlashDuration, comp.SlowTo); @@ -75,7 +75,7 @@ namespace Content.Server.Flash return; } - foreach (var entity in _entityLookup.GetEntitiesInRange(IoCManager.Resolve().GetComponent(comp.Owner).Coordinates, comp.Range)) + foreach (var entity in _entityLookup.GetEntitiesInRange(EntityManager.GetComponent(comp.Owner).Coordinates, comp.Range)) { Flash(entity, args.User, uid, comp.AoeFlashDuration, comp.SlowTo); } @@ -86,7 +86,7 @@ namespace Content.Server.Flash if (comp.HasUses) { // TODO flash visualizer - if (!IoCManager.Resolve().TryGetComponent(comp.Owner, out var sprite)) + if (!EntityManager.TryGetComponent(comp.Owner, out var sprite)) return false; if (--comp.Uses == 0) @@ -149,7 +149,7 @@ namespace Content.Server.Flash foreach (var entity in _entityLookup.GetEntitiesInRange(transform.Coordinates, range)) { - if (!IoCManager.Resolve().HasComponent(entity) || + if (!EntityManager.HasComponent(entity) || !transform.InRangeUnobstructed(entity, range, CollisionGroup.Opaque)) continue; Flash(entity, user, source, duration, slowTo, displayPopup); diff --git a/Content.Server/Gravity/EntitySystems/GravityGeneratorSystem.cs b/Content.Server/Gravity/EntitySystems/GravityGeneratorSystem.cs index 0a618b30b6..832cc917a2 100644 --- a/Content.Server/Gravity/EntitySystems/GravityGeneratorSystem.cs +++ b/Content.Server/Gravity/EntitySystems/GravityGeneratorSystem.cs @@ -184,7 +184,7 @@ namespace Content.Server.Gravity.EntitySystems private void UpdateGravityActive(GravityGeneratorComponent grav, bool shake) { - var gridId = IoCManager.Resolve().GetComponent(grav.Owner).GridID; + var gridId = EntityManager.GetComponent(grav.Owner).GridID; if (gridId == GridId.Invalid) return; diff --git a/Content.Server/Gravity/EntitySystems/GravitySystem.cs b/Content.Server/Gravity/EntitySystems/GravitySystem.cs index ea59f3a9a4..1345b70e1f 100644 --- a/Content.Server/Gravity/EntitySystems/GravitySystem.cs +++ b/Content.Server/Gravity/EntitySystems/GravitySystem.cs @@ -17,12 +17,12 @@ namespace Content.Server.Gravity.EntitySystems private void HandleGravityInitialize(EntityUid uid, GravityComponent component, ComponentInit args) { // Incase there's already a generator on the grid we'll just set it now. - var gridId = IoCManager.Resolve().GetComponent(component.Owner).GridID; + var gridId = EntityManager.GetComponent(component.Owner).GridID; GravityChangedMessage message; foreach (var generator in EntityManager.EntityQuery()) { - if (IoCManager.Resolve().GetComponent(generator.Owner).GridID == gridId && generator.GravityActive) + if (EntityManager.GetComponent(generator.Owner).GridID == gridId && generator.GravityActive) { component.Enabled = true; message = new GravityChangedMessage(gridId, true); @@ -41,7 +41,7 @@ namespace Content.Server.Gravity.EntitySystems if (comp.Enabled) return; comp.Enabled = true; - var gridId = IoCManager.Resolve().GetComponent(comp.Owner).GridID; + var gridId = EntityManager.GetComponent(comp.Owner).GridID; var message = new GravityChangedMessage(gridId, true); RaiseLocalEvent(message); } @@ -51,7 +51,7 @@ namespace Content.Server.Gravity.EntitySystems if (!comp.Enabled) return; comp.Enabled = false; - var gridId = IoCManager.Resolve().GetComponent(comp.Owner).GridID; + var gridId = EntityManager.GetComponent(comp.Owner).GridID; var message = new GravityChangedMessage(gridId, false); RaiseLocalEvent(message); } diff --git a/Content.Server/Labels/Label/HandLabelerSystem.cs b/Content.Server/Labels/Label/HandLabelerSystem.cs index dd500981b3..cc9293922b 100644 --- a/Content.Server/Labels/Label/HandLabelerSystem.cs +++ b/Content.Server/Labels/Label/HandLabelerSystem.cs @@ -53,7 +53,7 @@ namespace Content.Server.Labels LabelComponent label = target.EnsureComponent(); if (label.OriginalName != null) - IoCManager.Resolve().GetComponent(target).EntityName = label.OriginalName; + EntityManager.GetComponent(target).EntityName = label.OriginalName; label.OriginalName = null; if (handLabeler.AssignedLabel == string.Empty) @@ -63,16 +63,16 @@ namespace Content.Server.Labels return; } - label.OriginalName = IoCManager.Resolve().GetComponent(target).EntityName; - string val = IoCManager.Resolve().GetComponent(target).EntityName + $" ({handLabeler.AssignedLabel})"; - IoCManager.Resolve().GetComponent(target).EntityName = val; + label.OriginalName = EntityManager.GetComponent(target).EntityName; + string val = EntityManager.GetComponent(target).EntityName + $" ({handLabeler.AssignedLabel})"; + EntityManager.GetComponent(target).EntityName = val; label.CurrentLabel = handLabeler.AssignedLabel; result = Loc.GetString("hand-labeler-successfully-applied"); } private void OnUseInHand(EntityUid uid, HandLabelerComponent handLabeler, UseInHandEvent args) { - if (!IoCManager.Resolve().TryGetComponent(args.User, out ActorComponent? actor)) + if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) return; handLabeler.Owner.GetUIOrNull(HandLabelerUiKey.Key)?.Open(actor.PlayerSession); diff --git a/Content.Server/Light/EntitySystems/LightReplacerSystem.cs b/Content.Server/Light/EntitySystems/LightReplacerSystem.cs index 48f59c9c47..77a00db063 100644 --- a/Content.Server/Light/EntitySystems/LightReplacerSystem.cs +++ b/Content.Server/Light/EntitySystems/LightReplacerSystem.cs @@ -105,7 +105,7 @@ namespace Content.Server.Light.EntitySystems // try get first inserted bulb of the same type as targeted light fixtutre var bulb = replacer.InsertedBulbs.ContainedEntities.FirstOrDefault( - (e) => IoCManager.Resolve().GetComponentOrNull(e)?.Type == fixture.BulbType); + (e) => EntityManager.GetComponentOrNull(e)?.Type == fixture.BulbType); // found bulb in inserted storage if (bulb != null) @@ -123,7 +123,7 @@ namespace Content.Server.Light.EntitySystems // found right bulb, let's spawn it if (bulbEnt != null) { - bulb = EntityManager.SpawnEntity(bulbEnt.PrototypeName, IoCManager.Resolve().GetComponent(replacer.Owner).Coordinates); + bulb = EntityManager.SpawnEntity(bulbEnt.PrototypeName, EntityManager.GetComponent(replacer.Owner).Coordinates); bulbEnt.Amount--; } // not found any light bulbs diff --git a/Content.Server/Light/EntitySystems/MatchstickSystem.cs b/Content.Server/Light/EntitySystems/MatchstickSystem.cs index 3557453428..67bf4dc3ad 100644 --- a/Content.Server/Light/EntitySystems/MatchstickSystem.cs +++ b/Content.Server/Light/EntitySystems/MatchstickSystem.cs @@ -34,7 +34,7 @@ namespace Content.Server.Light.EntitySystems if (match.CurrentState != SmokableState.Lit) continue; - _atmosphereSystem.HotspotExpose(IoCManager.Resolve().GetComponent(match.Owner).Coordinates, 400, 50, true); + _atmosphereSystem.HotspotExpose(EntityManager.GetComponent(match.Owner).Coordinates, 400, 50, true); } } @@ -84,7 +84,7 @@ namespace Content.Server.Light.EntitySystems component.PointLightComponent.Enabled = component.CurrentState == SmokableState.Lit; } - if (IoCManager.Resolve().TryGetComponent(component.Owner, out ItemComponent? item)) + if (EntityManager.TryGetComponent(component.Owner, out ItemComponent? item)) { switch (component.CurrentState) { @@ -97,7 +97,7 @@ namespace Content.Server.Light.EntitySystems } } - if (IoCManager.Resolve().TryGetComponent(component.Owner, out AppearanceComponent? appearance)) + if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearance)) { appearance.SetData(SmokingVisuals.Smoking, component.CurrentState); } diff --git a/Content.Server/Light/EntitySystems/UnpoweredFlashlightSystem.cs b/Content.Server/Light/EntitySystems/UnpoweredFlashlightSystem.cs index bdaeb2dd3c..09201ecaf2 100644 --- a/Content.Server/Light/EntitySystems/UnpoweredFlashlightSystem.cs +++ b/Content.Server/Light/EntitySystems/UnpoweredFlashlightSystem.cs @@ -37,13 +37,13 @@ namespace Content.Server.Light.EntitySystems public void ToggleLight(UnpoweredFlashlightComponent flashlight) { - if (!IoCManager.Resolve().TryGetComponent(flashlight.Owner, out PointLightComponent? light)) + if (!EntityManager.TryGetComponent(flashlight.Owner, out PointLightComponent? light)) return; flashlight.LightOn = !flashlight.LightOn; light.Enabled = flashlight.LightOn; - if (IoCManager.Resolve().TryGetComponent(flashlight.Owner, out AppearanceComponent? appearance)) + if (EntityManager.TryGetComponent(flashlight.Owner, out AppearanceComponent? appearance)) appearance.SetData(UnpoweredFlashlightVisuals.LightOn, flashlight.LightOn); SoundSystem.Play(Filter.Pvs(light.Owner), flashlight.ToggleSound.GetSound(), flashlight.Owner); diff --git a/Content.Server/Lock/LockSystem.cs b/Content.Server/Lock/LockSystem.cs index 2a676636eb..44948fd3cf 100644 --- a/Content.Server/Lock/LockSystem.cs +++ b/Content.Server/Lock/LockSystem.cs @@ -35,7 +35,7 @@ namespace Content.Server.Lock private void OnStartup(EntityUid uid, LockComponent lockComp, ComponentStartup args) { - if (IoCManager.Resolve().TryGetComponent(lockComp.Owner, out AppearanceComponent? appearance)) + if (EntityManager.TryGetComponent(lockComp.Owner, out AppearanceComponent? appearance)) { appearance.SetData(StorageVisuals.CanLock, true); } @@ -64,7 +64,7 @@ namespace Content.Server.Lock args.PushText(Loc.GetString(lockComp.Locked ? "lock-comp-on-examined-is-locked" : "lock-comp-on-examined-is-unlocked", - ("entityName", Name: IoCManager.Resolve().GetComponent(lockComp.Owner).EntityName))); + ("entityName", Name: EntityManager.GetComponent(lockComp.Owner).EntityName))); } public bool TryLock(EntityUid uid, EntityUid user, LockComponent? lockComp = null) @@ -78,7 +78,7 @@ namespace Content.Server.Lock if (!HasUserAccess(uid, user, quiet: false)) return false; - lockComp.Owner.PopupMessage(user, Loc.GetString("lock-comp-do-lock-success", ("entityName",Name: IoCManager.Resolve().GetComponent(lockComp.Owner).EntityName))); + lockComp.Owner.PopupMessage(user, Loc.GetString("lock-comp-do-lock-success", ("entityName",Name: EntityManager.GetComponent(lockComp.Owner).EntityName))); lockComp.Locked = true; if(lockComp.LockSound != null) @@ -86,7 +86,7 @@ namespace Content.Server.Lock SoundSystem.Play(Filter.Pvs(lockComp.Owner), lockComp.LockSound.GetSound(), lockComp.Owner, AudioParams.Default.WithVolume(-5)); } - if (IoCManager.Resolve().TryGetComponent(lockComp.Owner, out AppearanceComponent? appearanceComp)) + if (EntityManager.TryGetComponent(lockComp.Owner, out AppearanceComponent? appearanceComp)) { appearanceComp.SetData(StorageVisuals.Locked, true); } @@ -107,7 +107,7 @@ namespace Content.Server.Lock if (!HasUserAccess(uid, user, quiet: false)) return false; - lockComp.Owner.PopupMessage(user, Loc.GetString("lock-comp-do-unlock-success", ("entityName", Name: IoCManager.Resolve().GetComponent(lockComp.Owner).EntityName))); + lockComp.Owner.PopupMessage(user, Loc.GetString("lock-comp-do-unlock-success", ("entityName", Name: EntityManager.GetComponent(lockComp.Owner).EntityName))); lockComp.Locked = false; if(lockComp.UnlockSound != null) @@ -115,7 +115,7 @@ namespace Content.Server.Lock SoundSystem.Play(Filter.Pvs(lockComp.Owner), lockComp.UnlockSound.GetSound(), lockComp.Owner, AudioParams.Default.WithVolume(-5)); } - if (IoCManager.Resolve().TryGetComponent(lockComp.Owner, out AppearanceComponent? appearanceComp)) + if (EntityManager.TryGetComponent(lockComp.Owner, out AppearanceComponent? appearanceComp)) { appearanceComp.SetData(StorageVisuals.Locked, false); } diff --git a/Content.Server/Medical/MedicalScannerSystem.cs b/Content.Server/Medical/MedicalScannerSystem.cs index 783e8ae7c0..1e69034e91 100644 --- a/Content.Server/Medical/MedicalScannerSystem.cs +++ b/Content.Server/Medical/MedicalScannerSystem.cs @@ -38,7 +38,7 @@ namespace Content.Server.Medical Verb verb = new(); verb.Act = () => component.InsertBody(args.Using.Value); verb.Category = VerbCategory.Insert; - verb.Text = IoCManager.Resolve().GetComponent(args.Using.Value).EntityName; + verb.Text = EntityManager.GetComponent(args.Using.Value).EntityName; args.Verbs.Add(verb); } diff --git a/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs b/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs index 41e2e5bde4..2d50fef708 100644 --- a/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/CreamPieSystem.cs @@ -27,7 +27,7 @@ namespace Content.Server.Nutrition.EntitySystems { SoundSystem.Play(Filter.Pvs(creamPie.Owner), creamPie.Sound.GetSound(), creamPie.Owner, AudioHelpers.WithVariation(0.125f)); - if (IoCManager.Resolve().TryGetComponent(creamPie.Owner, out var foodComp) && _solutionsSystem.TryGetSolution(creamPie.Owner, foodComp.SolutionName, out var solution)) + if (EntityManager.TryGetComponent(creamPie.Owner, out var foodComp) && _solutionsSystem.TryGetSolution(creamPie.Owner, foodComp.SolutionName, out var solution)) { _spillableSystem.SpillAt(creamPie.Owner, solution, "PuddleSmear", false); } diff --git a/Content.Server/Nutrition/EntitySystems/UtensilSystem.cs b/Content.Server/Nutrition/EntitySystems/UtensilSystem.cs index af744699a8..7ab9b73f48 100644 --- a/Content.Server/Nutrition/EntitySystems/UtensilSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/UtensilSystem.cs @@ -70,7 +70,7 @@ namespace Content.Server.Nutrition.EntitySystems if (_robustRandom.Prob(component.BreakChance)) { SoundSystem.Play(Filter.Pvs(userUid), component.BreakSound.GetSound(), userUid, AudioParams.Default.WithVolume(-2f)); - IoCManager.Resolve().DeleteEntity(component.Owner); + EntityManager.DeleteEntity(component.Owner); } } } diff --git a/Content.Server/PAI/PAISystem.cs b/Content.Server/PAI/PAISystem.cs index 1f469db7df..0908fa117e 100644 --- a/Content.Server/PAI/PAISystem.cs +++ b/Content.Server/PAI/PAISystem.cs @@ -74,7 +74,7 @@ namespace Content.Server.PAI // Ownership tag string val = Loc.GetString("pai-system-pai-name", ("owner", args.User)); - IoCManager.Resolve().GetComponent(component.Owner).EntityName = val; + EntityManager.GetComponent(component.Owner).EntityName = val; var ghostFinder = EntityManager.EnsureComponent(uid); diff --git a/Content.Server/PDA/PDASystem.cs b/Content.Server/PDA/PDASystem.cs index ee435ccd8a..5c95c183d3 100644 --- a/Content.Server/PDA/PDASystem.cs +++ b/Content.Server/PDA/PDASystem.cs @@ -73,7 +73,7 @@ namespace Content.Server.PDA private void OnItemInserted(EntityUid uid, PDAComponent pda, EntInsertedIntoContainerMessage args) { if (args.Container.ID == pda.IdSlot.ID) - pda.ContainedID = IoCManager.Resolve().GetComponentOrNull(args.Entity); + pda.ContainedID = EntityManager.GetComponentOrNull(args.Entity); UpdatePDAAppearance(pda); UpdatePDAUserInterface(pda); @@ -112,7 +112,7 @@ namespace Content.Server.PDA private bool OpenUI(PDAComponent pda, EntityUid user) { - if (!IoCManager.Resolve().TryGetComponent(user, out ActorComponent? actor)) + if (!EntityManager.TryGetComponent(user, out ActorComponent? actor)) return false; var ui = pda.Owner.GetUIOrNull(PDAUiKey.Key); @@ -123,7 +123,7 @@ namespace Content.Server.PDA private void UpdatePDAAppearance(PDAComponent pda) { - if (IoCManager.Resolve().TryGetComponent(pda.Owner, out AppearanceComponent? appearance)) + if (EntityManager.TryGetComponent(pda.Owner, out AppearanceComponent? appearance)) appearance.SetData(PDAVisuals.IDCardInserted, pda.ContainedID != null); } @@ -136,7 +136,7 @@ namespace Content.Server.PDA JobTitle = pda.ContainedID?.JobTitle }; - var hasUplink = IoCManager.Resolve().HasComponent(pda.Owner); + var hasUplink = EntityManager.HasComponent(pda.Owner); var ui = pda.Owner.GetUIOrNull(PDAUiKey.Key); ui?.SetState(new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo, hasUplink)); @@ -155,7 +155,7 @@ namespace Content.Server.PDA break; case PDAToggleFlashlightMessage _: { - if (IoCManager.Resolve().TryGetComponent(pda.Owner, out UnpoweredFlashlightComponent? flashlight)) + if (EntityManager.TryGetComponent(pda.Owner, out UnpoweredFlashlightComponent? flashlight)) _unpoweredFlashlight.ToggleLight(flashlight); break; } @@ -172,7 +172,7 @@ namespace Content.Server.PDA } case PDAShowUplinkMessage _: { - if (IoCManager.Resolve().TryGetComponent(pda.Owner, out UplinkComponent? uplink)) + if (EntityManager.TryGetComponent(pda.Owner, out UplinkComponent? uplink)) _uplinkSystem.ToggleUplinkUI(uplink, msg.Session); break; } diff --git a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorPartSystem.cs b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorPartSystem.cs index a1743c0403..b3ffd9d4bc 100644 --- a/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorPartSystem.cs +++ b/Content.Server/ParticleAccelerator/EntitySystems/ParticleAcceleratorPartSystem.cs @@ -26,7 +26,7 @@ namespace Content.Server.ParticleAccelerator.EntitySystems private static void RotateEvent(ref RotateEvent ev) { - if (IoCManager.Resolve().TryGetComponent(ev.Sender, out ParticleAcceleratorPartComponent? part)) + if (EntityManager.TryGetComponent(ev.Sender, out ParticleAcceleratorPartComponent? part)) { part.Rotated(); } diff --git a/Content.Server/Pinpointer/ServerPinpointerSystem.cs b/Content.Server/Pinpointer/ServerPinpointerSystem.cs index 82f57cb000..2ed782176e 100644 --- a/Content.Server/Pinpointer/ServerPinpointerSystem.cs +++ b/Content.Server/Pinpointer/ServerPinpointerSystem.cs @@ -62,7 +62,7 @@ namespace Content.Server.Pinpointer { if (whitelist.IsValid(e)) { - var dist = (IoCManager.Resolve().GetComponent(e).WorldPosition - transform.WorldPosition).LengthSquared; + var dist = (EntityManager.GetComponent(e).WorldPosition - transform.WorldPosition).LengthSquared; l.TryAdd(dist, e); } } diff --git a/Content.Server/Pointing/EntitySystems/RoguePointingSystem.cs b/Content.Server/Pointing/EntitySystems/RoguePointingSystem.cs index c21db27180..3bfea1b949 100644 --- a/Content.Server/Pointing/EntitySystems/RoguePointingSystem.cs +++ b/Content.Server/Pointing/EntitySystems/RoguePointingSystem.cs @@ -78,7 +78,7 @@ namespace Content.Server.Pointing.EntitySystems if (component.TurningDelay > 0) { - var difference = IoCManager.Resolve().GetComponent(chasing).WorldPosition - transform.WorldPosition; + var difference = EntityManager.GetComponent(chasing).WorldPosition - transform.WorldPosition; var angle = difference.ToAngle(); var adjusted = angle.Degrees + 90; var newAngle = Angle.FromDegrees(adjusted); @@ -93,7 +93,7 @@ namespace Content.Server.Pointing.EntitySystems UpdateAppearance(uid, component, transform); - var toChased = IoCManager.Resolve().GetComponent(chasing).WorldPosition - transform.WorldPosition; + var toChased = EntityManager.GetComponent(chasing).WorldPosition - transform.WorldPosition; transform.WorldPosition += toChased * frameTime * component.ChasingSpeed; diff --git a/Content.Server/Power/EntitySystems/BaseChargerSystem.cs b/Content.Server/Power/EntitySystems/BaseChargerSystem.cs index fe75406d6f..a7aafce0e4 100644 --- a/Content.Server/Power/EntitySystems/BaseChargerSystem.cs +++ b/Content.Server/Power/EntitySystems/BaseChargerSystem.cs @@ -43,7 +43,7 @@ namespace Content.Server.Power.EntitySystems return; Verb verb = new(); - verb.Text = IoCManager.Resolve().GetComponent(component.Container.ContainedEntity!.Value).EntityName; + verb.Text = EntityManager.GetComponent(component.Container.ContainedEntity!.Value).EntityName; verb.Category = VerbCategory.Eject; verb.Act = () => component.RemoveItem(args.User); args.Verbs.Add(verb); @@ -60,7 +60,7 @@ namespace Content.Server.Power.EntitySystems return; Verb verb = new(); - verb.Text = IoCManager.Resolve().GetComponent(@using).EntityName; + verb.Text = EntityManager.GetComponent(@using).EntityName; verb.Category = VerbCategory.Insert; verb.Act = () => component.TryInsertItem(@using); args.Verbs.Add(verb); diff --git a/Content.Server/Power/EntitySystems/CableMultitoolSystem.cs b/Content.Server/Power/EntitySystems/CableMultitoolSystem.cs index 0ab5d77913..bbcc87d782 100644 --- a/Content.Server/Power/EntitySystems/CableMultitoolSystem.cs +++ b/Content.Server/Power/EntitySystems/CableMultitoolSystem.cs @@ -43,7 +43,7 @@ namespace Content.Server.Power.EntitySystems if (args.IsInDetailsRange) { // Determine if they are holding a multitool. - if (IoCManager.Resolve().TryGetComponent(args.Examiner, out var hands) && hands.TryGetActiveHand(out var hand)) + if (EntityManager.TryGetComponent(args.Examiner, out var hands) && hands.TryGetActiveHand(out var hand)) { var held = hand.HeldEntity; // Pulsing is hardcoded here because I don't think it needs to be more complex than that right now. diff --git a/Content.Server/Power/EntitySystems/CableVisSystem.cs b/Content.Server/Power/EntitySystems/CableVisSystem.cs index 0ef104f270..5ed4866f76 100644 --- a/Content.Server/Power/EntitySystems/CableVisSystem.cs +++ b/Content.Server/Power/EntitySystems/CableVisSystem.cs @@ -63,7 +63,7 @@ namespace Content.Server.Power.EntitySystems if (reachable is not CableNode) continue; - var otherTransform = IoCManager.Resolve().GetComponent(reachable.Owner); + var otherTransform = EntityManager.GetComponent(reachable.Owner); if (otherTransform.GridID != grid.Index) continue; diff --git a/Content.Server/Power/EntitySystems/ExtensionCableSystem.cs b/Content.Server/Power/EntitySystems/ExtensionCableSystem.cs index 468c1f9f24..362908c9e4 100644 --- a/Content.Server/Power/EntitySystems/ExtensionCableSystem.cs +++ b/Content.Server/Power/EntitySystems/ExtensionCableSystem.cs @@ -85,7 +85,7 @@ namespace Content.Server.Power.EntitySystems if (EntityManager.TryGetComponent(entity, out var receiver) && receiver.Connectable && receiver.Provider == null && - IoCManager.Resolve().GetComponent(entity).Coordinates.TryDistance(IoCManager.Resolve(), IoCManager.Resolve().GetComponent(owner).Coordinates, out var distance) && + EntityManager.GetComponent(entity).Coordinates.TryDistance(EntityManager, EntityManager.GetComponent(owner).Coordinates, out var distance) && distance < Math.Min(range, receiver.ReceptionRange)) { yield return receiver; @@ -118,7 +118,7 @@ namespace Content.Server.Power.EntitySystems private void OnReceiverStarted(EntityUid uid, ExtensionCableReceiverComponent receiver, ComponentStartup args) { - if (IoCManager.Resolve().TryGetComponent(receiver.Owner, out PhysicsComponent? physicsComponent)) + if (EntityManager.TryGetComponent(receiver.Owner, out PhysicsComponent? physicsComponent)) { receiver.Connectable = physicsComponent.BodyType == BodyType.Static; } @@ -179,11 +179,11 @@ namespace Content.Server.Power.EntitySystems foreach (var entity in nearbyEntities) { - if (!IoCManager.Resolve().TryGetComponent(entity, out var provider)) continue; + if (!EntityManager.TryGetComponent(entity, out var provider)) continue; if (!provider.Connectable) continue; - if (!IoCManager.Resolve().GetComponent(entity).Coordinates.TryDistance(IoCManager.Resolve(), IoCManager.Resolve().GetComponent(owner).Coordinates, out var distance)) continue; + if (!EntityManager.GetComponent(entity).Coordinates.TryDistance(EntityManager, EntityManager.GetComponent(owner).Coordinates, out var distance)) continue; if (!(distance < Math.Min(range, provider.TransferRange))) continue; diff --git a/Content.Server/Power/EntitySystems/PowerNetSystem.cs b/Content.Server/Power/EntitySystems/PowerNetSystem.cs index 578021ac71..bef1c9b25e 100644 --- a/Content.Server/Power/EntitySystems/PowerNetSystem.cs +++ b/Content.Server/Power/EntitySystems/PowerNetSystem.cs @@ -343,7 +343,7 @@ namespace Content.Server.Power.EntitySystems foreach (var apc in net.Apcs) { - var netBattery = IoCManager.Resolve().GetComponent(apc.Owner); + var netBattery = EntityManager.GetComponent(apc.Owner); netNode.BatteriesDischarging.Add(netBattery.NetworkBattery.Id); netBattery.NetworkBattery.LinkedNetworkDischarging = netNode.Id; } @@ -372,14 +372,14 @@ namespace Content.Server.Power.EntitySystems foreach (var charger in net.Chargers) { - var battery = IoCManager.Resolve().GetComponent(charger.Owner); + var battery = EntityManager.GetComponent(charger.Owner); netNode.BatteriesCharging.Add(battery.NetworkBattery.Id); battery.NetworkBattery.LinkedNetworkCharging = netNode.Id; } foreach (var discharger in net.Dischargers) { - var battery = IoCManager.Resolve().GetComponent(discharger.Owner); + var battery = EntityManager.GetComponent(discharger.Owner); netNode.BatteriesDischarging.Add(battery.NetworkBattery.Id); battery.NetworkBattery.LinkedNetworkDischarging = netNode.Id; } diff --git a/Content.Server/PowerCell/PowerCellSystem.cs b/Content.Server/PowerCell/PowerCellSystem.cs index a7950fcb39..422025d370 100644 --- a/Content.Server/PowerCell/PowerCellSystem.cs +++ b/Content.Server/PowerCell/PowerCellSystem.cs @@ -47,12 +47,12 @@ namespace Content.Server.PowerCell !args.CanAccess || !args.CanInteract || component.HasCell || - !IoCManager.Resolve().HasComponent(@using) || + !EntityManager.HasComponent(@using) || !_actionBlockerSystem.CanDrop(args.User)) return; Verb verb = new(); - verb.Text = IoCManager.Resolve().GetComponent(@using).EntityName; + verb.Text = EntityManager.GetComponent(@using).EntityName; verb.Category = VerbCategory.Insert; verb.Act = () => component.InsertCell(@using); args.Verbs.Add(verb); diff --git a/Content.Server/Projectiles/ProjectileSystem.cs b/Content.Server/Projectiles/ProjectileSystem.cs index 631a0d20f9..8ae66eaca5 100644 --- a/Content.Server/Projectiles/ProjectileSystem.cs +++ b/Content.Server/Projectiles/ProjectileSystem.cs @@ -35,11 +35,11 @@ namespace Content.Server.Projectiles var otherEntity = args.OtherFixture.Body.Owner; - var coordinates = IoCManager.Resolve().GetComponent(args.OtherFixture.Body.Owner).Coordinates; + var coordinates = EntityManager.GetComponent(args.OtherFixture.Body.Owner).Coordinates; var playerFilter = Filter.Pvs(coordinates); if (!EntityManager.GetComponent(otherEntity).EntityDeleted && component.SoundHitSpecies != null && - IoCManager.Resolve().HasComponent(otherEntity)) + EntityManager.HasComponent(otherEntity)) { SoundSystem.Play(playerFilter, component.SoundHitSpecies.GetSound(), coordinates); } @@ -83,7 +83,7 @@ namespace Content.Server.Projectiles if (component.TimeLeft <= 0) { - IoCManager.Resolve().DeleteEntity(component.Owner); + EntityManager.DeleteEntity(component.Owner); } } } diff --git a/Content.Server/RCD/Systems/RCDSystem.cs b/Content.Server/RCD/Systems/RCDSystem.cs index b915ed892d..a26afd0556 100644 --- a/Content.Server/RCD/Systems/RCDSystem.cs +++ b/Content.Server/RCD/Systems/RCDSystem.cs @@ -128,11 +128,11 @@ namespace Content.Server.RCD.Systems // thus we early return to avoid the tile set code. case RcdMode.Walls: var ent = EntityManager.SpawnEntity("WallSolid", mapGrid.GridTileToLocal(snapPos)); - IoCManager.Resolve().GetComponent(ent).LocalRotation = Angle.Zero; // Walls always need to point south. + EntityManager.GetComponent(ent).LocalRotation = Angle.Zero; // Walls always need to point south. break; case RcdMode.Airlock: var airlock = EntityManager.SpawnEntity("Airlock", mapGrid.GridTileToLocal(snapPos)); - IoCManager.Resolve().GetComponent(airlock).LocalRotation = IoCManager.Resolve().GetComponent(rcd.Owner).LocalRotation; //Now apply icon smoothing. + EntityManager.GetComponent(airlock).LocalRotation = EntityManager.GetComponent(rcd.Owner).LocalRotation; //Now apply icon smoothing. break; default: args.Handled = true; diff --git a/Content.Server/Recycling/RecyclerSystem.cs b/Content.Server/Recycling/RecyclerSystem.cs index ea404ca977..58424d91ba 100644 --- a/Content.Server/Recycling/RecyclerSystem.cs +++ b/Content.Server/Recycling/RecyclerSystem.cs @@ -26,12 +26,12 @@ namespace Content.Server.Recycling // TODO: Prevent collision with recycled items // Can only recycle things that are recyclable... And also check the safety of the thing to recycle. - if (!IoCManager.Resolve().TryGetComponent(entity, out RecyclableComponent? recyclable) || !recyclable.Safe && component.Safe) return; + if (!EntityManager.TryGetComponent(entity, out RecyclableComponent? recyclable) || !recyclable.Safe && component.Safe) return; // Mobs are a special case! if (CanGib(component, entity)) { - IoCManager.Resolve().GetComponent(entity).Gib(true); + EntityManager.GetComponent(entity).Gib(true); Bloodstain(component); return; } @@ -42,13 +42,13 @@ namespace Content.Server.Recycling private bool CanGib(RecyclerComponent component, EntityUid entity) { // We suppose this entity has a Recyclable component. - return IoCManager.Resolve().HasComponent(entity) && !component.Safe && - IoCManager.Resolve().TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver) && receiver.Powered; + return EntityManager.HasComponent(entity) && !component.Safe && + EntityManager.TryGetComponent(component.Owner, out ApcPowerReceiverComponent? receiver) && receiver.Powered; } public void Bloodstain(RecyclerComponent component) { - if (IoCManager.Resolve().TryGetComponent(component.Owner, out AppearanceComponent? appearance)) + if (EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearance)) { appearance.SetData(RecyclerVisuals.Bloody, true); } diff --git a/Content.Server/Repairable/RepairableSystem.cs b/Content.Server/Repairable/RepairableSystem.cs index 4a5b675dbe..f331280403 100644 --- a/Content.Server/Repairable/RepairableSystem.cs +++ b/Content.Server/Repairable/RepairableSystem.cs @@ -27,7 +27,7 @@ namespace Content.Server.Repairable public async void Repair(EntityUid uid, RepairableComponent component, InteractUsingEvent args) { // Only try repair the target if it is damaged - if (!IoCManager.Resolve().TryGetComponent(component.Owner, out DamageableComponent? damageable) || damageable.TotalDamage == 0) + if (!EntityManager.TryGetComponent(component.Owner, out DamageableComponent? damageable) || damageable.TotalDamage == 0) return; // Can the tool actually repair this, does it have enough fuel? diff --git a/Content.Server/Rotatable/RotatableSystem.cs b/Content.Server/Rotatable/RotatableSystem.cs index d60b844f17..968a421e1f 100644 --- a/Content.Server/Rotatable/RotatableSystem.cs +++ b/Content.Server/Rotatable/RotatableSystem.cs @@ -39,12 +39,12 @@ namespace Content.Server.Rotatable // Check if the object is anchored, and whether we are still allowed to rotate it. if (!component.RotateWhileAnchored && - IoCManager.Resolve().TryGetComponent(component.Owner, out IPhysBody? physics) && + EntityManager.TryGetComponent(component.Owner, out IPhysBody? physics) && physics.BodyType == BodyType.Static) return; Verb resetRotation = new(); - resetRotation.Act = () => IoCManager.Resolve().GetComponent(component.Owner).LocalRotation = Angle.Zero; + resetRotation.Act = () => EntityManager.GetComponent(component.Owner).LocalRotation = Angle.Zero; resetRotation.Category = VerbCategory.Rotate; resetRotation.IconTexture = "/Textures/Interface/VerbIcons/refresh.svg.192dpi.png"; resetRotation.Text = "Reset"; @@ -54,7 +54,7 @@ namespace Content.Server.Rotatable // rotate clockwise Verb rotateCW = new(); - rotateCW.Act = () => IoCManager.Resolve().GetComponent(component.Owner).LocalRotation += Angle.FromDegrees(-90); + rotateCW.Act = () => EntityManager.GetComponent(component.Owner).LocalRotation += Angle.FromDegrees(-90); rotateCW.Category = VerbCategory.Rotate; rotateCW.IconTexture = "/Textures/Interface/VerbIcons/rotate_cw.svg.192dpi.png"; rotateCW.Priority = -1; @@ -63,7 +63,7 @@ namespace Content.Server.Rotatable // rotate counter-clockwise Verb rotateCCW = new(); - rotateCCW.Act = () => IoCManager.Resolve().GetComponent(component.Owner).LocalRotation += Angle.FromDegrees(90); + rotateCCW.Act = () => EntityManager.GetComponent(component.Owner).LocalRotation += Angle.FromDegrees(90); rotateCCW.Category = VerbCategory.Rotate; rotateCCW.IconTexture = "/Textures/Interface/VerbIcons/rotate_ccw.svg.192dpi.png"; rotateCCW.Priority = 0; @@ -76,19 +76,19 @@ namespace Content.Server.Rotatable /// public static void TryFlip(FlippableComponent component, EntityUid user) { - if (IoCManager.Resolve().TryGetComponent(component.Owner, out IPhysBody? physics) && + if (EntityManager.TryGetComponent(component.Owner, out IPhysBody? physics) && physics.BodyType == BodyType.Static) { component.Owner.PopupMessage(user, Loc.GetString("flippable-component-try-flip-is-stuck")); return; } - var oldTransform = IoCManager.Resolve().GetComponent(component.Owner); - var entity = IoCManager.Resolve().SpawnEntity(component.MirrorEntity, oldTransform.Coordinates); - var newTransform = IoCManager.Resolve().GetComponent(entity); + var oldTransform = EntityManager.GetComponent(component.Owner); + var entity = EntityManager.SpawnEntity(component.MirrorEntity, oldTransform.Coordinates); + var newTransform = EntityManager.GetComponent(entity); newTransform.LocalRotation = oldTransform.LocalRotation; newTransform.Anchored = false; - IoCManager.Resolve().DeleteEntity(component.Owner); + EntityManager.DeleteEntity(component.Owner); } } } diff --git a/Content.Server/Security/Systems/DeployableBarrierSystem.cs b/Content.Server/Security/Systems/DeployableBarrierSystem.cs index 316a324d30..2420b66f91 100644 --- a/Content.Server/Security/Systems/DeployableBarrierSystem.cs +++ b/Content.Server/Security/Systems/DeployableBarrierSystem.cs @@ -19,7 +19,7 @@ namespace Content.Server.Security.Systems private void OnStartup(EntityUid uid, DeployableBarrierComponent component, ComponentStartup args) { - if (!IoCManager.Resolve().TryGetComponent(component.Owner, out LockComponent? lockComponent)) + if (!EntityManager.TryGetComponent(component.Owner, out LockComponent? lockComponent)) return; ToggleBarrierDeploy(component, lockComponent.Locked); @@ -32,15 +32,15 @@ namespace Content.Server.Security.Systems private void ToggleBarrierDeploy(DeployableBarrierComponent component, bool isDeployed) { - IoCManager.Resolve().GetComponent(component.Owner).Anchored = isDeployed; + EntityManager.GetComponent(component.Owner).Anchored = isDeployed; - if (!IoCManager.Resolve().TryGetComponent(component.Owner, out AppearanceComponent? appearanceComponent)) + if (!EntityManager.TryGetComponent(component.Owner, out AppearanceComponent? appearanceComponent)) return; var state = isDeployed ? DeployableBarrierState.Deployed : DeployableBarrierState.Idle; appearanceComponent.SetData(DeployableBarrierVisuals.State, state); - if (IoCManager.Resolve().TryGetComponent(component.Owner, out PointLightComponent? light)) + if (EntityManager.TryGetComponent(component.Owner, out PointLightComponent? light)) light.Enabled = isDeployed; } } diff --git a/Content.Server/Shuttles/EntitySystems/ShuttleConsoleSystem.cs b/Content.Server/Shuttles/EntitySystems/ShuttleConsoleSystem.cs index a0d229f165..5e879cdbc7 100644 --- a/Content.Server/Shuttles/EntitySystems/ShuttleConsoleSystem.cs +++ b/Content.Server/Shuttles/EntitySystems/ShuttleConsoleSystem.cs @@ -133,7 +133,7 @@ namespace Content.Server.Shuttles.EntitySystems public void AddPilot(EntityUid entity, ShuttleConsoleComponent component) { if (!_blocker.CanInteract(entity) || - !IoCManager.Resolve().TryGetComponent(entity, out PilotComponent? pilotComponent) || + !EntityManager.TryGetComponent(entity, out PilotComponent? pilotComponent) || component.SubscribedPilots.Contains(pilotComponent)) { return; @@ -141,7 +141,7 @@ namespace Content.Server.Shuttles.EntitySystems component.SubscribedPilots.Add(pilotComponent); - if (IoCManager.Resolve().TryGetComponent(entity, out ServerAlertsComponent? alertsComponent)) + if (EntityManager.TryGetComponent(entity, out ServerAlertsComponent? alertsComponent)) { alertsComponent.ShowAlert(AlertType.PilotingShuttle); } @@ -163,7 +163,7 @@ namespace Content.Server.Shuttles.EntitySystems if (!helmsman.SubscribedPilots.Remove(pilotComponent)) return; - if (IoCManager.Resolve().TryGetComponent(pilotComponent.Owner, out ServerAlertsComponent? alertsComponent)) + if (EntityManager.TryGetComponent(pilotComponent.Owner, out ServerAlertsComponent? alertsComponent)) { alertsComponent.ClearAlert(AlertType.PilotingShuttle); } @@ -176,7 +176,7 @@ namespace Content.Server.Shuttles.EntitySystems public void RemovePilot(EntityUid entity) { - if (!IoCManager.Resolve().TryGetComponent(entity, out PilotComponent? pilotComponent)) return; + if (!EntityManager.TryGetComponent(entity, out PilotComponent? pilotComponent)) return; RemovePilot(pilotComponent); } diff --git a/Content.Server/Shuttles/EntitySystems/ShuttleSystem.cs b/Content.Server/Shuttles/EntitySystems/ShuttleSystem.cs index 646e2e0646..d88cb99cee 100644 --- a/Content.Server/Shuttles/EntitySystems/ShuttleSystem.cs +++ b/Content.Server/Shuttles/EntitySystems/ShuttleSystem.cs @@ -57,12 +57,12 @@ namespace Content.Server.Shuttles.EntitySystems private void OnShuttleStartup(EntityUid uid, ShuttleComponent component, ComponentStartup args) { - if (!IoCManager.Resolve().HasComponent(component.Owner)) + if (!EntityManager.HasComponent(component.Owner)) { return; } - if (!IoCManager.Resolve().TryGetComponent(component.Owner, out PhysicsComponent? physicsComponent)) + if (!EntityManager.TryGetComponent(component.Owner, out PhysicsComponent? physicsComponent)) { return; } @@ -75,7 +75,7 @@ namespace Content.Server.Shuttles.EntitySystems public void Toggle(ShuttleComponent component) { - if (!IoCManager.Resolve().TryGetComponent(component.Owner, out PhysicsComponent? physicsComponent)) return; + if (!EntityManager.TryGetComponent(component.Owner, out PhysicsComponent? physicsComponent)) return; component.Enabled = !component.Enabled; @@ -111,7 +111,7 @@ namespace Content.Server.Shuttles.EntitySystems // None of the below is necessary for any cleanup if we're just deleting. if (EntityManager.GetComponent(uid).EntityLifeStage >= EntityLifeStage.Terminating) return; - if (!IoCManager.Resolve().TryGetComponent(component.Owner, out PhysicsComponent? physicsComponent)) + if (!EntityManager.TryGetComponent(component.Owner, out PhysicsComponent? physicsComponent)) { return; } diff --git a/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs b/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs index a961df7d48..373d44dfbf 100644 --- a/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs +++ b/Content.Server/Singularity/EntitySystems/ContainmentFieldGeneratorSystem.cs @@ -22,7 +22,7 @@ namespace Content.Server.Singularity.EntitySystems private void HandleParticleCollide(EntityUid uid, ParticleProjectileComponent component, StartCollideEvent args) { - if (IoCManager.Resolve().TryGetComponent(args.OtherFixture.Body.Owner, out var singularityGeneratorComponent)) + if (EntityManager.TryGetComponent(args.OtherFixture.Body.Owner, out var singularityGeneratorComponent)) { singularityGeneratorComponent.Power += component.State switch { diff --git a/Content.Server/Singularity/EntitySystems/EmitterSystem.cs b/Content.Server/Singularity/EntitySystems/EmitterSystem.cs index 1d6f639009..e68c227a1a 100644 --- a/Content.Server/Singularity/EntitySystems/EmitterSystem.cs +++ b/Content.Server/Singularity/EntitySystems/EmitterSystem.cs @@ -44,7 +44,7 @@ namespace Content.Server.Singularity.EntitySystems return; } - if (IoCManager.Resolve().TryGetComponent(component.Owner, out PhysicsComponent? phys) && phys.BodyType == BodyType.Static) + if (EntityManager.TryGetComponent(component.Owner, out PhysicsComponent? phys) && phys.BodyType == BodyType.Static) { if (!component.IsOn) { @@ -166,9 +166,9 @@ namespace Content.Server.Singularity.EntitySystems private void Fire(EmitterComponent component) { - var projectile = IoCManager.Resolve().SpawnEntity(component.BoltType, IoCManager.Resolve().GetComponent(component.Owner).Coordinates); + var projectile = EntityManager.SpawnEntity(component.BoltType, EntityManager.GetComponent(component.Owner).Coordinates); - if (!IoCManager.Resolve().TryGetComponent(projectile, out var physicsComponent)) + if (!EntityManager.TryGetComponent(projectile, out var physicsComponent)) { Logger.Error("Emitter tried firing a bolt, but it was spawned without a PhysicsComponent"); return; @@ -176,7 +176,7 @@ namespace Content.Server.Singularity.EntitySystems physicsComponent.BodyStatus = BodyStatus.InAir; - if (!IoCManager.Resolve().TryGetComponent(projectile, out var projectileComponent)) + if (!EntityManager.TryGetComponent(projectile, out var projectileComponent)) { Logger.Error("Emitter tried firing a bolt, but it was spawned without a ProjectileComponent"); return; @@ -185,11 +185,11 @@ namespace Content.Server.Singularity.EntitySystems projectileComponent.IgnoreEntity(component.Owner); physicsComponent - .LinearVelocity = IoCManager.Resolve().GetComponent(component.Owner).WorldRotation.ToWorldVec() * 20f; - IoCManager.Resolve().GetComponent(projectile).WorldRotation = IoCManager.Resolve().GetComponent(component.Owner).WorldRotation; + .LinearVelocity = EntityManager.GetComponent(component.Owner).WorldRotation.ToWorldVec() * 20f; + EntityManager.GetComponent(projectile).WorldRotation = EntityManager.GetComponent(component.Owner).WorldRotation; // TODO: Move to projectile's code. - Timer.Spawn(3000, () => IoCManager.Resolve().DeleteEntity(projectile)); + Timer.Spawn(3000, () => EntityManager.DeleteEntity(projectile)); SoundSystem.Play(Filter.Pvs(component.Owner), component.FireSound.GetSound(), component.Owner, AudioHelpers.WithVariation(EmitterComponent.Variation).WithVolume(EmitterComponent.Volume).WithMaxDistance(EmitterComponent.Distance)); diff --git a/Content.Server/Singularity/EntitySystems/SingularitySystem.cs b/Content.Server/Singularity/EntitySystems/SingularitySystem.cs index a080ca4eef..ed128475d6 100644 --- a/Content.Server/Singularity/EntitySystems/SingularitySystem.cs +++ b/Content.Server/Singularity/EntitySystems/SingularitySystem.cs @@ -82,7 +82,7 @@ namespace Content.Server.Singularity.EntitySystems { if (component.BeingDeletedByAnotherSingularity) return; - var worldPos = IoCManager.Resolve().GetComponent(component.Owner).WorldPosition; + var worldPos = EntityManager.GetComponent(component.Owner).WorldPosition; DestroyEntities(component, worldPos); DestroyTiles(component, worldPos); PullEntities(component, worldPos); @@ -102,10 +102,10 @@ namespace Content.Server.Singularity.EntitySystems private bool CanDestroy(SharedSingularityComponent component, EntityUid entity) { return entity == component.Owner || - IoCManager.Resolve().HasComponent(entity) || - IoCManager.Resolve().HasComponent(entity) || - IoCManager.Resolve().HasComponent(entity) || - IoCManager.Resolve().HasComponent(entity); + EntityManager.HasComponent(entity) || + EntityManager.HasComponent(entity) || + EntityManager.HasComponent(entity) || + EntityManager.HasComponent(entity); } private void HandleDestroy(ServerSingularityComponent component, EntityUid entity) @@ -114,7 +114,7 @@ namespace Content.Server.Singularity.EntitySystems if (CanDestroy(component, entity)) return; // Singularity priority management / etc. - if (IoCManager.Resolve().TryGetComponent(entity, out var otherSingulo)) + if (EntityManager.TryGetComponent(entity, out var otherSingulo)) { // MERGE if (!otherSingulo.BeingDeletedByAnotherSingularity) @@ -125,9 +125,9 @@ namespace Content.Server.Singularity.EntitySystems otherSingulo.BeingDeletedByAnotherSingularity = true; } - IoCManager.Resolve().QueueDeleteEntity(entity); + EntityManager.QueueDeleteEntity(entity); - if (IoCManager.Resolve().TryGetComponent(entity, out var singuloFood)) + if (EntityManager.TryGetComponent(entity, out var singuloFood)) component.Energy += singuloFood.Energy; else component.Energy++; @@ -141,7 +141,7 @@ namespace Content.Server.Singularity.EntitySystems // The reason we don't /just/ use collision is because we'll be deleting stuff that may not necessarily have physics (e.g. carpets). var destroyRange = DestroyTileRange(component); - foreach (var entity in _lookup.GetEntitiesInRange(IoCManager.Resolve().GetComponent(component.Owner).MapID, worldPos, destroyRange)) + foreach (var entity in _lookup.GetEntitiesInRange(EntityManager.GetComponent(component.Owner).MapID, worldPos, destroyRange)) { HandleDestroy(component, entity); } @@ -149,9 +149,9 @@ namespace Content.Server.Singularity.EntitySystems private bool CanPull(EntityUid entity) { - return !(IoCManager.Resolve().HasComponent(entity) || - IoCManager.Resolve().HasComponent(entity) || - IoCManager.Resolve().HasComponent(entity) || + return !(EntityManager.HasComponent(entity) || + EntityManager.HasComponent(entity) || + EntityManager.HasComponent(entity) || entity.IsInContainer()); } @@ -162,16 +162,16 @@ namespace Content.Server.Singularity.EntitySystems var pullRange = PullRange(component); var destroyRange = DestroyTileRange(component); - foreach (var entity in _lookup.GetEntitiesInRange(IoCManager.Resolve().GetComponent(component.Owner).MapID, worldPos, pullRange)) + foreach (var entity in _lookup.GetEntitiesInRange(EntityManager.GetComponent(component.Owner).MapID, worldPos, pullRange)) { // I tried having it so level 6 can de-anchor. BAD IDEA, MASSIVE LAG. if (entity == component.Owner || - !IoCManager.Resolve().TryGetComponent(entity, out var collidableComponent) || + !EntityManager.TryGetComponent(entity, out var collidableComponent) || collidableComponent.BodyType == BodyType.Static) continue; if (!CanPull(entity)) continue; - var vec = worldPos - IoCManager.Resolve().GetComponent(entity).WorldPosition; + var vec = worldPos - EntityManager.GetComponent(entity).WorldPosition; if (vec.Length < destroyRange - 0.01f) continue; @@ -192,7 +192,7 @@ namespace Content.Server.Singularity.EntitySystems var circle = new Circle(worldPos, radius); var box = new Box2(worldPos - radius, worldPos + radius); - foreach (var grid in _mapManager.FindGridsIntersecting(IoCManager.Resolve().GetComponent(component.Owner).MapID, box)) + foreach (var grid in _mapManager.FindGridsIntersecting(EntityManager.GetComponent(component.Owner).MapID, box)) { foreach (var tile in grid.GetTilesIntersecting(circle)) { diff --git a/Content.Server/Stack/StackSystem.cs b/Content.Server/Stack/StackSystem.cs index 05fd3d66ea..1b4bb1b028 100644 --- a/Content.Server/Stack/StackSystem.cs +++ b/Content.Server/Stack/StackSystem.cs @@ -47,7 +47,7 @@ namespace Content.Server.Stack // Get a prototype ID to spawn the new entity. Null is also valid, although it should rarely be picked... var prototype = _prototypeManager.TryIndex(stack.StackTypeId, out var stackType) ? stackType.Spawn - : IoCManager.Resolve().GetComponent(stack.Owner).EntityPrototype?.ID; + : EntityManager.GetComponent(stack.Owner).EntityPrototype?.ID; // Try to remove the amount of things we want to split from the original stack... if (!Use(uid, amount, stack)) @@ -86,7 +86,7 @@ namespace Content.Server.Stack if (args.Handled) return; - if (!IoCManager.Resolve().TryGetComponent(args.Used, out var otherStack)) + if (!EntityManager.TryGetComponent(args.Used, out var otherStack)) return; if (!otherStack.StackTypeId.Equals(stack.StackTypeId)) @@ -100,7 +100,7 @@ namespace Content.Server.Stack if (!popupPos.IsValid(EntityManager)) { - popupPos = IoCManager.Resolve().GetComponent(args.User).Coordinates; + popupPos = EntityManager.GetComponent(args.User).Coordinates; } var filter = Filter.Entities(args.User); diff --git a/Content.Server/Storage/EntitySystems/ItemCounterSystem.cs b/Content.Server/Storage/EntitySystems/ItemCounterSystem.cs index 2e98793ec9..5b697eeb22 100644 --- a/Content.Server/Storage/EntitySystems/ItemCounterSystem.cs +++ b/Content.Server/Storage/EntitySystems/ItemCounterSystem.cs @@ -13,7 +13,7 @@ namespace Content.Server.Storage.EntitySystems { protected override int? GetCount(ContainerModifiedMessage msg, ItemCounterComponent itemCounter) { - if (!IoCManager.Resolve().TryGetComponent(msg.Container.Owner, out ServerStorageComponent? component) + if (!EntityManager.TryGetComponent(msg.Container.Owner, out ServerStorageComponent? component) || component.StoredEntities == null) { return null; diff --git a/Content.Server/Storage/EntitySystems/ItemMapperSystem.cs b/Content.Server/Storage/EntitySystems/ItemMapperSystem.cs index 62dfff8d2d..5ffebc1088 100644 --- a/Content.Server/Storage/EntitySystems/ItemMapperSystem.cs +++ b/Content.Server/Storage/EntitySystems/ItemMapperSystem.cs @@ -16,7 +16,7 @@ namespace Content.Server.Storage.EntitySystems ItemMapperComponent itemMapper, out IReadOnlyList showLayers) { - if (IoCManager.Resolve().TryGetComponent(msg.Container.Owner, out ServerStorageComponent? component)) + if (EntityManager.TryGetComponent(msg.Container.Owner, out ServerStorageComponent? component)) { var containedLayers = component.StoredEntities ?? new List(); var list = new List(); diff --git a/Content.Server/Storage/EntitySystems/StorageSystem.cs b/Content.Server/Storage/EntitySystems/StorageSystem.cs index 72a8aa4022..52c23d853f 100644 --- a/Content.Server/Storage/EntitySystems/StorageSystem.cs +++ b/Content.Server/Storage/EntitySystems/StorageSystem.cs @@ -92,7 +92,7 @@ namespace Content.Server.Storage.EntitySystems return; // Get the session for the user - var session = IoCManager.Resolve().GetComponentOrNull(args.User)?.PlayerSession; + var session = EntityManager.GetComponentOrNull(args.User)?.PlayerSession; if (session == null) return; @@ -118,7 +118,7 @@ namespace Content.Server.Storage.EntitySystems { var oldParentEntity = message.Container.Owner; - if (IoCManager.Resolve().TryGetComponent(oldParentEntity, out ServerStorageComponent? storageComp)) + if (EntityManager.TryGetComponent(oldParentEntity, out ServerStorageComponent? storageComp)) { storageComp.HandleEntityMaybeRemoved(message); } @@ -128,7 +128,7 @@ namespace Content.Server.Storage.EntitySystems { var oldParentEntity = message.Container.Owner; - if (IoCManager.Resolve().TryGetComponent(oldParentEntity, out ServerStorageComponent? storageComp)) + if (EntityManager.TryGetComponent(oldParentEntity, out ServerStorageComponent? storageComp)) { storageComp.HandleEntityMaybeInserted(message); } @@ -144,19 +144,19 @@ namespace Content.Server.Storage.EntitySystems if (_sessionCache.Count == 0) return; - var storagePos = IoCManager.Resolve().GetComponent(storageComp.Owner).WorldPosition; - var storageMap = IoCManager.Resolve().GetComponent(storageComp.Owner).MapID; + var storagePos = EntityManager.GetComponent(storageComp.Owner).WorldPosition; + var storageMap = EntityManager.GetComponent(storageComp.Owner).MapID; foreach (var session in _sessionCache) { // The component manages the set of sessions, so this invalid session should be removed soon. - if (session.AttachedEntity is not {} attachedEntity || !IoCManager.Resolve().EntityExists(attachedEntity)) + if (session.AttachedEntity is not {} attachedEntity || !EntityManager.EntityExists(attachedEntity)) continue; - if (storageMap != IoCManager.Resolve().GetComponent(attachedEntity).MapID) + if (storageMap != EntityManager.GetComponent(attachedEntity).MapID) continue; - var distanceSquared = (storagePos - IoCManager.Resolve().GetComponent(attachedEntity).WorldPosition).LengthSquared; + var distanceSquared = (storagePos - EntityManager.GetComponent(attachedEntity).WorldPosition).LengthSquared; if (distanceSquared > SharedInteractionSystem.InteractionRangeSquared) { storageComp.UnsubscribeSession(session); diff --git a/Content.Server/Strip/StrippableSystem.cs b/Content.Server/Strip/StrippableSystem.cs index 672054a19a..5a8039c83f 100644 --- a/Content.Server/Strip/StrippableSystem.cs +++ b/Content.Server/Strip/StrippableSystem.cs @@ -20,7 +20,7 @@ namespace Content.Server.Strip if (args.Hands == null || !args.CanAccess || !args.CanInteract || args.Target == args.User) return; - if (!IoCManager.Resolve().TryGetComponent(args.User, out ActorComponent? actor)) + if (!EntityManager.TryGetComponent(args.User, out ActorComponent? actor)) return; Verb verb = new(); diff --git a/Content.Server/Stunnable/StunSystem.cs b/Content.Server/Stunnable/StunSystem.cs index 2fa753c498..a2f8317d11 100644 --- a/Content.Server/Stunnable/StunSystem.cs +++ b/Content.Server/Stunnable/StunSystem.cs @@ -48,8 +48,8 @@ namespace Content.Server.Stunnable if (target != null) { // TODO: Use PopupSystem - source.PopupMessageOtherClients(Loc.GetString("stunned-component-disarm-success-others", ("source", Name: IoCManager.Resolve().GetComponent(source).EntityName), ("target", Name: IoCManager.Resolve().GetComponent(target).EntityName))); - source.PopupMessageCursor(Loc.GetString("stunned-component-disarm-success", ("target", Name: IoCManager.Resolve().GetComponent(target).EntityName))); + source.PopupMessageOtherClients(Loc.GetString("stunned-component-disarm-success-others", ("source", Name: EntityManager.GetComponent(source).EntityName), ("target", Name: EntityManager.GetComponent(target).EntityName))); + source.PopupMessageCursor(Loc.GetString("stunned-component-disarm-success", ("target", Name: EntityManager.GetComponent(target).EntityName))); } } diff --git a/Content.Server/Stunnable/StunbatonSystem.cs b/Content.Server/Stunnable/StunbatonSystem.cs index 076efcb646..9fec34edc2 100644 --- a/Content.Server/Stunnable/StunbatonSystem.cs +++ b/Content.Server/Stunnable/StunbatonSystem.cs @@ -175,12 +175,12 @@ namespace Content.Server.Stunnable return; } - if (!IoCManager.Resolve().TryGetComponent(comp.Owner, out var sprite) || - !IoCManager.Resolve().TryGetComponent(comp.Owner, out var item)) + if (!EntityManager.TryGetComponent(comp.Owner, out var sprite) || + !EntityManager.TryGetComponent(comp.Owner, out var item)) return; var playerFilter = Filter.Pvs(comp.Owner); - if (!IoCManager.Resolve().TryGetComponent(comp.Owner, out var slot)) + if (!EntityManager.TryGetComponent(comp.Owner, out var slot)) return; if (slot.Cell == null) diff --git a/Content.Server/Tabletop/TabletopSystem.Session.cs b/Content.Server/Tabletop/TabletopSystem.Session.cs index 4783c0277e..7ca26cb0ec 100644 --- a/Content.Server/Tabletop/TabletopSystem.Session.cs +++ b/Content.Server/Tabletop/TabletopSystem.Session.cs @@ -82,7 +82,7 @@ namespace Content.Server.Tabletop if (session.Players.ContainsKey(player)) return; - if(IoCManager.Resolve().TryGetComponent(attachedEntity, out var gamer)) + if(EntityManager.TryGetComponent(attachedEntity, out var gamer)) CloseSessionFor(player, gamer.Tabletop, false); // Set the entity as an absolute GAMER. @@ -111,13 +111,13 @@ namespace Content.Server.Tabletop if (!session.Players.TryGetValue(player, out var data)) return; - if(removeGamerComponent && player.AttachedEntity is {} attachedEntity && IoCManager.Resolve().TryGetComponent(attachedEntity, out TabletopGamerComponent? gamer)) + if(removeGamerComponent && player.AttachedEntity is {} attachedEntity && EntityManager.TryGetComponent(attachedEntity, out TabletopGamerComponent? gamer)) { // We invalidate this to prevent an infinite feedback from removing the component. gamer.Tabletop = EntityUid.Invalid; // You stop being a gamer....... - IoCManager.Resolve().RemoveComponent(attachedEntity); + EntityManager.RemoveComponent(attachedEntity); } session.Players.Remove(player); diff --git a/Content.Server/Tabletop/TabletopSystem.cs b/Content.Server/Tabletop/TabletopSystem.cs index 41ab8635c2..3f69d808a1 100644 --- a/Content.Server/Tabletop/TabletopSystem.cs +++ b/Content.Server/Tabletop/TabletopSystem.cs @@ -42,7 +42,7 @@ namespace Content.Server.Tabletop if (!args.CanAccess || !args.CanInteract) return; - if (!IoCManager.Resolve().TryGetComponent(args.User, out var actor)) + if (!EntityManager.TryGetComponent(args.User, out var actor)) return; Verb verb = new(); @@ -97,9 +97,9 @@ namespace Content.Server.Tabletop if (!EntityManager.EntityExists(gamer.Tabletop)) continue; - if (!IoCManager.Resolve().TryGetComponent(gamer.Owner, out ActorComponent? actor)) + if (!EntityManager.TryGetComponent(gamer.Owner, out ActorComponent? actor)) { - IoCManager.Resolve().RemoveComponent(gamer.Owner); + EntityManager.RemoveComponent(gamer.Owner); return; }; diff --git a/Content.Server/UserInterface/ActivatableUISystem.cs b/Content.Server/UserInterface/ActivatableUISystem.cs index c26f19f0f8..5cbabd3eb3 100644 --- a/Content.Server/UserInterface/ActivatableUISystem.cs +++ b/Content.Server/UserInterface/ActivatableUISystem.cs @@ -59,7 +59,7 @@ namespace Content.Server.UserInterface private bool InteractUI(EntityUid user, ActivatableUIComponent aui) { - if (!IoCManager.Resolve().TryGetComponent(user, out ActorComponent? actor)) return false; + if (!EntityManager.TryGetComponent(user, out ActorComponent? actor)) return false; if (aui.AdminOnly && !_adminManager.IsAdmin(actor.PlayerSession)) return false; diff --git a/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs b/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs index 5caf921d4d..131070c14e 100644 --- a/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs +++ b/Content.Server/Weapon/Melee/MeleeWeaponSystem.cs @@ -77,8 +77,8 @@ namespace Content.Server.Weapon.Melee if (curTime < comp.CooldownEnd || !args.Target.IsValid()) return; - var location = IoCManager.Resolve().GetComponent(args.User).Coordinates; - var diff = args.ClickLocation.ToMapPos(IoCManager.Resolve()) - location.ToMapPos(IoCManager.Resolve()); + var location = EntityManager.GetComponent(args.User).Coordinates; + var diff = args.ClickLocation.ToMapPos(EntityManager) - location.ToMapPos(EntityManager); var angle = Angle.FromWorldVec(diff); if (args.Target is {Valid: true} target) @@ -132,12 +132,12 @@ namespace Content.Server.Weapon.Melee return; } - var location = IoCManager.Resolve().GetComponent(args.User).Coordinates; - var diff = args.ClickLocation.ToMapPos(IoCManager.Resolve()) - location.ToMapPos(IoCManager.Resolve()); + var location = EntityManager.GetComponent(args.User).Coordinates; + var diff = args.ClickLocation.ToMapPos(EntityManager) - location.ToMapPos(EntityManager); var angle = Angle.FromWorldVec(diff); // This should really be improved. GetEntitiesInArc uses pos instead of bounding boxes. - var entities = ArcRayCast(IoCManager.Resolve().GetComponent(args.User).WorldPosition, angle, comp.ArcWidth, comp.Range, IoCManager.Resolve().GetComponent(owner).MapID, args.User); + var entities = ArcRayCast(EntityManager.GetComponent(args.User).WorldPosition, angle, comp.ArcWidth, comp.Range, EntityManager.GetComponent(owner).MapID, args.User); var hitEntities = new List(); foreach (var entity in entities) @@ -160,11 +160,11 @@ namespace Content.Server.Weapon.Melee { if (entities.Count != 0) { - SoundSystem.Play(Filter.Pvs(owner), comp.HitSound.GetSound(), IoCManager.Resolve().GetComponent(entities.First()).Coordinates); + SoundSystem.Play(Filter.Pvs(owner), comp.HitSound.GetSound(), EntityManager.GetComponent(entities.First()).Coordinates); } else { - SoundSystem.Play(Filter.Pvs(owner), comp.MissSound.GetSound(), IoCManager.Resolve().GetComponent(args.User).Coordinates); + SoundSystem.Play(Filter.Pvs(owner), comp.MissSound.GetSound(), EntityManager.GetComponent(args.User).Coordinates); } foreach (var entity in hitEntities) @@ -211,8 +211,8 @@ namespace Content.Server.Weapon.Melee if (!args.Target.HasValue) return; - var location = IoCManager.Resolve().GetComponent(args.User).Coordinates; - var diff = args.ClickLocation.ToMapPos(IoCManager.Resolve()) - location.ToMapPos(IoCManager.Resolve()); + var location = EntityManager.GetComponent(args.User).Coordinates; + var diff = args.ClickLocation.ToMapPos(EntityManager) - location.ToMapPos(EntityManager); var angle = Angle.FromWorldVec(diff); var hitEvent = new MeleeInteractEvent(args.Target.Value, args.User); @@ -260,10 +260,10 @@ namespace Content.Server.Weapon.Melee var hitBloodstreams = new List(); foreach (var entity in args.HitEntities) { - if ((!IoCManager.Resolve().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity).EntityLifeStage) >= EntityLifeStage.Deleted) + if ((!EntityManager.EntityExists(entity) ? EntityLifeStage.Deleted : EntityManager.GetComponent(entity).EntityLifeStage) >= EntityLifeStage.Deleted) continue; - if (IoCManager.Resolve().TryGetComponent(entity, out var bloodstream)) + if (EntityManager.TryGetComponent(entity, out var bloodstream)) hitBloodstreams.Add(bloodstream); } diff --git a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs index 7fbc39a22a..765a838ba6 100644 --- a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs +++ b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs @@ -57,7 +57,7 @@ namespace Content.Shared.Containers.ItemSlots if (slot.HasItem || string.IsNullOrEmpty(slot.StartingItem)) continue; - var item = EntityManager.SpawnEntity(slot.StartingItem, IoCManager.Resolve().GetComponent(itemSlots.Owner).Coordinates); + var item = EntityManager.SpawnEntity(slot.StartingItem, EntityManager.GetComponent(itemSlots.Owner).Coordinates); slot.ContainerSlot.Insert(item); } } @@ -82,7 +82,7 @@ namespace Content.Shared.Containers.ItemSlots var itemSlots = EntityManager.EnsureComponent(uid); slot.ContainerSlot = ContainerHelpers.EnsureContainer(itemSlots.Owner, id); if (itemSlots.Slots.ContainsKey(id)) - Logger.Error($"Duplicate item slot key. Entity: {IoCManager.Resolve().GetComponent(itemSlots.Owner).EntityName} ({uid}), key: {id}"); + Logger.Error($"Duplicate item slot key. Entity: {EntityManager.GetComponent(itemSlots.Owner).EntityName} ({uid}), key: {id}"); itemSlots.Slots[id] = slot; } @@ -364,7 +364,7 @@ namespace Content.Shared.Containers.ItemSlots var verbSubject = slot.Name != string.Empty ? Loc.GetString(slot.Name) - : IoCManager.Resolve().GetComponent(slot.Item!.Value).EntityName ?? string.Empty; + : EntityManager.GetComponent(slot.Item!.Value).EntityName ?? string.Empty; Verb verb = new(); verb.Act = () => TryEjectToHands(uid, slot, args.User); @@ -399,7 +399,7 @@ namespace Content.Shared.Containers.ItemSlots var verbSubject = slot.Name != string.Empty ? Loc.GetString(slot.Name) - : IoCManager.Resolve().GetComponent(slot.Item!.Value).EntityName ?? string.Empty; + : EntityManager.GetComponent(slot.Item!.Value).EntityName ?? string.Empty; Verb takeVerb = new(); takeVerb.Act = () => TryEjectToHands(uid, slot, args.User); @@ -425,7 +425,7 @@ namespace Content.Shared.Containers.ItemSlots var verbSubject = slot.Name != string.Empty ? Loc.GetString(slot.Name) - : IoCManager.Resolve().GetComponent(args.Using.Value).EntityName ?? string.Empty; + : EntityManager.GetComponent(args.Using.Value).EntityName ?? string.Empty; Verb insertVerb = new(); insertVerb.Act = () => Insert(uid, slot, args.Using.Value); diff --git a/Content.Shared/Disposal/SharedDisposalUnitSystem.cs b/Content.Shared/Disposal/SharedDisposalUnitSystem.cs index 4660b9d93a..8a62badacf 100644 --- a/Content.Shared/Disposal/SharedDisposalUnitSystem.cs +++ b/Content.Shared/Disposal/SharedDisposalUnitSystem.cs @@ -49,21 +49,21 @@ namespace Content.Shared.Disposal public virtual bool CanInsert(SharedDisposalUnitComponent component, EntityUid entity) { - if (!IoCManager.Resolve().GetComponent(component.Owner).Anchored) + if (!EntityManager.GetComponent(component.Owner).Anchored) return false; // TODO: Probably just need a disposable tag. - if (!IoCManager.Resolve().TryGetComponent(entity, out SharedItemComponent? storable) && - !IoCManager.Resolve().HasComponent(entity)) + if (!EntityManager.TryGetComponent(entity, out SharedItemComponent? storable) && + !EntityManager.HasComponent(entity)) { return false; } - if (!IoCManager.Resolve().TryGetComponent(entity, out IPhysBody? physics) || + if (!EntityManager.TryGetComponent(entity, out IPhysBody? physics) || !physics.CanCollide && storable == null) { - if (!(IoCManager.Resolve().TryGetComponent(entity, out MobStateComponent? damageState) && damageState.IsDead())) + if (!(EntityManager.TryGetComponent(entity, out MobStateComponent? damageState) && damageState.IsDead())) { return false; } diff --git a/Content.Shared/Examine/ExamineSystemShared.cs b/Content.Shared/Examine/ExamineSystemShared.cs index 07cf0cfa3c..7a78c6bee9 100644 --- a/Content.Shared/Examine/ExamineSystemShared.cs +++ b/Content.Shared/Examine/ExamineSystemShared.cs @@ -64,24 +64,24 @@ namespace Content.Shared.Examine [Pure] public bool CanExamine(EntityUid examiner, EntityUid examined) { - return CanExamine(examiner, IoCManager.Resolve().GetComponent(examined).MapPosition, + return CanExamine(examiner, EntityManager.GetComponent(examined).MapPosition, entity => entity == examiner || entity == examined); } [Pure] public virtual bool CanExamine(EntityUid examiner, MapCoordinates target, Ignored? predicate = null) { - if (!IoCManager.Resolve().TryGetComponent(examiner, out ExaminerComponent? examinerComponent)) + if (!EntityManager.TryGetComponent(examiner, out ExaminerComponent? examinerComponent)) return false; if (!examinerComponent.DoRangeCheck) return true; - if (IoCManager.Resolve().GetComponent(examiner).MapID != target.MapId) + if (EntityManager.GetComponent(examiner).MapID != target.MapId) return false; return InRangeUnOccluded( - IoCManager.Resolve().GetComponent(examiner).MapPosition, + EntityManager.GetComponent(examiner).MapPosition, target, GetExaminerRange(examiner), predicate: predicate, @@ -128,12 +128,12 @@ namespace Content.Shared.Examine foreach (var result in rayResults) { - if (!IoCManager.Resolve().TryGetComponent(result.HitEntity, out OccluderComponent? o)) + if (!EntityManager.TryGetComponent(result.HitEntity, out OccluderComponent? o)) { continue; } - var bBox = o.BoundingBox.Translated(IoCManager.Resolve().GetComponent(o.Owner).WorldPosition); + var bBox = o.BoundingBox.Translated(EntityManager.GetComponent(o.Owner).WorldPosition); if (bBox.Contains(origin.Position) || bBox.Contains(other.Position)) { @@ -148,54 +148,54 @@ namespace Content.Shared.Examine public static bool InRangeUnOccluded(EntityUid origin, EntityUid other, float range, Ignored? predicate, bool ignoreInsideBlocker = true) { - var originPos = IoCManager.Resolve().GetComponent(origin).MapPosition; - var otherPos = IoCManager.Resolve().GetComponent(other).MapPosition; + var originPos = EntityManager.GetComponent(origin).MapPosition; + var otherPos = EntityManager.GetComponent(other).MapPosition; return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker); } public static bool InRangeUnOccluded(EntityUid origin, IComponent other, float range, Ignored? predicate, bool ignoreInsideBlocker = true) { - var originPos = IoCManager.Resolve().GetComponent(origin).MapPosition; - var otherPos = IoCManager.Resolve().GetComponent(other.Owner).MapPosition; + var originPos = EntityManager.GetComponent(origin).MapPosition; + var otherPos = EntityManager.GetComponent(other.Owner).MapPosition; return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker); } public static bool InRangeUnOccluded(EntityUid origin, EntityCoordinates other, float range, Ignored? predicate, bool ignoreInsideBlocker = true) { - var originPos = IoCManager.Resolve().GetComponent(origin).MapPosition; - var otherPos = other.ToMap(IoCManager.Resolve()); + var originPos = EntityManager.GetComponent(origin).MapPosition; + var otherPos = other.ToMap(EntityManager); return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker); } public static bool InRangeUnOccluded(EntityUid origin, MapCoordinates other, float range, Ignored? predicate, bool ignoreInsideBlocker = true) { - var originPos = IoCManager.Resolve().GetComponent(origin).MapPosition; + var originPos = EntityManager.GetComponent(origin).MapPosition; return InRangeUnOccluded(originPos, other, range, predicate, ignoreInsideBlocker); } public static bool InRangeUnOccluded(ITargetedInteractEventArgs args, float range, Ignored? predicate, bool ignoreInsideBlocker = true) { - var originPos = IoCManager.Resolve().GetComponent(args.User).MapPosition; - var otherPos = IoCManager.Resolve().GetComponent(args.Target).MapPosition; + var originPos = EntityManager.GetComponent(args.User).MapPosition; + var otherPos = EntityManager.GetComponent(args.Target).MapPosition; return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker); } public static bool InRangeUnOccluded(DragDropEvent args, float range, Ignored? predicate, bool ignoreInsideBlocker = true) { - var originPos = IoCManager.Resolve().GetComponent(args.User).MapPosition; - var otherPos = args.DropLocation.ToMap(IoCManager.Resolve()); + var originPos = EntityManager.GetComponent(args.User).MapPosition; + var otherPos = args.DropLocation.ToMap(EntityManager); return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker); } public static bool InRangeUnOccluded(AfterInteractEventArgs args, float range, Ignored? predicate, bool ignoreInsideBlocker = true) { - var entityManager = IoCManager.Resolve(); + var entityManager = EntityManager; var originPos = entityManager.GetComponent(args.User).MapPosition; var target = args.Target; var otherPos = (target != null ? entityManager.GetComponent(target.Value).MapPosition : args.ClickLocation.ToMap(entityManager)); @@ -215,9 +215,9 @@ namespace Content.Shared.Examine var doNewline = false; //Add an entity description if one is declared - if (!string.IsNullOrEmpty(IoCManager.Resolve().GetComponent(entity).EntityDescription)) + if (!string.IsNullOrEmpty(EntityManager.GetComponent(entity).EntityDescription)) { - message.AddText(IoCManager.Resolve().GetComponent(entity).EntityDescription); + message.AddText(EntityManager.GetComponent(entity).EntityDescription); doNewline = true; } @@ -229,7 +229,7 @@ namespace Content.Shared.Examine RaiseLocalEvent(entity, examinedEvent); //Add component statuses from components that report one - foreach (var examineComponent in IoCManager.Resolve().GetComponents(entity)) + foreach (var examineComponent in EntityManager.GetComponents(entity)) { var subMessage = new FormattedMessage(); examineComponent.Examine(subMessage, isInDetailsRange); diff --git a/Content.Shared/Interaction/RotateToFaceSystem.cs b/Content.Shared/Interaction/RotateToFaceSystem.cs index 019ff49881..11f68bbfba 100644 --- a/Content.Shared/Interaction/RotateToFaceSystem.cs +++ b/Content.Shared/Interaction/RotateToFaceSystem.cs @@ -36,7 +36,7 @@ namespace Content.Shared.Interaction [Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!; public bool TryFaceCoordinates(EntityUid user, Vector2 coordinates) { - var diff = coordinates - IoCManager.Resolve().GetComponent(user).MapPosition.Position; + var diff = coordinates - EntityManager.GetComponent(user).MapPosition.Position; if (diff.LengthSquared <= 0.01f) return true; var diffAngle = Angle.FromWorldVec(diff); @@ -47,12 +47,12 @@ namespace Content.Shared.Interaction { if (_actionBlockerSystem.CanChangeDirection(user)) { - IoCManager.Resolve().GetComponent(user).WorldRotation = diffAngle; + EntityManager.GetComponent(user).WorldRotation = diffAngle; return true; } else { - if (IoCManager.Resolve().TryGetComponent(user, out SharedBuckleComponent? buckle) && buckle.Buckled) + if (EntityManager.TryGetComponent(user, out SharedBuckleComponent? buckle) && buckle.Buckled) { var suid = buckle.LastEntityBuckledTo; if (suid != null) @@ -64,7 +64,7 @@ namespace Content.Shared.Interaction // (Since the user being buckled to it holds it down with their weight.) // This is logically equivalent to RotateWhileAnchored. // Barstools and office chairs have independent wheels, while regular chairs don't. - IoCManager.Resolve().GetComponent(rotatable.Owner).WorldRotation = diffAngle; + EntityManager.GetComponent(rotatable.Owner).WorldRotation = diffAngle; return true; } } diff --git a/Content.Shared/Movement/EntitySystems/SharedMobMoverSystem.cs b/Content.Shared/Movement/EntitySystems/SharedMobMoverSystem.cs index 62c4751c17..389df8402a 100644 --- a/Content.Shared/Movement/EntitySystems/SharedMobMoverSystem.cs +++ b/Content.Shared/Movement/EntitySystems/SharedMobMoverSystem.cs @@ -43,7 +43,7 @@ namespace Content.Shared.Movement.EntitySystems if (otherBody.BodyType != BodyType.Dynamic || !otherFixture.Hard) return; - if (!IoCManager.Resolve().TryGetComponent(ourFixture.Body.Owner, out IMobMoverComponent? mobMover) || worldNormal == Vector2.Zero) return; + if (!EntityManager.TryGetComponent(ourFixture.Body.Owner, out IMobMoverComponent? mobMover) || worldNormal == Vector2.Zero) return; otherBody.ApplyLinearImpulse(-worldNormal * mobMover.PushStrength * frameTime); } diff --git a/Content.Shared/Movement/EntitySystems/SharedMoverSystem.cs b/Content.Shared/Movement/EntitySystems/SharedMoverSystem.cs index bc634059ae..d2cb047a91 100644 --- a/Content.Shared/Movement/EntitySystems/SharedMoverSystem.cs +++ b/Content.Shared/Movement/EntitySystems/SharedMoverSystem.cs @@ -82,10 +82,10 @@ namespace Content.Shared.Movement.EntitySystems var ent = session?.AttachedEntity; - if (ent == null || !IoCManager.Resolve().EntityExists(ent.Value)) + if (ent == null || !EntityManager.EntityExists(ent.Value)) return false; - if (!IoCManager.Resolve().TryGetComponent(ent.Value, out T? comp)) + if (!EntityManager.TryGetComponent(ent.Value, out T? comp)) return false; component = comp; diff --git a/Content.Shared/Nutrition/EntitySystems/SharedCreamPieSystem.cs b/Content.Shared/Nutrition/EntitySystems/SharedCreamPieSystem.cs index b690d57341..d0e7149778 100644 --- a/Content.Shared/Nutrition/EntitySystems/SharedCreamPieSystem.cs +++ b/Content.Shared/Nutrition/EntitySystems/SharedCreamPieSystem.cs @@ -62,7 +62,7 @@ namespace Content.Shared.Nutrition.EntitySystems private void OnCreamPiedHitBy(EntityUid uid, CreamPiedComponent creamPied, ThrowHitByEvent args) { - if (!IoCManager.Resolve().EntityExists(args.Thrown) || !IoCManager.Resolve().TryGetComponent(args.Thrown, out CreamPieComponent? creamPie)) return; + if (!EntityManager.EntityExists(args.Thrown) || !EntityManager.TryGetComponent(args.Thrown, out CreamPieComponent? creamPie)) return; SetCreamPied(uid, creamPied, true); diff --git a/Content.Shared/Placeable/PlaceableSurfaceSystem.cs b/Content.Shared/Placeable/PlaceableSurfaceSystem.cs index cd87905b2e..aa1b174ccb 100644 --- a/Content.Shared/Placeable/PlaceableSurfaceSystem.cs +++ b/Content.Shared/Placeable/PlaceableSurfaceSystem.cs @@ -52,19 +52,19 @@ namespace Content.Shared.Placeable if (!surface.IsPlaceable) return; - if(!IoCManager.Resolve().TryGetComponent(args.User, out var handComponent)) + if(!EntityManager.TryGetComponent(args.User, out var handComponent)) return; - if (!args.ClickLocation.IsValid(IoCManager.Resolve())) + if (!args.ClickLocation.IsValid(EntityManager)) return; - if(!handComponent.TryDropEntity(args.Used, IoCManager.Resolve().GetComponent(surface.Owner).Coordinates)) + if(!handComponent.TryDropEntity(args.Used, EntityManager.GetComponent(surface.Owner).Coordinates)) return; if (surface.PlaceCentered) - IoCManager.Resolve().GetComponent(args.Used).LocalPosition = IoCManager.Resolve().GetComponent(args.Target).LocalPosition + surface.PositionOffset; + EntityManager.GetComponent(args.Used).LocalPosition = EntityManager.GetComponent(args.Target).LocalPosition + surface.PositionOffset; else - IoCManager.Resolve().GetComponent(args.Used).Coordinates = args.ClickLocation; + EntityManager.GetComponent(args.Used).Coordinates = args.ClickLocation; args.Handled = true; }