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:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Content.Client.State
|
||||
{
|
||||
base.FrameUpdate(e);
|
||||
|
||||
var mousePosWorld = _eyeManager.ScreenToWorld(_inputManager.MouseScreenPosition);
|
||||
var mousePosWorld = _eyeManager.ScreenToMap(_inputManager.MouseScreenPosition);
|
||||
var entityToClick = _userInterfaceManager.CurrentlyHovered != null ? null : GetEntityUnderPosition(mousePosWorld);
|
||||
|
||||
var inRange = false;
|
||||
@@ -89,17 +89,21 @@ namespace Content.Client.State
|
||||
}
|
||||
}
|
||||
|
||||
public IEntity GetEntityUnderPosition(GridCoordinates coordinates)
|
||||
public IEntity GetEntityUnderPosition(MapCoordinates coordinates)
|
||||
{
|
||||
var entitiesUnderPosition = GetEntitiesUnderPosition(coordinates);
|
||||
return entitiesUnderPosition.Count > 0 ? entitiesUnderPosition[0] : null;
|
||||
}
|
||||
|
||||
public IList<IEntity> GetEntitiesUnderPosition(GridCoordinates coordinates)
|
||||
{
|
||||
return GetEntitiesUnderPosition(coordinates.ToMap(_mapManager));
|
||||
}
|
||||
|
||||
public IList<IEntity> GetEntitiesUnderPosition(MapCoordinates coordinates)
|
||||
{
|
||||
// Find all the entities intersecting our click
|
||||
var mapCoords = coordinates.ToMap(_mapManager);
|
||||
var entities = _entityManager.GetEntitiesIntersecting(mapCoords.MapId, mapCoords.Position);
|
||||
var entities = _entityManager.GetEntitiesIntersecting(coordinates.MapId, coordinates.Position);
|
||||
|
||||
// Check the entities against whether or not we can click them
|
||||
var foundEntities = new List<(IEntity clicked, int drawDepth)>();
|
||||
@@ -149,10 +153,15 @@ namespace Content.Client.State
|
||||
var func = args.Function;
|
||||
var funcId = _inputManager.NetworkBindMap.KeyFunctionID(func);
|
||||
|
||||
var mousePosWorld = _eyeManager.ScreenToWorld(args.PointerLocation);
|
||||
var mousePosWorld = _eyeManager.ScreenToMap(args.PointerLocation);
|
||||
var entityToClick = GetEntityUnderPosition(mousePosWorld);
|
||||
var message = new FullInputCmdMessage(_timing.CurTick, funcId, args.State, mousePosWorld,
|
||||
args.PointerLocation, entityToClick?.Uid ?? EntityUid.Invalid);
|
||||
|
||||
if (!_mapManager.TryFindGridAt(mousePosWorld, out var grid))
|
||||
grid = _mapManager.GetDefaultGrid(mousePosWorld.MapId);
|
||||
|
||||
var message = new FullInputCmdMessage(_timing.CurTick, funcId, args.State,
|
||||
grid.MapToGrid(mousePosWorld), args.PointerLocation,
|
||||
entityToClick?.Uid ?? EntityUid.Invalid);
|
||||
|
||||
// client side command handlers will always be sent the local player session.
|
||||
var session = _playerManager.LocalPlayer.Session;
|
||||
|
||||
@@ -15,6 +15,7 @@ using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Interfaces.Map;
|
||||
using Robust.Shared.Interfaces.Timing;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
@@ -30,6 +31,7 @@ namespace Content.Client.UserInterface
|
||||
[Dependency] private readonly IInputManager _inputManager;
|
||||
[Dependency] private readonly IEntitySystemManager _entitySystemManager;
|
||||
[Dependency] private readonly IEyeManager _eyeManager;
|
||||
[Dependency] private readonly IMapManager _mapManager;
|
||||
#pragma warning restore 0649
|
||||
|
||||
public bool SetItemSlot(ItemSlotButton button, IEntity entity)
|
||||
@@ -71,9 +73,12 @@ namespace Content.Client.UserInterface
|
||||
var func = args.Function;
|
||||
var funcId = _inputManager.NetworkBindMap.KeyFunctionID(args.Function);
|
||||
|
||||
var mousePosWorld = _eyeManager.ScreenToWorld(args.PointerLocation);
|
||||
var message = new FullInputCmdMessage(_gameTiming.CurTick, funcId, BoundKeyState.Down, mousePosWorld,
|
||||
args.PointerLocation, item.Uid);
|
||||
var mousePosWorld = _eyeManager.ScreenToMap(args.PointerLocation);
|
||||
if (!_mapManager.TryFindGridAt(mousePosWorld, out var grid))
|
||||
grid = _mapManager.GetDefaultGrid(mousePosWorld.MapId);
|
||||
|
||||
var message = new FullInputCmdMessage(_gameTiming.CurTick, funcId, BoundKeyState.Down,
|
||||
grid.MapToGrid(mousePosWorld), args.PointerLocation, item.Uid);
|
||||
|
||||
// client side command handlers will always be sent the local player session.
|
||||
var session = _playerManager.LocalPlayer.Session;
|
||||
|
||||
Reference in New Issue
Block a user