From 2bfec7ec628ec807207d12ce057338de2298d31d Mon Sep 17 00:00:00 2001 From: Vera Aguilera Puerto Date: Sat, 4 Dec 2021 14:14:22 +0100 Subject: [PATCH] Some more fixes --- Content.Client/Actions/ActionsSystem.cs | 8 ++++---- .../Components/MovedByPressureComponent.cs | 4 ++-- .../Coordinates/Helpers/SnapgridHelper.cs | 2 +- Content.Server/PDA/PDAExtensions.cs | 4 ++-- Content.Server/Popups/PopupExtensions.cs | 4 ++-- Content.Server/Throwing/ThrowHelper.cs | 2 +- .../UserInterface/UserInterfaceHelpers.cs | 2 +- .../Body/Components/SharedBodyComponent.cs | 2 +- .../CombatMode/SharedCombatModeSystem.cs | 4 ++-- Content.Shared/Examine/ExamineSystemShared.cs | 7 ++++--- Content.Shared/Hands/SharedHandsSystem.cs | 6 +++--- .../Helpers/SharedUnobstructedExtensions.cs | 13 ------------- .../EntitySystems/SharedMoverSystem.cs | 18 +++++++++--------- .../SharedPullingStateManagementSystem.cs | 4 ++-- .../Shuttles/Components/PilotComponent.cs | 6 ++++-- .../Slippery/SharedSlipperySystem.cs | 2 +- .../Spawning/EntitySystemExtensions.cs | 8 ++++---- Content.Shared/SubFloor/SubFloorHideSystem.cs | 4 ++-- .../Tabletop/SharedTabletopSystem.cs | 2 +- 19 files changed, 46 insertions(+), 56 deletions(-) diff --git a/Content.Client/Actions/ActionsSystem.cs b/Content.Client/Actions/ActionsSystem.cs index 521b684fab..37ef385d60 100644 --- a/Content.Client/Actions/ActionsSystem.cs +++ b/Content.Client/Actions/ActionsSystem.cs @@ -85,7 +85,7 @@ namespace Content.Client.Actions { var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; if (playerEntity == null || - !IoCManager.Resolve().TryGetComponent(playerEntity, out var actionsComponent)) return false; + !EntityManager.TryGetComponent(playerEntity.Value, out var actionsComponent)) return false; actionsComponent.HandleHotbarKeybind(slot, args); return true; @@ -99,7 +99,7 @@ namespace Content.Client.Actions { var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; if (playerEntity == null || - !IoCManager.Resolve().TryGetComponent(playerEntity, out var actionsComponent)) return false; + !EntityManager.TryGetComponent(playerEntity.Value, out var actionsComponent)) return false; actionsComponent.HandleChangeHotbarKeybind(hotbar, args); return true; @@ -111,7 +111,7 @@ namespace Content.Client.Actions { var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; if (playerEntity == null || - !IoCManager.Resolve().TryGetComponent(playerEntity, out var actionsComponent)) return false; + !EntityManager.TryGetComponent(playerEntity.Value, out var actionsComponent)) return false; return actionsComponent.TargetingOnUse(args); } @@ -120,7 +120,7 @@ namespace Content.Client.Actions { var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; if (playerEntity == null || - !IoCManager.Resolve().TryGetComponent(playerEntity, out var actionsComponent)) return; + !EntityManager.TryGetComponent(playerEntity.Value, out var actionsComponent)) return; actionsComponent.ToggleActionsMenu(); } diff --git a/Content.Server/Atmos/Components/MovedByPressureComponent.cs b/Content.Server/Atmos/Components/MovedByPressureComponent.cs index ac78981872..174e60f0a3 100644 --- a/Content.Server/Atmos/Components/MovedByPressureComponent.cs +++ b/Content.Server/Atmos/Components/MovedByPressureComponent.cs @@ -111,12 +111,12 @@ namespace Content.Server.Atmos.Components public static class MovedByPressureExtensions { - public static bool IsMovedByPressure(this IEntity entity) + public static bool IsMovedByPressure(this EntityUid entity) { return entity.IsMovedByPressure(out _); } - public static bool IsMovedByPressure(this IEntity entity, [NotNullWhen(true)] out MovedByPressureComponent? moved) + public static bool IsMovedByPressure(this EntityUid entity, [NotNullWhen(true)] out MovedByPressureComponent? moved) { return IoCManager.Resolve().TryGetComponent(entity, out moved) && moved.Enabled; diff --git a/Content.Server/Coordinates/Helpers/SnapgridHelper.cs b/Content.Server/Coordinates/Helpers/SnapgridHelper.cs index f0a82884ee..55d8c9705a 100644 --- a/Content.Server/Coordinates/Helpers/SnapgridHelper.cs +++ b/Content.Server/Coordinates/Helpers/SnapgridHelper.cs @@ -7,7 +7,7 @@ namespace Content.Server.Coordinates.Helpers { public static class SnapgridHelper { - public static void SnapToGrid(this IEntity entity, IEntityManager? entityManager = null, IMapManager? mapManager = null) + public static void SnapToGrid(this EntityUid entity, IEntityManager? entityManager = null, IMapManager? mapManager = null) { IoCManager.Resolve().GetComponent(entity).Coordinates = IoCManager.Resolve().GetComponent(entity).Coordinates.SnapToGrid(entityManager, mapManager); } diff --git a/Content.Server/PDA/PDAExtensions.cs b/Content.Server/PDA/PDAExtensions.cs index 3342f7974c..68c11f8a0f 100644 --- a/Content.Server/PDA/PDAExtensions.cs +++ b/Content.Server/PDA/PDAExtensions.cs @@ -15,7 +15,7 @@ namespace Content.Server.PDA /// /// The player to check in. /// The id card component. - public static IdCardComponent? GetHeldId(this IEntity player) + public static IdCardComponent? GetHeldId(this EntityUid player) { IdCardComponent? firstIdInPda = null; @@ -72,7 +72,7 @@ namespace Content.Server.PDA /// The player to check in. /// The id card component. /// true if found, false otherwise. - public static bool TryGetHeldId(this IEntity player, [NotNullWhen(true)] out IdCardComponent? id) + public static bool TryGetHeldId(this EntityUid player, [NotNullWhen(true)] out IdCardComponent? id) { return (id = player.GetHeldId()) != null; } diff --git a/Content.Server/Popups/PopupExtensions.cs b/Content.Server/Popups/PopupExtensions.cs index 12aa0afe96..8a34b3e1c6 100644 --- a/Content.Server/Popups/PopupExtensions.cs +++ b/Content.Server/Popups/PopupExtensions.cs @@ -17,7 +17,7 @@ namespace Content.Server.Popups /// /// The entity on which to popup the message. /// The message to show. - public static void PopupMessageOtherClients(this IEntity source, string message) + public static void PopupMessageOtherClients(this EntityUid source, string message) { var viewers = Filter.Empty() .AddPlayersByPvs(source) @@ -49,7 +49,7 @@ namespace Content.Server.Popups /// /// The range in which to search for players, defaulting to one screen. /// - public static void PopupMessageEveryone(this IEntity source, string message, IPlayerManager? playerManager = null, int range = 15) + public static void PopupMessageEveryone(this EntityUid source, string message, IPlayerManager? playerManager = null, int range = 15) { source.PopupMessage(message); source.PopupMessageOtherClients(message); diff --git a/Content.Server/Throwing/ThrowHelper.cs b/Content.Server/Throwing/ThrowHelper.cs index b9bfc9331d..0dc6e55f72 100644 --- a/Content.Server/Throwing/ThrowHelper.cs +++ b/Content.Server/Throwing/ThrowHelper.cs @@ -31,7 +31,7 @@ namespace Content.Server.Throwing /// How much the direction vector should be multiplied for velocity. /// /// The ratio of impulse applied to the thrower - internal static void TryThrow(this IEntity entity, Vector2 direction, float strength = 1.0f, IEntity? user = null, float pushbackRatio = 1.0f) + internal static void TryThrow(this EntityUid entity, Vector2 direction, float strength = 1.0f, EntityUid? user = null, float pushbackRatio = 1.0f) { if ((!IoCManager.Resolve().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(entity).EntityLifeStage) >= EntityLifeStage.Deleted || strength <= 0f || diff --git a/Content.Server/UserInterface/UserInterfaceHelpers.cs b/Content.Server/UserInterface/UserInterfaceHelpers.cs index 0ad14e3d17..e30a4054e4 100644 --- a/Content.Server/UserInterface/UserInterfaceHelpers.cs +++ b/Content.Server/UserInterface/UserInterfaceHelpers.cs @@ -6,7 +6,7 @@ namespace Content.Server.UserInterface { public static class UserInterfaceHelpers { - public static BoundUserInterface? GetUIOrNull(this IEntity entity, object uiKey) + public static BoundUserInterface? GetUIOrNull(this EntityUid entity, object uiKey) { return IoCManager.Resolve().GetComponentOrNull(entity)?.GetBoundUserInterfaceOrNull(uiKey); } diff --git a/Content.Shared/Body/Components/SharedBodyComponent.cs b/Content.Shared/Body/Components/SharedBodyComponent.cs index 98b21d97b3..e8ff4886ba 100644 --- a/Content.Shared/Body/Components/SharedBodyComponent.cs +++ b/Content.Shared/Body/Components/SharedBodyComponent.cs @@ -547,7 +547,7 @@ namespace Content.Shared.Body.Components continue; } - if (!IoCManager.Resolve().TryGetComponent(entity, out SharedBodyPartComponent? part)) + if (!IoCManager.Resolve().TryGetComponent(entity.Value, out SharedBodyPartComponent? part)) { continue; } diff --git a/Content.Shared/CombatMode/SharedCombatModeSystem.cs b/Content.Shared/CombatMode/SharedCombatModeSystem.cs index 8cef76c8bc..259ce11d6c 100644 --- a/Content.Shared/CombatMode/SharedCombatModeSystem.cs +++ b/Content.Shared/CombatMode/SharedCombatModeSystem.cs @@ -15,9 +15,9 @@ namespace Content.Shared.CombatMode private void CombatModeActiveHandler(CombatModeSystemMessages.SetCombatModeActiveMessage ev, EntitySessionEventArgs eventArgs) { - var entity = eventArgs.SenderSession?.AttachedEntity; + var entity = eventArgs.SenderSession.AttachedEntityUid; - if (entity == null || !IoCManager.Resolve().TryGetComponent(entity, out SharedCombatModeComponent? combatModeComponent)) + if (entity == null || !EntityManager.TryGetComponent(entity.Value, out SharedCombatModeComponent? combatModeComponent)) { return; } diff --git a/Content.Shared/Examine/ExamineSystemShared.cs b/Content.Shared/Examine/ExamineSystemShared.cs index 76aed20529..07cf0cfa3c 100644 --- a/Content.Shared/Examine/ExamineSystemShared.cs +++ b/Content.Shared/Examine/ExamineSystemShared.cs @@ -195,9 +195,10 @@ namespace Content.Shared.Examine public static bool InRangeUnOccluded(AfterInteractEventArgs args, float range, Ignored? predicate, bool ignoreInsideBlocker = true) { - var originPos = IoCManager.Resolve().GetComponent(args.User).MapPosition; - EntityUid? tempQualifier = args.Target; - var otherPos = (tempQualifier != null ? IoCManager.Resolve().GetComponent(tempQualifier) : null).MapPosition ?? args.ClickLocation.ToMap(IoCManager.Resolve()); + var entityManager = IoCManager.Resolve(); + var originPos = entityManager.GetComponent(args.User).MapPosition; + var target = args.Target; + var otherPos = (target != null ? entityManager.GetComponent(target.Value).MapPosition : args.ClickLocation.ToMap(entityManager)); return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker); } diff --git a/Content.Shared/Hands/SharedHandsSystem.cs b/Content.Shared/Hands/SharedHandsSystem.cs index 133ab0d945..dc8829c822 100644 --- a/Content.Shared/Hands/SharedHandsSystem.cs +++ b/Content.Shared/Hands/SharedHandsSystem.cs @@ -19,11 +19,11 @@ namespace Content.Shared.Hands SubscribeAllEvent(HandleSetHand); } - private static void HandleSetHand(RequestSetHandEvent msg, EntitySessionEventArgs eventArgs) + private void HandleSetHand(RequestSetHandEvent msg, EntitySessionEventArgs eventArgs) { - var entity = eventArgs.SenderSession.AttachedEntity; + var entity = eventArgs.SenderSession.AttachedEntityUid; - if (entity == null || !IoCManager.Resolve().TryGetComponent(entity, out SharedHandsComponent? hands)) + if (entity == null || !EntityManager.TryGetComponent(entity.Value, out SharedHandsComponent? hands)) return; hands.ActiveHand = msg.HandName; diff --git a/Content.Shared/Interaction/Helpers/SharedUnobstructedExtensions.cs b/Content.Shared/Interaction/Helpers/SharedUnobstructedExtensions.cs index f465280a7b..6f334c5579 100644 --- a/Content.Shared/Interaction/Helpers/SharedUnobstructedExtensions.cs +++ b/Content.Shared/Interaction/Helpers/SharedUnobstructedExtensions.cs @@ -14,19 +14,6 @@ namespace Content.Shared.Interaction.Helpers private static SharedInteractionSystem SharedInteractionSystem => EntitySystem.Get(); #region Entities - public static bool InRangeUnobstructed( - this EntityUid origin, - EntityUid other, - float range = InteractionRange, - CollisionGroup collisionMask = CollisionGroup.Impassable, - Ignored? predicate = null, - bool ignoreInsideBlocker = false, - bool popup = false) - { - return SharedInteractionSystem.InRangeUnobstructed(origin, other, range, collisionMask, predicate, - ignoreInsideBlocker, popup); - } - public static bool InRangeUnobstructed( this EntityUid origin, EntityUid other, diff --git a/Content.Shared/Movement/EntitySystems/SharedMoverSystem.cs b/Content.Shared/Movement/EntitySystems/SharedMoverSystem.cs index afc22122ea..7731b13a60 100644 --- a/Content.Shared/Movement/EntitySystems/SharedMoverSystem.cs +++ b/Content.Shared/Movement/EntitySystems/SharedMoverSystem.cs @@ -46,19 +46,19 @@ namespace Content.Shared.Movement.EntitySystems if (!TryGetAttachedComponent(session, out var moverComp)) return; - var owner = session?.AttachedEntity; + var owner = session?.AttachedEntityUid; if (owner != null && session != null) { - EntityManager.EventBus.RaiseLocalEvent(owner, new RelayMoveInputEvent(session)); + EntityManager.EventBus.RaiseLocalEvent(owner.Value, new RelayMoveInputEvent(session)); // For stuff like "Moving out of locker" or the likes - if (owner.IsInContainer() && - (!IoCManager.Resolve().TryGetComponent(owner, out MobStateComponent? mobState) || + if (owner.Value.IsInContainer() && + (!EntityManager.TryGetComponent(owner.Value, out MobStateComponent? mobState) || mobState.IsAlive())) { - var relayMoveEvent = new RelayMovementEntityEvent(owner); - IoCManager.Resolve().EventBus.RaiseLocalEvent(IoCManager.Resolve().GetComponent(owner).ParentUid, relayMoveEvent); + var relayMoveEvent = new RelayMovementEntityEvent(owner.Value); + EntityManager.EventBus.RaiseLocalEvent(EntityManager.GetComponent(owner.Value).ParentUid, relayMoveEvent); } } @@ -80,12 +80,12 @@ namespace Content.Shared.Movement.EntitySystems { component = default; - var ent = session?.AttachedEntity; + var ent = session?.AttachedEntityUid; - if (ent == null || !IoCManager.Resolve().EntityExists(ent)) + if (ent == null || !IoCManager.Resolve().EntityExists(ent.Value)) return false; - if (!IoCManager.Resolve().TryGetComponent(ent, out T? comp)) + if (!IoCManager.Resolve().TryGetComponent(ent.Value, out T? comp)) return false; component = comp; diff --git a/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs b/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs index 6da2947219..010ee42fc7 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingStateManagementSystem.cs @@ -81,14 +81,14 @@ namespace Content.Shared.Pulling var pullableOldPullerE = pullable?.Puller; if (pullableOldPullerE != null) { - ForceDisconnect(IoCManager.Resolve().GetComponent(pullableOldPullerE), pullable!); + ForceDisconnect(IoCManager.Resolve().GetComponent(pullableOldPullerE.Value), pullable!); } // Continue with the puller. var pullerOldPullableE = puller?.Pulling; if (pullerOldPullableE != null) { - ForceDisconnect(puller!, IoCManager.Resolve().GetComponent(pullerOldPullableE)); + ForceDisconnect(puller!, IoCManager.Resolve().GetComponent(pullerOldPullableE.Value)); } // And now for the actual connection (if any). diff --git a/Content.Shared/Shuttles/Components/PilotComponent.cs b/Content.Shared/Shuttles/Components/PilotComponent.cs index ef6091f8a0..2e71591334 100644 --- a/Content.Shared/Shuttles/Components/PilotComponent.cs +++ b/Content.Shared/Shuttles/Components/PilotComponent.cs @@ -38,8 +38,10 @@ namespace Content.Shared.Shuttles.Components return; } - if (!IoCManager.Resolve().TryGetEntity(state.Console.Value, out var consoleEnt) || - !IoCManager.Resolve().TryGetComponent(consoleEnt, out SharedShuttleConsoleComponent? shuttleConsoleComponent)) + var entityManager = IoCManager.Resolve(); + + if (!entityManager.TryGetEntity(state.Console.Value, out var consoleEnt) || + !entityManager.TryGetComponent(consoleEnt.Value, out SharedShuttleConsoleComponent? shuttleConsoleComponent)) { Logger.Warning($"Unable to set Helmsman console to {state.Console.Value}"); return; diff --git a/Content.Shared/Slippery/SharedSlipperySystem.cs b/Content.Shared/Slippery/SharedSlipperySystem.cs index fe28ed8706..12407835fe 100644 --- a/Content.Shared/Slippery/SharedSlipperySystem.cs +++ b/Content.Shared/Slippery/SharedSlipperySystem.cs @@ -130,7 +130,7 @@ namespace Content.Shared.Slippery continue; } - if (!IoCManager.Resolve().TryGetComponent(entity, out PhysicsComponent? otherPhysics) || + if (!EntityManager.TryGetComponent(entity.Value, out PhysicsComponent? otherPhysics) || !body.GetWorldAABB().Intersects(otherPhysics.GetWorldAABB())) { component.Colliding.Remove(uid); diff --git a/Content.Shared/Spawning/EntitySystemExtensions.cs b/Content.Shared/Spawning/EntitySystemExtensions.cs index 0bd9bc78d7..497852f3a2 100644 --- a/Content.Shared/Spawning/EntitySystemExtensions.cs +++ b/Content.Shared/Spawning/EntitySystemExtensions.cs @@ -10,7 +10,7 @@ namespace Content.Shared.Spawning { public static class EntitySystemExtensions { - public static IEntity? SpawnIfUnobstructed( + public static EntityUid? SpawnIfUnobstructed( this IEntityManager entityManager, string? prototypeName, EntityCoordinates coordinates, @@ -24,7 +24,7 @@ namespace Content.Shared.Spawning return entityManager.SpawnIfUnobstructed(prototypeName, mapCoordinates, collisionLayer, box, physicsManager); } - public static IEntity? SpawnIfUnobstructed( + public static EntityUid? SpawnIfUnobstructed( this IEntityManager entityManager, string? prototypeName, MapCoordinates coordinates, @@ -59,7 +59,7 @@ namespace Content.Shared.Spawning string? prototypeName, EntityCoordinates coordinates, CollisionGroup collisionLayer, - [NotNullWhen(true)] out IEntity? entity, + [NotNullWhen(true)] out EntityUid? entity, Box2? box = null, SharedPhysicsSystem? physicsManager = null) { @@ -73,7 +73,7 @@ namespace Content.Shared.Spawning string? prototypeName, MapCoordinates coordinates, CollisionGroup collisionLayer, - [NotNullWhen(true)] out IEntity? entity, + [NotNullWhen(true)] out EntityUid? entity, in Box2? box = null, SharedPhysicsSystem? physicsManager = null) { diff --git a/Content.Shared/SubFloor/SubFloorHideSystem.cs b/Content.Shared/SubFloor/SubFloorHideSystem.cs index 512f2e8964..e127431bcf 100644 --- a/Content.Shared/SubFloor/SubFloorHideSystem.cs +++ b/Content.Shared/SubFloor/SubFloorHideSystem.cs @@ -79,8 +79,8 @@ namespace Content.Shared.SubFloor private void OnSubFloorTerminating(EntityUid uid, SubFloorHideComponent component, ComponentShutdown _) { // If component is being deleted don't need to worry about updating any component stuff because it won't matter very shortly. - IEntity tempQualifier = EntityManager.GetEntity(uid); - if ((!IoCManager.Resolve().EntityExists(tempQualifier) ? EntityLifeStage.Deleted : IoCManager.Resolve().GetComponent(tempQualifier).EntityLifeStage) >= EntityLifeStage.Terminating) return; + if (EntityManager.GetComponent(uid).EntityLifeStage >= EntityLifeStage.Terminating) + return; // Regardless of whether we're on a subfloor or not, unhide. UpdateEntity(uid, true); diff --git a/Content.Shared/Tabletop/SharedTabletopSystem.cs b/Content.Shared/Tabletop/SharedTabletopSystem.cs index 8a91acb4ba..da267354de 100644 --- a/Content.Shared/Tabletop/SharedTabletopSystem.cs +++ b/Content.Shared/Tabletop/SharedTabletopSystem.cs @@ -44,7 +44,7 @@ namespace Content.Shared.Tabletop return false; } - if (!IoCManager.Resolve().HasComponent(parent) && !IoCManager.Resolve().HasComponent(parent)) + if (!EntityManager.HasComponent(parent) && !EntityManager.HasComponent(parent)) { return false; }