diff --git a/Content.Server/Pointing/EntitySystems/PointingSystem.cs b/Content.Server/Pointing/EntitySystems/PointingSystem.cs index adc23667bc89..10c524be0e50 100644 --- a/Content.Server/Pointing/EntitySystems/PointingSystem.cs +++ b/Content.Server/Pointing/EntitySystems/PointingSystem.cs @@ -7,6 +7,7 @@ using Content.Shared.Input; using Content.Shared.Interaction; using Content.Shared.Interaction.Helpers; +using Content.Shared.MobState.Components; using Content.Shared.Popups; using Content.Shared.Verbs; using JetBrains.Annotations; @@ -76,9 +77,9 @@ private void SendMessage(EntityUid source, IEnumerable viewers, public bool InRange(EntityUid pointer, EntityCoordinates coordinates) { - if (EntityManager.HasComponent(pointer)) + if (HasComp(pointer)) { - return EntityManager.GetComponent(pointer).Coordinates.InRange(EntityManager, coordinates, 15); + return Transform(pointer).Coordinates.InRange(EntityManager, coordinates, 15); } else { @@ -100,12 +101,19 @@ public bool TryPoint(ICommonSession? session, EntityCoordinates coords, EntityUi return false; } - if (EntityManager.EntityExists(pointed)) + if (HasComp(pointed)) { // this is a pointing arrow. no pointing here... return false; } + // Checking mob state directly instead of some action blocker, as many action blockers are blocked for + // ghosts and there is no obvious choice for pointing. + if (TryComp(player, out MobStateComponent? mob) && mob.IsIncapacitated()) + { + return false; + } + if (!InRange(player, coords)) { player.PopupMessage(Loc.GetString("pointing-system-try-point-cannot-reach")); @@ -117,7 +125,7 @@ public bool TryPoint(ICommonSession? session, EntityCoordinates coords, EntityUi var arrow = EntityManager.SpawnEntity("pointingarrow", mapCoords); var layer = (int) VisibilityFlags.Normal; - if (EntityManager.TryGetComponent(player, out VisibilityComponent? playerVisibility)) + if (TryComp(player, out VisibilityComponent? playerVisibility)) { var arrowVisibility = arrow.EnsureComponent(); layer = arrowVisibility.Layer = playerVisibility.Layer; @@ -127,11 +135,11 @@ public bool TryPoint(ICommonSession? session, EntityCoordinates coords, EntityUi bool ViewerPredicate(IPlayerSession playerSession) { if (playerSession.ContentData()?.Mind?.CurrentEntity is not {Valid: true} ent || - !EntityManager.TryGetComponent(ent, out var eyeComp) || + !TryComp(ent, out EyeComponent? eyeComp) || (eyeComp.VisibilityMask & layer) == 0) return false; - return EntityManager.GetComponent(ent).MapPosition.InRange(EntityManager.GetComponent(player).MapPosition, PointingRange); + return Transform(ent).MapPosition.InRange(Transform(player).MapPosition, PointingRange); } var viewers = Filter.Empty() @@ -141,18 +149,21 @@ bool ViewerPredicate(IPlayerSession playerSession) string selfMessage; string viewerMessage; string? viewerPointedAtMessage = null; + var playerName = Name(player); - if (EntityManager.EntityExists(pointed)) + if (Exists(pointed)) { + var pointedName = Name(pointed); + selfMessage = player == pointed ? Loc.GetString("pointing-system-point-at-self") - : Loc.GetString("pointing-system-point-at-other", ("other", pointed)); + : Loc.GetString("pointing-system-point-at-other", ("other", pointedName)); viewerMessage = player == pointed - ? Loc.GetString("pointing-system-point-at-self-others", ("otherName", Name: EntityManager.GetComponent(player).EntityName), ("other", player)) - : Loc.GetString("pointing-system-point-at-other-others", ("otherName", Name: EntityManager.GetComponent(player).EntityName), ("other", pointed)); + ? Loc.GetString("pointing-system-point-at-self-others", ("otherName", playerName), ("other", playerName)) + : Loc.GetString("pointing-system-point-at-other-others", ("otherName", playerName), ("other", pointedName)); - viewerPointedAtMessage = Loc.GetString("pointing-system-point-at-you-other", ("otherName", Name: EntityManager.GetComponent(player).EntityName)); + viewerPointedAtMessage = Loc.GetString("pointing-system-point-at-you-other", ("otherName", playerName)); } else { @@ -167,7 +178,7 @@ bool ViewerPredicate(IPlayerSession playerSession) selfMessage = Loc.GetString("pointing-system-point-at-tile", ("tileName", tileDef.DisplayName)); - viewerMessage = Loc.GetString("pointing-system-other-point-at-tile", ("otherName", Name: EntityManager.GetComponent(player).EntityName), ("tileName", tileDef.DisplayName)); + viewerMessage = Loc.GetString("pointing-system-other-point-at-tile", ("otherName", playerName), ("tileName", tileDef.DisplayName)); } _pointers[session] = _gameTiming.CurTime; @@ -196,17 +207,19 @@ private void AddPointingVerb(GetOtherVerbsEvent args) return; //Check if the object is already being pointed at - if (EntityManager.HasComponent(args.Target)) + if (HasComp(args.Target)) return; + var transform = Transform(args.Target); + if (!EntityManager.TryGetComponent(args.User, out var actor) || - !InRange(args.User, EntityManager.GetComponent(args.Target).Coordinates)) + !InRange(args.User, transform.Coordinates)) return; Verb verb = new(); verb.Text = Loc.GetString("pointing-verb-get-data-text"); verb.IconTexture = "/Textures/Interface/VerbIcons/point.svg.192dpi.png"; - verb.Act = () => TryPoint(actor.PlayerSession, EntityManager.GetComponent(args.Target).Coordinates, args.Target); ; + verb.Act = () => TryPoint(actor.PlayerSession, transform.Coordinates, args.Target); args.Verbs.Add(verb); }