Overlays: Avoid using IEyeManager whenever possible (#5709)
This commit is contained in:
@@ -21,7 +21,6 @@ namespace Content.Client.NodeContainer
|
||||
private readonly IEntityLookup _lookup;
|
||||
private readonly IMapManager _mapManager;
|
||||
private readonly IInputManager _inputManager;
|
||||
private readonly IEyeManager _eyeManager;
|
||||
private readonly IEntityManager _entityManager;
|
||||
|
||||
private readonly Dictionary<(int, int), NodeRenderData> _nodeIndex = new();
|
||||
@@ -29,6 +28,7 @@ namespace Content.Client.NodeContainer
|
||||
|
||||
private readonly Font _font;
|
||||
|
||||
private Vector2 _mouseWorldPos = default;
|
||||
private (int group, int node)? _hovered;
|
||||
private float _time;
|
||||
|
||||
@@ -39,7 +39,6 @@ namespace Content.Client.NodeContainer
|
||||
IEntityLookup lookup,
|
||||
IMapManager mapManager,
|
||||
IInputManager inputManager,
|
||||
IEyeManager eyeManager,
|
||||
IResourceCache cache,
|
||||
IEntityManager entityManager)
|
||||
{
|
||||
@@ -47,7 +46,6 @@ namespace Content.Client.NodeContainer
|
||||
_lookup = lookup;
|
||||
_mapManager = mapManager;
|
||||
_inputManager = inputManager;
|
||||
_eyeManager = eyeManager;
|
||||
_entityManager = entityManager;
|
||||
|
||||
_font = cache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 12);
|
||||
@@ -67,6 +65,12 @@ namespace Content.Client.NodeContainer
|
||||
|
||||
private void DrawScreen(in OverlayDrawArgs args)
|
||||
{
|
||||
var mousePos = _inputManager.MouseScreenPosition.Position;
|
||||
_mouseWorldPos = args
|
||||
.ViewportControl!
|
||||
.ScreenToMap(new Vector2(mousePos.X, mousePos.Y))
|
||||
.Position;
|
||||
|
||||
if (_hovered == null)
|
||||
return;
|
||||
|
||||
@@ -75,7 +79,6 @@ namespace Content.Client.NodeContainer
|
||||
var group = _system.Groups[groupId];
|
||||
var node = _system.NodeLookup[(groupId, nodeId)];
|
||||
|
||||
var mousePos = _inputManager.MouseScreenPosition.Position;
|
||||
|
||||
var gridId = _entityManager.GetComponent<TransformComponent>(node.Entity).GridID;
|
||||
var grid = _mapManager.GetGrid(gridId);
|
||||
@@ -102,12 +105,9 @@ namespace Content.Client.NodeContainer
|
||||
if (map == MapId.Nullspace)
|
||||
return;
|
||||
|
||||
var mouseScreenPos = _inputManager.MouseScreenPosition;
|
||||
var mouseWorldPos = _eyeManager.ScreenToMap(mouseScreenPos).Position;
|
||||
|
||||
_hovered = default;
|
||||
|
||||
var cursorBox = Box2.CenteredAround(mouseWorldPos, (nodeSize, nodeSize));
|
||||
var cursorBox = Box2.CenteredAround(_mouseWorldPos, (nodeSize, nodeSize));
|
||||
|
||||
// Group visible nodes by grid tiles.
|
||||
var worldAABB = overlayDrawArgs.WorldAABB;
|
||||
|
||||
Reference in New Issue
Block a user