From 6bd6b9789a70fd087102763768fb6772aae021dc Mon Sep 17 00:00:00 2001 From: Vera Aguilera Puerto Date: Fri, 6 Aug 2021 18:27:37 +0200 Subject: [PATCH] Pointing coordinate fixes. --- .../Pointing/EntitySystems/PointingSystem.cs | 15 +++++++++++---- Resources/Changelog/Changelog.yml | 2 +- Resources/Changelog/Parts/pointing_self.yml | 4 ++++ Resources/Changelog/Parts/pointing_space.yml | 4 ++++ 4 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 Resources/Changelog/Parts/pointing_self.yml create mode 100644 Resources/Changelog/Parts/pointing_space.yml diff --git a/Content.Server/Pointing/EntitySystems/PointingSystem.cs b/Content.Server/Pointing/EntitySystems/PointingSystem.cs index e855c9270c..007e931658 100644 --- a/Content.Server/Pointing/EntitySystems/PointingSystem.cs +++ b/Content.Server/Pointing/EntitySystems/PointingSystem.cs @@ -89,6 +89,7 @@ namespace Content.Server.Pointing.EntitySystems public bool TryPoint(ICommonSession? session, EntityCoordinates coords, EntityUid uid) { + var mapCoords = coords.ToMap(EntityManager); var player = (session as IPlayerSession)?.ContentData()?.Mind?.CurrentEntity; if (player == null) { @@ -115,14 +116,14 @@ namespace Content.Server.Pointing.EntitySystems if (_actionBlockerSystem.CanChangeDirection(player)) { - var diff = coords.ToMapPos(EntityManager) - player.Transform.MapPosition.Position; + var diff = mapCoords.Position - player.Transform.MapPosition.Position; if (diff.LengthSquared > 0.01f) { player.Transform.LocalRotation = new Angle(diff); } } - var arrow = EntityManager.SpawnEntity("pointingarrow", coords); + var arrow = EntityManager.SpawnEntity("pointingarrow", mapCoords); var layer = (int) VisibilityFlags.Normal; if (player.TryGetComponent(out VisibilityComponent? playerVisibility)) @@ -160,8 +161,14 @@ namespace Content.Server.Pointing.EntitySystems } else { - var tileRef = _mapManager.GetGrid(coords.GetGridId(EntityManager)).GetTileRef(coords); - var tileDef = _tileDefinitionManager[tileRef.Tile.TypeId]; + TileRef? tileRef = null; + + if (_mapManager.TryFindGridAt(mapCoords, out var grid)) + { + tileRef = grid.GetTileRef(grid.WorldToTile(mapCoords.Position)); + } + + var tileDef = _tileDefinitionManager[tileRef?.Tile.TypeId ?? 0]; selfMessage = Loc.GetString("pointing-system-point-at-tile", ("tileName", tileDef.DisplayName)); diff --git a/Resources/Changelog/Changelog.yml b/Resources/Changelog/Changelog.yml index 2424cee6db..f50985cb2a 100644 --- a/Resources/Changelog/Changelog.yml +++ b/Resources/Changelog/Changelog.yml @@ -1690,7 +1690,7 @@ Entries: situations.', type: Fix} id: 301 time: '2021-08-06T15:53:48.856573+00:00' -- author: Your_Name_Here +- author: Zumorica changes: - {message: Fixes pickup animation not showing under certain conditions., type: Fix} id: 302 diff --git a/Resources/Changelog/Parts/pointing_self.yml b/Resources/Changelog/Parts/pointing_self.yml new file mode 100644 index 0000000000..3d6d5d1b30 --- /dev/null +++ b/Resources/Changelog/Parts/pointing_self.yml @@ -0,0 +1,4 @@ +author: Zumorica +changes: + - type: Fix # One of the following: Add, Remove, Tweak, Fix + message: Fix pointing at an item in your inventory resulting in the pointing arrow playing a weird animation. diff --git a/Resources/Changelog/Parts/pointing_space.yml b/Resources/Changelog/Parts/pointing_space.yml new file mode 100644 index 0000000000..17bd93c9af --- /dev/null +++ b/Resources/Changelog/Parts/pointing_space.yml @@ -0,0 +1,4 @@ +author: Zumorica +changes: + - type: Fix # One of the following: Add, Remove, Tweak, Fix + message: Fix bug where you couldn't point at space.