Skip to content

Commit

Permalink
Purge uses of TransformComponent.AttachToGridOrMap (space-wizards#34940)
Browse files Browse the repository at this point in the history
Switches over all extant uses of TransformComponent.AttachToGridOrMap to use SharedTransformSystem.AttachToGridOrMap
  • Loading branch information
TemporalOroboros authored Feb 7, 2025
1 parent 14d96e0 commit f37d5c9
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Content.Server/Administration/Commands/WarpCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
}

var xform = _entManager.GetComponent<TransformComponent>(playerEntity);
var xformSystem = _entManager.System<SharedTransformSystem>();
xform.Coordinates = coords;
xform.AttachToGridOrMap();
xformSystem.AttachToGridOrMap(playerEntity, xform);
if (_entManager.TryGetComponent(playerEntity, out PhysicsComponent? physics))
{
_entManager.System<SharedPhysicsSystem>().SetLinearVelocity(playerEntity, Vector2.Zero, body: physics);
Expand Down
6 changes: 3 additions & 3 deletions Content.Server/Construction/ConstructionSystem.Graph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ public bool ChangeNode(EntityUid uid, EntityUid? userUid, string id, bool perfor
return null;

// [Optional] Exit if the new entity's prototype is a parent of the original
// E.g., if an entity with the 'AirlockCommand' prototype was to be replaced with a new entity that
// had the 'Airlock' prototype, and DoNotReplaceInheritingEntities was true, the code block would
// E.g., if an entity with the 'AirlockCommand' prototype was to be replaced with a new entity that
// had the 'Airlock' prototype, and DoNotReplaceInheritingEntities was true, the code block would
// exit here because 'AirlockCommand' is derived from 'Airlock'
if (GetCurrentNode(uid, construction)?.DoNotReplaceInheritingEntities == true &&
metaData.EntityPrototype?.ID != null)
Expand Down Expand Up @@ -362,7 +362,7 @@ public bool ChangeNode(EntityUid uid, EntityUid? userUid, string id, bool perfor

// Transform transferring.
var newTransform = Transform(newUid);
newTransform.AttachToGridOrMap(); // in case in hands or a container
TransformSystem.AttachToGridOrMap(newUid, newTransform); // in case in hands or a container
newTransform.LocalRotation = transform.LocalRotation;
newTransform.Anchored = transform.Anchored;

Expand Down
1 change: 1 addition & 0 deletions Content.Shared/Construction/SharedConstructionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public abstract class SharedConstructionSystem : EntitySystem
{
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] protected readonly IPrototypeManager PrototypeManager = default!;
[Dependency] protected readonly SharedTransformSystem TransformSystem = default!;

/// <summary>
/// Get predicate for construction obstruction checks.
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Containers/ContainerFillSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ private void OnMapInit(EntityUid uid, ContainerFillComponent component, MapInitE
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();
_transform.AttachToGridOrMap(ent);
break;
}
}
Expand Down

0 comments on commit f37d5c9

Please sign in to comment.