Some more fixes

This commit is contained in:
Vera Aguilera Puerto
2021-12-04 14:14:22 +01:00
parent 2ff16a580b
commit 2bfec7ec62
19 changed files with 46 additions and 56 deletions

View File

@@ -85,7 +85,7 @@ namespace Content.Client.Actions
{ {
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
if (playerEntity == null || if (playerEntity == null ||
!IoCManager.Resolve<IEntityManager>().TryGetComponent<ClientActionsComponent?>(playerEntity, out var actionsComponent)) return false; !EntityManager.TryGetComponent<ClientActionsComponent?>(playerEntity.Value, out var actionsComponent)) return false;
actionsComponent.HandleHotbarKeybind(slot, args); actionsComponent.HandleHotbarKeybind(slot, args);
return true; return true;
@@ -99,7 +99,7 @@ namespace Content.Client.Actions
{ {
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
if (playerEntity == null || if (playerEntity == null ||
!IoCManager.Resolve<IEntityManager>().TryGetComponent<ClientActionsComponent?>(playerEntity, out var actionsComponent)) return false; !EntityManager.TryGetComponent<ClientActionsComponent?>(playerEntity.Value, out var actionsComponent)) return false;
actionsComponent.HandleChangeHotbarKeybind(hotbar, args); actionsComponent.HandleChangeHotbarKeybind(hotbar, args);
return true; return true;
@@ -111,7 +111,7 @@ namespace Content.Client.Actions
{ {
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
if (playerEntity == null || if (playerEntity == null ||
!IoCManager.Resolve<IEntityManager>().TryGetComponent<ClientActionsComponent?>(playerEntity, out var actionsComponent)) return false; !EntityManager.TryGetComponent<ClientActionsComponent?>(playerEntity.Value, out var actionsComponent)) return false;
return actionsComponent.TargetingOnUse(args); return actionsComponent.TargetingOnUse(args);
} }
@@ -120,7 +120,7 @@ namespace Content.Client.Actions
{ {
var playerEntity = _playerManager.LocalPlayer?.ControlledEntity; var playerEntity = _playerManager.LocalPlayer?.ControlledEntity;
if (playerEntity == null || if (playerEntity == null ||
!IoCManager.Resolve<IEntityManager>().TryGetComponent<ClientActionsComponent?>(playerEntity, out var actionsComponent)) return; !EntityManager.TryGetComponent<ClientActionsComponent?>(playerEntity.Value, out var actionsComponent)) return;
actionsComponent.ToggleActionsMenu(); actionsComponent.ToggleActionsMenu();
} }

View File

@@ -111,12 +111,12 @@ namespace Content.Server.Atmos.Components
public static class MovedByPressureExtensions public static class MovedByPressureExtensions
{ {
public static bool IsMovedByPressure(this IEntity entity) public static bool IsMovedByPressure(this EntityUid entity)
{ {
return entity.IsMovedByPressure(out _); 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<IEntityManager>().TryGetComponent(entity, out moved) && return IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out moved) &&
moved.Enabled; moved.Enabled;

View File

@@ -7,7 +7,7 @@ namespace Content.Server.Coordinates.Helpers
{ {
public static class SnapgridHelper 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<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates.SnapToGrid(entityManager, mapManager); IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(entity).Coordinates.SnapToGrid(entityManager, mapManager);
} }

View File

@@ -15,7 +15,7 @@ namespace Content.Server.PDA
/// </summary> /// </summary>
/// <param name="player">The player to check in.</param> /// <param name="player">The player to check in.</param>
/// <returns>The id card component.</returns> /// <returns>The id card component.</returns>
public static IdCardComponent? GetHeldId(this IEntity player) public static IdCardComponent? GetHeldId(this EntityUid player)
{ {
IdCardComponent? firstIdInPda = null; IdCardComponent? firstIdInPda = null;
@@ -72,7 +72,7 @@ namespace Content.Server.PDA
/// <param name="player">The player to check in.</param> /// <param name="player">The player to check in.</param>
/// <param name="id">The id card component.</param> /// <param name="id">The id card component.</param>
/// <returns>true if found, false otherwise.</returns> /// <returns>true if found, false otherwise.</returns>
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; return (id = player.GetHeldId()) != null;
} }

View File

@@ -17,7 +17,7 @@ namespace Content.Server.Popups
/// </summary> /// </summary>
/// <param name="source">The entity on which to popup the message.</param> /// <param name="source">The entity on which to popup the message.</param>
/// <param name="message">The message to show.</param> /// <param name="message">The message to show.</param>
public static void PopupMessageOtherClients(this IEntity source, string message) public static void PopupMessageOtherClients(this EntityUid source, string message)
{ {
var viewers = Filter.Empty() var viewers = Filter.Empty()
.AddPlayersByPvs(source) .AddPlayersByPvs(source)
@@ -49,7 +49,7 @@ namespace Content.Server.Popups
/// <param name="range"> /// <param name="range">
/// The range in which to search for players, defaulting to one screen. /// The range in which to search for players, defaulting to one screen.
/// </param> /// </param>
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.PopupMessage(message);
source.PopupMessageOtherClients(message); source.PopupMessageOtherClients(message);

View File

@@ -31,7 +31,7 @@ namespace Content.Server.Throwing
/// <param name="strength">How much the direction vector should be multiplied for velocity.</param> /// <param name="strength">How much the direction vector should be multiplied for velocity.</param>
/// <param name="user"></param> /// <param name="user"></param>
/// <param name="pushbackRatio">The ratio of impulse applied to the thrower</param> /// <param name="pushbackRatio">The ratio of impulse applied to the thrower</param>
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<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted || if ((!IoCManager.Resolve<IEntityManager>().EntityExists(entity) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(entity).EntityLifeStage) >= EntityLifeStage.Deleted ||
strength <= 0f || strength <= 0f ||

View File

@@ -6,7 +6,7 @@ namespace Content.Server.UserInterface
{ {
public static class UserInterfaceHelpers 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<IEntityManager>().GetComponentOrNull<ServerUserInterfaceComponent>(entity)?.GetBoundUserInterfaceOrNull(uiKey); return IoCManager.Resolve<IEntityManager>().GetComponentOrNull<ServerUserInterfaceComponent>(entity)?.GetBoundUserInterfaceOrNull(uiKey);
} }

View File

@@ -547,7 +547,7 @@ namespace Content.Shared.Body.Components
continue; continue;
} }
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out SharedBodyPartComponent? part)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity.Value, out SharedBodyPartComponent? part))
{ {
continue; continue;
} }

View File

@@ -15,9 +15,9 @@ namespace Content.Shared.CombatMode
private void CombatModeActiveHandler(CombatModeSystemMessages.SetCombatModeActiveMessage ev, EntitySessionEventArgs eventArgs) private void CombatModeActiveHandler(CombatModeSystemMessages.SetCombatModeActiveMessage ev, EntitySessionEventArgs eventArgs)
{ {
var entity = eventArgs.SenderSession?.AttachedEntity; var entity = eventArgs.SenderSession.AttachedEntityUid;
if (entity == null || !IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out SharedCombatModeComponent? combatModeComponent)) if (entity == null || !EntityManager.TryGetComponent(entity.Value, out SharedCombatModeComponent? combatModeComponent))
{ {
return; return;
} }

View File

@@ -195,9 +195,10 @@ namespace Content.Shared.Examine
public static bool InRangeUnOccluded(AfterInteractEventArgs args, float range, Ignored? predicate, bool ignoreInsideBlocker = true) public static bool InRangeUnOccluded(AfterInteractEventArgs args, float range, Ignored? predicate, bool ignoreInsideBlocker = true)
{ {
var originPos = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(args.User).MapPosition; var entityManager = IoCManager.Resolve<IEntityManager>();
EntityUid? tempQualifier = args.Target; var originPos = entityManager.GetComponent<TransformComponent>(args.User).MapPosition;
var otherPos = (tempQualifier != null ? IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(tempQualifier) : null).MapPosition ?? args.ClickLocation.ToMap(IoCManager.Resolve<IEntityManager>()); var target = args.Target;
var otherPos = (target != null ? entityManager.GetComponent<TransformComponent>(target.Value).MapPosition : args.ClickLocation.ToMap(entityManager));
return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker); return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
} }

View File

@@ -19,11 +19,11 @@ namespace Content.Shared.Hands
SubscribeAllEvent<RequestSetHandEvent>(HandleSetHand); SubscribeAllEvent<RequestSetHandEvent>(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<IEntityManager>().TryGetComponent(entity, out SharedHandsComponent? hands)) if (entity == null || !EntityManager.TryGetComponent(entity.Value, out SharedHandsComponent? hands))
return; return;
hands.ActiveHand = msg.HandName; hands.ActiveHand = msg.HandName;

View File

@@ -14,19 +14,6 @@ namespace Content.Shared.Interaction.Helpers
private static SharedInteractionSystem SharedInteractionSystem => EntitySystem.Get<SharedInteractionSystem>(); private static SharedInteractionSystem SharedInteractionSystem => EntitySystem.Get<SharedInteractionSystem>();
#region Entities #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( public static bool InRangeUnobstructed(
this EntityUid origin, this EntityUid origin,
EntityUid other, EntityUid other,

View File

@@ -46,19 +46,19 @@ namespace Content.Shared.Movement.EntitySystems
if (!TryGetAttachedComponent<IMoverComponent>(session, out var moverComp)) if (!TryGetAttachedComponent<IMoverComponent>(session, out var moverComp))
return; return;
var owner = session?.AttachedEntity; var owner = session?.AttachedEntityUid;
if (owner != null && session != null) 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 // For stuff like "Moving out of locker" or the likes
if (owner.IsInContainer() && if (owner.Value.IsInContainer() &&
(!IoCManager.Resolve<IEntityManager>().TryGetComponent(owner, out MobStateComponent? mobState) || (!EntityManager.TryGetComponent(owner.Value, out MobStateComponent? mobState) ||
mobState.IsAlive())) mobState.IsAlive()))
{ {
var relayMoveEvent = new RelayMovementEntityEvent(owner); var relayMoveEvent = new RelayMovementEntityEvent(owner.Value);
IoCManager.Resolve<IEntityManager>().EventBus.RaiseLocalEvent(IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(owner).ParentUid, relayMoveEvent); EntityManager.EventBus.RaiseLocalEvent(EntityManager.GetComponent<TransformComponent>(owner.Value).ParentUid, relayMoveEvent);
} }
} }
@@ -80,12 +80,12 @@ namespace Content.Shared.Movement.EntitySystems
{ {
component = default; component = default;
var ent = session?.AttachedEntity; var ent = session?.AttachedEntityUid;
if (ent == null || !IoCManager.Resolve<IEntityManager>().EntityExists(ent)) if (ent == null || !IoCManager.Resolve<IEntityManager>().EntityExists(ent.Value))
return false; return false;
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(ent, out T? comp)) if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(ent.Value, out T? comp))
return false; return false;
component = comp; component = comp;

View File

@@ -81,14 +81,14 @@ namespace Content.Shared.Pulling
var pullableOldPullerE = pullable?.Puller; var pullableOldPullerE = pullable?.Puller;
if (pullableOldPullerE != null) if (pullableOldPullerE != null)
{ {
ForceDisconnect(IoCManager.Resolve<IEntityManager>().GetComponent<SharedPullerComponent>(pullableOldPullerE), pullable!); ForceDisconnect(IoCManager.Resolve<IEntityManager>().GetComponent<SharedPullerComponent>(pullableOldPullerE.Value), pullable!);
} }
// Continue with the puller. // Continue with the puller.
var pullerOldPullableE = puller?.Pulling; var pullerOldPullableE = puller?.Pulling;
if (pullerOldPullableE != null) if (pullerOldPullableE != null)
{ {
ForceDisconnect(puller!, IoCManager.Resolve<IEntityManager>().GetComponent<SharedPullableComponent>(pullerOldPullableE)); ForceDisconnect(puller!, IoCManager.Resolve<IEntityManager>().GetComponent<SharedPullableComponent>(pullerOldPullableE.Value));
} }
// And now for the actual connection (if any). // And now for the actual connection (if any).

View File

@@ -38,8 +38,10 @@ namespace Content.Shared.Shuttles.Components
return; return;
} }
if (!IoCManager.Resolve<IEntityManager>().TryGetEntity(state.Console.Value, out var consoleEnt) || var entityManager = IoCManager.Resolve<IEntityManager>();
!IoCManager.Resolve<IEntityManager>().TryGetComponent(consoleEnt, out SharedShuttleConsoleComponent? shuttleConsoleComponent))
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}"); Logger.Warning($"Unable to set Helmsman console to {state.Console.Value}");
return; return;

View File

@@ -130,7 +130,7 @@ namespace Content.Shared.Slippery
continue; continue;
} }
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out PhysicsComponent? otherPhysics) || if (!EntityManager.TryGetComponent(entity.Value, out PhysicsComponent? otherPhysics) ||
!body.GetWorldAABB().Intersects(otherPhysics.GetWorldAABB())) !body.GetWorldAABB().Intersects(otherPhysics.GetWorldAABB()))
{ {
component.Colliding.Remove(uid); component.Colliding.Remove(uid);

View File

@@ -10,7 +10,7 @@ namespace Content.Shared.Spawning
{ {
public static class EntitySystemExtensions public static class EntitySystemExtensions
{ {
public static IEntity? SpawnIfUnobstructed( public static EntityUid? SpawnIfUnobstructed(
this IEntityManager entityManager, this IEntityManager entityManager,
string? prototypeName, string? prototypeName,
EntityCoordinates coordinates, EntityCoordinates coordinates,
@@ -24,7 +24,7 @@ namespace Content.Shared.Spawning
return entityManager.SpawnIfUnobstructed(prototypeName, mapCoordinates, collisionLayer, box, physicsManager); return entityManager.SpawnIfUnobstructed(prototypeName, mapCoordinates, collisionLayer, box, physicsManager);
} }
public static IEntity? SpawnIfUnobstructed( public static EntityUid? SpawnIfUnobstructed(
this IEntityManager entityManager, this IEntityManager entityManager,
string? prototypeName, string? prototypeName,
MapCoordinates coordinates, MapCoordinates coordinates,
@@ -59,7 +59,7 @@ namespace Content.Shared.Spawning
string? prototypeName, string? prototypeName,
EntityCoordinates coordinates, EntityCoordinates coordinates,
CollisionGroup collisionLayer, CollisionGroup collisionLayer,
[NotNullWhen(true)] out IEntity? entity, [NotNullWhen(true)] out EntityUid? entity,
Box2? box = null, Box2? box = null,
SharedPhysicsSystem? physicsManager = null) SharedPhysicsSystem? physicsManager = null)
{ {
@@ -73,7 +73,7 @@ namespace Content.Shared.Spawning
string? prototypeName, string? prototypeName,
MapCoordinates coordinates, MapCoordinates coordinates,
CollisionGroup collisionLayer, CollisionGroup collisionLayer,
[NotNullWhen(true)] out IEntity? entity, [NotNullWhen(true)] out EntityUid? entity,
in Box2? box = null, in Box2? box = null,
SharedPhysicsSystem? physicsManager = null) SharedPhysicsSystem? physicsManager = null)
{ {

View File

@@ -79,8 +79,8 @@ namespace Content.Shared.SubFloor
private void OnSubFloorTerminating(EntityUid uid, SubFloorHideComponent component, ComponentShutdown _) 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. // 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 (EntityManager.GetComponent<MetaDataComponent>(uid).EntityLifeStage >= EntityLifeStage.Terminating)
if ((!IoCManager.Resolve<IEntityManager>().EntityExists(tempQualifier) ? EntityLifeStage.Deleted : IoCManager.Resolve<IEntityManager>().GetComponent<MetaDataComponent>(tempQualifier).EntityLifeStage) >= EntityLifeStage.Terminating) return; return;
// Regardless of whether we're on a subfloor or not, unhide. // Regardless of whether we're on a subfloor or not, unhide.
UpdateEntity(uid, true); UpdateEntity(uid, true);

View File

@@ -44,7 +44,7 @@ namespace Content.Shared.Tabletop
return false; return false;
} }
if (!IoCManager.Resolve<IEntityManager>().HasComponent<MapComponent>(parent) && !IoCManager.Resolve<IEntityManager>().HasComponent<IMapGridComponent>(parent)) if (!EntityManager.HasComponent<MapComponent>(parent) && !EntityManager.HasComponent<IMapGridComponent>(parent))
{ {
return false; return false;
} }