[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
+ private SharedTransformSystem? _xformSystem = null;
private readonly SpawnExplosionEui _eui;
if (!_entMan.TryGetComponent(_playerManager.LocalEntity, out TransformComponent? transform))
return;
+ _xformSystem ??= _entMan.SystemOrNull<SharedTransformSystem>();
+ if (_xformSystem is null)
+ return;
+
_pausePreview = true;
MapOptions.Select(_mapData.IndexOf(transform.MapID));
- (MapX.Value, MapY.Value) = transform.MapPosition.Position;
+ (MapX.Value, MapY.Value) = _xformSystem.GetWorldPosition(transform);
_pausePreview = false;
UpdatePreview();
{
private readonly IEntityManager _entManager;
private readonly IMapManager _mapManager;
+ private readonly SharedTransformSystem _xformSystem;
public override OverlaySpace Space => OverlaySpace.WorldSpaceEntities;
private readonly ShaderInstance _shader;
{
_entManager = entManager;
_mapManager = IoCManager.Resolve<IMapManager>();
+ _xformSystem = _entManager.System<SharedTransformSystem>();
_shader = protoMan.Index<ShaderPrototype>("unshaded").Instance();
ZIndex = GasOverlayZIndex;
_fireFrameCounter,
_shader,
overlayQuery,
- xformQuery);
+ xformQuery,
+ _xformSystem);
var mapUid = _mapManager.GetMapEntityId(args.MapId);
int[] fireFrameCounter,
ShaderInstance shader,
EntityQuery<GasTileOverlayComponent> overlayQuery,
- EntityQuery<TransformComponent> xformQuery) state) =>
+ EntityQuery<TransformComponent> xformQuery,
+ SharedTransformSystem xformSystem) state) =>
{
if (!state.overlayQuery.TryGetComponent(uid, out var comp) ||
!state.xformQuery.TryGetComponent(uid, out var gridXform))
return true;
}
- var (_, _, worldMatrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
+ var (_, _, worldMatrix, invMatrix) = state.xformSystem.GetWorldPositionRotationMatrixWithInv(gridXform);
state.drawHandle.SetTransform(worldMatrix);
var floatBounds = invMatrix.TransformBox(in state.WorldBounds).Enlarged(grid.TileSize);
var localBounds = new Box2i(
if (!xformQuery.TryGetComponent(source, out var xform))
return;
- var sourcePos = _transform.GetMapCoordinates(source, xform);
+ var sourcePos = _transform.GetMapCoordinates((source, xform));
//Any mob that can move should be surprised?
//God mind rework needs to come faster so it can just check for mind
{
[Dependency] private readonly IEyeManager _eyeManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
[Dependency] protected readonly IConfigurationManager ConfigManager = default!;
public enum SpeechType : byte
public SpeechBubble(ChatMessage message, EntityUid senderEntity, string speechStyleClass, Color? fontColor = null)
{
IoCManager.InjectDependencies(this);
+ _xformSystem = _entityManager.System<SharedTransformSystem>();
_senderEntity = senderEntity;
// Use text clipping so new messages don't overlap old ones being pushed up.
}
var offset = (-_eyeManager.CurrentEye.Rotation).ToWorldVec() * -EntityVerticalOffset;
- var worldPos = xform.WorldPosition + offset;
+ var worldPos = _xformSystem.GetWorldPosition(xform) + offset;
var lowerCenter = _eyeManager.WorldToScreen(worldPos) / UIScale;
var screenPos = lowerCenter - new Vector2(ContentSize.X / 2, ContentSize.Y + _verticalOffsetAchieved);
-using System.Numerics;
-using Robust.Client.GameObjects;
-using Robust.Client.Graphics;
-using Robust.Client.Utility;
-using Robust.Shared.Graphics;
-using static Robust.Client.GameObjects.SpriteComponent;
-using Direction = Robust.Shared.Maths.Direction;
+namespace Content.Client.Clickable;
-namespace Content.Client.Clickable
+/// <summary>
+/// Makes it possible to click the associated entity.
+/// </summary>
+[RegisterComponent]
+public sealed partial class ClickableComponent : Component
{
- [RegisterComponent]
- public sealed partial class ClickableComponent : Component
+ /// <summary>
+ /// A set of AABBs used as an approximate check for whether a click could hit this entity.
+ /// </summary>
+ [DataField("bounds")]
+ public DirBoundData? Bounds;
+
+ /// <summary>
+ /// A set of AABBs associated with the cardinal directions used for approximate click intersection calculations.
+ /// </summary>
+ [DataDefinition]
+ public sealed partial class DirBoundData
{
- [Dependency] private readonly IClickMapManager _clickMapManager = default!;
-
- [DataField("bounds")] public DirBoundData? Bounds;
-
- /// <summary>
- /// Used to check whether a click worked. Will first check if the click falls inside of some explicit bounding
- /// boxes (see <see cref="Bounds"/>). If that fails, attempts to use automatically generated click maps.
- /// </summary>
- /// <param name="worldPos">The world position that was clicked.</param>
- /// <param name="drawDepth">
- /// The draw depth for the sprite that captured the click.
- /// </param>
- /// <returns>True if the click worked, false otherwise.</returns>
- public bool CheckClick(SpriteComponent sprite, TransformComponent transform, EntityQuery<TransformComponent> xformQuery, Vector2 worldPos, IEye eye, out int drawDepth, out uint renderOrder, out float bottom)
- {
- if (!sprite.Visible)
- {
- drawDepth = default;
- renderOrder = default;
- bottom = default;
- return false;
- }
-
- drawDepth = sprite.DrawDepth;
- renderOrder = sprite.RenderOrder;
- var (spritePos, spriteRot) = transform.GetWorldPositionRotation(xformQuery);
- var spriteBB = sprite.CalculateRotatedBoundingBox(spritePos, spriteRot, eye.Rotation);
- bottom = Matrix3.CreateRotation(eye.Rotation).TransformBox(spriteBB).Bottom;
-
- var invSpriteMatrix = Matrix3.Invert(sprite.GetLocalMatrix());
-
- // This should have been the rotation of the sprite relative to the screen, but this is not the case with no-rot or directional sprites.
- var relativeRotation = (spriteRot + eye.Rotation).Reduced().FlipPositive();
-
- Angle cardinalSnapping = sprite.SnapCardinals ? relativeRotation.GetCardinalDir().ToAngle() : Angle.Zero;
-
- // First we get `localPos`, the clicked location in the sprite-coordinate frame.
- var entityXform = Matrix3.CreateInverseTransform(transform.WorldPosition, sprite.NoRotation ? -eye.Rotation : spriteRot - cardinalSnapping);
- var localPos = invSpriteMatrix.Transform(entityXform.Transform(worldPos));
-
- // Check explicitly defined click-able bounds
- if (CheckDirBound(sprite, relativeRotation, localPos))
- return true;
-
- // Next check each individual sprite layer using automatically computed click maps.
- foreach (var spriteLayer in sprite.AllLayers)
- {
- if (!spriteLayer.Visible || spriteLayer is not Layer layer)
- continue;
-
- // Check the layer's texture, if it has one
- if (layer.Texture != null)
- {
- // Convert to image coordinates
- var imagePos = (Vector2i) (localPos * EyeManager.PixelsPerMeter * new Vector2(1, -1) + layer.Texture.Size / 2f);
-
- if (_clickMapManager.IsOccluding(layer.Texture, imagePos))
- return true;
- }
-
- // Either we weren't clicking on the texture, or there wasn't one. In which case: check the RSI next
- if (layer.ActualRsi is not { } rsi || !rsi.TryGetState(layer.State, out var rsiState))
- continue;
-
- var dir = Layer.GetDirection(rsiState.RsiDirections, relativeRotation);
-
- // convert to layer-local coordinates
- layer.GetLayerDrawMatrix(dir, out var matrix);
- var inverseMatrix = Matrix3.Invert(matrix);
- var layerLocal = inverseMatrix.Transform(localPos);
-
- // Convert to image coordinates
- var layerImagePos = (Vector2i) (layerLocal * EyeManager.PixelsPerMeter * new Vector2(1, -1) + rsiState.Size / 2f);
-
- // Next, to get the right click map we need the "direction" of this layer that is actually being used to draw the sprite on the screen.
- // This **can** differ from the dir defined before, but can also just be the same.
- if (sprite.EnableDirectionOverride)
- dir = sprite.DirectionOverride.Convert(rsiState.RsiDirections);
- dir = dir.OffsetRsiDir(layer.DirOffset);
-
- if (_clickMapManager.IsOccluding(layer.ActualRsi!, layer.State, dir, layer.AnimationFrame, layerImagePos))
- return true;
- }
-
- drawDepth = default;
- renderOrder = default;
- bottom = default;
- return false;
- }
-
- public bool CheckDirBound(SpriteComponent sprite, Angle relativeRotation, Vector2 localPos)
- {
- if (Bounds == null)
- return false;
-
- // These explicit bounds only work for either 1 or 4 directional sprites.
-
- // This would be the orientation of a 4-directional sprite.
- var direction = relativeRotation.GetCardinalDir();
-
- var modLocalPos = sprite.NoRotation
- ? localPos
- : direction.ToAngle().RotateVec(localPos);
-
- // First, check the bounding box that is valid for all orientations
- if (Bounds.All.Contains(modLocalPos))
- return true;
-
- // Next, get and check the appropriate bounding box for the current sprite orientation
- var boundsForDir = (sprite.EnableDirectionOverride ? sprite.DirectionOverride : direction) switch
- {
- Direction.East => Bounds.East,
- Direction.North => Bounds.North,
- Direction.South => Bounds.South,
- Direction.West => Bounds.West,
- _ => throw new InvalidOperationException()
- };
-
- return boundsForDir.Contains(modLocalPos);
- }
-
- [DataDefinition]
- public sealed partial class DirBoundData
- {
- [DataField("all")] public Box2 All;
- [DataField("north")] public Box2 North;
- [DataField("south")] public Box2 South;
- [DataField("east")] public Box2 East;
- [DataField("west")] public Box2 West;
- }
+ [DataField("all")] public Box2 All;
+ [DataField("north")] public Box2 North;
+ [DataField("south")] public Box2 South;
+ [DataField("east")] public Box2 East;
+ [DataField("west")] public Box2 West;
}
}
--- /dev/null
+using Robust.Client.GameObjects;
+using Robust.Client.Graphics;
+using static Robust.Client.GameObjects.SpriteComponent;
+using Robust.Client.Utility;
+using Robust.Shared.Graphics;
+using Direction = Robust.Shared.Maths.Direction;
+using System.Numerics;
+
+namespace Content.Client.Clickable;
+
+public sealed partial class ClickableSystem : EntitySystem
+{
+ [Dependency] private readonly IClickMapManager _clickMapManager = default!;
+ [Dependency] private readonly SharedTransformSystem _transformSystem = default!;
+
+ /// <summary>
+ /// Used to check whether a click worked. Will first check if the click falls inside of some explicit bounding
+ /// boxes (see <see cref="Bounds"/>). If that fails, attempts to use automatically generated click maps.
+ /// </summary>
+ /// <param name="entity">The entity that we are trying to click.</param>
+ /// <param name="worldPos">The world position that was clicked.</param>
+ /// <param name="eye">The PoV the click is originating from.</param>
+ /// <param name="drawDepth">The draw depth for the sprite that captured the click.</param>
+ /// <param name="renderOrder">The render order for the sprite that captured the click.</param>
+ /// <param name="bottom">The bottom of the sprite AABB from the perspective of the eye doing the click.</param>
+ /// <returns>True if the click worked, false otherwise.</returns>
+ public bool CheckClick(Entity<ClickableComponent, SpriteComponent, TransformComponent> entity, Vector2 worldPos, IEye eye, out int drawDepth, out uint renderOrder, out float bottom)
+ {
+ var (uid, clickable, sprite, xform) = entity;
+
+ if (!sprite.Visible)
+ {
+ drawDepth = default;
+ renderOrder = default;
+ bottom = default;
+ return false;
+ }
+
+ drawDepth = sprite.DrawDepth;
+ renderOrder = sprite.RenderOrder;
+ var (spritePos, spriteRot) = _transformSystem.GetWorldPositionRotation(xform);
+ var spriteBB = sprite.CalculateRotatedBoundingBox(spritePos, spriteRot, eye.Rotation);
+ bottom = Matrix3.CreateRotation(eye.Rotation).TransformBox(spriteBB).Bottom;
+
+ var invSpriteMatrix = Matrix3.Invert(sprite.GetLocalMatrix());
+
+ // This should have been the rotation of the sprite relative to the screen, but this is not the case with no-rot or directional sprites.
+ var relativeRotation = (spriteRot + eye.Rotation).Reduced().FlipPositive();
+
+ Angle cardinalSnapping = sprite.SnapCardinals ? relativeRotation.GetCardinalDir().ToAngle() : Angle.Zero;
+
+ // First we get `localPos`, the clicked location in the sprite-coordinate frame.
+ var entityXform = Matrix3.CreateInverseTransform(_transformSystem.GetWorldPosition(xform), sprite.NoRotation ? -eye.Rotation : spriteRot - cardinalSnapping);
+ var localPos = invSpriteMatrix.Transform(entityXform.Transform(worldPos));
+
+ // Check explicitly defined click-able bounds
+ if (CheckDirBound((uid, clickable, sprite), relativeRotation, localPos))
+ return true;
+
+ // Next check each individual sprite layer using automatically computed click maps.
+ foreach (var spriteLayer in sprite.AllLayers)
+ {
+ if (!spriteLayer.Visible || spriteLayer is not Layer layer)
+ continue;
+
+ // Check the layer's texture, if it has one
+ if (layer.Texture != null)
+ {
+ // Convert to image coordinates
+ var imagePos = (Vector2i) (localPos * EyeManager.PixelsPerMeter * new Vector2(1, -1) + layer.Texture.Size / 2f);
+
+ if (_clickMapManager.IsOccluding(layer.Texture, imagePos))
+ return true;
+ }
+
+ // Either we weren't clicking on the texture, or there wasn't one. In which case: check the RSI next
+ if (layer.ActualRsi is not { } rsi || !rsi.TryGetState(layer.State, out var rsiState))
+ continue;
+
+ var dir = Layer.GetDirection(rsiState.RsiDirections, relativeRotation);
+
+ // convert to layer-local coordinates
+ layer.GetLayerDrawMatrix(dir, out var matrix);
+ var inverseMatrix = Matrix3.Invert(matrix);
+ var layerLocal = inverseMatrix.Transform(localPos);
+
+ // Convert to image coordinates
+ var layerImagePos = (Vector2i) (layerLocal * EyeManager.PixelsPerMeter * new Vector2(1, -1) + rsiState.Size / 2f);
+
+ // Next, to get the right click map we need the "direction" of this layer that is actually being used to draw the sprite on the screen.
+ // This **can** differ from the dir defined before, but can also just be the same.
+ if (sprite.EnableDirectionOverride)
+ dir = sprite.DirectionOverride.Convert(rsiState.RsiDirections);
+ dir = dir.OffsetRsiDir(layer.DirOffset);
+
+ if (_clickMapManager.IsOccluding(layer.ActualRsi!, layer.State, dir, layer.AnimationFrame, layerImagePos))
+ return true;
+ }
+
+ drawDepth = default;
+ renderOrder = default;
+ bottom = default;
+ return false;
+ }
+
+ /// <summary>
+ /// Used to check whether a click worked lands inside of the AABB for the current sprite for a clickable entity.
+ /// </summary>
+ /// <param name="localPos">The world position that was clicked.</param>
+ /// <param name="relativeRotation">The angle of the entity to check relative to the PoV that the click is coming from.</param>
+ /// <returns>True if the click lands inside the relevant AABB.</returns>
+ public bool CheckDirBound(Entity<ClickableComponent, SpriteComponent> entity, Angle relativeRotation, Vector2 localPos)
+ {
+ var (uid, clickable, sprite) = entity;
+
+ if (clickable.Bounds == null)
+ return false;
+
+ // These explicit bounds only work for either 1 or 4 directional sprites.
+
+ // This would be the orientation of a 4-directional sprite.
+ var direction = relativeRotation.GetCardinalDir();
+
+ var modLocalPos = sprite.NoRotation
+ ? localPos
+ : direction.ToAngle().RotateVec(localPos);
+
+ // First, check the bounding box that is valid for all orientations
+ if (clickable.Bounds.All.Contains(modLocalPos))
+ return true;
+
+ // Next, get and check the appropriate bounding box for the current sprite orientation
+ var boundsForDir = (sprite.EnableDirectionOverride ? sprite.DirectionOverride : direction) switch
+ {
+ Direction.East => clickable.Bounds.East,
+ Direction.North => clickable.Bounds.North,
+ Direction.South => clickable.Bounds.South,
+ Direction.West => clickable.Bounds.West,
+ _ => throw new InvalidOperationException()
+ };
+
+ return boundsForDir.Contains(modLocalPos);
+ }
+}
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
private readonly Dictionary<int, EntityUid> _ghosts = new();
ghost = EntityManager.SpawnEntity("constructionghost", loc);
var comp = EntityManager.GetComponent<ConstructionGhostComponent>(ghost.Value);
comp.Prototype = prototype;
- EntityManager.GetComponent<TransformComponent>(ghost.Value).LocalRotation = dir.ToAngle();
+ _xformSystem.SetLocalRotation(ghost.Value, dir.ToAngle());
_ghosts.Add(ghost.GetHashCode(), ghost.Value);
var sprite = EntityManager.GetComponent<SpriteComponent>(ghost.Value);
sprite.Color = new Color(48, 255, 48, 128);
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IPrototypeManager _proto = default!;
+ private SharedTransformSystem _xformSystem = default!;
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV;
public ExplosionOverlay()
{
IoCManager.InjectDependencies(this);
+ _xformSystem = _entMan.System<SharedTransformSystem>();
_shader = _proto.Index<ShaderPrototype>("unshaded").Instance();
}
continue;
var xform = xforms.GetComponent(gridId);
- var (_, _, worldMatrix, invWorldMatrix) = xform.GetWorldPositionRotationMatrixWithInv(xforms);
+ var (_, _, worldMatrix, invWorldMatrix) = _xformSystem.GetWorldPositionRotationMatrixWithInv(xform);
gridBounds = invWorldMatrix.TransformBox(worldBounds).Enlarged(grid.TileSize * 2);
drawHandle.SetTransform(worldMatrix);
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IEntitySystemManager _entitySystemManager = default!;
private readonly PuddleDebugOverlaySystem _debugOverlaySystem;
+ private readonly SharedTransformSystem _xformSystem;
private readonly Color _heavyPuddle = new(0, 255, 255, 50);
private readonly Color _mediumPuddle = new(0, 150, 255, 50);
{
IoCManager.InjectDependencies(this);
_debugOverlaySystem = _entitySystemManager.GetEntitySystem<PuddleDebugOverlaySystem>();
+ _xformSystem = _entitySystemManager.GetEntitySystem<SharedTransformSystem>();
var cache = IoCManager.Resolve<IResourceCache>();
_font = new VectorFont(cache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 8);
}
continue;
var gridXform = xformQuery.GetComponent(gridId);
- var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(xformQuery);
+ var (_, _, worldMatrix, invWorldMatrix) = _xformSystem.GetWorldPositionRotationMatrixWithInv(gridXform);
gridBounds = invWorldMatrix.TransformBox(args.WorldBounds).Enlarged(mapGrid.TileSize * 2);
drawHandle.SetTransform(worldMatrix);
continue;
var gridXform = xformQuery.GetComponent(gridId);
- var (_, _, matrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv(xformQuery);
+ var (_, _, matrix, invMatrix) = _xformSystem.GetWorldPositionRotationMatrixWithInv(gridXform);
var gridBounds = invMatrix.TransformBox(args.WorldBounds).Enlarged(mapGrid.TileSize * 2);
foreach (var debugOverlayData in _debugOverlaySystem.GetData(gridId))
private readonly RichTextLabel _label;
private float _updateDif;
private readonly IEntityManager _entMan;
+ private readonly SharedTransformSystem _xformSystem;
public HandheldGpsStatusControl(Entity<HandheldGPSComponent> parent)
{
_parent = parent;
_entMan = IoCManager.Resolve<IEntityManager>();
+ _xformSystem = _entMan.System<SharedTransformSystem>();
_label = new RichTextLabel { StyleClasses = { StyleNano.StyleClassItemStatus } };
AddChild(_label);
UpdateGpsDetails();
var posText = "Error";
if (_entMan.TryGetComponent(_parent, out TransformComponent? transComp))
{
- var pos = transComp.MapPosition;
+ var pos = _xformSystem.GetMapCoordinates((_parent, transComp));
var x = (int) pos.X;
var y = (int) pos.Y;
posText = $"({x}, {y})";
// Check the entities against whether or not we can click them
var foundEntities = new List<(EntityUid, int, uint, float)>(entities.Count);
var clickQuery = _entityManager.GetEntityQuery<ClickableComponent>();
- var xformQuery = _entityManager.GetEntityQuery<TransformComponent>();
+ var clickSystem = _entityManager.System<ClickableSystem>();
// TODO: Smelly
var eye = _eyeManager.CurrentEye;
foreach (var entity in entities)
{
if (clickQuery.TryGetComponent(entity.Uid, out var component) &&
- component.CheckClick(entity.Component, entity.Transform, xformQuery, coordinates.Position, eye, out var drawDepthClicked, out var renderOrder, out var bottom))
+ clickSystem.CheckClick((entity.Uid, component, entity.Component, entity.Transform), coordinates.Position, eye, out var drawDepthClicked, out var renderOrder, out var bottom))
{
foundEntities.Add((entity.Uid, drawDepthClicked, renderOrder, bottom));
}
[Dependency] private readonly RgbLightControllerSystem _rgbLightControllerSystem = default!;
[Dependency] private readonly SharedPointLightSystem _pointLightSystem = default!;
[Dependency] private readonly TagSystem _tags = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public event Action<List<string>, List<string>?, string?, bool, string?>? OnGuidebookOpen;
public const string GuideEmbedTag = "GuideEmbeded";
{
Act = () =>
{
- if (Transform(uid).LocalRotation != Angle.Zero)
- Transform(uid).LocalRotation -= Angle.FromDegrees(90);
+ var xform = Transform(uid);
+ if (xform.LocalRotation != Angle.Zero)
+ _xformSystem.SetLocalRotation(uid, xform.LocalRotation - Angle.FromDegrees(90), xform);
},
Text = Loc.GetString("guidebook-monkey-unspin"),
Priority = -9999,
private void OnGuidebookControlsTestActivateInWorld(EntityUid uid, GuidebookControlsTestComponent component, ActivateInWorldEvent args)
{
- Transform(uid).LocalRotation += Angle.FromDegrees(90);
+ var xform = Transform(uid);
+ _xformSystem.SetLocalRotation(uid, xform.LocalRotation + Angle.FromDegrees(90), xform);
}
private void OnGuidebookControlsTestInteractHand(EntityUid uid, GuidebookControlsTestComponent component, InteractHandEvent args)
{
if (_timing.CurTime < comp.TargetTime)
continue;
+
comp.TargetTime = _timing.CurTime + TimeSpan.FromSeconds(comp.EffectCooldown);
Spawn("HotPotatoEffect", _transform.GetMapCoordinates(uid).Offset(_random.NextVector2(0.25f)));
}
[Dependency] private readonly ActionBlockerSystem _actionBlockerSystem = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
// how often to recheck possible targets (prevents calling expensive
// check logic each update)
dragSprite.DrawDepth = (int) DrawDepth.Overlays;
if (!dragSprite.NoRotation)
{
- Transform(_dragShadow.Value).WorldRotation = Transform(_draggedEntity.Value).WorldRotation;
+ _xformSystem.SetWorldRotation(_dragShadow.Value, _xformSystem.GetWorldRotation(_draggedEntity.Value));
}
// drag initiated
if (Exists(_dragShadow))
{
var mousePos = _eyeManager.PixelToMap(_inputManager.MouseScreenPosition);
- Transform(_dragShadow.Value).WorldPosition = mousePos.Position;
+ _xformSystem.SetWorldPosition(_dragShadow.Value, mousePos.Position);
}
}
}
[Dependency] private readonly IInputManager _inputManager = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly InputSystem _inputSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public bool Enabled { get; set; }
xform.MapID == _lastMousePosition.Value.MapId)
{
var tickTime = _gameTiming.TickPeriod;
- var distance = _lastMousePosition.Value.Position - xform.WorldPosition;
+ var distance = _lastMousePosition.Value.Position - _xformSystem.GetWorldPosition(xform);
RaiseNetworkEvent(new GridDragVelocityRequest()
{
Grid = GetNetEntity(_dragging.Value),
if (!_mapManager.TryFindGridAt(mousePos, out var gridUid, out var grid))
return;
- StartDragging(gridUid, Transform(gridUid).InvWorldMatrix.Transform(mousePos.Position));
+ StartDragging(gridUid, _xformSystem.GetInvWorldMatrix(gridUid).Transform(mousePos.Position));
}
if (!TryComp<TransformComponent>(_dragging, out var xform))
return;
}
- var localToWorld = xform.WorldMatrix.Transform(_localPosition);
+ var localToWorld = _xformSystem.GetWorldMatrix(xform).Transform(_localPosition);
if (localToWorld.EqualsApprox(mousePos.Position, 0.01f)) return;
- var requestedGridOrigin = mousePos.Position - xform.WorldRotation.RotateVec(_localPosition);
+ var requestedGridOrigin = mousePos.Position - _xformSystem.GetWorldRotation(xform).RotateVec(_localPosition);
_lastMousePosition = new MapCoordinates(requestedGridOrigin, mousePos.MapId);
RaiseNetworkEvent(new GridDragRequestPosition()
if (mapPos.MapId == MapId.Nullspace)
return;
- var angle = (mapPos.Position - xform.MapPosition.Position).ToWorldAngle();
+ var angle = (mapPos.Position - _transform.GetMapCoordinates((player.Value, xform)).Position).ToWorldAngle();
var curRot = _transform.GetWorldRotation(xform);
{
private readonly IEntityManager _entManager = default!;
private readonly Font _font = default!;
+ private SharedTransformSystem? _xformSystem = null;
public override OverlaySpace Space => OverlaySpace.ScreenSpace;
if (args.ViewportControl == null)
return;
+ _xformSystem ??= _entManager.SystemOrNull<SharedTransformSystem>();
+ if (_xformSystem is null)
+ return;
+
var handle = args.ScreenHandle;
foreach (var (comp, xform) in _entManager.EntityQuery<HTNComponent, TransformComponent>(true))
if (string.IsNullOrEmpty(comp.DebugText) || xform.MapID != args.MapId)
continue;
- var worldPos = xform.WorldPosition;
+ var worldPos = _xformSystem.GetWorldPosition(xform);
if (!args.WorldAABB.Contains(worldPos))
continue;
protected override void Draw(in OverlayDrawArgs args)
{
+ var xformSystem = _entManager.SystemOrNull<SharedTransformSystem>();
+ if (xformSystem is null)
+ return;
+
foreach (var (comp, mover, xform) in _entManager.EntityQuery<NPCSteeringComponent, InputMoverComponent, TransformComponent>(true))
{
if (xform.MapID != args.MapId)
continue;
}
- var (worldPos, worldRot) = xform.GetWorldPositionRotation();
+ var (worldPos, worldRot) = xformSystem.GetWorldPositionRotation(xform);
if (!args.WorldAABB.Contains(worldPos))
continue;
private readonly IMapManager _mapManager;
private readonly PathfindingSystem _system;
private readonly MapSystem _mapSystem;
+ private readonly SharedTransformSystem _xformSystem;
public override OverlaySpace Space => OverlaySpace.ScreenSpace | OverlaySpace.WorldSpace;
_mapManager = mapManager;
_system = system;
_mapSystem = mapSystem;
+ _xformSystem = _entManager.System<SharedTransformSystem>();
_font = new VectorFont(cache.GetResource<FontResource>("/Fonts/NotoSans/NotoSans-Regular.ttf"), 10);
}
if (found || !_system.Breadcrumbs.TryGetValue(netGrid, out var crumbs) || !xformQuery.TryGetComponent(grid, out var gridXform))
continue;
- var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
+ var (_, _, worldMatrix, invWorldMatrix) = _xformSystem.GetWorldPositionRotationMatrixWithInv(gridXform);
var localAABB = invWorldMatrix.TransformBox(aabb.Enlarged(float.Epsilon - SharedPathfindingSystem.ChunkSize));
foreach (var chunk in crumbs)
return;
}
- var invGridMatrix = gridXform.InvWorldMatrix;
+ var invGridMatrix = _xformSystem.GetInvWorldMatrix(gridXform);
DebugPathPoly? nearest = null;
var nearestDistance = float.MaxValue;
continue;
}
- var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
+ var (_, _, worldMatrix, invWorldMatrix) = _xformSystem.GetWorldPositionRotationMatrixWithInv(gridXform);
worldHandle.SetTransform(worldMatrix);
var localAABB = invWorldMatrix.TransformBox(aabb);
!xformQuery.TryGetComponent(grid, out var gridXform))
continue;
- var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
+ var (_, _, worldMatrix, invWorldMatrix) = _xformSystem.GetWorldPositionRotationMatrixWithInv(gridXform);
worldHandle.SetTransform(worldMatrix);
var localAABB = invWorldMatrix.TransformBox(aabb);
!xformQuery.TryGetComponent(grid, out var gridXform))
continue;
- var (_, _, worldMatrix, invMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
+ var (_, _, worldMatrix, invMatrix) = _xformSystem.GetWorldPositionRotationMatrixWithInv(gridXform);
worldHandle.SetTransform(worldMatrix);
var localAABB = invMatrix.TransformBox(aabb);
!xformQuery.TryGetComponent(grid, out var gridXform))
continue;
- var (_, _, worldMatrix, invWorldMatrix) = gridXform.GetWorldPositionRotationMatrixWithInv();
+ var (_, _, worldMatrix, invWorldMatrix) = _xformSystem.GetWorldPositionRotationMatrixWithInv(gridXform);
worldHandle.SetTransform(worldMatrix);
var localAABB = invWorldMatrix.TransformBox(args.WorldBounds);
if (!_entManager.TryGetComponent<TransformComponent>(_entManager.GetEntity(node.GraphUid), out var graphXform))
continue;
- worldHandle.SetTransform(graphXform.WorldMatrix);
+ worldHandle.SetTransform(_xformSystem.GetWorldMatrix(graphXform));
worldHandle.DrawRect(node.Box, Color.Orange.WithAlpha(0.10f));
}
}
continue;
matrix = graph;
- worldHandle.SetTransform(graphXform.WorldMatrix);
+ worldHandle.SetTransform(_xformSystem.GetWorldMatrix(graphXform));
}
worldHandle.DrawRect(node.Box, new Color(0f, cost / highestGScore, 1f - (cost / highestGScore), 0.10f));
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
private readonly DeviceListSystem _deviceListSystem;
+ private readonly SharedTransformSystem _xformSystem;
public Dictionary<EntityUid, Color> Colors = new();
public EntityUid? Action;
IoCManager.InjectDependencies(this);
_deviceListSystem = _entityManager.System<DeviceListSystem>();
+ _xformSystem = _entityManager.System<SharedTransformSystem>();
}
protected override void Draw(in OverlayDrawArgs args)
continue;
}
- args.WorldHandle.DrawLine(sourceTransform.WorldPosition, linkTransform.WorldPosition, Colors[uid]);
+ args.WorldHandle.DrawLine(_xformSystem.GetWorldPosition(sourceTransform), _xformSystem.GetWorldPosition(linkTransform), Colors[uid]);
}
}
}
private readonly IMapManager _mapManager;
private readonly IInputManager _inputManager;
private readonly IEntityManager _entityManager;
+ private readonly SharedTransformSystem _xformSystem;
private readonly Dictionary<(int, int), NodeRenderData> _nodeIndex = new();
private readonly Dictionary<EntityUid, Dictionary<Vector2i, List<(GroupData, NodeDatum)>>> _gridIndex = new ();
_mapManager = mapManager;
_inputManager = inputManager;
_entityManager = entityManager;
+ _xformSystem = _entityManager.System<SharedTransformSystem>();
_font = cache.GetFont("/Fonts/NotoSans/NotoSans-Regular.ttf", 12);
}
foreach (var (gridId, gridDict) in _gridIndex)
{
var grid = _mapManager.GetGrid(gridId);
- var (_, _, worldMatrix, invMatrix) = _entityManager.GetComponent<TransformComponent>(gridId).GetWorldPositionRotationMatrixWithInv();
+ var (_, _, worldMatrix, invMatrix) = _xformSystem.GetWorldPositionRotationMatrixWithInv(gridId);
var lCursorBox = invMatrix.TransformBox(cursorBox);
foreach (var (pos, list) in gridDict)
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
private bool _enabled = false;
valid = _interactionSystem.InRangeUnobstructed(player, entity, Range);
else if (Range >= 0)
{
- var origin = Transform(player).WorldPosition;
- var target = Transform(entity).WorldPosition;
+ var origin = _xformSystem.GetWorldPosition(player);
+ var target = _xformSystem.GetWorldPosition(entity);
valid = (origin - target).LengthSquared() <= Range;
}
{
var query = _entManager.GetEntityQuery<NavMapComponent>();
var xformQuery = _entManager.GetEntityQuery<TransformComponent>();
+ var xformSystem = _entManager.System<SharedTransformSystem>();
var scale = Matrix3.CreateScale(new Vector2(1f, 1f));
_grids.Clear();
continue;
// TODO: Faster helper method
- var (_, _, matrix, invMatrix) = xform.GetWorldPositionRotationMatrixWithInv();
+ var (_, _, matrix, invMatrix) = xformSystem.GetWorldPositionRotationMatrixWithInv(xform);
var localAABB = invMatrix.TransformBox(args.WorldBounds);
Matrix3.Multiply(in scale, in matrix, out var matty);
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
+ private SharedTransformSystem? _xformSystem = null;
private const float MaxDist = 15.0f;
//Queries all pulses on the map and either adds or removes them from the list of rendered pulses based on whether they should be drawn (in range? on the same z-level/map? pulse entity still exists?)
private void RadiationQuery(IEye? currentEye)
{
- if (currentEye == null)
+ _xformSystem ??= _entityManager.SystemOrNull<SharedTransformSystem>();
+
+ if (_xformSystem is null || currentEye is null)
{
_pulses.Clear();
return;
(
_baseShader.Duplicate(),
new RadiationShaderInstance(
- _entityManager.GetComponent<TransformComponent>(pulseEntity).MapPosition,
+ _xformSystem.GetMapCoordinates(pulseEntity),
pulse.VisualRange,
pulse.StartTime,
pulse.VisualDuration
_entityManager.TryGetComponent(pulseEntity, out RadiationPulseComponent? pulse))
{
var shaderInstance = _pulses[pulseEntity];
- shaderInstance.instance.CurrentMapCoords = _entityManager.GetComponent<TransformComponent>(pulseEntity).MapPosition;
+ shaderInstance.instance.CurrentMapCoords = _xformSystem.GetMapCoordinates(pulseEntity);
shaderInstance.instance.Range = pulse.VisualRange;
} else {
_pulses[pulseEntity].shd.Dispose();
if (data.Local != null && data.Local.Value.Coords.IsValid(EntityManager))
{
- var newXform = SpawnSpectatorGhost(data.Local.Value.Coords, false);
- newXform.LocalRotation = data.Local.Value.Rot;
+ var (newUid, newXform) = SpawnSpectatorGhost(data.Local.Value.Coords, false);
+ _transform.SetLocalRotation(newUid, data.Local.Value.Rot, newXform);
}
else if (data.World != null && data.World.Value.Coords.IsValid(EntityManager))
{
- var newXform = SpawnSpectatorGhost(data.World.Value.Coords, true);
- newXform.LocalRotation = data.World.Value.Rot;
+ var (newUid, newXform) = SpawnSpectatorGhost(data.World.Value.Coords, true);
+ _transform.SetLocalRotation(newUid, data.World.Value.Rot, newXform);
}
else if (TryFindFallbackSpawn(out var coords))
{
- var newXform = SpawnSpectatorGhost(coords, true);
- newXform.LocalRotation = 0;
+ var (newUid, newXform) = SpawnSpectatorGhost(coords, true);
+ _transform.SetLocalRotation(newUid, 0, newXform);
}
else
{
RemComp<ReplaySpectatorComponent>(old.Value);
}
- public TransformComponent SpawnSpectatorGhost(EntityCoordinates coords, bool gridAttach)
+ public Entity<TransformComponent> SpawnSpectatorGhost(EntityCoordinates coords, bool gridAttach)
{
var old = _player.LocalEntity;
var session = _player.GetSessionById(DefaultUser);
_stateMan.RequestStateChange<ReplayGhostState>();
_spectatorData = GetSpectatorData();
- return xform;
+ return (ent, xform);
}
private void SpectateCommand(IConsoleShell shell, string argStr, string[] args)
public sealed class EmergencyShuttleOverlay : Overlay
{
private IEntityManager _entManager;
+ private SharedTransformSystem _xformSystem;
public override OverlaySpace Space => OverlaySpace.WorldSpace;
public EmergencyShuttleOverlay(IEntityManager entManager)
{
_entManager = entManager;
+ _xformSystem = _entManager.System<SharedTransformSystem>();
}
protected override void Draw(in OverlayDrawArgs args)
{
if (Position == null || !_entManager.TryGetComponent<TransformComponent>(StationUid, out var xform)) return;
- args.WorldHandle.SetTransform(xform.WorldMatrix);
+ args.WorldHandle.SetTransform(_xformSystem.GetWorldMatrix(xform));
args.WorldHandle.DrawRect(Position.Value, Color.Red.WithAlpha(100));
args.WorldHandle.SetTransform(Matrix3.Identity);
}
{
private readonly IEntityManager _entManager;
private readonly IMapManager _mapManager;
+ private readonly SharedTransformSystem _xformSystem;
private float _range = 8f;
private float _rangeSquared = 0f;
{
_entManager = IoCManager.Resolve<IEntityManager>();
_mapManager = IoCManager.Resolve<IMapManager>();
+ _xformSystem = _entManager.System<SharedTransformSystem>();
_rangeSquared = _range * _range;
MinSize = new Vector2(SizeFull, SizeFull);
}
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 = _xformSystem.GetWorldMatrix(gridXform).Transform(Coordinates.Value.Position);
+ var gridInvMatrix = _xformSystem.GetInvWorldMatrix(gridXform);
Matrix3.Multiply(in gridInvMatrix, in matrix, out var invMatrix);
// TODO: Getting some overdraw so need to fix that.
if (!_entManager.TryGetComponent<FixturesComponent>(grid, out var gridFixtures))
continue;
- var gridMatrix = xformQuery.GetComponent(grid).WorldMatrix;
+ var gridMatrix = _xformSystem.GetWorldMatrix(grid);
Matrix3.Multiply(in gridMatrix, in invMatrix, out var matty);
{
private readonly IEntityManager _entManager;
private readonly IGameTiming _timing;
+ private SharedTransformSystem? _xformSystem = null;
private EntityUid? _shuttleEntity;
{
base.Draw(handle);
- if (!_entManager.TryGetComponent<PhysicsComponent>(_shuttleEntity, out var gridBody) ||
+ _xformSystem ??= _entManager.SystemOrNull<SharedTransformSystem>();
+ if (_xformSystem is null ||
+ !_entManager.TryGetComponent<PhysicsComponent>(_shuttleEntity, out var gridBody) ||
!_entManager.TryGetComponent<TransformComponent>(_shuttleEntity, out var gridXform))
{
return;
FTLTimer.Text = GetFTLText();
- var (_, worldRot, worldMatrix) = gridXform.GetWorldPositionRotationMatrix();
+ var (_, worldRot, worldMatrix) = _xformSystem.GetWorldPositionRotationMatrix(gridXform);
var worldPos = worldMatrix.Transform(gridBody.LocalCenter);
// Get the positive reduced angle.
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IStateManager _stateManager = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
private readonly HashSet<FadingSpriteComponent> _comps = new();
spriteQuery.TryGetComponent(player, out var playerSprite))
{
var fadeQuery = GetEntityQuery<SpriteFadeComponent>();
- var mapPos = playerXform.MapPosition;
+ var mapPos = _xformSystem.GetMapCoordinates((player.Value, playerXform));
// Also want to handle large entities even if they may not be clickable.
foreach (var ent in state.GetClickableEntities(mapPos))
public sealed class StealthSystem : SharedStealthSystem
{
[Dependency] private readonly IPrototypeManager _protoMan = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
private ShaderInstance _shader = default!;
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(_xformSystem.GetWorldPosition(parentXform));
reference.X = -reference.X;
var visibility = GetVisibility(uid, component);
[Dependency] private readonly IPlayerManager _playerManager = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly AppearanceSystem _appearance = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = 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
if (clampedCoords.Equals(MapCoordinates.Nullspace)) return;
// Move the entity locally every update
- EntityManager.GetComponent<TransformComponent>(_draggedEntity.Value).WorldPosition = clampedCoords.Position;
+ _xformSystem.SetWorldPosition(_draggedEntity.Value, clampedCoords.Position);
// Increment total time passed
_timePassed += frameTime;
// Set the dragging player on the component to noone
if (broadcast && _draggedEntity != null && EntityManager.HasComponent<TabletopDraggableComponent>(_draggedEntity.Value))
{
- RaisePredictiveEvent(new TabletopMoveEvent(GetNetEntity(_draggedEntity.Value), Transform(_draggedEntity.Value).MapPosition, GetNetEntity(_table!.Value)));
+ RaisePredictiveEvent(new TabletopMoveEvent(GetNetEntity(_draggedEntity.Value), Transforms.GetMapCoordinates(_draggedEntity.Value), GetNetEntity(_table!.Value)));
RaisePredictiveEvent(new TabletopDraggingPlayerChangedEvent(GetNetEntity(_draggedEntity.Value), false));
}
[UISystemDependency] private readonly GhostSystem? _ghost = default;
[UISystemDependency] private readonly TypingIndicatorSystem? _typingIndicator = default;
[UISystemDependency] private readonly ChatSystem? _chatSys = default;
+ [UISystemDependency] private readonly SharedTransformSystem? _xformSystem = default!;
[ValidatePrototypeId<ColorPalettePrototype>]
private const string ChatNamePalette = "ChatNames";
private void UpdateQueuedSpeechBubbles(FrameEventArgs delta)
{
// Update queued speech bubbles.
- if (_queuedSpeechBubbles.Count == 0 || _examine == null)
+ if (_queuedSpeechBubbles.Count == 0 || _examine is null || _xformSystem is null)
{
return;
}
var predicate = static (EntityUid uid, (EntityUid compOwner, EntityUid? attachedEntity) data)
=> uid == data.compOwner || uid == data.attachedEntity;
var playerPos = player != null
- ? EntityManager.GetComponent<TransformComponent>(player.Value).MapPosition
+ ? _xformSystem.GetMapCoordinates(player.Value)
: MapCoordinates.Nullspace;
var occluded = player != null && _examine.IsOccluded(player.Value);
continue;
}
- var otherPos = EntityManager.GetComponent<TransformComponent>(ent).MapPosition;
+ var otherPos = _xformSystem.GetMapCoordinates(ent);
if (occluded && !ExamineSystemShared.InRangeUnOccluded(
playerPos,
using Content.Shared.CCVar;
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;
[Dependency] private readonly IPlayerManager _playerMan = default!;
[Dependency] private readonly IEntityManager _entMan = default!;
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
+ [UISystemDependency] private readonly SharedTransformSystem? _xformSystem = default!;
public static readonly Vector2i ViewportSize = (EyeManager.PixelsPerMeter * 21, EyeManager.PixelsPerMeter * 15);
public const int ViewportHeight = 15;
_entMan.TryGetComponent(ent, out EyeComponent? eye);
if (eye?.Eye == _eyeManager.CurrentEye
- && _entMan.GetComponent<TransformComponent>(ent.Value).WorldPosition == default)
+ && (_xformSystem is null || _xformSystem.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
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly EntityLookupSystem _entityLookup = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
/// <summary>
/// When a user right clicks somewhere, how large is the box we use to get entities for the context menu?
// Remove any entities that do not have LOS
if ((visibility & MenuVisibility.NoFov) == 0)
{
- var xformQuery = GetEntityQuery<TransformComponent>();
- var playerPos = xformQuery.GetComponent(player.Value).MapPosition;
+ var playerPos = _xformSystem.GetMapCoordinates(player.Value);
for (var i = entities.Count - 1; i >= 0; i--)
{
if (!ExamineSystemShared.InRangeUnOccluded(
playerPos,
- xformQuery.GetComponent(entity).MapPosition,
+ _xformSystem.GetMapCoordinates(entity),
ExamineSystemShared.ExamineRange,
null))
{
private readonly IPlayerManager _playerManager;
private readonly MeleeWeaponSystem _melee;
private readonly SharedCombatModeSystem _combatMode;
+ private readonly SharedTransformSystem _xformSystem;
public override OverlaySpace Space => OverlaySpace.WorldSpaceBelowFOV;
_playerManager = playerManager;
_melee = melee;
_combatMode = combatMode;
+ _xformSystem = _entManager.System<SharedTransformSystem>();
}
protected override void Draw(in OverlayDrawArgs args)
if (mapPos.MapId != args.MapId)
return;
- var playerPos = xform.MapPosition;
+ var playerPos = _xformSystem.GetMapCoordinates((player.Value, xform));
if (mapPos.MapId != playerPos.MapId)
return;
TransformSystem.AttachToGridOrMap(animationUid, xform);
var worldPos = mapPos + (mapRot - userXform.LocalRotation).RotateVec(localPos);
var newLocalPos = TransformSystem.GetInvWorldMatrix(xform.ParentUid).Transform(worldPos);
- TransformSystem.SetLocalPositionNoLerp(xform, newLocalPos);
+ TransformSystem.SetLocalPositionNoLerp(animationUid, newLocalPos, xform);
if (arcComponent.Fadeout)
_animation.Play(animationUid, GetFadeAnimation(sprite, 0f, 0.15f), FadeAnimationKey);
break;
// Light attack
if (useDown == BoundKeyState.Down)
{
- var attackerPos = Transform(entity).MapPosition;
+ var attackerPos = TransformSystem.GetMapCoordinates(entity);
if (mousePos.MapId != attackerPos.MapId ||
(attackerPos.Position - mousePos.Position).Length() > weapon.Range)
private readonly IInputManager _input;
private readonly IPlayerManager _player;
private readonly GunSystem _guns;
+ private readonly SharedTransformSystem _xforms;
public GunSpreadOverlay(IEntityManager entManager, IEyeManager eyeManager, IGameTiming timing, IInputManager input, IPlayerManager player, GunSystem system)
{
_timing = timing;
_player = player;
_guns = system;
+ _xforms = entManager.System<SharedTransformSystem>();
}
protected override void Draw(in OverlayDrawArgs args)
return;
}
- var mapPos = xform.MapPosition;
+ var mapPos = _xforms.GetMapCoordinates((player.Value, xform));
if (mapPos.MapId == MapId.Nullspace)
return;
var ent = Spawn(HitscanProto, coords);
var sprite = Comp<SpriteComponent>(ent);
- var xform = Transform(ent);
- xform.LocalRotation = a.angle;
+ TransformSystem.SetLocalRotation(ent, a.angle);
sprite[EffectLayers.Unshaded].AutoAnimated = false;
sprite.LayerSetSprite(EffectLayers.Unshaded, rsi);
sprite.LayerSetState(EffectLayers.Unshaded, rsi.RsiState);
var ent = Spawn(message.Prototype, coordinates);
var effectXform = Transform(ent);
- TransformSystem.SetLocalPositionRotation(effectXform,
+ TransformSystem.SetLocalPositionRotation(ent,
effectXform.LocalPosition + new Vector2(0f, -0.5f),
- effectXform.LocalRotation - MathF.PI / 2);
+ effectXform.LocalRotation - MathF.PI / 2,
+ effectXform
+ );
var lifetime = 0.4f;
var eyeManager = client.ResolveDependency<IEyeManager>();
var spriteQuery = clientEntManager.GetEntityQuery<SpriteComponent>();
var xformQuery = clientEntManager.GetEntityQuery<TransformComponent>();
+ var clickSystem = clientEntManager.System<ClickableSystem>();
var eye = client.ResolveDependency<IEyeManager>().CurrentEye;
var testMap = await pair.CreateTestMap();
var pos = clientEntManager.System<SharedTransformSystem>().GetWorldPosition(clientEnt);
var clickable = clientEntManager.GetComponent<ClickableComponent>(clientEnt);
- hit = clickable.CheckClick(sprite, xformQuery.GetComponent(clientEnt), xformQuery, new Vector2(clickPosX, clickPosY) + pos, eye, out _, out _, out _);
+ hit = clickSystem.CheckClick((clientEnt, clickable, sprite, xformQuery.GetComponent(clientEnt)), new Vector2(clickPosX, clickPosY) + pos, eye, out _, out _, out _);
});
await server.WaitPost(() =>
human = entityManager.SpawnEntity("HumanDisposalDummy", coordinates);
wrench = entityManager.SpawnEntity("WrenchDummy", coordinates);
disposalUnit = entityManager.SpawnEntity("DisposalUnitDummy", coordinates);
- disposalTrunk = entityManager.SpawnEntity("DisposalTrunkDummy",
- entityManager.GetComponent<TransformComponent>(disposalUnit).MapPosition);
+ disposalTrunk = entityManager.SpawnEntity("DisposalTrunkDummy", xformSystem.GetMapCoordinates(disposalUnit));
// Test for components existing
unitUid = disposalUnit;
var playerMan = server.ResolveDependency<IPlayerManager>();
var mapMan = server.ResolveDependency<IMapManager>();
var sys = entMan.System<SharedHandsSystem>();
+ var xfm = entMan.System<SharedTransformSystem>();
var data = await pair.CreateTestMap();
await pair.RunTicksSync(5);
{
player = playerMan.Sessions.First().AttachedEntity!.Value;
var xform = entMan.GetComponent<TransformComponent>(player);
- item = entMan.SpawnEntity("Crowbar", xform.MapPosition);
+ item = entMan.SpawnEntity("Crowbar", xfm.GetMapCoordinates(xform));
hands = entMan.GetComponent<HandsComponent>(player);
sys.TryPickup(player, item, hands.ActiveHand!);
});
var sEntities = server.ResolveDependency<IEntityManager>();
var mapManager = server.ResolveDependency<IMapManager>();
var conSystem = sEntities.EntitySysManager.GetEntitySystem<SharedContainerSystem>();
+ var xfmSystem = sEntities.EntitySysManager.GetEntitySystem<SharedTransformSystem>();
EntityUid origin = default;
EntityUid other = default;
origin = sEntities.SpawnEntity(HumanId, coordinates);
other = sEntities.SpawnEntity(HumanId, coordinates);
conSystem.EnsureContainer<Container>(other, "InRangeUnobstructedTestOtherContainer");
- mapCoordinates = sEntities.GetComponent<TransformComponent>(other).MapPosition;
+ mapCoordinates = xfmSystem.GetMapCoordinates(other);
});
await server.WaitIdleAsync();
var entityManager = server.ResolveDependency<IEntityManager>();
var gameTiming = server.ResolveDependency<IGameTiming>();
var batterySys = entityManager.System<BatterySystem>();
+ var xformSys = entityManager.System<SharedTransformSystem>();
PowerConsumerComponent consumer = default!;
PowerSupplierComponent supplier = default!;
PowerNetworkBatteryComponent netBattery = default!;
}
var terminal = entityManager.SpawnEntity("CableTerminal", grid.ToCoordinates(0, 1));
- entityManager.GetComponent<TransformComponent>(terminal).LocalRotation = Angle.FromDegrees(180);
+ xformSys.SetLocalRotation(terminal, Angle.FromDegrees(180));
var batteryEnt = entityManager.SpawnEntity("FullBatteryDummy", grid.ToCoordinates(0, 2));
var supplyEnt = entityManager.SpawnEntity("GeneratorDummy", grid.ToCoordinates(0, 0));
var entityManager = server.ResolveDependency<IEntityManager>();
var gameTiming = server.ResolveDependency<IGameTiming>();
var batterySys = entityManager.System<BatterySystem>();
+ var xformSys = entityManager.System<SharedTransformSystem>();
PowerConsumerComponent consumer = default!;
PowerSupplierComponent supplier = default!;
PowerNetworkBatteryComponent netBattery = default!;
}
var terminal = entityManager.SpawnEntity("CableTerminal", grid.ToCoordinates(0, 1));
- entityManager.GetComponent<TransformComponent>(terminal).LocalRotation = Angle.FromDegrees(180);
+ xformSys.SetLocalRotation(terminal, Angle.FromDegrees(180));
var batteryEnt = entityManager.SpawnEntity("FullBatteryDummy", grid.ToCoordinates(0, 2));
var supplyEnt = entityManager.SpawnEntity("GeneratorDummy", grid.ToCoordinates(0, 0));
var mapManager = server.ResolveDependency<IMapManager>();
var entityManager = server.ResolveDependency<IEntityManager>();
var batterySys = entityManager.System<BatterySystem>();
+ var xformSys = entityManager.System<SharedTransformSystem>();
PowerConsumerComponent consumer1 = default!;
PowerConsumerComponent consumer2 = default!;
PowerSupplierComponent supplier = default!;
entityManager.SpawnEntity("CableTerminal", grid.ToCoordinates(0, 2));
var terminal = entityManager.SpawnEntity("CableTerminal", grid.ToCoordinates(0, 2));
- entityManager.GetComponent<TransformComponent>(terminal).LocalRotation = Angle.FromDegrees(180);
+ xformSys.SetLocalRotation(terminal, Angle.FromDegrees(180));
var batteryEnt1 = entityManager.SpawnEntity("FullBatteryDummy", grid.ToCoordinates(0, 1));
var batteryEnt2 = entityManager.SpawnEntity("FullBatteryDummy", grid.ToCoordinates(0, 3));
var mapManager = server.ResolveDependency<IMapManager>();
var entityManager = server.ResolveDependency<IEntityManager>();
var batterySys = entityManager.System<BatterySystem>();
+ var xformSys = entityManager.System<SharedTransformSystem>();
PowerConsumerComponent consumer1 = default!;
PowerConsumerComponent consumer2 = default!;
PowerSupplierComponent supplier = default!;
entityManager.SpawnEntity("CableTerminal", grid.ToCoordinates(0, 2));
var terminal = entityManager.SpawnEntity("CableTerminal", grid.ToCoordinates(0, 2));
- entityManager.GetComponent<TransformComponent>(terminal).LocalRotation = Angle.FromDegrees(180);
+ xformSys.SetLocalRotation(terminal, Angle.FromDegrees(180));
var batteryEnt1 = entityManager.SpawnEntity("FullBatteryDummy", grid.ToCoordinates(0, 1));
var batteryEnt2 = entityManager.SpawnEntity("FullBatteryDummy", grid.ToCoordinates(0, 3));
var mapManager = server.ResolveDependency<IMapManager>();
var entityManager = server.ResolveDependency<IEntityManager>();
var batterySys = entityManager.System<BatterySystem>();
+ var xformSys = entityManager.System<SharedTransformSystem>();
PowerConsumerComponent consumer = default!;
PowerSupplierComponent supplier = default!;
PowerNetworkBatteryComponent netBattery = default!;
}
var terminal = entityManager.SpawnEntity("CableTerminal", grid.ToCoordinates(0, 1));
- entityManager.GetComponent<TransformComponent>(terminal).LocalRotation = Angle.FromDegrees(180);
+ xformSys.SetLocalRotation(terminal, Angle.FromDegrees(180));
var batteryEnt = entityManager.SpawnEntity("FullBatteryDummy", grid.ToCoordinates(0, 2));
var supplyEnt = entityManager.SpawnEntity("GeneratorDummy", grid.ToCoordinates(0, 0));
var mapManager = server.ResolveDependency<IMapManager>();
var entityManager = server.ResolveDependency<IEntityManager>();
var nodeContainer = entityManager.System<NodeContainerSystem>();
+ var xformSys = entityManager.System<SharedTransformSystem>();
CableNode leftNode = default!;
CableNode rightNode = default!;
Node batteryInput = default!;
var rightEnt = entityManager.SpawnEntity("CableHV", grid.ToCoordinates(0, 3));
var terminal = entityManager.SpawnEntity("CableTerminal", grid.ToCoordinates(0, 1));
- entityManager.GetComponent<TransformComponent>(terminal).LocalRotation = Angle.FromDegrees(180);
+ xformSys.SetLocalRotation(terminal, Angle.FromDegrees(180));
var battery = entityManager.SpawnEntity("FullBatteryDummy", grid.ToCoordinates(0, 2));
var batteryNodeContainer = entityManager.GetComponent<NodeContainerComponent>(battery);
mapSystem.SetTiles(grid1.Owner, grid1.Comp, tiles1);
var dock1 = entManager.SpawnEntity("AirlockShuttle", new EntityCoordinates(grid1Ent, dock1Pos));
- var dock1Xform = entManager.GetComponent<TransformComponent>(dock1);
- dock1Xform.LocalRotation = dock1Angle;
+ xformSystem.SetLocalRotation(dock1, dock1Angle);
var tiles2 = new List<(Vector2i Index, Tile Tile)>()
{
mapSystem.SetTiles(grid2.Owner, grid2.Comp, tiles2);
var dock2 = entManager.SpawnEntity("AirlockShuttle", new EntityCoordinates(grid2Ent, dock2Pos));
- var dock2Xform = entManager.GetComponent<TransformComponent>(dock2);
- dock2Xform.LocalRotation = dock2Angle;
+ xformSystem.SetLocalRotation(dock2, dock2Angle);
var config = dockingSystem.GetDockingConfig(grid1Ent, grid2Ent);
? _entities.GetComponent<TransformComponent>(player.AttachedEntity.Value).Coordinates
: EntitySystem.Get<GameTicker>().GetObserverSpawnPoint();
var ghost = _entities.SpawnEntity(GameTicker.AdminObserverPrototypeName, coordinates);
- _entities.GetComponent<TransformComponent>(ghost).AttachToGridOrMap();
+ _entities.System<SharedTransformSystem>().AttachToGridOrMap(ghost);
if (canReturn)
{
if (args.Length > 4)
coords = new MapCoordinates(new Vector2(x, y), xform.MapID);
else
- coords = xform.MapPosition;
+ coords = entMan.System<SharedTransformSystem>().GetMapCoordinates(xform);
}
ExplosionPrototype? type;
}
var xform = _entManager.GetComponent<TransformComponent>(playerEntity);
- xform.Coordinates = coords;
- xform.AttachToGridOrMap();
+ var xformSystem = _entManager.System<SharedTransformSystem>();
+
+ xformSystem.SetCoordinates((playerEntity, xform, _entManager.GetComponent<MetaDataComponent>(playerEntity)), coords);
+ xformSystem.AttachToGridOrMap(playerEntity, xform);
if (_entManager.TryGetComponent(playerEntity, out PhysicsComponent? physics))
{
_entManager.System<SharedPhysicsSystem>().SetLinearVelocity(playerEntity, Vector2.Zero, body: physics);
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/smite.svg.192dpi.png")),
Act = () =>
{
- var coords = Transform(args.Target).MapPosition;
+ var coords = _transformSystem.GetMapCoordinates(args.Target);
Timer.Spawn(_gameTiming.TickPeriod,
() => _explosionSystem.QueueExplosion(coords, ExplosionSystem.DefaultExplosionPrototypeId,
4, 1, 2, maxTileBreak: 0), // it gibs, damage doesn't need to be high.
Filter.PvsExcept(args.Target), true, PopupType.MediumCaution);
var board = Spawn("ChessBoard", xform.Coordinates);
var session = _tabletopSystem.EnsureSession(Comp<TabletopGameComponent>(board));
- xform.Coordinates = EntityCoordinates.FromMap(_mapManager, session.Position);
- xform.WorldRotation = Angle.Zero;
+ _transformSystem.SetCoordinates((args.Target, xform, MetaData(args.Target)), EntityCoordinates.FromMap(_mapManager, session.Position));
+ _transformSystem.SetWorldRotation(xform, Angle.Zero);
},
Impact = LogImpact.Extreme,
Message = Loc.GetString("admin-smite-chess-dimension-description")
{
var xform = Transform(args.Target);
var fixtures = Comp<FixturesComponent>(args.Target);
- xform.Anchored = false; // Just in case.
+ _xformSystem.Unanchor(args.Target, xform); // Just in case.
_physics.SetBodyType(args.Target, BodyType.Dynamic, manager: fixtures, body: physics);
_physics.SetBodyStatus(physics, BodyStatus.InAir);
_physics.WakeBody(args.Target, manager: fixtures, body: physics);
{
var xform = Transform(args.Target);
var fixtures = Comp<FixturesComponent>(args.Target);
- xform.Anchored = false; // Just in case.
+ _xformSystem.Unanchor(args.Target, xform); // Just in case.
_physics.SetBodyType(args.Target, BodyType.Dynamic, body: physics);
_physics.SetBodyStatus(physics, BodyStatus.InAir);
foreach (var ent in allEnts)
{
if (xformQuery.TryGetComponent(ent, out var xf))
- coords.Add(xf.MapPosition.Position);
+ coords.Add(_xform.GetWorldPosition(xf));
}
_random.Shuffle(coords);
var damage = (int) (elec.MaxElectrocuteDamage * anom.Severity);
var duration = elec.MaxElectrocuteDuration * anom.Severity;
- foreach (var (ent, comp) in _lookup.GetEntitiesInRange<StatusEffectsComponent>(xform.MapPosition, range))
+ foreach (var (ent, comp) in _lookup.GetEntitiesInRange<StatusEffectsComponent>(_transform.GetMapCoordinates((uid, xform)), range))
{
_electrocution.TryDoElectrocution(ent, uid, damage, duration, true, statusEffects: comp, ignoreInsulation: true);
}
{
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly SolutionContainerSystem _solutionContainer = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
private EntityQuery<InjectableSolutionComponent> _injectableQuery;
//We get all the entity in the radius into which the reagent will be injected.
var xformQuery = GetEntityQuery<TransformComponent>();
var xform = xformQuery.GetComponent(entity);
- var allEnts = _lookup.GetEntitiesInRange<InjectableSolutionComponent>(xform.MapPosition, injectRadius)
+ var allEnts = _lookup.GetEntitiesInRange<InjectableSolutionComponent>(_xformSystem.GetMapCoordinates((entity.Owner, xform)), injectRadius)
.Select(x => x.Owner).ToList();
//for each matching entity found
var oxygen = air.GetMoles(filter.Oxygen) / air.TotalMoles;
var gases = oxygen >= filter.TargetOxygen ? filter.Gases : filter.OverflowGases;
- var coordinates = Transform(uid).MapPosition;
+ var coordinates = _transform.GetMapCoordinates(uid);
GasMixture? destination = null;
if (_map.TryFindGridAt(coordinates, out _, out var grid))
{
if (airtight.Comp.FixAirBlockedDirectionInitialize)
{
- var moveEvent = new MoveEvent(airtight, default, default, Angle.Zero, xform.LocalRotation, xform, false);
+ var moveEvent = new MoveEvent((airtight, xform, MetaData(airtight)), default, default, Angle.Zero, xform.LocalRotation);
if (AirtightMove(airtight, ref moveEvent))
return;
}
return;
// Used by ExperiencePressureDifference to correct push/throw directions from tile-relative to physics world.
- var gridWorldRotation = xforms.GetComponent(gridAtmosphere).WorldRotation;
+ var gridWorldRotation = _transformSystem.GetWorldRotation(gridAtmosphere);
// If we're using monstermos, smooth out the yeet direction to follow the flow
if (MonstermosEqualization)
// 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 - xform.WorldPosition).Normalized() + dirVec).Normalized();
+ var pos = ((throwTarget.ToMap(EntityManager).Position - _transformSystem.GetWorldPosition(xform)).Normalized() + dirVec).Normalized();
_physics.ApplyLinearImpulse(uid, pos * moveForce, body: physics);
}
else
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedBroadphaseSystem _broadphase = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
if (Deleted(user) || Deleted(target))
return;
- var userMapPos = Transform(user).MapPosition;
- var targetMapPos = Transform(target).MapPosition;
+ var userMapPos = _xformSystem.GetMapCoordinates(user);
+ var targetMapPos = _xformSystem.GetMapCoordinates(target);
//The distance between the target and the user.
var calculatedDistance = targetMapPos.Position - userMapPos.Position;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly RandomHelperSystem _randomHelper = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
{
var xform = Transform(plank);
_containerSystem.AttachParentToContainerOrGrid((plank, xform));
- xform.LocalRotation = 0;
+ _xformSystem.SetLocalRotation(plank, 0, xform);
_randomHelper.RandomOffset(plank, 0.25f);
}
}
{
[Dependency] private readonly SharedPopupSystem _popups = default!;
[Dependency] private readonly SolutionContainerSystem _solutions = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
[Dependency] private readonly IRobustRandom _random = default!;
public override void Initialize()
var target = Spawn(randomMob, Transform(uid).Coordinates);
- Transform(target).AttachToGridOrMap();
+ _xformSystem.AttachToGridOrMap(target);
var ev = new GotRehydratedEvent(target);
RaiseLocalEvent(uid, ref ev);
[Dependency] private readonly SolutionContainerSystem _solutionContainerSystem = default!;
[Dependency] private readonly ThrowingSystem _throwing = default!;
[Dependency] private readonly ReactiveSystem _reactive = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
private const float ReactTime = 0.125f;
_throwing.TryThrow(vapor, dir, speed, user: user);
- var distance = (target.Position - vaporXform.WorldPosition).Length();
+ var distance = (target.Position - _xformSystem.GetWorldPosition(vaporXform)).Length();
var time = (distance / physics.LinearVelocity.Length());
despawn.Lifetime = MathF.Min(aliveTime, time);
}
var spreadAmount = (int) Math.Max(0, Math.Ceiling((args.Quantity / OverflowThreshold).Float()));
var splitSolution = args.Source.SplitSolution(args.Source.Volume);
var transform = args.EntityManager.GetComponent<TransformComponent>(args.SolutionEntity);
+ var xformSystem = args.EntityManager.System<SharedTransformSystem>();
var mapManager = IoCManager.Resolve<IMapManager>();
- if (!mapManager.TryFindGridAt(transform.MapPosition, out _, out var grid) ||
+ var mapCoordinates = xformSystem.GetMapCoordinates((args.SolutionEntity, transform));
+ if (!mapManager.TryFindGridAt(mapCoordinates, out _, out var grid) ||
!grid.TryGetTileRef(transform.Coordinates, out var tileRef) ||
tileRef.Tile.IsSpace())
{
return;
}
- var coords = grid.MapToGrid(transform.MapPosition);
+ var coords = grid.MapToGrid(mapCoordinates);
var ent = args.EntityManager.SpawnEntity(_prototypeId, coords.SnapToGrid());
var smoke = args.EntityManager.System<SmokeSystem>();
for (var i = 0; i < quantity; i++)
{
- var uid = args.EntityManager.SpawnEntity(Entity, transform.MapPosition);
+ var uid = args.EntityManager.SpawnEntity(Entity, transformSystem.GetMapCoordinates((args.SolutionEntity, transform)));
transformSystem.AttachToGridOrMap(uid);
// TODO figure out how to properly spawn inside of containers
var range = MathF.Min((float) (args.Quantity*EmpRangePerUnit), EmpMaxRange);
args.EntityManager.System<EmpSystem>().EmpPulse(
- transform.MapPosition,
+ args.EntityManager.System<SharedTransformSystem>().GetMapCoordinates((args.SolutionEntity, transform)),
range,
EnergyConsumption,
DisableDuration);
}
// end of genetic damage checks
- var mob = Spawn(speciesPrototype.Prototype, Transform(uid).MapPosition);
+ var mob = Spawn(speciesPrototype.Prototype, _transformSystem.GetMapCoordinates(uid));
_humanoidSystem.CloneAppearance(bodyToClone, mob);
var ev = new CloningEvent(bodyToClone, mob);
public static string SubstituteEntityDetails(IConsoleShell shell, EntityUid ent, string ruleString)
{
var entMan = IoCManager.Resolve<IEntityManager>();
+ var xfmSys = entMan.System<SharedTransformSystem>();
var transform = entMan.GetComponent<TransformComponent>(ent);
+ var worldPosition = xfmSys.GetWorldPosition(transform);
// 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("$WX", worldPosition.X.ToString(CultureInfo.InvariantCulture));
+ ruleString = ruleString.Replace("$WY", 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 { } player)
if (player.AttachedEntity is {Valid: true} p)
{
var pTransform = entMan.GetComponent<TransformComponent>(p);
+ var pPosition = xfmSys.GetWorldPosition(pTransform);
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));
+ ruleString = ruleString.Replace("$PWX", pPosition.X.ToString(CultureInfo.InvariantCulture));
+ ruleString = ruleString.Replace("$PWY", pPosition.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;
var changed = 0;
var tagSystem = _entManager.EntitySysManager.GetEntitySystem<TagSystem>();
+ var xformSystem = _entManager.System<SharedTransformSystem>();
var enumerator = xformQuery.GetComponent(gridId.Value).ChildEnumerator;
if (childXform.LocalRotation != Angle.Zero)
{
- childXform.LocalRotation = Angle.Zero;
+ xformSystem.SetLocalRotation(child, Angle.Zero, childXform);
changed++;
}
}
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
{
var transform = entityManager.GetComponent<TransformComponent>(uid);
- transform.Anchored = Value;
+ if (Value == transform.Anchored)
+ return;
+
+ var xformSystem = entityManager.System<SharedTransformSystem>();
+ if (Value)
+ xformSystem.AnchorEntity((uid, transform));
+ else
+ xformSystem.Unanchor(uid, transform);
}
}
}
{
var transform = entityManager.GetComponent<TransformComponent>(uid);
+ var xformSystem = entityManager.System<SharedTransformSystem>();
if (!transform.Anchored)
- transform.Coordinates = transform.Coordinates.SnapToGrid(entityManager);
+ xformSystem.SetCoordinates((uid, transform, entityManager.GetComponent<MetaDataComponent>(uid)), transform.Coordinates.SnapToGrid(entityManager));
if (SouthRotation)
- {
- transform.LocalRotation = Angle.Zero;
- }
+ xformSystem.SetLocalRotation(uid, Angle.Zero, transform);
}
}
}
// Transform transferring.
var newTransform = Transform(newUid);
- newTransform.AttachToGridOrMap(); // in case in hands or a container
- newTransform.LocalRotation = transform.LocalRotation;
- newTransform.Anchored = transform.Anchored;
+ _xformSystem.AttachToGridOrMap(newUid, newTransform); // in case in hands or a container
+ _xformSystem.SetLocalRotation(newUid, transform.LocalRotation, newTransform);
+ if (transform.Anchored)
+ _xformSystem.AnchorEntity((newUid, newTransform));
+ else
+ _xformSystem.Unanchor(newUid, newTransform);
// Container transferring.
if (containerManager != null)
[Dependency] private readonly EntityLookupSystem _lookupSystem = default!;
[Dependency] private readonly StorageSystem _storageSystem = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
// --- WARNING! LEGACY CODE AHEAD! ---
// This entire file contains the legacy code for initial construction.
}
}
- var pos = Transform(user).MapPosition;
+ var pos = _xformSystem.GetMapCoordinates(user);
foreach (var near in _lookupSystem.GetEntitiesInRange(pos, 2f, LookupFlags.Contained | LookupFlags.Dynamic | LookupFlags.Sundries | LookupFlags.Approximate))
{
// ikr
var xform = Transform(structure);
var wasAnchored = xform.Anchored;
- xform.Anchored = false;
- xform.Coordinates = GetCoordinates(ev.Location);
- xform.LocalRotation = constructionPrototype.CanRotate ? ev.Angle : Angle.Zero;
- xform.Anchored = wasAnchored;
+ if (wasAnchored)
+ _xformSystem.Unanchor(structure, xform);
+ _xformSystem.SetCoordinates((structure, xform, MetaData(structure)), GetCoordinates(ev.Location));
+ _xformSystem.SetLocalRotation(structure, constructionPrototype.CanRotate ? ev.Angle : Angle.Zero, xform);
+ if (wasAnchored)
+ _xformSystem.AnchorEntity((structure, xform));
RaiseNetworkEvent(new AckStructureConstructionMessage(ev.Ack, GetNetEntity(structure)));
_adminLogger.Add(LogType.Construction, LogImpact.Low, $"{ToPrettyString(user):player} has turned a {ev.PrototypeName} construction ghost into {ToPrettyString(structure)} at {Transform(structure).Coordinates}");
[Dependency] public readonly IPrototypeManager PrototypeManager = default!;
[Dependency] public readonly IComponentFactory ComponentFactory = default!;
[Dependency] public readonly IAdminLogManager _adminLogger = default!;
+ [Dependency] public readonly SharedTransformSystem TransformSystem = default!;
public override void Initialize()
{
{
var spawned = system.EntityManager.SpawnEntity(entityId, xform.Coordinates.Offset(system.Random.NextVector2(-Offset, Offset)));
system.StackSystem.SetCount(spawned, toSpawn);
- system.EntityManager.GetComponent<TransformComponent>(spawned).LocalRotation = system.Random.NextAngle();
+ system.TransformSystem.SetLocalRotation(spawned, system.Random.NextAngle());
}
else
{
for (var i = 0; i < toSpawn; i++)
{
var spawned = system.EntityManager.SpawnEntity(entityId, xform.Coordinates.Offset(system.Random.NextVector2(-Offset, Offset)));
- system.EntityManager.GetComponent<TransformComponent>(spawned).LocalRotation = system.Random.NextAngle();
+ system.TransformSystem.SetLocalRotation(spawned, system.Random.NextAngle());
}
}
}
public void Execute(EntityUid owner, DestructibleSystem system, EntityUid? cause = null)
{
- var position = system.EntityManager.GetComponent<TransformComponent>(owner).MapPosition;
+ var position = system.TransformSystem.GetMapCoordinates(owner);
var getRandomVector = () => new Vector2(system.Random.NextFloat(-Offset, Offset), system.Random.NextFloat(-Offset, Offset));
[UsedImplicitly]
public sealed class WirelessNetworkSystem : EntitySystem
{
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
+
public override void Initialize()
{
base.Initialize();
return;
if (xform.MapID != args.SenderTransform.MapID
- || (ownPosition - xform.WorldPosition).Length() > sendingComponent.Range)
+ || (ownPosition - _xformSystem.GetWorldPosition(xform)).Length() > sendingComponent.Range)
{
args.Cancel();
}
[Dependency] private readonly DisposableSystem _disposableSystem = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly AtmosphereSystem _atmosSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
+
public override void Initialize()
{
base.Initialize();
if (!Resolve(uid, ref entry))
return false;
- var xform = Transform(uid);
- var holder = Spawn(DisposalEntryComponent.HolderPrototypeId, xform.MapPosition);
+ var holder = Spawn(DisposalEntryComponent.HolderPrototypeId, _xformSystem.GetMapCoordinates(uid));
var holderComponent = Comp<DisposalHolderComponent>(holder);
foreach (var entity in from.Container.ContainedEntities.ToArray())
[Dependency] private readonly RoleSystem _role = default!;
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
private EntityQuery<CarpRiftsConditionComponent> _objQuery;
}
// cant put a rift on solars
- foreach (var tile in grid.GetTilesIntersecting(new Circle(xform.WorldPosition, RiftTileRadius), false))
+ foreach (var tile in grid.GetTilesIntersecting(new Circle(_xformSystem.GetWorldPosition(xform), RiftTileRadius), false))
{
if (!tile.IsSpace(_tileDef))
continue;
return;
}
- var carpUid = Spawn(component.RiftPrototype, xform.MapPosition);
+ var carpUid = Spawn(component.RiftPrototype, _xformSystem.GetMapCoordinates((uid, xform)));
component.Rifts.Add(carpUid);
Comp<DragonRiftComponent>(carpUid).Dragon = uid;
}
public sealed class EmpSystem : SharedEmpSystem
{
[Dependency] private readonly EntityLookupSystem _lookup = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public const string EmpPulseEffectPrototype = "EffectEmpPulse";
private void HandleEmpTrigger(EntityUid uid, EmpOnTriggerComponent comp, TriggerEvent args)
{
- EmpPulse(Transform(uid).MapPosition, comp.Range, comp.EnergyConsumption, comp.DisableDuration);
+ EmpPulse(_xformSystem.GetMapCoordinates(uid), comp.Range, comp.EnergyConsumption, comp.DisableDuration);
args.Handled = true;
}
return;
_needToTransform = true;
+ var entMan = IoCManager.Resolve<IEntityManager>();
+ var xfmSys = entMan.System<SharedTransformSystem>();
var transform = IoCManager.Resolve<IEntityManager>().GetComponent<TransformComponent>(Grid.Owner);
var size = (float) Grid.TileSize;
_matrix.R0C2 = size / 2;
_matrix.R1C2 = size / 2;
- _matrix *= transform.WorldMatrix * Matrix3.Invert(spaceMatrix);
- var relativeAngle = transform.WorldRotation - spaceAngle;
+ _matrix *= xfmSys.GetWorldMatrix(transform) * Matrix3.Invert(spaceMatrix);
+ var relativeAngle = xfmSys.GetWorldRotation(transform) - spaceAngle;
_offset = relativeAngle.RotateVec(new Vector2(size / 4, size / 4));
}
{
var targetGrid = Comp<MapGridComponent>(referenceGrid.Value);
var xform = Transform(referenceGrid.Value);
- targetAngle = xform.WorldRotation;
- targetMatrix = xform.InvWorldMatrix;
+ targetAngle = _transformSystem.GetWorldRotation(xform);
+ targetMatrix = _transformSystem.GetInvWorldMatrix(xform);
tileSize = targetGrid.TileSize;
}
var xforms = EntityManager.GetEntityQuery<TransformComponent>();
var xform = xforms.GetComponent(gridToTransform);
- var (_, gridWorldRotation, gridWorldMatrix, invGridWorldMatrid) = xform.GetWorldPositionRotationMatrixWithInv(xforms);
+ var (_, gridWorldRotation, gridWorldMatrix, invGridWorldMatrid) = _transformSystem.GetWorldPositionRotationMatrixWithInv(xform);
var localEpicentre = (Vector2i) invGridWorldMatrid.Transform(epicentre.Position);
var matrix = offsetMatrix * gridWorldMatrix * targetMatrix;
if (referenceGrid != null)
{
var xform = Transform(_mapManager.GetGrid(referenceGrid.Value).Owner);
- spaceMatrix = xform.WorldMatrix;
- spaceAngle = xform.WorldRotation;
+ spaceMatrix = _transformSystem.GetWorldMatrix(xform);
+ spaceAngle = _transformSystem.GetWorldRotation(xform);
}
// is the explosion starting on a grid?
if (player.AttachedEntity is not EntityUid uid)
continue;
- var playerPos = Transform(player.AttachedEntity!.Value).WorldPosition;
+ var playerPos = _transformSystem.GetWorldPosition(player.AttachedEntity!.Value);
var delta = epicenter.Position - playerPos;
if (delta.EqualsApprox(Vector2.Zero))
{
[Dependency] private readonly IMapManager _mapMan = default!;
[Dependency] private readonly SmokeSystem _smoke = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
private void OnTrigger(EntityUid uid, SmokeOnTriggerComponent comp, TriggerEvent args)
{
var xform = Transform(uid);
- if (!_mapMan.TryFindGridAt(xform.MapPosition, out _, out var grid) ||
+ var mapCoords = _xformSystem.GetMapCoordinates((uid, xform));
+ if (!_mapMan.TryFindGridAt(mapCoords, out _, out var grid) ||
!grid.TryGetTileRef(xform.Coordinates, out var tileRef) ||
tileRef.Tile.IsSpace())
{
return;
}
- var coords = grid.MapToGrid(xform.MapPosition);
+ var coords = grid.MapToGrid(mapCoords);
var ent = Spawn(comp.SmokePrototype, coords.SnapToGrid());
if (!TryComp<SmokeComponent>(ent, out var smoke))
{
// Gets location of the implant
var ownerXform = Transform(uid);
- var pos = ownerXform.MapPosition;
+ var pos = _transformSystem.GetMapCoordinates((uid, ownerXform));
var x = (int) pos.X;
var y = (int) pos.Y;
var posText = $"({x}, {y})";
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly StunSystem _stun = default!;
[Dependency] private readonly TagSystem _tag = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
[Dependency] private readonly PuddleSystem _puddleSystem = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
puddles.Clear();
- foreach (var entity in _lookup.GetEntitiesInRange(xform.MapPosition, drain.Range))
+ foreach (var entity in _lookup.GetEntitiesInRange(_xformSystem.GetMapCoordinates((uid, xform)), drain.Range))
{
// No InRangeUnobstructed because there's no collision group that fits right now
// and these are placed by mappers and not buildable/movable so shouldnt really be a problem...
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly PuddleSystem _puddle = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
private readonly HashSet<ICommonSession> _playerObservers = new();
private List<Entity<MapGridComponent>> _grids = new();
var transform = EntityManager.GetComponent<TransformComponent>(entity);
- var worldBounds = Box2.CenteredAround(transform.WorldPosition,
+ var worldBounds = Box2.CenteredAround(_xformSystem.GetWorldPosition(transform),
new Vector2(LocalViewRange, LocalViewRange));
_grids.Clear();
var gridXform = Transform(gridUid);
return new EntityCoordinates(gridUid,
- gridXform.InvWorldMatrix.Transform(toMap.Position));
+ _transform.GetInvWorldMatrix(gridXform).Transform(toMap.Position));
}
return spawn;
[Dependency] private readonly RespawnRuleSystem _respawn = default!;
[Dependency] private readonly RoundEndSystem _roundEnd = default!;
[Dependency] private readonly StationSpawningSystem _stationSpawning = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
_point.AdjustPointValue(assist.PlayerId, 1, uid, point);
var spawns = EntitySpawnCollection.GetSpawns(dm.RewardSpawns).Cast<string?>().ToList();
- EntityManager.SpawnEntities(Transform(ev.Entity).MapPosition, spawns);
+ EntityManager.SpawnEntities(_xformSystem.GetMapCoordinates(ev.Entity), spawns);
}
}
[Dependency] private readonly SharedMindSystem _mindSystem = default!;
[Dependency] private readonly SharedAudioSystem _audioSystem = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
+
[ValidatePrototypeId<EntityPrototype>]
private const string GameRuleId = "Pirates";
var aabbs = EntityQuery<StationDataComponent>().SelectMany(x =>
x.Grids.Select(x =>
- xformQuery.GetComponent(x).WorldMatrix.TransformBox(_mapManager.GetGridComp(x).LocalAABB)))
+ _xformSystem.GetWorldMatrix(x).TransformBox(_mapManager.GetGridComp(x).LocalAABB)))
.ToArray();
var aabb = aabbs[0];
where TEntComp: IComponent
where TGameRuleComp: IComponent
{
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
+
/// <summary>
/// Used so we don't modify while enumerating
/// if the replaced entity also has <see cref="TEntComp"/>.
{
var (spawn, coords, rot) = tup;
var newEnt = Spawn(spawn, coords);
- Transform(newEnt).LocalRotation = rot;
+ _xformSystem.SetLocalRotation(newEnt, rot);
}
Log.Debug($"Entity replacement took {stopwatch.Elapsed} with {Stations.GetTileCount(args.Station)} tiles");
[Dependency] private readonly DestructibleSystem _destructible = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly TagSystem _tagSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
if (component.MappedLoot == null)
return;
- var pos = Transform(gatheredUid).MapPosition;
+ var pos = _xformSystem.GetMapCoordinates(gatheredUid);
foreach (var (tag, table) in component.MappedLoot)
{
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly BodySystem _bodySystem = default!;
[Dependency] private readonly SharedContainerSystem _container = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
var hostXform = Transform(args.Args.Target.Value);
var host = EnsureComp<GuardianHostComponent>(args.Args.Target.Value);
// Use map position so it's not inadvertantly parented to the host + if it's in a container it spawns outside I guess.
- var guardian = Spawn(component.GuardianProto, hostXform.MapPosition);
+ var guardian = Spawn(component.GuardianProto, _xformSystem.GetMapCoordinates(hostXform));
_container.Insert(guardian, host.GuardianContainer);
host.HostedGuardian = guardian;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly PullingSystem _pullingSystem = default!;
[Dependency] private readonly ThrowingSystem _throwingSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
throwEnt = splitStack.Value;
}
- var direction = coordinates.ToMapPos(EntityManager) - Transform(player).WorldPosition;
+ var direction = coordinates.ToMapPos(EntityManager) - _xformSystem.GetWorldPosition(player);
if (direction == Vector2.Zero)
return true;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Update(float frameTime)
{
var vel = component.DirectionOverride.Degrees switch
{
0f => _random.NextVector2(component.MinSpeed, component.MaxSpeed),
- _ => xform.WorldRotation.RotateVec(component.DirectionOverride.ToVec()) * _random.NextFloat(component.MinSpeed, component.MaxSpeed)
+ _ => _xformSystem.GetWorldRotation(xform).RotateVec(component.DirectionOverride.ToVec()) * _random.NextFloat(component.MinSpeed, component.MaxSpeed)
};
_physics.ApplyLinearImpulse(uid, vel, body: phys);
- xform.LocalRotation = (vel - xform.WorldPosition).ToWorldAngle() + MathHelper.PiOver2;
+ _xformSystem.SetLocalRotation(uid, (vel - _xformSystem.GetWorldPosition(xform)).ToWorldAngle() + MathHelper.PiOver2, xform);
}
}
[Dependency] private readonly ContainerSystem _containerSystem = default!;
[Dependency] private readonly MobStateSystem _mobStateSystem = default!;
[Dependency] private readonly IRobustRandom _robustRandom = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
}
var spawnEntities = EntitySpawnCollection.GetSpawns(butcher.SpawnedEntities, _robustRandom);
- var coords = Transform(args.Args.Target.Value).MapPosition;
+ var coords = _xformSystem.GetMapCoordinates(args.Args.Target.Value);
EntityUid popupEnt = default!;
foreach (var proto in spawnEntities)
{
[Dependency] private readonly BeamSystem _beam = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
//To Do: This is still pretty bad for perf but better than before and at least it doesn't re-allocate
// several hashsets every time
- var targets = _lookup.GetComponentsInRange<LightningTargetComponent>(Transform(user).MapPosition, range).ToList();
+ var targets = _lookup.GetComponentsInRange<LightningTargetComponent>(_xformSystem.GetMapCoordinates(user), range).ToList();
_random.Shuffle(targets);
targets.Sort((x, y) => y.Priority.CompareTo(x.Priority));
{
[Dependency] private readonly DamageableSystem _damageable = default!;
[Dependency] private readonly ExplosionSystem _explosionSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
if (uid.Comp.LightningExplode)
{
_explosionSystem.QueueExplosion(
- Transform(uid).MapPosition,
+ _xformSystem.GetMapCoordinates(uid),
uid.Comp.ExplosionPrototype,
uid.Comp.TotalIntensity, uid.Comp.Dropoff,
uid.Comp.MaxTileIntensity,
if (transform.MapID != args.Target.GetMapId(EntityManager)) return;
_transformSystem.SetCoordinates(args.Performer, args.Target);
- transform.AttachToGridOrMap();
+ _transformSystem.AttachToGridOrMap(args.Performer, transform);
_audio.PlayPvs(args.BlinkSound, args.Performer, AudioParams.Default.WithVolume(args.BlinkVolume));
Speak(args);
args.Handled = true;
ev.Handled = true;
Speak(ev);
- var direction = Transform(ev.Target).MapPosition.Position - Transform(ev.Performer).MapPosition.Position;
+ var direction = _transformSystem.GetWorldPosition(ev.Target) - _transformSystem.GetWorldPosition(ev.Performer);
var impulseVector = direction * 10000;
_physics.ApplyLinearImpulse(ev.Target, impulseVector);
{
[Dependency] private readonly IConGroupController _admin = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
private readonly HashSet<ICommonSession> _draggers = new();
var gridXform = Transform(grid);
- gridXform.WorldPosition = msg.WorldPosition;
+ _xformSystem.SetWorldPosition(gridXform, msg.WorldPosition);
}
}
var (mechPos, mechRot) = _transform.GetWorldPositionRotation(mechxform);
var offset = mechPos + mechRot.RotateVec(component.DepositOffset);
- _transform.SetWorldPositionRotation(xform, offset, Angle.Zero);
+ _transform.SetWorldPositionRotation(toRemove, offset, Angle.Zero, xform);
_mech.UpdateUserInterface(mech);
}
return Vector2.Zero;
}
- endPos = startXform.InvWorldMatrix.Transform(endXform.WorldMatrix.Transform(endPos));
+ endPos = _transform.GetInvWorldMatrix(startXform).Transform(_transform.GetWorldMatrix(endXform).Transform(endPos));
}
// TODO: Numerics when we changeover.
return null;
}
- var localPos = xform.InvWorldMatrix.Transform(coordinates.ToMapPos(EntityManager));
+ var localPos = _transform.GetInvWorldMatrix(xform).Transform(coordinates.ToMapPos(EntityManager));
var origin = GetOrigin(localPos);
if (!TryGetChunk(origin, comp, out var chunk))
}
var targetPos = steering.Coordinates.ToMap(EntityManager, _transform);
- var ourPos = xform.MapPosition;
+ var ourPos = _transform.GetMapCoordinates((uid, xform));
PrunePath(uid, ourPos, targetPos.Position - ourPos.Position, result.Path);
steering.CurrentPath = new Queue<PathPoly>(result.Path);
if (compQuery.Components.Count == 0)
return;
- var mapPos = _xformQuery.GetComponent(owner).MapPosition;
+ var mapPos = _transform.GetMapCoordinates(owner);
_compTypes.Clear();
var i = -1;
EntityPrototype.ComponentRegistryEntry compZero = default!;
public sealed partial class NpcFactionSystem : EntitySystem
{
[Dependency] private readonly EntityLookupSystem _lookup = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
[Dependency] private readonly IPrototypeManager _protoManager = default!;
private ISawmill _sawmill = default!;
if (!xformQuery.TryGetComponent(entity, out var entityXform))
yield break;
- foreach (var ent in _lookup.GetEntitiesInRange<NpcFactionMemberComponent>(entityXform.MapPosition, range))
+ foreach (var ent in _lookup.GetEntitiesInRange<NpcFactionMemberComponent>(_xformSystem.GetMapCoordinates((entity, entityXform)), range))
{
if (ent.Owner == entity)
continue;
if (stationUid != null)
_alertLevel.SetLevel(stationUid.Value, component.AlertLevelOnActivate, true, true, true, true);
- var pos = nukeXform.MapPosition;
+ var pos = _transform.GetMapCoordinates(nukeXform);
var x = (int) pos.X;
var y = (int) pos.Y;
var posText = $"({x}, {y})";
[Dependency] private readonly StackSystem _stack = default!;
[Dependency] private readonly StomachSystem _stomach = default!;
[Dependency] private readonly UtensilSystem _utensil = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public const float MaxFeedDistance = 1.0f;
return (false, true);
// TODO make do-afters account for fixtures in the range check.
- if (!Transform(user).MapPosition.InRange(Transform(target).MapPosition, MaxFeedDistance))
+ if (!_xformSystem.GetMapCoordinates(user).InRange(_xformSystem.GetMapCoordinates(target), MaxFeedDistance))
{
var message = Loc.GetString("interaction-system-user-interaction-cannot-reach");
_popup.PopupEntity(message, user, user);
}
//We're empty. Become trash.
- var position = Transform(food).MapPosition;
+ var position = _xformSystem.GetMapCoordinates(food);
var finisher = Spawn(component.Trash, position);
// If the user is holding the item
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
private readonly Dictionary<NetUserId, TimeSpan> _lastSetRingtoneAt = new();
_audio.PlayEntity(
GetSound(ringer.Ringtone[ringer.NoteCount]),
- Filter.Empty().AddInRange(ringerXform.MapPosition, ringer.Range),
+ Filter.Empty().AddInRange(_xformSystem.GetMapCoordinates(ringerXform), ringer.Range),
uid,
true,
AudioParams.Default.WithMaxDistance(ringer.Range).WithVolume(ringer.Volume)
// At least for now unless we do lookups or smth, only work with anchoring.
if (_xformQuery.TryGetComponent(ent, out var xform) && !xform.Anchored)
{
- _transform.AnchorEntity(ent, xform, gridUid, grid, indices);
+ _transform.AnchorEntity((ent, xform), (gridUid, grid), indices);
}
loadedEntities.Add(ent, indices);
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly IComponentFactory _componentFactory = default!;
[Dependency] private readonly ISerializationManager _serializationManager = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
var solStringB = SolutionContainerSystem.ToPrettyString(solutionB);
_adminLogger.Add(LogType.ChemicalReaction,
- $"Chemical bomb payload {ToPrettyString(entity.Owner):payload} at {Transform(entity.Owner).MapPosition:location} is combining two solutions: {solStringA:solutionA} and {solStringB:solutionB}");
+ $"Chemical bomb payload {ToPrettyString(entity.Owner):payload} at {_xformSystem.GetMapCoordinates(entity.Owner):location} is combining two solutions: {solStringA:solutionA} and {solStringB:solutionB}");
solutionA.MaxVolume += solutionB.MaxVolume;
_solutionContainerSystem.TryAddSolution(solnA.Value, solutionB);
var baseRotation = pulledData.WorldRotation - pulledXform.LocalRotation;
var localRotation = newAngle - baseRotation;
var localRotationSnapped = Angle.FromDegrees(Math.Floor((localRotation.Degrees / ThresholdRotAngle) + 0.5f) * ThresholdRotAngle);
- TransformSystem.SetLocalRotation(pulledXform, localRotationSnapped);
+ TransformSystem.SetLocalRotation(pulled, localRotationSnapped, pulledXform);
}
}
}
// Now that's over with...
- var pullerPosition = pullerXform.MapPosition;
+ var pullerPosition = TransformSystem.GetMapCoordinates((puller, pullerXform));
var movingTo = pullable.MovingTo.Value.ToMap(EntityManager, _transform);
if (movingTo.MapId != pullerPosition.MapId)
{
}
var movingPosition = movingTo.Position;
- var ownerPosition = pullableXform.MapPosition.Position;
+ var ownerPosition = TransformSystem.GetWorldPosition(pullableXform);
var diff = movingPosition - ownerPosition;
var diffLength = diff.Length();
[Dependency] private readonly VisibilitySystem _visibilitySystem = default!;
[Dependency] private readonly SharedMindSystem _minds = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
private static readonly TimeSpan PointDelay = TimeSpan.FromSeconds(0.5f);
(eyeComp.VisibilityMask & layer) == 0)
return false;
- return Transform(ent).MapPosition.InRange(Transform(player).MapPosition, PointingRange);
+ return _xformSystem.GetMapCoordinates(ent).InRange(_xformSystem.GetMapCoordinates(player), PointingRange);
}
var viewers = Filter.Empty()
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly ExplosionSystem _explosion = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
private EntityUid? RandomNearbyPlayer(EntityUid uid, RoguePointingArrowComponent? component = null, TransformComponent? transform = null)
{
if (component.TurningDelay > 0)
{
- var difference = Comp<TransformComponent>(chasing).WorldPosition - transform.WorldPosition;
+ var difference = _xformSystem.GetWorldPosition(chasing) - _xformSystem.GetWorldPosition(transform);
var angle = difference.ToAngle();
var adjusted = angle.Degrees + 90;
var newAngle = Angle.FromDegrees(adjusted);
- transform.WorldRotation = newAngle;
+ _xformSystem.SetWorldRotation(transform, newAngle);
UpdateAppearance(uid, component, transform);
continue;
}
- transform.WorldRotation += Angle.FromDegrees(20);
+ _xformSystem.SetWorldRotation(transform, _xformSystem.GetWorldRotation(transform) + Angle.FromDegrees(20));
UpdateAppearance(uid, component, transform);
- var toChased = Comp<TransformComponent>(chasing).WorldPosition - transform.WorldPosition;
+ var worldPosition = _xformSystem.GetWorldPosition(transform);
+ var toChased = _xformSystem.GetWorldPosition(chasing) - worldPosition;
- transform.WorldPosition += toChased * frameTime * component.ChasingSpeed;
+ _xformSystem.SetWorldPosition(transform, worldPosition + toChased * frameTime * component.ChasingSpeed);
component.ChasingTime -= frameTime;
// If the templated entity was anchored then anchor us too.
if (anchored && !childXform.Anchored)
- _transform.AnchorEntity(ent, childXform, grid);
+ _transform.AnchorEntity((ent, childXform), (gridUid, grid));
else if (!anchored && childXform.Anchored)
_transform.Unanchor(ent, childXform);
}
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly TurfSystem _turf = default!;
[Dependency] private readonly IChatManager _chat = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
{
var xform = Transform(entityGridUid.Value);
var pos = xform.Coordinates;
- var mapPos = xform.MapPosition;
+ var mapPos = _xformSystem.GetMapCoordinates((entityGridUid.Value, xform));
var circle = new Circle(mapPos.Position, 2);
var found = false;
var tile = tileRef.GridIndices;
var found = false;
- var (gridPos, _, gridMatrix) = xform.GetWorldPositionRotationMatrix();
+ var (gridPos, _, gridMatrix) = _xformSystem.GetWorldPositionRotationMatrix(xform);
var gridBounds = gridMatrix.TransformBox(grid.LocalAABB);
//Obviously don't put anything ridiculous in here
[Dependency] private readonly MobThresholdSystem _mobThresholdSystem = default!;
[Dependency] private readonly GhostSystem _ghost = default!;
[Dependency] private readonly TileSystem _tile = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
private void InitializeAbilities()
{
var xform = Transform(uid);
if (!_mapManager.TryGetGrid(xform.GridUid, out var map))
return;
- var tiles = map.GetTilesIntersecting(Box2.CenteredAround(xform.WorldPosition,
+ var tiles = map.GetTilesIntersecting(Box2.CenteredAround(_xformSystem.GetWorldPosition(xform),
new Vector2(component.DefileRadius * 2, component.DefileRadius))).ToArray();
_random.Shuffle(tiles);
public sealed class RotatableSystem : EntitySystem
{
[Dependency] private readonly PopupSystem _popup = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
Verb resetRotation = new ()
{
DoContactInteraction = true,
- Act = () => EntityManager.GetComponent<TransformComponent>(uid).LocalRotation = Angle.Zero,
+ Act = () => _xformSystem.SetLocalRotation(uid, Angle.Zero),
Category = VerbCategory.Rotate,
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/refresh.svg.192dpi.png")),
Text = "Reset",
// rotate clockwise
Verb rotateCW = new()
{
- Act = () => EntityManager.GetComponent<TransformComponent>(uid).LocalRotation -= component.Increment,
+ Act = () =>
+ {
+ var xform = Transform(uid);
+ _xformSystem.SetLocalRotation(uid, xform.LocalRotation - component.Increment, xform);
+ },
Category = VerbCategory.Rotate,
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/rotate_cw.svg.192dpi.png")),
Priority = -1,
// rotate counter-clockwise
Verb rotateCCW = new()
{
- Act = () => EntityManager.GetComponent<TransformComponent>(uid).LocalRotation += component.Increment,
+ Act = () =>
+ {
+ var xform = Transform(uid);
+ _xformSystem.SetLocalRotation(uid, xform.LocalRotation + component.Increment, xform);
+ },
Category = VerbCategory.Rotate,
Icon = new SpriteSpecifier.Texture(new ("/Textures/Interface/VerbIcons/rotate_ccw.svg.192dpi.png")),
Priority = 0,
var oldTransform = EntityManager.GetComponent<TransformComponent>(uid);
var entity = EntityManager.SpawnEntity(component.MirrorEntity, oldTransform.Coordinates);
var newTransform = EntityManager.GetComponent<TransformComponent>(entity);
- newTransform.LocalRotation = oldTransform.LocalRotation;
- newTransform.Anchored = false;
+ _xformSystem.SetLocalRotation(entity, oldTransform.LocalRotation, newTransform);
+ _xformSystem.Unanchor(entity, newTransform);
EntityManager.DeleteEntity(uid);
}
}
var fromRotation = _transform.GetWorldRotation(xform);
var width = Comp<MapGridComponent>(uid).LocalAABB.Width;
- xform.Coordinates = new EntityCoordinates(_mapManager.GetMapEntityId(_hyperSpaceMap!.Value),
- new Vector2(_index + width / 2f, 0f));
- xform.LocalRotation = Angle.Zero;
+ _transform.SetCoordinates((uid, xform, MetaData(uid)), new EntityCoordinates(_mapManager.GetMapEntityId(_hyperSpaceMap!.Value),
+ new Vector2(_index + width / 2f, 0f)));
+ _transform.SetLocalRotation(uid, Angle.Zero, xform);
_index += width + Buffer;
comp.Accumulator += comp.TravelTime - DefaultArrivalTime;
}
else
{
- xform.Coordinates = comp.TargetCoordinates;
+ _transform.SetCoordinates((uid, xform, MetaData(uid)), comp.TargetCoordinates);
mapId = comp.TargetCoordinates.GetMapId(EntityManager);
}
if (config != null)
{
- FTLDock(config, shuttleXform);
+ FTLDock((shuttleUid, shuttleXform), config);
return true;
}
/// <summary>
/// Forces an FTL dock.
/// </summary>
- public void FTLDock(DockingConfig config, TransformComponent shuttleXform)
+ public void FTLDock(Entity<TransformComponent> shuttle, DockingConfig config)
{
// Set position
- shuttleXform.Coordinates = config.Coordinates;
- _transform.SetWorldRotation(shuttleXform, config.Angle);
+ _transform.SetCoordinates((shuttle.Owner, shuttle.Comp, MetaData(shuttle)), config.Coordinates);
+ _transform.SetWorldRotation(shuttle.Comp, config.Angle);
// Connect everything
foreach (var (dockAUid, dockBUid, dockA, dockB) in config.Docks)
spawnPos = _transform.GetWorldPosition(targetXform, xformQuery);
}
- xform.Coordinates = new EntityCoordinates(targetXform.MapUid.Value, spawnPos);
+ _transform.SetCoordinates((shuttleUid, xform, MetaData(shuttleUid)), new EntityCoordinates(targetXform.MapUid.Value, spawnPos));
if (!HasComp<MapComponent>(targetXform.GridUid))
{
- _transform.SetLocalRotation(xform, _random.NextAngle());
+ _transform.SetLocalRotation(shuttleUid, _random.NextAngle(), xform);
}
else
{
- _transform.SetLocalRotation(xform, Angle.Zero);
+ _transform.SetLocalRotation(shuttleUid, Angle.Zero, xform);
}
return true;
if (config != null)
{
- FTLDock(config, shuttleXform);
+ FTLDock((ent[0], shuttleXform), config);
if (TryComp<StationMemberComponent>(xform.GridUid, out var stationMember))
{
var otherXform = Transform(args.OtherEntity);
- var ourPoint = ourXform.InvWorldMatrix.Transform(args.WorldPoint);
- var otherPoint = otherXform.InvWorldMatrix.Transform(args.WorldPoint);
+ var ourPoint = _transform.GetInvWorldMatrix(ourXform).Transform(args.WorldPoint);
+ var otherPoint = _transform.GetInvWorldMatrix(otherXform).Transform(args.WorldPoint);
var ourVelocity = _physics.GetLinearVelocity(uid, ourPoint, ourBody, ourXform);
var otherVelocity = _physics.GetLinearVelocity(args.OtherEntity, otherPoint, otherBody, otherXform);
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly SharedPointLightSystem _light = default!;
[Dependency] private readonly TagSystem _tags = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
if (!gen1XForm.Anchored)
return false;
- var genWorldPosRot = gen1XForm.GetWorldPositionRotation();
+ var genWorldPosRot = _xformSystem.GetWorldPositionRotation(gen1XForm);
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);
var newField = Spawn(firstGen.Comp.CreatedField, currentCoords);
var fieldXForm = Transform(newField);
- fieldXForm.AttachParent(firstGen);
+ _xformSystem.SetParent(newField, fieldXForm, firstGen);
if (dirVec.GetDir() == Direction.East || dirVec.GetDir() == Direction.West)
{
var angle = fieldXForm.LocalPosition.ToAngle();
var rotateBy90 = angle.Degrees + 90;
var rotatedAngle = Angle.FromDegrees(rotateBy90);
- fieldXForm.LocalRotation = rotatedAngle;
+ _xformSystem.SetLocalRotation(newField, rotatedAngle, fieldXForm);
}
fieldList.Add(newField);
{
[Dependency] private readonly ThrowingSystem _throwing = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
if (TryComp<PhysicsComponent>(otherBody, out var physics) && physics.Mass <= component.MaxMass && physics.Hard)
{
- var fieldDir = Transform(uid).WorldPosition;
- var playerDir = Transform(otherBody).WorldPosition;
+ var fieldDir = _xformSystem.GetWorldPosition(uid);
+ var playerDir = _xformSystem.GetWorldPosition(otherBody);
_throwing.TryThrow(otherBody, playerDir-fieldDir, strength: component.ThrowForce);
}
var range2 = range * range;
var xformQuery = EntityManager.GetEntityQuery<TransformComponent>();
var epicenter = _xformSystem.GetWorldPosition(xform, xformQuery);
- foreach (var entity in _lookup.GetEntitiesInRange(xform.MapPosition, range, flags: LookupFlags.Uncontained))
+ foreach (var entity in _lookup.GetEntitiesInRange(_xformSystem.GetMapCoordinates((uid, xform)), range, flags: LookupFlags.Uncontained))
{
if (entity == uid)
continue;
if (!Resolve(uid, ref xform) || !Resolve(uid, ref eventHorizon))
return;
- var mapPos = xform.MapPosition;
+ var mapPos = _xformSystem.GetMapCoordinates((uid, xform));
var box = Box2.CenteredAround(mapPos.Position, new Vector2(range, range));
var circle = new Circle(mapPos.Position, range);
var grids = new List<Entity<MapGridComponent>>();
{
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly SharedPhysicsSystem _physicsSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
/// <summary>
/// Maximum panel angular velocity range - used to stop people rotating panels fast enough that the lag prevention becomes noticable
while (query.MoveNext(out var uid, out var panel, out var xform))
{
TotalPanelPower += panel.MaxSupply * panel.Coverage;
- xform.WorldRotation = TargetPanelRotation;
+ _xformSystem.SetWorldRotation(xform, TargetPanelRotation);
_updateQueue.Enqueue((uid, panel));
}
}
// directly downwards (abs(theta) = pi) = coverage -1
// as TowardsSun + = CCW,
// panelRelativeToSun should - = CW
- var panelRelativeToSun = xform.WorldRotation - TowardsSun;
+ var panelRelativeToSun = _xformSystem.GetWorldRotation(xform) - 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.
if (coverage > 0)
{
// Determine if the solar panel is occluded, and zero out coverage if so.
- var ray = new CollisionRay(xform.WorldPosition, TowardsSun.ToWorldVec(), (int) CollisionGroup.Opaque);
+ var ray = new CollisionRay(_xformSystem.GetWorldPosition(xform), TowardsSun.ToWorldVec(), (int) CollisionGroup.Opaque);
var rayCastResults = _physicsSystem.IntersectRayWithPredicate(
xform.MapID,
ray,
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly ThrowingSystem _throwingSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
private void FallOver(EntityUid uid, StandingStateComponent component, DropHandItemsEvent args)
{
if (!TryComp(uid, out HandsComponent? handsComp))
return;
- var worldRotation = EntityManager.GetComponent<TransformComponent>(uid).WorldRotation.ToVec();
+ var worldRotation = _xformSystem.GetWorldRotation(uid).ToVec();
foreach (var hand in handsComp.Hands.Values)
{
if (hand.HeldEntity is not EntityUid held)
public abstract class BaseWorldSystem : EntitySystem
{
[Dependency] private readonly WorldControllerSystem _worldController = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
/// <summary>
/// Gets a chunk's coordinates in chunk space as an integer value.
if (!Resolve(ent, ref xform))
throw new Exception("Failed to resolve transform, somehow.");
- return WorldGen.WorldToChunkCoords(xform.WorldPosition).Floored();
+ return WorldGen.WorldToChunkCoords(_xformSystem.GetWorldPosition(xform)).Floored();
}
/// <summary>
if (!Resolve(ent, ref xform))
throw new Exception("Failed to resolve transform, somehow.");
- return WorldGen.WorldToChunkCoords(xform.WorldPosition);
+ return WorldGen.WorldToChunkCoords(_xformSystem.GetWorldPosition(xform));
}
/// <summary>
public sealed class EmpArtifactSystem : EntitySystem
{
[Dependency] private readonly EmpSystem _emp = default!;
+ [Dependency] private readonly SharedTransformSystem _xform = default!;
/// <inheritdoc/>
public override void Initialize()
private void OnActivate(EntityUid uid, EmpArtifactComponent component, ArtifactActivatedEvent args)
{
- _emp.EmpPulse(Transform(uid).MapPosition, component.Range, component.EnergyConsumption, component.DisableDuration);
+ _emp.EmpPulse(_xform.GetMapCoordinates(uid), component.Range, component.EnergyConsumption, component.DisableDuration);
}
}
\ No newline at end of file
if (component.Spawns is not {} spawns)
return;
- var artifactCord = Transform(uid).MapPosition;
+ var artifactCord = _transform.GetMapCoordinates(uid);
foreach (var spawn in EntitySpawnCollection.GetSpawns(spawns, _random))
{
var dx = _random.NextFloat(-component.Range, component.Range);
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly ThrowingSystem _throwing = default!;
[Dependency] private readonly TileSystem _tile = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
/// <inheritdoc/>
public override void Initialize()
if (_map.TryGetGrid(xform.GridUid, out var grid))
{
var tiles = grid.GetTilesIntersecting(
- Box2.CenteredAround(xform.WorldPosition, new Vector2(component.Range * 2, component.Range)));
+ Box2.CenteredAround(_xformSystem.GetWorldPosition(xform), new Vector2(component.Range * 2, component.Range)));
foreach (var tile in tiles)
{
&& (phys.CollisionMask & (int) CollisionGroup.GhostImpassable) != 0)
continue;
- var tempXform = Transform(ent);
-
- var foo = tempXform.MapPosition.Position - xform.MapPosition.Position;
+ var foo = _xformSystem.GetWorldPosition(ent) - _xformSystem.GetWorldPosition(xform);
_throwing.TryThrow(ent, foo*2, component.ThrowStrength, uid, 0);
}
}
_transform.SetWorldRotation(buckleXform, oldBuckledToWorldRot);
if (strapComp.UnbuckleOffset != Vector2.Zero)
- buckleXform.Coordinates = oldBuckledXform.Coordinates.Offset(strapComp.UnbuckleOffset);
+ _transform.SetCoordinates((buckleUid, buckleXform, MetaData(buckleUid)), oldBuckledXform.Coordinates.Offset(strapComp.UnbuckleOffset));
}
if (TryComp(buckleUid, out AppearanceComponent? appearance))
public bool Condition(EntityUid user, EntityCoordinates location, Direction direction)
{
var entManager = IoCManager.Resolve<IEntityManager>();
+ var xfmSystem = entManager.System<SharedTransformSystem>();
// get blueprint and user position
- var userWorldPosition = entManager.GetComponent<TransformComponent>(user).WorldPosition;
+ var userWorldPosition = xfmSystem.GetWorldPosition(user);
var objWorldPosition = location.ToMap(entManager).Position;
// find direction from user to blueprint
var userToObject = (objWorldPosition - userWorldPosition);
// get direction of the grid being placed on as an offset.
- var gridRotation = entManager.GetComponent<TransformComponent>(location.EntityId).WorldRotation;
+ var gridRotation = xfmSystem.GetWorldRotation(location.EntityId);
var directionWithOffset = gridRotation.RotateVec(direction.ToVec());
// dot product will be positive if user direction and blueprint are co-directed
// Snap rotation to cardinal (multiple of 90)
var rot = xform.LocalRotation;
- xform.LocalRotation = Math.Round(rot / (Math.PI / 2)) * (Math.PI / 2);
+ _transformSystem.SetLocalRotation(uid, Math.Round(rot / (Math.PI / 2)) * (Math.PI / 2), xform);
if (TryComp<SharedPullableComponent>(uid, out var pullable) && pullable.Puller != null)
{
public sealed class ContainerFillSystem : EntitySystem
{
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
if (!_containerSystem.Insert(ent, container, containerXform: xform))
{
Log.Error($"Entity {ToPrettyString(uid)} with a {nameof(ContainerFillComponent)} failed to insert an entity: {ToPrettyString(ent)}.");
- Transform(ent).AttachToGridOrMap();
+ _xformSystem.AttachToGridOrMap(ent);
break;
}
}
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[Dependency] private readonly SharedPopupSystem _popupSystem = default!;
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
+
private ISawmill _sawmill = default!;
public const string InvokedPort = "link_port";
private bool InRange(EntityUid sourceUid, EntityUid sinkUid, float range)
{
// TODO: This should be using an existing method and also coordinates inrange instead.
- return Transform(sourceUid).MapPosition.InRange(Transform(sinkUid).MapPosition, range);
+ return _xformSystem.GetMapCoordinates(sourceUid).InRange(_xformSystem.GetMapCoordinates(sinkUid), range);
}
private void SendNewLinkEvent(EntityUid? user, EntityUid sourceUid, string source, EntityUid sinkUid, string sink)
[Dependency] private readonly SharedTransformSystem _transform = default!;
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
[Dependency] protected readonly MobStateSystem MobStateSystem = default!;
public const float MaxRaycastRange = 100;
if (!ignoreInsideBlocker) return false;
+ var xfmSys = entMan.System<SharedTransformSystem>();
foreach (var result in rayResults)
{
if (!entMan.TryGetComponent(result.HitEntity, out OccluderComponent? o))
}
var bBox = o.BoundingBox;
- bBox = bBox.Translated(entMan.GetComponent<TransformComponent>(result.HitEntity).WorldPosition);
+ bBox = bBox.Translated(xfmSys.GetWorldPosition(result.HitEntity));
if (bBox.Contains(origin.Position) || bBox.Contains(other.Position))
{
public static bool InRangeUnOccluded(EntityUid origin, EntityUid other, float range = ExamineRange, Ignored? predicate = null, bool ignoreInsideBlocker = true)
{
var entMan = IoCManager.Resolve<IEntityManager>();
- var originPos = entMan.GetComponent<TransformComponent>(origin).MapPosition;
- var otherPos = entMan.GetComponent<TransformComponent>(other).MapPosition;
+ var xfmSys = entMan.System<SharedTransformSystem>();
+
+ var originPos = xfmSys.GetMapCoordinates(origin);
+ var otherPos = xfmSys.GetMapCoordinates(other);
return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
}
public static bool InRangeUnOccluded(EntityUid origin, EntityCoordinates other, float range = ExamineRange, Ignored? predicate = null, bool ignoreInsideBlocker = true)
{
var entMan = IoCManager.Resolve<IEntityManager>();
- var originPos = entMan.GetComponent<TransformComponent>(origin).MapPosition;
- var otherPos = other.ToMap(entMan);
+ var xfmSys = entMan.System<SharedTransformSystem>();
+
+ var originPos = xfmSys.GetMapCoordinates(origin);
+ var otherPos = other.ToMap(entMan, xfmSys);
return InRangeUnOccluded(originPos, otherPos, range, predicate, ignoreInsideBlocker);
}
public static bool InRangeUnOccluded(EntityUid origin, MapCoordinates other, float range = ExamineRange, Ignored? predicate = null, bool ignoreInsideBlocker = true)
{
var entMan = IoCManager.Resolve<IEntityManager>();
- var originPos = entMan.GetComponent<TransformComponent>(origin).MapPosition;
+ var xfmSys = entMan.System<SharedTransformSystem>();
+
+ var originPos = xfmSys.GetMapCoordinates(origin);
return InRangeUnOccluded(originPos, other, range, predicate, ignoreInsideBlocker);
}
}
var target = targetDropLocation.Value.ToMap(EntityManager, TransformSystem);
- TransformSystem.SetWorldPosition(itemXform, GetFinalDropCoordinates(uid, userXform.MapPosition, target));
+ TransformSystem.SetWorldPosition(itemXform, GetFinalDropCoordinates(uid, TransformSystem.GetMapCoordinates((uid, userXform)), target));
return true;
}
var xform = Transform(uid);
var coordinateEntity = xform.ParentUid.IsValid() ? xform.ParentUid : uid;
var itemXform = Transform(entity);
- var itemPos = itemXform.MapPosition;
+ var itemPos = TransformSystem.GetMapCoordinates((entity, itemXform));
if (itemPos.MapId == xform.MapID
- && (itemPos.Position - xform.MapPosition.Position).Length() <= MaxAnimationRange
+ && (itemPos.Position - TransformSystem.GetMapCoordinates((uid, xform)).Position).Length() <= MaxAnimationRange
&& MetaData(entity).VisibilityMask == MetaData(uid).VisibilityMask) // Don't animate aghost pickups.
{
var initialPosition = EntityCoordinates.FromMap(coordinateEntity, itemPos, EntityManager);
if (!Resolve(user, ref xform))
return false;
- var diff = coordinates - xform.MapPosition.Position;
+ var diff = coordinates - _transform.GetMapCoordinates((user, xform)).Position;
if (diff.LengthSquared() <= 0.01f)
return true;
fixtureB.FixtureCount > 0 &&
TryComp<TransformComponent>(origin, out var xformA))
{
- var (worldPosA, worldRotA) = xformA.GetWorldPositionRotation();
+ var (worldPosA, worldRotA) = _transform.GetWorldPositionRotation(xformA);
var xfA = new Transform(worldPosA, worldRotA);
var parentRotB = _transform.GetWorldRotation(otherCoordinates.EntityId);
var xfB = new Transform(targetPos.Position, parentRotB + otherAngle);
else
{
// We'll still do the raycast from the centres but we'll bump the range as we know they're in range.
- originPos = xformA.MapPosition;
+ originPos = _transform.GetMapCoordinates(xformA);
range = (originPos.Position - targetPos.Position).Length();
}
}
// No fixtures, e.g. wallmounts.
else
{
- originPos = Transform(origin).MapPosition;
+ originPos = _transform.GetMapCoordinates(origin);
var otherParent = Transform(other).ParentUid;
targetRot = otherParent.IsValid() ? Transform(otherParent).LocalRotation + otherAngle : otherAngle;
}
Ignored? predicate = null)
{
var transform = Transform(target);
- var (position, rotation) = transform.GetWorldPositionRotation();
+ var (position, rotation) = _transform.GetWorldPositionRotation(transform);
var mapPos = new MapCoordinates(position, transform.MapID);
var combinedPredicate = GetPredicate(origin, target, mapPos, rotation, collisionMask, predicate);
bool popup = false)
{
Ignored combinedPredicate = e => e == origin || (predicate?.Invoke(e) ?? false);
- var originPosition = Transform(origin).MapPosition;
+ var originPosition = _transform.GetMapCoordinates(origin);
var inRange = InRangeUnobstructed(originPosition, other, range, collisionMask, combinedPredicate, ShouldCheckAccess(origin));
if (!inRange && popup && _gameTiming.IsFirstTimePredicted)
rotation = mover.TargetRelativeRotation;
}
- Transform(item).LocalRotation = rotation;
+ _transform.SetLocalRotation(item, rotation);
}
#endregion
[Dependency] private readonly SharedDecalSystem _decal = default!;
[Dependency] private readonly SharedMapSystem _maps = default!;
[Dependency] private readonly TurfSystem _turf = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
/// <summary>
/// Returns a weighted pick of a tile variant.
//Actually spawn the relevant tile item at the right position and give it some random offset.
var tileItem = Spawn(tileDef.ItemDropPrototypeName, coordinates);
- Transform(tileItem).LocalRotation = _robustRandom.NextDouble() * Math.Tau;
+ _xformSystem.SetLocalRotation(tileItem, _robustRandom.NextDouble() * Math.Tau);
// Destroy any decals on the tile
var decals = _decal.GetDecalsInRange(gridUid, coordinates.SnapToGrid(EntityManager, _mapManager).Position, 0.5f);
private static bool GetWorldTileBox(TileRef turf, out Box2Rotated res)
{
var entManager = IoCManager.Resolve<IEntityManager>();
+ var xfmSystem = entManager.System<SharedTransformSystem>();
var map = IoCManager.Resolve<IMapManager>();
if (map.TryGetGrid(turf.GridUid, out var tileGrid))
{
- var gridRot = entManager.GetComponent<TransformComponent>(turf.GridUid).WorldRotation;
+ var gridRot = xfmSystem.GetWorldRotation(turf.GridUid);
// This is scaled to 90 % so it doesn't encompass walls on other tiles.
var tileBox = Box2.UnitCentered.Scale(0.9f);
// TODO apparently this results in a duplicate move event because "This should have its event run during
// island solver"??. So maybe SetRotation needs an argument to avoid raising an event?
var worldRot = _transform.GetWorldRotation(xform);
- _transform.SetLocalRotation(xform, xform.LocalRotation + worldTotal.ToWorldAngle() - worldRot);
+ _transform.SetLocalRotation(physicsUid, xform.LocalRotation + worldTotal.ToWorldAngle() - worldRot, xform);
}
if (!weightless && MobMoverQuery.TryGetComponent(uid, out var mobMover) &&
return;
}
- var origin = Transform(user).MapPosition;
+ var origin = _transform.GetMapCoordinates(user);
var target = args.Target.ToMap(EntityManager, _transform);
// prevent collision with the user duh
if (!_interaction.InRangeUnobstructed(origin, target, 0f, CollisionGroup.Opaque, uid => uid == user))
var itemRelative = conveyorPos - localPos;
localPos += Convey(direction, speed, frameTime, itemRelative);
- transform.LocalPosition = localPos;
+ TransformSystem.SetLocalPosition(entity, localPos, transform);
// Force it awake for collisionwake reasons.
Physics.SetAwake(entity, body, true);
public sealed class PlaceableSurfaceSystem : EntitySystem
{
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
public override void Initialize()
{
return;
if (surface.PlaceCentered)
- Transform(args.Used).LocalPosition = Transform(uid).LocalPosition + surface.PositionOffset;
+ {
+ _xformSystem.SetLocalPosition(args.Used, Transform(uid).LocalPosition + surface.PositionOffset);
+ }
else
- Transform(args.Used).Coordinates = args.ClickLocation;
+ _xformSystem.SetCoordinates(args.Used, args.ClickLocation);
args.Handled = true;
}
[Dependency] private readonly TagSystem _tag = default!;
[Dependency] private readonly TurfSystem _turf = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
+ [Dependency] private readonly SharedTransformSystem _xformSystem = default!;
private readonly int RcdModeCount = Enum.GetValues(typeof(RcdMode)).Length;
if (_net.IsServer)
{
var ent = Spawn("WallSolid", mapGrid.GridTileToLocal(snapPos));
- Transform(ent).LocalRotation = Angle.Zero; // Walls always need to point south.
+ _xformSystem.SetLocalRotation(ent, Angle.Zero); // Walls always need to point south.
_adminLogger.Add(LogType.RCD, LogImpact.High, $"{ToPrettyString(args.User):user} used RCD to spawn {ToPrettyString(ent)} at {snapPos} on grid {tile.GridUid}");
}
break;
if (_net.IsServer)
{
var airlock = Spawn("Airlock", mapGrid.GridTileToLocal(snapPos));
- Transform(airlock).LocalRotation = Transform(uid).LocalRotation; //Now apply icon smoothing.
+ _xformSystem.SetLocalRotation(airlock, Transform(uid).LocalRotation); //Now apply icon smoothing.
_adminLogger.Add(LogType.RCD, LogImpact.High, $"{ToPrettyString(args.User):user} used RCD to spawn {ToPrettyString(airlock)} at {snapPos} on grid {tile.GridUid}");
}
break;
var offset = new Vector2(randomX, randomY);
var xform = Transform(entity);
- _transform.SetLocalPosition(xform, xform.LocalPosition + offset);
+ _transform.SetLocalPosition(entity, xform.LocalPosition + offset, xform);
}
public void RandomOffset(EntityUid entity, float min, float max)
private void OnMove(EntityUid uid, StealthOnMoveComponent component, ref MoveEvent args)
{
- if (args.FromStateHandling)
+ if (_timing.ApplyingState)
return;
if (args.NewPosition.EntityId != args.OldPosition.EntityId)
// the problem is that stack pickups delete the original entity, which is fine, but due to
// game state handling we can't show a lerp animation for it.
var nearXform = Transform(near);
- var nearMap = nearXform.MapPosition;
+ var nearMap = _transform.GetMapCoordinates(nearXform);
var nearCoords = EntityCoordinates.FromMap(moverCoords.EntityId, nearMap, _transform, EntityManager);
if (!_storage.Insert(uid, near, out var stacked, storageComp: storage, playSound: !playedSound))
public abstract class SharedTabletopSystem : EntitySystem
{
[Dependency] protected readonly ActionBlockerSystem ActionBlockerSystem = default!;
+ [Dependency] protected readonly SharedTransformSystem Transforms = default!;
[Dependency] private readonly SharedInteractionSystem _interactionSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
- [Dependency] private readonly SharedTransformSystem _transforms = default!;
[Dependency] private readonly IMapManager _mapMan = default!;
public override void Initialize()
// Move the entity and dirty it (we use the map ID from the entity so noone can try to be funny and move the item to another map)
var transform = EntityManager.GetComponent<TransformComponent>(moved);
- _transforms.SetParent(moved, transform, _mapMan.GetMapEntityId(transform.MapID));
- _transforms.SetLocalPositionNoLerp(transform, msg.Coordinates.Position);
+ var coordinates = new EntityCoordinates(_mapMan.GetMapEntityId(transform.MapID), msg.Coordinates.Position);
+ Transforms.SetCoordinates(moved, transform, coordinates);
}
private void OnDraggingPlayerChanged(TabletopDraggingPlayerChangedEvent msg, EntitySessionEventArgs args)
float pushbackRatio = PushbackDefault,
bool playSound = true)
{
- var thrownPos = Transform(uid).MapPosition;
+ var thrownPos = _transform.GetMapCoordinates(uid);
var mapPos = coordinates.ToMap(EntityManager, _transform);
if (mapPos.MapId != thrownPos.MapId)
_blocker.UpdateCanMove(target);
// Invisible tether entity
- var tether = Spawn("TetherEntity", Transform(target).MapPosition);
+ var tether = Spawn("TetherEntity", TransformSystem.GetMapCoordinates(target));
var tetherPhysics = Comp<PhysicsComponent>(tether);
component.TetherEntity = tether;
_physics.WakeBody(tether);
if (args.Handled)
return;
- ManualCycle(uid, component, Transform(uid).MapPosition, args.User);
+ ManualCycle(uid, component, TransformSystem.GetMapCoordinates(uid), args.User);
args.Handled = true;
}
{
Text = Loc.GetString("gun-ballistic-cycle"),
Disabled = GetBallisticShots(component) == 0,
- Act = () => ManualCycle(uid, component, Transform(uid).MapPosition, args.User),
+ Act = () => ManualCycle(uid, component, TransformSystem.GetMapCoordinates(uid), args.User),
});
}
var coordinates = xform.Coordinates;
coordinates = coordinates.Offset(offsetPos);
- TransformSystem.SetLocalRotation(xform, Random.NextAngle());
- TransformSystem.SetCoordinates(entity, xform, coordinates);
+ TransformSystem.SetCoordinates(entity, xform, coordinates, Random.NextAngle());
// decides direction the casing ejects and only when not cycling
if (angle != null)