Revert "Remove most usages of obsolete TransformComponent methods (#1… (#19714)

This commit is contained in:
metalgearsloth
2023-09-01 12:30:29 +10:00
committed by GitHub
parent 37222930d9
commit 4cfc578011
91 changed files with 227 additions and 315 deletions

View File

@@ -48,7 +48,7 @@ namespace Content.Server.Administration.Commands
? _entities.GetComponent<TransformComponent>(player.AttachedEntity.Value).Coordinates
: EntitySystem.Get<GameTicker>().GetObserverSpawnPoint();
var ghost = _entities.SpawnEntity("AdminObserver", coordinates);
_entities.System<SharedTransformSystem>().AttachToGridOrMap(ghost);
_entities.GetComponent<TransformComponent>(ghost).AttachToGridOrMap();
if (canReturn)
{

View File

@@ -4,7 +4,6 @@ using Content.Server.Warps;
using Content.Shared.Administration;
using Content.Shared.Follower;
using Content.Shared.Ghost;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Enums;
@@ -122,9 +121,9 @@ namespace Content.Server.Administration.Commands
return;
}
var transform = _entManager.System<SharedTransformSystem>();
transform.SetCoordinates(playerEntity, coords);
transform.AttachToGridOrMap(playerEntity);
var xform = _entManager.GetComponent<TransformComponent>(playerEntity);
xform.Coordinates = coords;
xform.AttachToGridOrMap();
if (_entManager.TryGetComponent(playerEntity, out PhysicsComponent? physics))
{
_entManager.System<SharedPhysicsSystem>().SetLinearVelocity(playerEntity, Vector2.Zero, body: physics);

View File

@@ -76,7 +76,6 @@ public sealed partial class AdminVerbSystem
[Dependency] private readonly VomitSystem _vomitSystem = default!;
[Dependency] private readonly WeldableSystem _weldableSystem = default!;
[Dependency] private readonly SharedContentEyeSystem _eyeSystem = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
// All smite verbs have names so invokeverb works.
private void AddSmiteVerbs(GetVerbsEvent<Verb> args)
@@ -131,8 +130,8 @@ public sealed partial class AdminVerbSystem
Filter.PvsExcept(args.Target), true, PopupType.MediumCaution);
var board = Spawn("ChessBoard", xform.Coordinates);
var session = _tabletopSystem.EnsureSession(Comp<TabletopGameComponent>(board));
_transform.SetCoordinates(args.Target, EntityCoordinates.FromMap(_mapManager, session.Position));
_transform.SetWorldRotation(xform, Angle.Zero);
xform.Coordinates = EntityCoordinates.FromMap(_mapManager, session.Position);
xform.WorldRotation = Angle.Zero;
},
Impact = LogImpact.Extreme,
Message = Loc.GetString("admin-smite-chess-dimension-description")

View File

@@ -18,7 +18,6 @@ namespace Content.Server.Atmos.EntitySystems
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly IConfigurationManager _configManager = default!;
[Dependency] private readonly AtmosphereSystem _atmosphereSystem = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
/// <summary>
/// Players allowed to see the atmos debug overlay.
@@ -135,7 +134,7 @@ namespace Content.Server.Atmos.EntitySystems
var mapIsSpace = _atmosphereSystem.IsTileSpace(null, mapUid, Vector2i.Zero);
var worldBounds = Box2.CenteredAround(_transform.GetWorldPosition(transform),
var worldBounds = Box2.CenteredAround(transform.WorldPosition,
new Vector2(LocalViewRange, LocalViewRange));
foreach (var grid in _mapManager.FindGridsIntersecting(transform.MapID, worldBounds))

View File

@@ -15,8 +15,6 @@ namespace Content.Server.Atmos.EntitySystems
{
public sealed partial class AtmosphereSystem
{
[Dependency] private readonly SharedTransformSystem _transform = default!;
private const int SpaceWindSoundCooldownCycles = 75;
private int _spaceWindSoundCooldown = 0;
@@ -120,7 +118,7 @@ namespace Content.Server.Atmos.EntitySystems
return;
// Used by ExperiencePressureDifference to correct push/throw directions from tile-relative to physics world.
var gridWorldRotation = _transform.GetWorldRotation(gridAtmosphere.Owner);
var gridWorldRotation = xforms.GetComponent(gridAtmosphere.Owner).WorldRotation;
// If we're using monstermos, smooth out the yeet direction to follow the flow
if (MonstermosEqualization)
@@ -236,7 +234,7 @@ namespace Content.Server.Atmos.EntitySystems
// TODO: Technically these directions won't be correct but uhh I'm just here for optimisations buddy not to fix my old bugs.
if (throwTarget != EntityCoordinates.Invalid)
{
var pos = ((throwTarget.ToMap(EntityManager).Position - _transform.GetWorldPosition(xform)).Normalized() + dirVec).Normalized();
var pos = ((throwTarget.ToMap(EntityManager).Position - xform.WorldPosition).Normalized() + dirVec).Normalized();
_physics.ApplyLinearImpulse(uid, pos * moveForce, body: physics);
}
else

View File

@@ -29,7 +29,6 @@ namespace Content.Server.Bible
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedActionsSystem _actionsSystem = default!;
[Dependency] private readonly UseDelaySystem _delay = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize()
{
@@ -236,7 +235,7 @@ namespace Content.Server.Bible
if (HasComp<GhostRoleMobSpawnerComponent>(familiar))
{
_popupSystem.PopupEntity(Loc.GetString("bible-summon-requested"), user, PopupType.Medium);
_transform.SetParent(familiar, component.Owner);
Transform(familiar).AttachParent(component.Owner);
}
component.AlreadySummoned = true;
_actionsSystem.RemoveAction(user, component.SummonAction);

View File

@@ -4,6 +4,7 @@ using Content.Server.Body.Components;
using Content.Server.GameTicking;
using Content.Server.Humanoid;
using Content.Server.Kitchen.Components;
using Content.Server.Mind;
using Content.Shared.Body.Components;
using Content.Shared.Body.Organ;
using Content.Shared.Body.Part;
@@ -28,8 +29,7 @@ public sealed class BodySystem : SharedBodySystem
[Dependency] private readonly HumanoidAppearanceSystem _humanoidSystem = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly MindSystem _mindSystem = default!;
public override void Initialize()
{
@@ -127,7 +127,7 @@ public sealed class BodySystem : SharedBodySystem
return;
// Don't microwave animals, kids
_transform.AttachToGridOrMap(uid);
Transform(uid).AttachToGridOrMap();
GibBody(uid, false, component);
args.Handled = true;
@@ -209,7 +209,7 @@ public sealed class BodySystem : SharedBodySystem
else
{
cont.Remove(ent, EntityManager, force: true);
_transform.SetCoordinates(ent, coordinates);
Transform(ent).Coordinates = coordinates;
ent.RandomOffset(0.25f);
}
}

View File

@@ -10,7 +10,6 @@ public sealed class RehydratableSystem : EntitySystem
[Dependency] private readonly SharedPopupSystem _popups = default!;
[Dependency] private readonly SolutionContainerSystem _solutions = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize()
{
@@ -37,7 +36,7 @@ public sealed class RehydratableSystem : EntitySystem
var target = Spawn(randomMob, Transform(uid).Coordinates);
_transform.AttachToGridOrMap(target);
Transform(target).AttachToGridOrMap();
var ev = new GotRehydratedEvent(target);
RaiseLocalEvent(uid, ref ev);

View File

@@ -27,7 +27,6 @@ namespace Content.Server.Chemistry.EntitySystems
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
[Dependency] private readonly ThrowingSystem _throwing = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
private const float ReactTime = 0.125f;
@@ -70,7 +69,7 @@ namespace Content.Server.Chemistry.EntitySystems
_throwing.TryThrow(vapor.Owner, dir, speed, user: user, pushbackRatio: ThrowingSystem.PushbackDefault * 10f);
var distance = (target.Position - _transform.GetWorldPosition(vaporXform)).Length();
var distance = (target.Position - vaporXform.WorldPosition).Length();
var time = (distance / physics.LinearVelocity.Length());
despawn.Lifetime = MathF.Min(aliveTime, time);
}

View File

@@ -45,7 +45,6 @@ public sealed class ClimbSystem : SharedClimbSystem
[Dependency] private readonly InteractionSystem _interactionSystem = default!;
[Dependency] private readonly StunSystem _stunSystem = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
private const string ClimbingFixtureName = "climb";
private const int ClimbingCollisionGroup = (int) (CollisionGroup.TableLayer | CollisionGroup.LowImpassable);
@@ -395,8 +394,8 @@ public sealed class ClimbSystem : SharedClimbSystem
if (!Resolve(uid, ref physics, ref climbing, false))
return;
var from = _transform.GetWorldPosition(uid);
var to = _transform.GetWorldPosition(target);
var from = Transform(uid).WorldPosition;
var to = Transform(target).WorldPosition;
var (x, y) = (to - from).Normalized();
if (MathF.Abs(x) < 0.6f) // user climbed mostly vertically so lets make it a clean straight line

View File

@@ -1,4 +1,5 @@
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using Robust.Server.Player;
using Robust.Shared.Console;
using Robust.Shared.Network;
@@ -48,5 +49,42 @@ namespace Content.Server.Commands
attachedEntity = session.AttachedEntity.Value;
return true;
}
public static string SubstituteEntityDetails(IConsoleShell shell, EntityUid ent, string ruleString)
{
var entMan = IoCManager.Resolve<IEntityManager>();
var transform = entMan.GetComponent<TransformComponent>(ent);
// gross, is there a better way to do this?
ruleString = ruleString.Replace("$ID", ent.ToString());
ruleString = ruleString.Replace("$WX",
transform.WorldPosition.X.ToString(CultureInfo.InvariantCulture));
ruleString = ruleString.Replace("$WY",
transform.WorldPosition.Y.ToString(CultureInfo.InvariantCulture));
ruleString = ruleString.Replace("$LX",
transform.LocalPosition.X.ToString(CultureInfo.InvariantCulture));
ruleString = ruleString.Replace("$LY",
transform.LocalPosition.Y.ToString(CultureInfo.InvariantCulture));
ruleString = ruleString.Replace("$NAME", entMan.GetComponent<MetaDataComponent>(ent).EntityName);
if (shell.Player is IPlayerSession player)
{
if (player.AttachedEntity is {Valid: true} p)
{
var pTransform = entMan.GetComponent<TransformComponent>(p);
ruleString = ruleString.Replace("$PID", ent.ToString());
ruleString = ruleString.Replace("$PWX",
pTransform.WorldPosition.X.ToString(CultureInfo.InvariantCulture));
ruleString = ruleString.Replace("$PWY",
pTransform.WorldPosition.Y.ToString(CultureInfo.InvariantCulture));
ruleString = ruleString.Replace("$PLX",
pTransform.LocalPosition.X.ToString(CultureInfo.InvariantCulture));
ruleString = ruleString.Replace("$PLY",
pTransform.LocalPosition.Y.ToString(CultureInfo.InvariantCulture));
}
}
return ruleString;
}
}
}

View File

@@ -15,7 +15,7 @@ namespace Content.Server.Construction.Completions
var transform = entityManager.GetComponent<TransformComponent>(uid);
if (!transform.Anchored)
entityManager.System<SharedTransformSystem>().SetCoordinates(uid, transform, transform.Coordinates.SnapToGrid(entityManager));
transform.Coordinates = transform.Coordinates.SnapToGrid(entityManager);
if (SouthRotation)
{

View File

@@ -341,7 +341,7 @@ namespace Content.Server.Construction
// Transform transferring.
var newTransform = Transform(newUid);
_transform.AttachToGridOrMap(newUid, newTransform); // in case in hands or a container
newTransform.AttachToGridOrMap(); // in case in hands or a container
newTransform.LocalRotation = transform.LocalRotation;
newTransform.Anchored = transform.Anchored;

View File

@@ -31,7 +31,6 @@ namespace Content.Server.Construction
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly EntityLookupSystem _lookupSystem = default!;
[Dependency] private readonly StorageSystem _storageSystem = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
// --- WARNING! LEGACY CODE AHEAD! ---
// This entire file contains the legacy code for initial construction.
@@ -516,7 +515,7 @@ namespace Content.Server.Construction
var xform = Transform(structure);
var wasAnchored = xform.Anchored;
xform.Anchored = false;
_transform.SetCoordinates(structure, xform, ev.Location);
xform.Coordinates = ev.Location;
xform.LocalRotation = constructionPrototype.CanRotate ? ev.Angle : Angle.Zero;
xform.Anchored = wasAnchored;

View File

@@ -6,8 +6,6 @@ namespace Content.Server.DeviceNetwork.Systems
[UsedImplicitly]
public sealed class WirelessNetworkSystem : EntitySystem
{
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize()
{
base.Initialize();
@@ -27,7 +25,7 @@ namespace Content.Server.DeviceNetwork.Systems
return;
if (xform.MapID != args.SenderTransform.MapID
|| (ownPosition - _transform.GetWorldPosition(xform)).Length() > sendingComponent.Range)
|| (ownPosition - xform.WorldPosition).Length() > sendingComponent.Range)
{
args.Cancel();
}

View File

@@ -38,7 +38,6 @@ public sealed partial class DragonSystem : EntitySystem
[Dependency] private readonly MovementSpeedModifierSystem _movement = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
[Dependency] private readonly NPCSystem _npc = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
/// <summary>
/// Minimum distance between 2 rifts allowed.
@@ -252,7 +251,7 @@ public sealed partial class DragonSystem : EntitySystem
}
}
foreach (var tile in grid.GetTilesIntersecting(new Circle(_transform.GetWorldPosition(xform), RiftTileRadius), false))
foreach (var tile in grid.GetTilesIntersecting(new Circle(xform.WorldPosition, RiftTileRadius), false))
{
if (!tile.IsSpace(_tileDef))
continue;

View File

@@ -69,14 +69,13 @@ public sealed class ExplosionGridTileFlood : ExplosionTileFlood
return;
_needToTransform = true;
var transform = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<SharedTransformSystem>();
var transform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Grid.Owner);
var size = (float) Grid.TileSize;
_matrix.R0C2 = size / 2;
_matrix.R1C2 = size / 2;
var (_, rot, mat) = transform.GetWorldPositionRotationMatrix(Grid.Owner);
_matrix *= mat * Matrix3.Invert(spaceMatrix);
var relativeAngle = rot - spaceAngle;
_matrix *= transform.WorldMatrix * Matrix3.Invert(spaceMatrix);
var relativeAngle = transform.WorldRotation - spaceAngle;
_offset = relativeAngle.RotateVec(new Vector2(size / 4, size / 4));
}

View File

@@ -61,9 +61,8 @@ public sealed partial class ExplosionSystem : EntitySystem
{
var targetGrid = _mapManager.GetGrid(referenceGrid.Value);
var xform = Transform(targetGrid.Owner);
var (_, rot, invMat) = _transformSystem.GetWorldPositionRotationInvMatrix(xform);
targetAngle = rot;
targetMatrix = invMat;
targetAngle = xform.WorldRotation;
targetMatrix = xform.InvWorldMatrix;
tileSize = targetGrid.TileSize;
}
@@ -96,7 +95,7 @@ public sealed partial class ExplosionSystem : EntitySystem
var xforms = EntityManager.GetEntityQuery<TransformComponent>();
var xform = xforms.GetComponent(grid.Owner);
var (_, gridWorldRotation, gridWorldMatrix, invGridWorldMatrid) = _transformSystem.GetWorldPositionRotationMatrixWithInv(xform, xforms);
var (_, gridWorldRotation, gridWorldMatrix, invGridWorldMatrid) = xform.GetWorldPositionRotationMatrixWithInv(xforms);
var localEpicentre = (Vector2i) invGridWorldMatrid.Transform(epicentre.Position);
var matrix = offsetMatrix * gridWorldMatrix * targetMatrix;

View File

@@ -87,8 +87,8 @@ public sealed partial class ExplosionSystem : EntitySystem
if (referenceGrid != null)
{
var xform = Transform(_mapManager.GetGrid(referenceGrid.Value).Owner);
spaceMatrix = _transformSystem.GetWorldMatrix(xform);
spaceAngle = _transformSystem.GetWorldRotation(xform);
spaceMatrix = xform.WorldMatrix;
spaceAngle = xform.WorldRotation;
}
// is the explosion starting on a grid?

View File

@@ -340,7 +340,7 @@ public sealed partial class ExplosionSystem : EntitySystem
if (player.AttachedEntity is not EntityUid uid)
continue;
var playerPos = _transformSystem.GetWorldPosition(player.AttachedEntity.Value);
var playerPos = Transform(player.AttachedEntity!.Value).WorldPosition;
var delta = epicenter.Position - playerPos;
if (delta.EqualsApprox(Vector2.Zero))

View File

@@ -13,7 +13,6 @@ public sealed class PuddleDebugDebugOverlaySystem : SharedPuddleDebugOverlaySyst
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly PuddleSystem _puddle = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
private readonly HashSet<IPlayerSession> _playerObservers = new();
@@ -56,7 +55,7 @@ public sealed class PuddleDebugDebugOverlaySystem : SharedPuddleDebugOverlaySyst
var transform = EntityManager.GetComponent<TransformComponent>(entity);
var worldBounds = Box2.CenteredAround(_transform.GetWorldPosition(transform),
var worldBounds = Box2.CenteredAround(transform.WorldPosition,
new Vector2(LocalViewRange, LocalViewRange));

View File

@@ -375,7 +375,7 @@ namespace Content.Server.GameTicking
var gridXform = Transform(gridUid);
return new EntityCoordinates(gridUid,
_transform.GetInvWorldMatrix(gridXform).Transform(toMap.Position));
gridXform.InvWorldMatrix.Transform(toMap.Position));
}
return spawn;

View File

@@ -2,6 +2,8 @@ using System.Linq;
using System.Numerics;
using Content.Server.GameTicking;
using Content.Server.Ghost.Components;
using Content.Server.Mind;
using Content.Server.Roles.Jobs;
using Content.Server.Visible;
using Content.Server.Warps;
using Content.Shared.Actions;
@@ -37,9 +39,8 @@ namespace Content.Server.Ghost
[Dependency] private readonly FollowerSystem _followerSystem = default!;
[Dependency] private readonly MobStateSystem _mobState = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedMindSystem _minds = default!;
[Dependency] private readonly SharedJobSystem _jobs = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly MindSystem _minds = default!;
[Dependency] private readonly JobSystem _jobs = default!;
public override void Initialize()
{
@@ -206,8 +207,8 @@ namespace Content.Server.Ghost
private void OnGhostWarpToTargetRequest(GhostWarpToTargetRequestEvent msg, EntitySessionEventArgs args)
{
if (args.SenderSession.AttachedEntity is not { Valid: true } attached ||
!EntityManager.HasComponent<GhostComponent>(attached))
if (args.SenderSession.AttachedEntity is not {Valid: true} attached ||
!EntityManager.TryGetComponent(attached, out GhostComponent? ghost))
{
Logger.Warning($"User {args.SenderSession.Name} tried to warp to {msg.Target} without being a ghost.");
return;
@@ -222,12 +223,13 @@ namespace Content.Server.Ghost
if (TryComp(msg.Target, out WarpPointComponent? warp) && warp.Follow
|| HasComp<MobStateComponent>(msg.Target))
{
_followerSystem.StartFollowingEntity(attached, msg.Target);
_followerSystem.StartFollowingEntity(ghost.Owner, msg.Target);
return;
}
_transform.SetCoordinates(attached, Transform(msg.Target).Coordinates);
_transform.AttachToGridOrMap(attached);
var xform = Transform(ghost.Owner);
xform.Coordinates = Transform(msg.Target).Coordinates;
xform.AttachToGridOrMap();
if (TryComp(attached, out PhysicsComponent? physics))
_physics.SetLinearVelocity(attached, Vector2.Zero, body: physics);
}

View File

@@ -45,7 +45,6 @@ namespace Content.Server.Hands.Systems
[Dependency] private readonly StorageSystem _storageSystem = default!;
[Dependency] private readonly ISharedPlayerManager _player = default!;
[Dependency] private readonly IConfigurationManager _configuration = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize()
{
@@ -202,7 +201,7 @@ namespace Content.Server.Hands.Systems
throwEnt = splitStack.Value;
}
var direction = coords.ToMapPos(EntityManager) - _transform.GetWorldPosition(player);
var direction = coords.ToMapPos(EntityManager) - Transform(player).WorldPosition;
if (direction == Vector2.Zero)
return true;

View File

@@ -20,7 +20,6 @@ public sealed class ImmovableRodSystem : EntitySystem
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Update(float frameTime)
{
@@ -63,11 +62,11 @@ public sealed class ImmovableRodSystem : EntitySystem
var vel = component.DirectionOverride.Degrees switch
{
0f => _random.NextVector2(component.MinSpeed, component.MaxSpeed),
_ => _transform.GetWorldRotation(xform).RotateVec(component.DirectionOverride.ToVec()) * _random.NextFloat(component.MinSpeed, component.MaxSpeed),
_ => xform.WorldRotation.RotateVec(component.DirectionOverride.ToVec()) * _random.NextFloat(component.MinSpeed, component.MaxSpeed)
};
_physics.ApplyLinearImpulse(uid, vel, body: phys);
xform.LocalRotation = (vel - _transform.GetWorldPosition(xform)).ToWorldAngle() + MathHelper.PiOver2;
xform.LocalRotation = (vel - xform.WorldPosition).ToWorldAngle() + MathHelper.PiOver2;
}
}

View File

@@ -16,7 +16,6 @@ public sealed class LightningSystem : SharedLightningSystem
[Dependency] private readonly PhysicsSystem _physics = default!;
[Dependency] private readonly BeamSystem _beam = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize()
{
@@ -98,7 +97,7 @@ public sealed class LightningSystem : SharedLightningSystem
for (int i = 0; i < directions; i++)
{
var direction = (Direction) i;
var (targetPos, targetRot) = _transform.GetWorldPositionRotation(targetXForm, xformQuery);
var (targetPos, targetRot) = targetXForm.GetWorldPositionRotation(xformQuery);
var dirRad = direction.ToAngle() + targetRot;
var ray = new CollisionRay(targetPos, dirRad.ToVec(), component.CollisionMask);
var rayCastResults = _physics.IntersectRay(targetXForm.MapID, ray, component.MaxLength, target, false).ToList();

View File

@@ -274,11 +274,10 @@ public sealed class MagicSystem : EntitySystem
var transform = Transform(args.Performer);
if (transform.MapID != args.Target.GetMapId(EntityManager))
return;
if (transform.MapID != args.Target.GetMapId(EntityManager)) return;
_transformSystem.SetCoordinates(args.Performer, args.Target);
_transformSystem.AttachToGridOrMap(args.Performer, transform);
transform.AttachToGridOrMap();
_audio.PlayPvs(args.BlinkSound, args.Performer, AudioParams.Default.WithVolume(args.BlinkVolume));
Speak(args);
args.Handled = true;

View File

@@ -13,7 +13,6 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem
{
[Dependency] private readonly IConGroupController _admin = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
private readonly HashSet<ICommonSession> _draggers = new();
@@ -66,11 +65,10 @@ public sealed class GridDraggingSystem : SharedGridDraggingSystem
if (args.SenderSession is not IPlayerSession playerSession ||
!_admin.CanCommand(playerSession, CommandName) ||
!Exists(msg.Grid) ||
Deleted(msg.Grid))
{
return;
}
Deleted(msg.Grid)) return;
_transform.SetWorldPosition(msg.Grid, msg.WorldPosition);
var gridXform = Transform(msg.Grid);
gridXform.WorldPosition = msg.WorldPosition;
}
}

View File

@@ -77,7 +77,7 @@ public sealed class MechGrabberSystem : EntitySystem
component.ItemContainer.Remove(toRemove);
var mechxform = Transform(mech);
var xform = Transform(toRemove);
_transform.AttachToGridOrMap(toRemove, xform);
xform.AttachToGridOrMap();
var offset = _transform.GetWorldPosition(mechxform) + _transform.GetWorldRotation(mechxform).RotateVec(component.DepositOffset);
_transform.SetWorldPosition(xform, offset);

View File

@@ -36,7 +36,7 @@ public sealed partial class PathfindingSystem
return Vector2.Zero;
}
endPos = _transform.GetInvWorldMatrix(startXform).Transform(_transform.GetWorldMatrix(endXform).Transform(endPos));
endPos = startXform.InvWorldMatrix.Transform(endXform.WorldMatrix.Transform(endPos));
}
// TODO: Numerics when we changeover.

View File

@@ -410,7 +410,8 @@ public sealed partial class PathfindingSystem
private Vector2i GetOrigin(EntityCoordinates coordinates, EntityUid gridUid)
{
var localPos = _transform.GetInvWorldMatrix(gridUid).Transform(coordinates.ToMapPos(EntityManager));
var gridXform = Transform(gridUid);
var localPos = gridXform.InvWorldMatrix.Transform(coordinates.ToMapPos(EntityManager));
return new Vector2i((int) Math.Floor(localPos.X / ChunkSize), (int) Math.Floor(localPos.Y / ChunkSize));
}

View File

@@ -47,7 +47,6 @@ namespace Content.Server.NPC.Pathfinding
[Dependency] private readonly FixtureSystem _fixtures = default!;
[Dependency] private readonly NPCSystem _npc = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
private readonly Dictionary<ICommonSession, PathfindingDebugMode> _subscribedSessions = new();
@@ -383,7 +382,7 @@ namespace Content.Server.NPC.Pathfinding
return null;
}
var localPos = _transform.GetInvWorldMatrix(xform).Transform(coordinates.ToMapPos(EntityManager));
var localPos = xform.InvWorldMatrix.Transform(coordinates.ToMapPos(EntityManager));
var origin = GetOrigin(localPos);
if (!TryGetChunk(origin, comp, out var chunk))

View File

@@ -16,7 +16,6 @@ namespace Content.Server.Pointing.EntitySystems
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly ExplosionSystem _explosion = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
private EntityUid? RandomNearbyPlayer(EntityUid uid, RoguePointingArrowComponent? component = null, TransformComponent? transform = null)
{
@@ -69,24 +68,24 @@ namespace Content.Server.Pointing.EntitySystems
if (component.TurningDelay > 0)
{
var difference = _transform.GetWorldPosition(chasing) - _transform.GetWorldPosition(transform);
var difference = EntityManager.GetComponent<TransformComponent>(chasing).WorldPosition - transform.WorldPosition;
var angle = difference.ToAngle();
var adjusted = angle.Degrees + 90;
var newAngle = Angle.FromDegrees(adjusted);
_transform.SetWorldRotation(transform, newAngle);
transform.WorldRotation = newAngle;
UpdateAppearance(uid, component, transform);
continue;
}
_transform.SetWorldRotation(transform, _transform.GetWorldRotation(transform) + Angle.FromDegrees(20));
transform.WorldRotation += Angle.FromDegrees(20);
UpdateAppearance(uid, component, transform);
var toChased = _transform.GetWorldPosition(chasing) - _transform.GetWorldPosition(transform);
var toChased = EntityManager.GetComponent<TransformComponent>(chasing).WorldPosition - transform.WorldPosition;
_transform.SetWorldPosition(transform, _transform.GetWorldPosition(transform) + toChased * frameTime * component.ChasingSpeed);
transform.WorldPosition += toChased * frameTime * component.ChasingSpeed;
component.ChasingTime -= frameTime;

View File

@@ -266,8 +266,8 @@ namespace Content.Server.Polymorph.Systems
var parentXform = Transform(parent);
_transform.SetParent(parent, parentXform, uidXform.ParentUid);
_transform.SetCoordinates(parent, parentXform, uidXform.Coordinates);
_transform.SetLocalRotation(parentXform, uidXform.LocalRotation);
parentXform.Coordinates = uidXform.Coordinates;
parentXform.LocalRotation = uidXform.LocalRotation;
if (proto.TransferDamage &&
TryComp<DamageableComponent>(parent, out var damageParent) &&
@@ -306,7 +306,7 @@ namespace Content.Server.Polymorph.Systems
_mindSystem.TransferTo(mindId, parent, mind: mind);
// if an item polymorph was picked up, put it back down after reverting
_transform.AttachToGridOrMap(parent);
Transform(parent).AttachToGridOrMap();
_popup.PopupEntity(Loc.GetString("polymorph-revert-popup-generic",
("parent", Identity.Entity(uid, EntityManager)),

View File

@@ -22,7 +22,6 @@ public sealed class SpecialRespawnSystem : SharedSpecialRespawnSystem
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly TurfSystem _turf = default!;
[Dependency] private readonly IChatManager _chat = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize()
{
@@ -157,7 +156,7 @@ public sealed class SpecialRespawnSystem : SharedSpecialRespawnSystem
var tile = tileRef.GridIndices;
var found = false;
var (gridPos, _, gridMatrix) = _transform.GetWorldPositionRotationMatrix(xform);
var (gridPos, _, gridMatrix) = xform.GetWorldPositionRotationMatrix();
var gridBounds = gridMatrix.TransformBox(grid.LocalAABB);
//Obviously don't put anything ridiculous in here

View File

@@ -40,7 +40,6 @@ public sealed partial class RevenantSystem
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
[Dependency] private readonly GhostSystem _ghost = default!;
[Dependency] private readonly TileSystem _tile = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
private void InitializeAbilities()
{
@@ -215,7 +214,7 @@ public sealed partial class RevenantSystem
var xform = Transform(uid);
if (!_mapManager.TryGetGrid(xform.GridUid, out var map))
return;
var tiles = map.GetTilesIntersecting(Box2.CenteredAround(_transform.GetWorldPosition(xform),
var tiles = map.GetTilesIntersecting(Box2.CenteredAround(xform.WorldPosition,
new Vector2(component.DefileRadius * 2, component.DefileRadius))).ToArray();
_random.Shuffle(tiles);

View File

@@ -50,7 +50,7 @@ sealed class SalvageRulerCommand : IConsoleCommand
var first = true;
foreach (var mapGrid in _maps.GetAllMapGrids(entityTransform.MapID))
{
var aabb = _entities.System<SharedTransformSystem>().GetWorldMatrix(mapGrid.Owner).TransformBox(mapGrid.LocalAABB);
var aabb = _entities.GetComponent<TransformComponent>(mapGrid.Owner).WorldMatrix.TransformBox(mapGrid.LocalAABB);
if (first)
{
total = aabb;

View File

@@ -54,7 +54,6 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
[Dependency] private readonly ShuttleSystem _shuttle = default!;
[Dependency] private readonly StationSystem _station = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
private ISawmill _sawmill = default!;
@@ -416,6 +415,6 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem
if (!Resolve(shuttle, ref grid, ref shuttleXform))
return false;
return _transform.GetWorldMatrix(shuttleXform).TransformBox(grid.LocalAABB).Contains(_transform.GetWorldPosition(xform));
return shuttleXform.WorldMatrix.TransformBox(grid.LocalAABB).Contains(xform.WorldPosition);
}
}

View File

@@ -250,8 +250,8 @@ public sealed partial class ShuttleSystem
var fromRotation = _transform.GetWorldRotation(xform);
var width = Comp<MapGridComponent>(uid).LocalAABB.Width;
_transform.SetCoordinates(uid, xform, new EntityCoordinates(_mapManager.GetMapEntityId(_hyperSpaceMap!.Value), new Vector2(_index + width / 2f, 0f)));
_transform.SetLocalRotation(xform, Angle.Zero);
xform.Coordinates = new EntityCoordinates(_mapManager.GetMapEntityId(_hyperSpaceMap!.Value), new Vector2(_index + width / 2f, 0f));
xform.LocalRotation = Angle.Zero;
_index += width + Buffer;
comp.Accumulator += comp.TravelTime - DefaultArrivalTime;
@@ -336,7 +336,7 @@ public sealed partial class ShuttleSystem
}
else
{
_transform.SetCoordinates(uid, xform, comp.TargetCoordinates);
xform.Coordinates = comp.TargetCoordinates;
mapId = comp.TargetCoordinates.GetMapId(EntityManager);
}
@@ -506,7 +506,7 @@ public sealed partial class ShuttleSystem
if (config != null)
{
FTLDock(config, shuttleUid, shuttleXform);
FTLDock(config, shuttleXform);
return true;
}
@@ -517,13 +517,10 @@ public sealed partial class ShuttleSystem
/// <summary>
/// Forces an FTL dock.
/// </summary>
public void FTLDock(DockingConfig config, EntityUid uid, TransformComponent? shuttleXform = null)
public void FTLDock(DockingConfig config, TransformComponent shuttleXform)
{
if (!Resolve(uid, ref shuttleXform))
return;
// Set position
_transform.SetCoordinates(uid, shuttleXform, config.Coordinates);
shuttleXform.Coordinates = config.Coordinates;
_transform.SetWorldRotation(shuttleXform, config.Angle);
// Connect everything
@@ -632,7 +629,7 @@ public sealed partial class ShuttleSystem
spawnPos = _transform.GetWorldPosition(targetXform, xformQuery);
}
_transform.SetCoordinates(shuttleUid, xform, new EntityCoordinates(targetXform.MapUid.Value, spawnPos));
xform.Coordinates = new EntityCoordinates(targetXform.MapUid.Value, spawnPos);
if (!HasComp<MapComponent>(targetXform.GridUid))
{

View File

@@ -115,7 +115,7 @@ public sealed partial class ShuttleSystem
if (config != null)
{
FTLDock(config, ent[0], shuttleXform);
FTLDock(config, shuttleXform);
if (TryComp<StationMemberComponent>(xform.GridUid, out var stationMember))
{

View File

@@ -38,8 +38,8 @@ public sealed partial class ShuttleSystem
var otherXform = Transform(args.OtherEntity);
var ourPoint = _transform.GetInvWorldMatrix(ourXform).Transform(args.WorldPoint);
var otherPoint = _transform.GetInvWorldMatrix(otherXform).Transform(args.WorldPoint);
var ourPoint = ourXform.InvWorldMatrix.Transform(args.WorldPoint);
var otherPoint = otherXform.InvWorldMatrix.Transform(args.WorldPoint);
var ourVelocity = _physics.GetLinearVelocity(uid, ourPoint, ourBody, ourXform);
var otherVelocity = _physics.GetLinearVelocity(args.OtherEntity, otherPoint, otherBody, otherXform);

View File

@@ -22,7 +22,6 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly PhysicsSystem _physics = default!;
[Dependency] private readonly AppearanceSystem _visualizer = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize()
{
@@ -229,7 +228,7 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
if (!gen1XForm.Anchored)
return false;
var genWorldPosRot = _transform.GetWorldPositionRotation(gen1XForm);
var genWorldPosRot = gen1XForm.GetWorldPositionRotation();
var dirRad = dir.ToAngle() + genWorldPosRot.WorldRotation; //needs to be like this for the raycast to work properly
var ray = new CollisionRay(genWorldPosRot.WorldPosition, dirRad.ToVec(), component.CollisionMask);
@@ -305,7 +304,7 @@ public sealed class ContainmentFieldGeneratorSystem : EntitySystem
var newField = Spawn(firstGenComp.CreatedField, currentCoords);
var fieldXForm = Transform(newField);
_transform.SetParent(newField, fieldXForm, firstGenComp.Owner);
fieldXForm.AttachParent(firstGenComp.Owner);
if (dirVec.GetDir() == Direction.East || dirVec.GetDir() == Direction.West)
{
var angle = fieldXForm.LocalPosition.ToAngle();

View File

@@ -13,7 +13,6 @@ public sealed class ContainmentFieldSystem : EntitySystem
{
[Dependency] private readonly ThrowingSystem _throwing = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize()
{
@@ -27,16 +26,16 @@ public sealed class ContainmentFieldSystem : EntitySystem
{
var otherBody = args.OtherEntity;
if (HasComp<SpaceGarbageComponent>(otherBody))
if (TryComp<SpaceGarbageComponent>(otherBody, out var garbage))
{
_popupSystem.PopupEntity(Loc.GetString("comp-field-vaporized", ("entity", otherBody)), uid, PopupType.LargeCaution);
QueueDel(otherBody);
_popupSystem.PopupEntity(Loc.GetString("comp-field-vaporized", ("entity", otherBody)), component.Owner, PopupType.LargeCaution);
QueueDel(garbage.Owner);
}
if (TryComp<PhysicsComponent>(otherBody, out var physics) && physics.Mass <= component.MaxMass && physics.Hard)
{
var fieldDir = _transform.GetWorldPosition(uid);
var playerDir = _transform.GetWorldPosition(otherBody);
var fieldDir = Transform(component.Owner).WorldPosition;
var playerDir = Transform(otherBody).WorldPosition;
_throwing.TryThrow(otherBody, playerDir-fieldDir, strength: component.ThrowForce);
}

View File

@@ -18,7 +18,6 @@ namespace Content.Server.Solar.EntitySystems
{
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly SharedPhysicsSystem _physicsSystem = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
/// <summary>
/// Maximum panel angular velocity range - used to stop people rotating panels fast enough that the lag prevention becomes noticable
@@ -112,7 +111,7 @@ namespace Content.Server.Solar.EntitySystems
foreach (var (panel, xform) in EntityManager.EntityQuery<SolarPanelComponent, TransformComponent>())
{
TotalPanelPower += panel.MaxSupply * panel.Coverage;
_transform.SetWorldRotation(xform, TargetPanelRotation);
xform.WorldRotation = TargetPanelRotation;
_updateQueue.Enqueue(panel);
}
}
@@ -135,7 +134,7 @@ namespace Content.Server.Solar.EntitySystems
// directly downwards (abs(theta) = pi) = coverage -1
// as TowardsSun + = CCW,
// panelRelativeToSun should - = CW
var panelRelativeToSun = _transform.GetWorldRotation(xform) - TowardsSun;
var panelRelativeToSun = xform.WorldRotation - TowardsSun;
// essentially, given cos = X & sin = Y & Y is 'downwards',
// then for the first 90 degrees of rotation in either direction,
// this plots the lower-right quadrant of a circle.
@@ -153,7 +152,7 @@ namespace Content.Server.Solar.EntitySystems
if (coverage > 0)
{
// Determine if the solar panel is occluded, and zero out coverage if so.
var ray = new CollisionRay(_transform.GetWorldPosition(xform), TowardsSun.ToWorldVec(), (int) CollisionGroup.Opaque);
var ray = new CollisionRay(xform.WorldPosition, TowardsSun.ToWorldVec(), (int) CollisionGroup.Opaque);
var rayCastResults = _physicsSystem.IntersectRayWithPredicate(
xform.MapID,
ray,

View File

@@ -13,7 +13,6 @@ public sealed class StandingStateSystem : EntitySystem
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly ThrowingSystem _throwingSystem = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
private void FallOver(EntityUid uid, StandingStateComponent component, DropHandItemsEvent args)
{
@@ -26,7 +25,7 @@ public sealed class StandingStateSystem : EntitySystem
if (!TryComp(uid, out HandsComponent? handsComp))
return;
var worldRotation = _transform.GetWorldRotation(uid).ToVec();
var worldRotation = EntityManager.GetComponent<TransformComponent>(uid).WorldRotation.ToVec();
foreach (var hand in handsComp.Hands.Values)
{
if (hand.HeldEntity is not EntityUid held)

View File

@@ -12,7 +12,6 @@ namespace Content.Server.Worldgen.Systems;
public abstract class BaseWorldSystem : EntitySystem
{
[Dependency] private readonly WorldControllerSystem _worldController = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
/// <summary>
/// Gets a chunk's coordinates in chunk space as an integer value.
@@ -26,7 +25,7 @@ public abstract class BaseWorldSystem : EntitySystem
if (!Resolve(ent, ref xform))
throw new Exception("Failed to resolve transform, somehow.");
return WorldGen.WorldToChunkCoords(_transform.GetWorldPosition(xform)).Floored();
return WorldGen.WorldToChunkCoords(xform.WorldPosition).Floored();
}
/// <summary>
@@ -41,7 +40,7 @@ public abstract class BaseWorldSystem : EntitySystem
if (!Resolve(ent, ref xform))
throw new Exception("Failed to resolve transform, somehow.");
return WorldGen.WorldToChunkCoords(_transform.GetWorldPosition(xform));
return WorldGen.WorldToChunkCoords(xform.WorldPosition);
}
/// <summary>

View File

@@ -16,7 +16,6 @@ public sealed class ThrowArtifactSystem : EntitySystem
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly ThrowingSystem _throwing = default!;
[Dependency] private readonly TileSystem _tile = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
/// <inheritdoc/>
public override void Initialize()
@@ -30,7 +29,7 @@ public sealed class ThrowArtifactSystem : EntitySystem
if (_map.TryGetGrid(xform.GridUid, out var grid))
{
var tiles = grid.GetTilesIntersecting(
Box2.CenteredAround(_transform.GetWorldPosition(xform), new Vector2(component.Range * 2, component.Range)));
Box2.CenteredAround(xform.WorldPosition, new Vector2(component.Range * 2, component.Range)));
foreach (var tile in tiles)
{