Remove most usages of obsolete TransformComponent methods (#19571)

This commit is contained in:
Visne
2023-08-30 04:05:19 +02:00
committed by GitHub
parent 3ba60835ec
commit 1416942bea
91 changed files with 312 additions and 221 deletions

View File

@@ -14,6 +14,7 @@ public sealed class ExplosionDebugOverlay : Overlay
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
private readonly SharedTransformSystem _transform;
public Dictionary<int, List<Vector2i>>? SpaceTiles;
public Dictionary<EntityUid, Dictionary<int, List<Vector2i>>> Tiles = new();
@@ -35,6 +36,8 @@ public sealed class ExplosionDebugOverlay : Overlay
var cache = IoCManager.Resolve<IResourceCache>();
_font = new VectorFont(cache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 8);
_transform = _entityManager.System<SharedTransformSystem>();
}
protected override void Draw(in OverlayDrawArgs args)
@@ -68,7 +71,7 @@ public sealed class ExplosionDebugOverlay : Overlay
continue;
var gridXform = xformQuery.GetComponent(grid.Owner);
var (_, _, matrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(xformQuery);
var (_, _, matrix, invMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform, xformQuery);
gridBounds = invMatrix.TransformBox(args.WorldBounds).Enlarged(grid.TileSize * 2);
DrawText(handle, gridBounds, matrix, tileSets, grid.TileSize);
}
@@ -136,7 +139,7 @@ public sealed class ExplosionDebugOverlay : Overlay
continue;
var gridXform = xformQuery.GetComponent(grid.Owner);
var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(xformQuery);
var (_, _, worldMatrix, invWorldMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform, xformQuery);
gridBounds = invWorldMatrix.TransformBox(args.WorldBounds).Enlarged(grid.TileSize * 2);
handle.SetTransform(worldMatrix);
DrawTiles(handle, gridBounds, tileSets, SpaceTileSize);

View File

@@ -17,6 +17,7 @@ namespace Content.Client.Atmos.Overlays
[Dependency] private readonly IEntityManager _entManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
private readonly SharedTransformSystem _transform;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
@@ -25,6 +26,7 @@ namespace Content.Client.Atmos.Overlays
IoCManager.InjectDependencies(this);
_atmosDebugOverlaySystem = system;
_transform = _entManager.System<SharedTransformSystem>();
}
protected override void Draw(in OverlayDrawArgs args)
@@ -47,7 +49,7 @@ namespace Content.Client.Atmos.Overlays
!_entManager.TryGetComponent<TransformComponent>(mapGrid.Owner, out var xform))
continue;
drawHandle.SetTransform(xform.WorldMatrix);
drawHandle.SetTransform(_transform.GetWorldMatrix(xform));
for (var pass = 0; pass < 2; pass++)
{

View File

@@ -19,6 +19,7 @@ namespace Content.Client.Atmos.Overlays
public sealed class GasTileOverlay : Overlay
{
private readonly IEntityManager _entManager;
private readonly SharedTransformSystem _transform;
private readonly IMapManager _mapManager;
public override OverlaySpace Space => OverlaySpace.WorldSpaceEntities;
@@ -48,6 +49,7 @@ namespace Content.Client.Atmos.Overlays
public GasTileOverlay(GasTileOverlaySystem system, IEntityManager entManager, IResourceCache resourceCache, IPrototypeManager protoMan, SpriteSystem spriteSys)
{
_entManager = entManager;
_transform = entManager.System<SharedTransformSystem>();
_mapManager = IoCManager.Resolve<IMapManager>();
_shader = protoMan.Index<ShaderPrototype>("unshaded").Instance();
ZIndex = GasOverlayZIndex;
@@ -182,7 +184,7 @@ namespace Content.Client.Atmos.Overlays
// TODO: WorldBounds callback.
_mapManager.FindGridsIntersecting(args.MapId, args.WorldAABB, ref gridState,
static (EntityUid uid, MapGridComponent grid,
(EntityUid uid, MapGridComponent grid,
ref (Box2Rotated WorldBounds,
DrawingHandleWorld drawHandle,
int gasCount,
@@ -200,7 +202,7 @@ namespace Content.Client.Atmos.Overlays
return true;
}
var (_, _, worldMatrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
var (_, _, worldMatrix, invMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform);
state.drawHandle.SetTransform(worldMatrix);
var floatBounds = invMatrix.TransformBox(in state.WorldBounds).Enlarged(grid.TileSize);
var localBounds = new Box2i(

View File

@@ -29,6 +29,7 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
protected override void QueueUpdate(EntityUid uid, AmbientSoundComponent ambience)
=> _treeSys.QueueTreeUpdate(uid, ambience);
@@ -201,7 +202,7 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
}
}
private static bool Callback(
private bool Callback(
ref QueryState state,
in ComponentTreeEntry<AmbientSoundComponent> value)
{
@@ -211,7 +212,7 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
var delta = xform.ParentUid == state.Player.ParentUid
? xform.LocalPosition - state.Player.LocalPosition
: xform.WorldPosition - state.MapPos;
: _transform.GetWorldPosition(xform) - state.MapPos;
var range = delta.Length();
if (range >= ambientComp.Range)
@@ -253,7 +254,7 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
{
var distance = (xform.ParentUid == playerXform.ParentUid)
? xform.LocalPosition - playerXform.LocalPosition
: xform.WorldPosition - mapPos.Position;
: _transform.GetWorldPosition(xform) - mapPos.Position;
if (distance.LengthSquared() < comp.Range * comp.Range)
continue;

View File

@@ -10,6 +10,7 @@ namespace Content.Client.CardboardBox;
public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
{
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize()
{
@@ -55,7 +56,7 @@ public sealed class CardboardBoxSystem : SharedCardboardBoxSystem
continue;
sprite.Offset = new Vector2(0, 1);
entTransform.AttachParent(mob);
_transform.SetParent(ent, entTransform, mob);
}
}
}

View File

@@ -36,6 +36,7 @@ namespace Content.Client.Chat.UI
private readonly EntityUid _senderEntity;
private readonly IChatManager _chatManager;
private readonly IEntityManager _entityManager;
private readonly SharedTransformSystem _transform;
private float _timeLeft = TotalTime;
@@ -47,30 +48,43 @@ namespace Content.Client.Chat.UI
// man down
public event Action<EntityUid, SpeechBubble>? OnDied;
public static SpeechBubble CreateSpeechBubble(SpeechType type, string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager)
public static SpeechBubble CreateSpeechBubble(SpeechType type,
string text,
EntityUid senderEntity,
IEyeManager eyeManager,
IChatManager chatManager,
IEntityManager entityManager,
SharedTransformSystem transform)
{
switch (type)
{
case SpeechType.Emote:
return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, "emoteBox");
return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, transform, "emoteBox");
case SpeechType.Say:
return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, "sayBox");
return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, transform, "sayBox");
case SpeechType.Whisper:
return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, "whisperBox");
return new TextSpeechBubble(text, senderEntity, eyeManager, chatManager, entityManager, transform, "whisperBox");
default:
throw new ArgumentOutOfRangeException();
}
}
public SpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager, string speechStyleClass)
public SpeechBubble(string text,
EntityUid senderEntity,
IEyeManager eyeManager,
IChatManager chatManager,
IEntityManager entityManager,
SharedTransformSystem transform,
string speechStyleClass)
{
_chatManager = chatManager;
_senderEntity = senderEntity;
_eyeManager = eyeManager;
_entityManager = entityManager;
_transform = transform;
// Use text clipping so new messages don't overlap old ones being pushed up.
RectClipContent = true;
@@ -128,7 +142,7 @@ namespace Content.Client.Chat.UI
}
var offset = (-_eyeManager.CurrentEye.Rotation).ToWorldVec() * -EntityVerticalOffset;
var worldPos = xform.WorldPosition + offset;
var worldPos = _transform.GetWorldPosition(xform) + offset;
var lowerCenter = _eyeManager.WorldToScreen(worldPos) / UIScale;
var screenPos = lowerCenter - new Vector2(ContentSize.X / 2, ContentSize.Y + _verticalOffsetAchieved);
@@ -164,8 +178,14 @@ namespace Content.Client.Chat.UI
public sealed class TextSpeechBubble : SpeechBubble
{
public TextSpeechBubble(string text, EntityUid senderEntity, IEyeManager eyeManager, IChatManager chatManager, IEntityManager entityManager, string speechStyleClass)
: base(text, senderEntity, eyeManager, chatManager, entityManager, speechStyleClass)
public TextSpeechBubble(string text,
EntityUid senderEntity,
IEyeManager eyeManager,
IChatManager chatManager,
IEntityManager entityManager,
SharedTransformSystem transform,
string speechStyleClass)
: base(text, senderEntity, eyeManager, chatManager, entityManager, transform, speechStyleClass)
{
}

View File

@@ -11,6 +11,7 @@ namespace Content.Client.Decals.Overlays
private readonly SpriteSystem _sprites;
private readonly IEntityManager _entManager;
private readonly IPrototypeManager _prototypeManager;
private readonly SharedTransformSystem _transform;
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowEntities;
@@ -24,6 +25,7 @@ namespace Content.Client.Decals.Overlays
_sprites = sprites;
_entManager = entManager;
_prototypeManager = prototypeManager;
_transform = _entManager.System<SharedTransformSystem>();
}
protected override void Draw(in OverlayDrawArgs args)
@@ -44,7 +46,7 @@ namespace Content.Client.Decals.Overlays
if (xform.MapID != args.MapId)
continue;
var (_, worldRot, worldMatrix) = xform.GetWorldPositionRotationMatrix(xformQuery);
var (_, worldRot, worldMatrix) = _transform.GetWorldPositionRotationMatrix(xform, xformQuery);
handle.SetTransform(worldMatrix);

View File

@@ -44,6 +44,7 @@ public sealed class DragDropSystem : SharedDragDropSystem
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
private ISawmill _sawmill = default!;
@@ -253,9 +254,7 @@ public sealed class DragDropSystem : SharedDragDropSystem
// keep it on top of everything
dragSprite.DrawDepth = (int) DrawDepth.Overlays;
if (!dragSprite.NoRotation)
{
Transform(_dragShadow.Value).WorldRotation = Transform(_draggedEntity.Value).WorldRotation;
}
_transform.SetWorldRotation(_dragShadow.Value, _transform.GetWorldRotation(_draggedEntity.Value));
// drag initiated
return;
@@ -536,7 +535,7 @@ public sealed class DragDropSystem : SharedDragDropSystem
if (Exists(_dragShadow))
{
var mousePos = _eyeManager.PixelToMap(_inputManager.MouseScreenPosition);
Transform(_dragShadow.Value).WorldPosition = mousePos.Position;
_transform.SetWorldPosition(_dragShadow.Value, mousePos.Position);
}
}
}

View File

@@ -16,6 +16,7 @@ public sealed class ExplosionOverlay : Overlay
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
private readonly SharedTransformSystem _transform;
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV;
@@ -25,6 +26,7 @@ public sealed class ExplosionOverlay : Overlay
{
IoCManager.InjectDependencies(this);
_shader = _proto.Index<ShaderPrototype>("unshaded").Instance();
_transform = _entMan.System<SharedTransformSystem>();
}
protected override void Draw(in OverlayDrawArgs args)
@@ -67,7 +69,7 @@ public sealed class ExplosionOverlay : Overlay
continue;
var xform = xforms.GetComponent(grid.Owner);
var (_, _, worldMatrix, invWorldMatrix) = xform.GetWorldPositionRotationMatrixWithInv(xforms);
var (_, _, worldMatrix, invWorldMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(xform, xforms);
gridBounds = invWorldMatrix.TransformBox(worldBounds).Enlarged(grid.TileSize * 2);
drawHandle.SetTransform(worldMatrix);

View File

@@ -14,6 +14,7 @@ public sealed class PuddleOverlay : Overlay
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
private readonly PuddleDebugOverlaySystem _debugOverlaySystem;
private readonly SharedTransformSystem _transform;
private readonly Color _heavyPuddle = new(0, 255, 255, 50);
private readonly Color _mediumPuddle = new(0, 150, 255, 50);
@@ -27,6 +28,7 @@ public sealed class PuddleOverlay : Overlay
{
IoCManager.InjectDependencies(this);
_debugOverlaySystem = _entitySystemManager.GetEntitySystem<PuddleDebugOverlaySystem>();
_transform = _entitySystemManager.GetEntitySystem<SharedTransformSystem>();
var cache = IoCManager.Resolve<IResourceCache>();
_font = new VectorFont(cache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 8);
}
@@ -56,7 +58,7 @@ public sealed class PuddleOverlay : Overlay
continue;
var gridXform = xformQuery.GetComponent(gridId);
var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(xformQuery);
var (_, _, worldMatrix, invWorldMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform, xformQuery);
gridBounds = invWorldMatrix.TransformBox(args.WorldBounds).Enlarged(mapGrid.TileSize * 2);
drawHandle.SetTransform(worldMatrix);
@@ -89,7 +91,7 @@ public sealed class PuddleOverlay : Overlay
continue;
var gridXform = xformQuery.GetComponent(gridId);
var (_, _, matrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(xformQuery);
var (_, _, matrix, invMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform, xformQuery);
var gridBounds = invMatrix.TransformBox(args.WorldBounds).Enlarged(mapGrid.TileSize * 2);
foreach (var debugOverlayData in _debugOverlaySystem.GetData(mapGrid.Owner))

View File

@@ -16,6 +16,7 @@ namespace Content.Client.HealthOverlay
{
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IEntityManager _entities = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
private readonly Dictionary<EntityUid, HealthOverlayGui> _guis = new();
private EntityUid? _attachedEntity;
@@ -85,7 +86,7 @@ namespace Content.Client.HealthOverlay
var entity = mobState.Owner;
if (_entities.GetComponent<TransformComponent>(ent).MapID != _entities.GetComponent<TransformComponent>(entity).MapID ||
!viewBox.Contains(_entities.GetComponent<TransformComponent>(entity).WorldPosition))
!viewBox.Contains(_transform.GetWorldPosition(entity)))
{
if (_guis.TryGetValue(entity, out var oldGui))
{

View File

@@ -18,6 +18,7 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly InputSystem _inputSystem = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public bool Enabled { get; set; }
@@ -66,7 +67,7 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem
xform.MapID == _lastMousePosition.Value.MapId)
{
var tickTime = _gameTiming.TickPeriod;
var distance = _lastMousePosition.Value.Position - xform.WorldPosition;
var distance = _lastMousePosition.Value.Position - _transform.GetWorldPosition(xform);
RaiseNetworkEvent(new GridDragVelocityRequest()
{
Grid = _dragging.Value,
@@ -101,7 +102,7 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem
if (!_mapManager.TryFindGridAt(mousePos, out var gridUid, out var grid))
return;
StartDragging(gridUid, Transform(gridUid).InvWorldMatrix.Transform(mousePos.Position));
StartDragging(gridUid, _transform.GetInvWorldMatrix(gridUid).Transform(mousePos.Position));
}
if (!TryComp<TransformComponent>(_dragging, out var xform))
@@ -116,11 +117,12 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem
return;
}
var localToWorld = xform.WorldMatrix.Transform(_localPosition);
var localToWorld = _transform.GetWorldMatrix(xform).Transform(_localPosition);
if (localToWorld.EqualsApprox(mousePos.Position, 0.01f)) return;
if (localToWorld.EqualsApprox(mousePos.Position, 0.01f))
return;
var requestedGridOrigin = mousePos.Position - xform.WorldRotation.RotateVec(_localPosition);
var requestedGridOrigin = mousePos.Position - _transform.GetWorldRotation(xform).RotateVec(_localPosition);
_lastMousePosition = new MapCoordinates(requestedGridOrigin, mousePos.MapId);
RaiseNetworkEvent(new GridDragRequestPosition()

View File

@@ -21,6 +21,7 @@ namespace Content.Client.Medical.CrewMonitoring
private List<(DirectionIcon Icon, Vector2 Position)> _directionIcons = new();
private readonly IEntityManager _entManager;
private readonly IEyeManager _eye;
private readonly SharedTransformSystem _transform;
private EntityUid? _stationUid;
private CrewMonitoringButton? _trackedButton;
@@ -31,6 +32,7 @@ namespace Content.Client.Medical.CrewMonitoring
RobustXamlLoader.Load(this);
_eye = IoCManager.Resolve<IEyeManager>();
_entManager = IoCManager.Resolve<IEntityManager>();
_transform = _entManager.System<SharedTransformSystem>();
_stationUid = mapUid;
if (_entManager.TryGetComponent<TransformComponent>(mapUid, out var xform))
@@ -193,7 +195,7 @@ namespace Content.Client.Medical.CrewMonitoring
// Apply the offset relative to the eye.
// For a station at 45 degrees rotation, the current eye rotation is -45 degrees.
// TODO: This feels sketchy. Is there something underlying wrong with eye rotation?
offsetAngle = -(_eye.CurrentEye.Rotation + xform.WorldRotation);
offsetAngle = -(_eye.CurrentEye.Rotation + _transform.GetWorldRotation(xform));
}
foreach (var (icon, pos) in _directionIcons)

View File

@@ -7,14 +7,16 @@ namespace Content.Client.NPC.HTN;
public sealed class HTNOverlay : Overlay
{
private readonly IEntityManager _entManager = default!;
private readonly Font _font = default!;
private readonly IEntityManager _entManager;
private readonly SharedTransformSystem _transform;
private readonly Font _font;
public override OverlaySpace Space => OverlaySpace.ScreenSpace;
public HTNOverlay(IEntityManager entManager, IResourceCache resourceCache)
{
_entManager = entManager;
_transform = entManager.System<SharedTransformSystem>();
_font = new VectorFont(resourceCache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10);
}
@@ -30,7 +32,7 @@ public sealed class HTNOverlay : Overlay
if (string.IsNullOrEmpty(comp.DebugText) || xform.MapID != args.MapId)
continue;
var worldPos = xform.WorldPosition;
var worldPos = _transform.GetWorldPosition(xform);
if (!args.WorldAABB.Contains(worldPos))
continue;

View File

@@ -78,10 +78,12 @@ public sealed class NPCSteeringOverlay : Overlay
public override OverlaySpace Space => OverlaySpace.WorldSpace;
private readonly IEntityManager _entManager;
private readonly SharedTransformSystem _transform;
public NPCSteeringOverlay(IEntityManager entManager)
{
_entManager = entManager;
_transform = entManager.System<SharedTransformSystem>();
}
protected override void Draw(in OverlayDrawArgs args)
@@ -93,7 +95,7 @@ public sealed class NPCSteeringOverlay : Overlay
continue;
}
var (worldPos, worldRot) = xform.GetWorldPositionRotation();
var worldPos = _transform.GetWorldPosition(xform);
if (!args.WorldAABB.Contains(worldPos))
continue;

View File

@@ -2,6 +2,7 @@ using System.Linq;
using System.Numerics;
using System.Text;
using Content.Shared.NPC;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.ResourceManagement;
@@ -20,6 +21,7 @@ namespace Content.Client.NPC
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IResourceCache _cache = default!;
[Dependency] private readonly NPCSteeringSystem _steering = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public PathfindingDebugMode Modes
{
@@ -136,6 +138,7 @@ namespace Content.Client.NPC
private readonly IInputManager _inputManager;
private readonly IMapManager _mapManager;
private readonly PathfindingSystem _system;
private readonly SharedTransformSystem _transform;
public override OverlaySpace Space => OverlaySpace.ScreenSpace | OverlaySpace.WorldSpace;
@@ -154,6 +157,7 @@ namespace Content.Client.NPC
_inputManager = inputManager;
_mapManager = mapManager;
_system = system;
_transform = entManager.System<TransformSystem>();
_font = new VectorFont(cache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10);
}
@@ -187,7 +191,7 @@ namespace Content.Client.NPC
if (found || !_system.Breadcrumbs.TryGetValue(grid.Owner, out var crumbs) || !xformQuery.TryGetComponent(grid.Owner, out var gridXform))
continue;
var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
var (_, _, worldMatrix, invWorldMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform);
var localAABB = invWorldMatrix.TransformBox(aabb.Enlarged(float.Epsilon - SharedPathfindingSystem.ChunkSize));
foreach (var chunk in crumbs)
@@ -271,9 +275,8 @@ namespace Content.Client.NPC
return;
}
var invGridMatrix = gridXform.InvWorldMatrix;
var invGridMatrix = _transform.GetInvWorldMatrix(gridXform);
DebugPathPoly? nearest = null;
var nearestDistance = float.MaxValue;
foreach (var poly in tile)
{
@@ -339,7 +342,7 @@ namespace Content.Client.NPC
continue;
}
var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
var (_, _, worldMatrix, invWorldMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform);
worldHandle.SetTransform(worldMatrix);
var localAABB = invWorldMatrix.TransformBox(aabb);
@@ -394,7 +397,7 @@ namespace Content.Client.NPC
!xformQuery.TryGetComponent(grid.Owner, out var gridXform))
continue;
var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
var (_, _, worldMatrix, invWorldMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform);
worldHandle.SetTransform(worldMatrix);
var localAABB = invWorldMatrix.TransformBox(aabb);
@@ -428,7 +431,7 @@ namespace Content.Client.NPC
!xformQuery.TryGetComponent(grid.Owner, out var gridXform))
continue;
var (_, _, worldMatrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
var (_, _, worldMatrix, invMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform);
worldHandle.SetTransform(worldMatrix);
var localAABB = invMatrix.TransformBox(aabb);
@@ -482,7 +485,7 @@ namespace Content.Client.NPC
!xformQuery.TryGetComponent(grid.Owner, out var gridXform))
continue;
var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
var (_, _, worldMatrix, invWorldMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridXform);
worldHandle.SetTransform(worldMatrix);
var localAABB = invWorldMatrix.TransformBox(args.WorldBounds);
@@ -509,7 +512,7 @@ namespace Content.Client.NPC
if (!_entManager.TryGetComponent<TransformComponent>(node.GraphUid, out var graphXform))
continue;
worldHandle.SetTransform(graphXform.WorldMatrix);
worldHandle.SetTransform(_transform.GetWorldMatrix(graphXform));
worldHandle.DrawRect(node.Box, Color.Orange.WithAlpha(0.10f));
}
}
@@ -531,7 +534,7 @@ namespace Content.Client.NPC
continue;
matrix = node.GraphUid;
worldHandle.SetTransform(graphXform.WorldMatrix);
worldHandle.SetTransform(_transform.GetWorldMatrix(graphXform));
}
worldHandle.DrawRect(node.Box, new Color(0f, cost / highestGScore, 1f - (cost / highestGScore), 0.10f));

View File

@@ -13,6 +13,7 @@ public sealed class NetworkConfiguratorLinkOverlay : Overlay
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
private readonly DeviceListSystem _deviceListSystem;
private readonly SharedTransformSystem _transform;
private Dictionary<EntityUid, Color> _colors = new();
@@ -23,6 +24,7 @@ public sealed class NetworkConfiguratorLinkOverlay : Overlay
IoCManager.InjectDependencies(this);
_deviceListSystem = _entityManager.System<DeviceListSystem>();
_transform = _entityManager.System<SharedTransformSystem>();
}
public void ClearEntity(EntityUid uid)
@@ -70,7 +72,7 @@ public sealed class NetworkConfiguratorLinkOverlay : Overlay
continue;
}
args.WorldHandle.DrawLine(sourceTransform.WorldPosition, linkTransform.WorldPosition, _colors[tracker.Owner]);
args.WorldHandle.DrawLine(_transform.GetWorldPosition(sourceTransform), _transform.GetWorldPosition(linkTransform), _colors[tracker.Owner]);
}
}
}

View File

@@ -19,6 +19,7 @@ namespace Content.Client.NodeContainer
private readonly IMapManager _mapManager;
private readonly IInputManager _inputManager;
private readonly IEntityManager _entityManager;
private readonly SharedTransformSystem _transform;
private readonly Dictionary<(int, int), NodeRenderData> _nodeIndex = new();
private readonly Dictionary<EntityUid, Dictionary<Vector2i, List<(GroupData, NodeDatum)>>> _gridIndex = new ();
@@ -44,6 +45,7 @@ namespace Content.Client.NodeContainer
_mapManager = mapManager;
_inputManager = inputManager;
_entityManager = entityManager;
_transform = entityManager.System<SharedTransformSystem>();
_font = cache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 12);
}
@@ -141,7 +143,7 @@ namespace Content.Client.NodeContainer
foreach (var (gridId, gridDict) in _gridIndex)
{
var grid = _mapManager.GetGrid(gridId);
var (_, _, worldMatrix, invMatrix) = _entityManager.GetComponent<TransformComponent>(grid.Owner).GetWorldPositionRotationMatrixWithInv();
var (_, _, worldMatrix, invMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(gridId);
var lCursorBox = invMatrix.TransformBox(cursorBox);
foreach (var (pos, list) in gridDict)

View File

@@ -22,6 +22,7 @@ public sealed class TargetOutlineSystem : EntitySystem
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
private bool _enabled = false;
@@ -164,8 +165,8 @@ public sealed class TargetOutlineSystem : EntitySystem
valid = _interactionSystem.InRangeUnobstructed(player, entity, Range);
else if (Range >= 0)
{
var origin = Transform(player).WorldPosition;
var target = Transform(entity).WorldPosition;
var origin = _transform.GetWorldPosition(player);
var target = _transform.GetWorldPosition(entity);
valid = (origin - target).LengthSquared() <= Range;
}

View File

@@ -35,6 +35,7 @@ public sealed class NavMapSystem : SharedNavMapSystem
public sealed class NavMapOverlay : Overlay
{
private readonly IEntityManager _entManager;
private readonly SharedTransformSystem _transform;
private readonly IMapManager _mapManager;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
@@ -42,6 +43,7 @@ public sealed class NavMapOverlay : Overlay
public NavMapOverlay(IEntityManager entManager, IMapManager mapManager)
{
_entManager = entManager;
_transform = entManager.System<SharedTransformSystem>();
_mapManager = mapManager;
}
@@ -57,7 +59,7 @@ public sealed class NavMapOverlay : Overlay
continue;
// TODO: Faster helper method
var (_, _, matrix, invMatrix) = xform.GetWorldPositionRotationMatrixWithInv();
var (_, _, matrix, invMatrix) = _transform.GetWorldPositionRotationMatrixWithInv(xform);
var localAABB = invMatrix.TransformBox(args.WorldBounds);
Matrix3.Multiply(in scale, in matrix, out var matty);

View File

@@ -20,6 +20,7 @@ namespace Content.Client.Pinpointer.UI;
public sealed class NavMapControl : MapGridControl
{
[Dependency] private readonly IEntityManager _entManager = default!;
private readonly SharedTransformSystem _transform;
public EntityUid? MapUid;
@@ -52,6 +53,9 @@ public sealed class NavMapControl : MapGridControl
public NavMapControl() : base(8f, 128f, 48f)
{
IoCManager.InjectDependencies(this);
_transform = _entManager.System<SharedTransformSystem>();
RectClipContent = true;
HorizontalExpand = true;
VerticalExpand = true;
@@ -326,7 +330,7 @@ public sealed class NavMapControl : MapGridControl
if (mapPos.MapId != MapId.Nullspace)
{
var position = xform.InvWorldMatrix.Transform(mapPos.Position) - offset;
var position = _transform.GetInvWorldMatrix(xform).Transform(mapPos.Position) - offset;
position = Scale(new Vector2(position.X, -position.Y));
handle.DrawCircle(position, MinimapScale / 2f, value.Color);

View File

@@ -56,7 +56,8 @@ public sealed partial class ReplaySpectatorSystem
return data;
data.Local = (xform.Coordinates, xform.LocalRotation);
data.World = (new(xform.MapUid.Value, xform.WorldPosition), xform.WorldRotation);
var (pos, rot) = _transform.GetWorldPositionRotation(xform);
data.World = (new(xform.MapUid.Value, pos), rot);
if (TryComp(player, out InputMoverComponent? mover))
data.Eye = (mover.RelativeEntity, mover.TargetRelativeRotation);

View File

@@ -57,7 +57,8 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
/// </summary>
public sealed class EmergencyShuttleOverlay : Overlay
{
private IEntityManager _entManager;
private readonly IEntityManager _entManager;
private readonly SharedTransformSystem _transform;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
@@ -67,13 +68,15 @@ public sealed class EmergencyShuttleOverlay : Overlay
public EmergencyShuttleOverlay(IEntityManager entManager)
{
_entManager = entManager;
_transform = entManager.System<SharedTransformSystem>();
}
protected override void Draw(in OverlayDrawArgs args)
{
if (Position == null || !_entManager.TryGetComponent<TransformComponent>(StationUid, out var xform)) return;
if (Position == null || !_entManager.TryGetComponent<TransformComponent>(StationUid, out var xform))
return;
args.WorldHandle.SetTransform(xform.WorldMatrix);
args.WorldHandle.SetTransform(_transform.GetWorldMatrix(xform));
args.WorldHandle.DrawRect(Position.Value, Color.Red.WithAlpha(100));
args.WorldHandle.SetTransform(Matrix3.Identity);
}

View File

@@ -16,6 +16,7 @@ namespace Content.Client.Shuttles.UI;
public class DockingControl : Control
{
private readonly IEntityManager _entManager;
private readonly SharedTransformSystem _transform;
private readonly IMapManager _mapManager;
private float _range = 8f;
@@ -46,6 +47,7 @@ public class DockingControl : Control
public DockingControl()
{
_entManager = IoCManager.Resolve<IEntityManager>();
_transform = _entManager.System<SharedTransformSystem>();
_mapManager = IoCManager.Resolve<IMapManager>();
_rangeSquared = _range * _range;
MinSize = new Vector2(SizeFull, SizeFull);
@@ -78,7 +80,10 @@ public class DockingControl : Control
if (Coordinates == null ||
Angle == null ||
!_entManager.TryGetComponent<TransformComponent>(GridEntity, out var gridXform)) return;
!_entManager.TryGetComponent<TransformComponent>(GridEntity, out var gridXform))
{
return;
}
var rotation = Matrix3.CreateRotation(-Angle.Value + Math.PI);
var matrix = Matrix3.CreateTranslation(-Coordinates.Value.Position);
@@ -140,8 +145,8 @@ public class DockingControl : Control
ScalePosition(rotation.Transform(new Vector2(0.5f, -0.5f)))), Color.Green);
// Draw nearby grids
var worldPos = gridXform.WorldMatrix.Transform(Coordinates.Value.Position);
var gridInvMatrix = gridXform.InvWorldMatrix;
var worldPos = _transform.GetWorldMatrix(gridXform).Transform(Coordinates.Value.Position);
var gridInvMatrix = _transform.GetInvWorldMatrix(gridXform);
Matrix3.Multiply(in gridInvMatrix, in matrix, out var invMatrix);
// TODO: Getting some overdraw so need to fix that.
@@ -157,7 +162,7 @@ public class DockingControl : Control
if (!_entManager.TryGetComponent<FixturesComponent>(grid.Owner, out var gridFixtures))
continue;
var gridMatrix = xformQuery.GetComponent(grid.Owner).WorldMatrix;
var gridMatrix = _transform.GetWorldMatrix(grid.Owner);
Matrix3.Multiply(in gridMatrix, in invMatrix, out var matty);

View File

@@ -21,6 +21,7 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
{
private readonly IEntityManager _entManager;
private readonly IGameTiming _timing;
private readonly SharedTransformSystem _transform;
private EntityUid? _shuttleUid;
@@ -51,6 +52,7 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
RobustXamlLoader.Load(this);
_entManager = IoCManager.Resolve<IEntityManager>();
_timing = IoCManager.Resolve<IGameTiming>();
_transform = _entManager.System<SharedTransformSystem>();
WorldRangeChange(RadarScreen.WorldRange);
RadarScreen.WorldRangeChanged += WorldRangeChange;
@@ -323,7 +325,7 @@ public sealed partial class ShuttleConsoleWindow : FancyWindow,
FTLTimer.Text = GetFTLText();
var (_, worldRot, worldMatrix) = gridXform.GetWorldPositionRotationMatrix();
var (_, worldRot, worldMatrix) = _transform.GetWorldPositionRotationMatrix(gridXform);
var worldPos = worldMatrix.Transform(gridBody.LocalCenter);
// Get the positive reduced angle.

View File

@@ -10,6 +10,7 @@ namespace Content.Client.Stealth;
public sealed class StealthSystem : SharedStealthSystem
{
[Dependency] private readonly IPrototypeManager _protoMan = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
private ShaderInstance _shader = default!;
@@ -79,7 +80,7 @@ public sealed class StealthSystem : SharedStealthSystem
if (!parent.IsValid())
return; // should never happen, but lets not kill the client.
var parentXform = Transform(parent);
var reference = args.Viewport.WorldToLocal(parentXform.WorldPosition);
var reference = args.Viewport.WorldToLocal(_transform.GetWorldPosition(parentXform));
reference.X = -reference.X;
var visibility = GetVisibility(uid, component);

View File

@@ -28,6 +28,7 @@ namespace Content.Client.Tabletop
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly AppearanceSystem _appearance = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
// Time in seconds to wait until sending the location of a dragged entity to the server again
private const float Delay = 1f / 10; // 10 Hz
@@ -76,7 +77,8 @@ namespace Content.Client.Tabletop
}
// If no entity is being dragged or no viewport is clicked, return
if (_draggedEntity == null || _viewport == null) return;
if (_draggedEntity == null || _viewport == null)
return;
if (!CanDrag(playerEntity, _draggedEntity.Value, out var draggableComponent))
{
@@ -98,10 +100,11 @@ namespace Content.Client.Tabletop
// Clamp coordinates to viewport
var clampedCoords = ClampPositionToViewport(coords, _viewport);
if (clampedCoords.Equals(MapCoordinates.Nullspace)) return;
if (clampedCoords.Equals(MapCoordinates.Nullspace))
return;
// Move the entity locally every update
EntityManager.GetComponent<TransformComponent>(_draggedEntity.Value).WorldPosition = clampedCoords.Position;
_transform.SetWorldPosition(_draggedEntity.Value, clampedCoords.Position);
// Increment total time passed
_timePassed += frameTime;
@@ -182,10 +185,11 @@ namespace Content.Client.Tabletop
{
if (_draggedEntity != null && _table != null)
{
var ev = new TabletopRequestTakeOut();
ev.Entity = _draggedEntity.Value;
ev.TableUid = _table.Value;
RaiseNetworkEvent(ev);
RaiseNetworkEvent(new TabletopRequestTakeOut
{
Entity = _draggedEntity.Value,
TableUid = _table.Value,
});
}
return false;
}
@@ -278,10 +282,12 @@ namespace Content.Client.Tabletop
/// <returns>Coordinates clamped to the viewport.</returns>
private static MapCoordinates ClampPositionToViewport(MapCoordinates coordinates, ScalingViewport viewport)
{
if (coordinates == MapCoordinates.Nullspace) return MapCoordinates.Nullspace;
if (coordinates == MapCoordinates.Nullspace)
return MapCoordinates.Nullspace;
var eye = viewport.Eye;
if (eye == null) return MapCoordinates.Nullspace;
if (eye == null)
return MapCoordinates.Nullspace;
var size = (Vector2) viewport.ViewportSize / EyeManager.PixelsPerMeter; // Convert to tiles instead of pixels
var eyePosition = eye.Position.Position;

View File

@@ -19,6 +19,7 @@ using Content.Shared.Chat;
using Content.Shared.Examine;
using Content.Shared.Input;
using Content.Shared.Radio;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Input;
using Robust.Client.Player;
@@ -55,6 +56,7 @@ public sealed class ChatUIController : UIController
[UISystemDependency] private readonly GhostSystem? _ghost = default;
[UISystemDependency] private readonly TypingIndicatorSystem? _typingIndicator = default;
[UISystemDependency] private readonly ChatSystem? _chatSys = default;
[UISystemDependency] private readonly TransformSystem _transform = default!;
private ISawmill _sawmill = default!;
@@ -408,7 +410,7 @@ public sealed class ChatUIController : UIController
private void CreateSpeechBubble(EntityUid entity, SpeechBubbleData speechData)
{
var bubble =
SpeechBubble.CreateSpeechBubble(speechData.Type, speechData.Message, entity, _eye, _manager, _entities);
SpeechBubble.CreateSpeechBubble(speechData.Type, speechData.Message, entity, _eye, _manager, _entities, _transform);
bubble.OnDied += SpeechBubbleDied;

View File

@@ -4,6 +4,7 @@ using Content.Shared.CCVar;
using Robust.Client.GameObjects;
using Robust.Client.Graphics;
using Robust.Client.Player;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
using Robust.Shared.Configuration;
using Robust.Shared.Timing;
@@ -16,6 +17,7 @@ public sealed class ViewportUIController : UIController
[Dependency] private readonly IPlayerManager _playerMan = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[UISystemDependency] private readonly TransformSystem _transform = default!;
public static readonly Vector2i ViewportSize = (EyeManager.PixelsPerMeter * 21, EyeManager.PixelsPerMeter * 15);
public const int ViewportHeight = 15;
@@ -87,9 +89,10 @@ public sealed class ViewportUIController : UIController
_entMan.TryGetComponent(ent, out EyeComponent? eye);
if (eye?.Eye == _eyeManager.CurrentEye
&& _entMan.GetComponent<TransformComponent>(ent.Value).WorldPosition == default)
if (eye?.Eye == _eyeManager.CurrentEye && _transform.GetWorldPosition(ent.Value) == default)
{
return; // nothing to worry about, the player is just in null space... actually that is probably a problem?
}
// Currently, this shouldn't happen. This likely happened because the main eye was set to null. When this
// does happen it can create hard to troubleshoot bugs, so lets print some helpful warnings: