mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-01 17:47:24 +02:00
* Move MapManager queries to SharedMapSystem Moves all variants of FindGridsIntersecting/TryFindGridAt to SharedMapSystem Hollows out the MapManager methods and converts them into relays to SharedMapSystem * Move CreateGrid to SharedMapSystem Moves the functionality for CreateGrid and its variants to SharedMapSystem Hollows out the MapManager methods and converts them into relays for the SharedMapSystem methods Obsoletes them too Also moves over the GetAllMapGrids and GetAllGrids methods * Move RaiseOnTileChanged to SharedMapSystem Also moves the SuppressOnTileChanged flag member to SharedMapSystem Hollows out and obsoletes the MapManager versions * Move default value constants to SharedMapSystem * Converts map pausing events into LocalizedEntityCommands * Move MapManager related delegates/structs to SharedMapSystem Moves the GridCreationOptions struct to the same namespace as SharedMapSystem and converts it into a record struct Move the GridCallback delegates to the same namespace as SharedMapSystem * Move CullDeletionHistory to SharedMapSystem Well, that was less painful than I thought it would be * Actually obsolete the NetworkedMapManager method * Rename file * Doc comments for new SharedMapSystem methods * Doc comment * Doc comments * Fix access * Purge all references to IMapManagerInternal * Cull easy IMapManager references * The rest * Purge IMapManager * Private internal FindGridsIntersecting method * please die * 41 * notes --------- Co-authored-by: ArtisticRoomba <145879011+ArtisticRoomba@users.noreply.github.com>
141 lines
5.3 KiB
C#
141 lines
5.3 KiB
C#
using System.Text;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.Input;
|
|
using Robust.Client.Player;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Maths;
|
|
using Robust.Shared.Timing;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Robust.Client.UserInterface.CustomControls.DebugMonitorControls
|
|
{
|
|
internal sealed partial class DebugCoordsPanel : PanelContainer
|
|
{
|
|
[Dependency] private IPlayerManager _playerManager = default!;
|
|
[Dependency] private IEyeManager _eyeManager = default!;
|
|
[Dependency] private IInputManager _inputManager = default!;
|
|
[Dependency] private IEntityManager _entityManager = default!;
|
|
[Dependency] private IClyde _displayManager = default!;
|
|
[Dependency] private IBaseClient _baseClient = default!;
|
|
|
|
private readonly StringBuilder _textBuilder = new();
|
|
private readonly char[] _textBuffer = new char[1024];
|
|
|
|
private readonly Label _contents;
|
|
|
|
public DebugCoordsPanel()
|
|
{
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
HorizontalAlignment = HAlignment.Left;
|
|
|
|
_contents = new Label
|
|
{
|
|
FontColorShadowOverride = Color.Black
|
|
};
|
|
AddChild(_contents);
|
|
|
|
PanelOverride = new StyleBoxFlat
|
|
{
|
|
BackgroundColor = new Color(67, 105, 255, 138),
|
|
ContentMarginLeftOverride = 5,
|
|
ContentMarginTopOverride = 5
|
|
};
|
|
|
|
MouseFilter = _contents.MouseFilter = MouseFilterMode.Ignore;
|
|
MinWidth = 175;
|
|
}
|
|
|
|
protected override void FrameUpdate(FrameEventArgs args)
|
|
{
|
|
if (!VisibleInTree)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_textBuilder.Clear();
|
|
|
|
var isInGame = _baseClient.RunLevel.IsInGameLike();
|
|
var mouseScreenPos = _inputManager.MouseScreenPosition;
|
|
var screenSize = _displayManager.ScreenSize;
|
|
var screenScale = _displayManager.MainWindow.ContentScale;
|
|
|
|
EntityCoordinates mouseGridPos = default;
|
|
TileRef tile = default;
|
|
MapCoordinates mouseWorldMap = default;
|
|
|
|
if (isInGame)
|
|
{
|
|
mouseWorldMap = _eyeManager.PixelToMap(mouseScreenPos);
|
|
if (mouseWorldMap != MapCoordinates.Nullspace)
|
|
{
|
|
var mapSystem = _entityManager.System<SharedMapSystem>();
|
|
var xformSystem = _entityManager.System<SharedTransformSystem>();
|
|
|
|
if (mapSystem.TryFindGridAt(mouseWorldMap, out var mouseGridUid, out var mouseGrid))
|
|
{
|
|
mouseGridPos = mapSystem.MapToGrid(mouseGridUid, mouseWorldMap);
|
|
tile = mapSystem.GetTileRef(mouseGridUid, mouseGrid, mouseGridPos);
|
|
}
|
|
else
|
|
{
|
|
mouseGridPos = new EntityCoordinates(mapSystem.GetMapOrInvalid(mouseWorldMap.MapId),
|
|
mouseWorldMap.Position);
|
|
tile = new TileRef(EntityUid.Invalid,
|
|
mouseGridPos.ToVector2i(_entityManager, xformSystem), Tile.Empty);
|
|
}
|
|
}
|
|
}
|
|
|
|
var controlHovered = UserInterfaceManager.CurrentlyHovered;
|
|
|
|
_textBuilder.Append($@"Positioning Debug:
|
|
Screen Size: {screenSize} (scale: {screenScale})
|
|
Mouse Pos:
|
|
Screen: {mouseScreenPos}
|
|
{mouseWorldMap}
|
|
{_entityManager.GetNetCoordinates(mouseGridPos)}
|
|
{tile}
|
|
GUI: {controlHovered}");
|
|
|
|
if (isInGame)
|
|
{
|
|
var xformSystem = _entityManager.System<SharedTransformSystem>();
|
|
|
|
_textBuilder.AppendLine("\nAttached NetEntity:");
|
|
var controlledEntity = _playerManager.LocalSession?.AttachedEntity ?? EntityUid.Invalid;
|
|
|
|
if (controlledEntity == EntityUid.Invalid)
|
|
{
|
|
_textBuilder.AppendLine("No attached netentity.");
|
|
}
|
|
else
|
|
{
|
|
var entityTransform = _entityManager.GetComponent<TransformComponent>(controlledEntity);
|
|
var playerWorldOffset = xformSystem.GetMapCoordinates(entityTransform);
|
|
var playerScreen = _eyeManager.WorldToScreen(playerWorldOffset.Position);
|
|
|
|
var playerCoordinates = entityTransform.Coordinates;
|
|
var playerRotation = xformSystem.GetWorldRotation(entityTransform);
|
|
var gridRotation = entityTransform.GridUid != null
|
|
? xformSystem.GetWorldRotation(entityTransform.GridUid.Value)
|
|
: Angle.Zero;
|
|
|
|
_textBuilder.Append($@" Screen: {playerScreen}
|
|
{playerWorldOffset}
|
|
{_entityManager.GetNetCoordinates(playerCoordinates)}
|
|
Rotation: {playerRotation.Degrees:F2}°
|
|
NEntId: {_entityManager.GetNetEntity(controlledEntity)}
|
|
Grid NEntId: {_entityManager.GetNetEntity(entityTransform.GridUid)}
|
|
Grid Rotation: {gridRotation.Degrees:F2}°");
|
|
}
|
|
}
|
|
|
|
_contents.TextMemory = FormatHelpers.BuilderToMemory(_textBuilder, _textBuffer);
|
|
}
|
|
}
|
|
}
|