Purges uses of TransformComponent.WorldMatrix and TransformComponent.InvWorldMatrix (#34944)
This commit is contained in:
@@ -102,7 +102,7 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem
|
||||
if (!_mapManager.TryFindGridAt(mousePos, out var gridUid, out var grid))
|
||||
return;
|
||||
|
||||
StartDragging(gridUid, Vector2.Transform(mousePos.Position, Transform(gridUid).InvWorldMatrix));
|
||||
StartDragging(gridUid, Vector2.Transform(mousePos.Position, _transformSystem.GetInvWorldMatrix(gridUid)));
|
||||
}
|
||||
|
||||
if (!TryComp(_dragging, out TransformComponent? xform))
|
||||
@@ -117,7 +117,7 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem
|
||||
return;
|
||||
}
|
||||
|
||||
var localToWorld = Vector2.Transform(_localPosition, xform.WorldMatrix);
|
||||
var localToWorld = Vector2.Transform(_localPosition, _transformSystem.GetWorldMatrix(xform));
|
||||
|
||||
if (localToWorld.EqualsApprox(mousePos.Position, 0.01f)) return;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
|
||||
|
||||
if (_enableShuttlePosition)
|
||||
{
|
||||
_overlay = new EmergencyShuttleOverlay(EntityManager);
|
||||
_overlay = new EmergencyShuttleOverlay(EntityManager.TransformQuery, XformSystem);
|
||||
overlayManager.AddOverlay(_overlay);
|
||||
RaiseNetworkEvent(new EmergencyShuttleRequestPositionMessage());
|
||||
}
|
||||
@@ -57,23 +57,26 @@ public sealed partial class ShuttleSystem : SharedShuttleSystem
|
||||
/// </summary>
|
||||
public sealed class EmergencyShuttleOverlay : Overlay
|
||||
{
|
||||
private IEntityManager _entManager;
|
||||
private readonly EntityQuery<TransformComponent> _transformQuery;
|
||||
private readonly SharedTransformSystem _transformSystem;
|
||||
|
||||
public override OverlaySpace Space => OverlaySpace.WorldSpace;
|
||||
|
||||
public EntityUid? StationUid;
|
||||
public Box2? Position;
|
||||
|
||||
public EmergencyShuttleOverlay(IEntityManager entManager)
|
||||
public EmergencyShuttleOverlay(EntityQuery<TransformComponent> transformQuery, SharedTransformSystem transformSystem)
|
||||
{
|
||||
_entManager = entManager;
|
||||
_transformQuery = transformQuery;
|
||||
_transformSystem = transformSystem;
|
||||
}
|
||||
|
||||
protected override void Draw(in OverlayDrawArgs args)
|
||||
{
|
||||
if (Position == null || !_entManager.TryGetComponent<TransformComponent>(StationUid, out var xform)) return;
|
||||
if (Position == null || !_transformQuery.TryGetComponent(StationUid, out var xform))
|
||||
return;
|
||||
|
||||
args.WorldHandle.SetTransform(xform.WorldMatrix);
|
||||
args.WorldHandle.SetTransform(_transformSystem.GetWorldMatrix(xform));
|
||||
args.WorldHandle.DrawRect(Position.Value, Color.Red.WithAlpha(100));
|
||||
args.WorldHandle.SetTransform(Matrix3x2.Identity);
|
||||
}
|
||||
|
||||
@@ -73,13 +73,14 @@ public sealed class ExplosionGridTileFlood : ExplosionTileFlood
|
||||
|
||||
var transformSystem = entityManager.System<SharedTransformSystem>();
|
||||
var transform = entityManager.GetComponent<TransformComponent>(Grid.Owner);
|
||||
var size = (float) Grid.TileSize;
|
||||
var size = (float)Grid.TileSize;
|
||||
|
||||
_matrix.M31 = size / 2;
|
||||
_matrix.M32 = size / 2;
|
||||
Matrix3x2.Invert(spaceMatrix, out var invSpace);
|
||||
_matrix *= transform.WorldMatrix * invSpace;
|
||||
var relativeAngle = transformSystem.GetWorldRotation(transform) - spaceAngle;
|
||||
var (_, relativeAngle, worldMatrix) = transformSystem.GetWorldPositionRotationMatrix(transform);
|
||||
relativeAngle -= spaceAngle;
|
||||
_matrix *= worldMatrix * invSpace;
|
||||
_offset = relativeAngle.RotateVec(new Vector2(size / 4, size / 4));
|
||||
}
|
||||
|
||||
|
||||
@@ -71,8 +71,7 @@ public sealed partial class ExplosionSystem
|
||||
{
|
||||
var targetGrid = Comp<MapGridComponent>(referenceGrid.Value);
|
||||
var xform = Transform(referenceGrid.Value);
|
||||
targetAngle = _transformSystem.GetWorldRotation(xform);
|
||||
targetMatrix = xform.InvWorldMatrix;
|
||||
(_, targetAngle, targetMatrix) = _transformSystem.GetWorldPositionRotationInvMatrix(xform);
|
||||
tileSize = targetGrid.TileSize;
|
||||
}
|
||||
|
||||
|
||||
@@ -89,8 +89,7 @@ public sealed partial class ExplosionSystem
|
||||
if (referenceGrid != null)
|
||||
{
|
||||
var xform = Transform(Comp<MapGridComponent>(referenceGrid.Value).Owner);
|
||||
spaceMatrix = xform.WorldMatrix;
|
||||
spaceAngle = _transformSystem.GetWorldRotation(xform);
|
||||
(_, spaceAngle, spaceMatrix) = _transformSystem.GetWorldPositionRotationMatrix(xform);
|
||||
}
|
||||
|
||||
// is the explosion starting on a grid?
|
||||
|
||||
@@ -423,7 +423,7 @@ namespace Content.Server.GameTicking
|
||||
{
|
||||
var gridXform = Transform(gridUid);
|
||||
|
||||
return new EntityCoordinates(gridUid, Vector2.Transform(toMap.Position, gridXform.InvWorldMatrix));
|
||||
return new EntityCoordinates(gridUid, Vector2.Transform(toMap.Position, _transform.GetInvWorldMatrix(gridXform)));
|
||||
}
|
||||
|
||||
return spawn;
|
||||
|
||||
@@ -36,7 +36,7 @@ public sealed partial class PathfindingSystem
|
||||
return Vector2.Zero;
|
||||
}
|
||||
|
||||
endPos = Vector2.Transform(Vector2.Transform(endPos, endXform.WorldMatrix), startXform.InvWorldMatrix);
|
||||
endPos = Vector2.Transform(Vector2.Transform(endPos, _transform.GetWorldMatrix(endXform)), _transform.GetInvWorldMatrix(startXform));
|
||||
}
|
||||
|
||||
// TODO: Numerics when we changeover.
|
||||
|
||||
@@ -405,7 +405,7 @@ namespace Content.Server.NPC.Pathfinding
|
||||
return null;
|
||||
}
|
||||
|
||||
var localPos = Vector2.Transform(coordinates.ToMapPos(EntityManager, _transform), xform.InvWorldMatrix);
|
||||
var localPos = Vector2.Transform(coordinates.ToMapPos(EntityManager, _transform), _transform.GetInvWorldMatrix(xform));
|
||||
var origin = GetOrigin(localPos);
|
||||
|
||||
if (!TryGetChunk(origin, comp, out var chunk))
|
||||
|
||||
Reference in New Issue
Block a user