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