Silence ScreenToWorld warnings (#1098)

This fixes one case of GridCoordinates being used unnecessarily, in
GameScreenBase.

It replaces other cases with explicit calls to TryFindGridAt and
GetDefaultGrid.
This commit is contained in:
ComicIronic
2020-06-12 17:36:25 +01:00
committed by GitHub
parent 7817681894
commit 3cedcaf004
3 changed files with 31 additions and 12 deletions

View File

@@ -6,6 +6,7 @@ using Robust.Client.Interfaces.Input;
using Robust.Client.Player;
using Robust.Shared.GameObjects.Systems;
using Robust.Shared.Input;
using Robust.Shared.Interfaces.Map;
using Robust.Shared.Interfaces.Timing;
using Robust.Shared.IoC;
using Robust.Shared.Log;
@@ -18,6 +19,7 @@ namespace Content.Client.GameObjects.EntitySystems
#pragma warning disable 649
[Dependency] private readonly IPlayerManager _playerManager;
[Dependency] private readonly IEyeManager _eyeManager;
[Dependency] private readonly IMapManager _mapManager;
[Dependency] private readonly IInputManager _inputManager;
[Dependency] private readonly IGameTiming _gameTiming;
#pragma warning restore 649
@@ -74,11 +76,14 @@ namespace Content.Client.GameObjects.EntitySystems
return;
}
var worldPos = _eyeManager.ScreenToWorld(_inputManager.MouseScreenPosition);
var worldPos = _eyeManager.ScreenToMap(_inputManager.MouseScreenPosition);
if (!_mapManager.TryFindGridAt(worldPos, out var grid))
grid = _mapManager.GetDefaultGrid(worldPos.MapId);
if (weapon.Automatic || canFireSemi)
{
weapon.SyncFirePos(worldPos);
weapon.SyncFirePos(grid.MapToGrid(worldPos));
}
}
}