From a4001fba1b3071f1b26d24d136cf70f8b93cb850 Mon Sep 17 00:00:00 2001 From: TemporalOroboros Date: Thu, 20 Feb 2025 04:06:39 -0800 Subject: [PATCH] Purge uses of TransformComponent.Anchored.set. Also adds parentheses. (#34938) --- Content.IntegrationTests/Tests/Disposal/DisposalUnitTest.cs | 4 ++-- .../Administration/Systems/AdminVerbSystem.Smites.cs | 4 ++-- .../Atmos/EntitySystems/PipeRestrictOverlapSystem.cs | 2 +- Content.Server/Cargo/Systems/CargoSystem.Orders.cs | 2 +- Content.Server/Construction/Completions/SetAnchor.cs | 4 ++-- Content.Server/Construction/ConstructionSystem.Graph.cs | 2 +- Content.Server/Defusable/Systems/DefusableSystem.cs | 4 ++-- Content.Server/Explosion/EntitySystems/TriggerSystem.cs | 2 +- Content.Server/Holosign/HolosignSystem.cs | 2 +- Content.Server/Nuke/NukeSystem.cs | 6 +++--- .../Procedural/DungeonJob/DungeonJob.PostGenBiome.cs | 4 ++-- .../DungeonJob/DungeonJob.PostGenBiomeMarkerLayer.cs | 2 +- Content.Server/Procedural/DungeonSystem.Rooms.cs | 2 +- Content.Server/Rotatable/RotatableSystem.cs | 3 ++- Content.Shared/Blocking/BlockingSystem.cs | 4 ++-- .../Construction/EntitySystems/AnchorableSystem.cs | 4 ++-- Content.Shared/Construction/SharedConstructionSystem.cs | 4 ++-- Content.Shared/Magic/SharedMagicSystem.cs | 2 +- .../Polymorph/Systems/SharedChameleonProjectorSystem.cs | 4 ++-- Content.Shared/Security/Systems/DeployableBarrierSystem.cs | 4 ++-- Content.Shared/Weapons/Melee/MeleeThrowOnHitSystem.cs | 2 +- Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs | 2 +- 22 files changed, 35 insertions(+), 34 deletions(-) diff --git a/Content.IntegrationTests/Tests/Disposal/DisposalUnitTest.cs b/Content.IntegrationTests/Tests/Disposal/DisposalUnitTest.cs index 9109fdbe4f..8c087fcb25 100644 --- a/Content.IntegrationTests/Tests/Disposal/DisposalUnitTest.cs +++ b/Content.IntegrationTests/Tests/Disposal/DisposalUnitTest.cs @@ -181,14 +181,14 @@ namespace Content.IntegrationTests.Tests.Disposal }); // Can't insert, unanchored and unpowered - xformSystem.Unanchor(unitUid, entityManager.GetComponent(unitUid)); + xformSystem.Unanchor((unitUid, entityManager.GetComponent(unitUid))); UnitInsertContains(disposalUnit, unitComponent, false, disposalSystem, human, wrench, disposalUnit, disposalTrunk); }); await server.WaitAssertion(() => { // Anchor the disposal unit - xformSystem.AnchorEntity(unitUid, entityManager.GetComponent(unitUid)); + xformSystem.AnchorEntity((unitUid, entityManager.GetComponent(unitUid))); // No power Assert.That(unitComponent.Powered, Is.False); diff --git a/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs b/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs index ed46412a08..4ea15ced85 100644 --- a/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs +++ b/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs @@ -421,7 +421,7 @@ public sealed partial class AdminVerbSystem { var xform = Transform(args.Target); var fixtures = Comp(args.Target); - xform.Anchored = false; // Just in case. + _transformSystem.Unanchor((args.Target, xform)); // Just in case. _physics.SetBodyType(args.Target, BodyType.Dynamic, manager: fixtures, body: physics); _physics.SetBodyStatus(args.Target, physics, BodyStatus.InAir); _physics.WakeBody(args.Target, manager: fixtures, body: physics); @@ -456,7 +456,7 @@ public sealed partial class AdminVerbSystem { var xform = Transform(args.Target); var fixtures = Comp(args.Target); - xform.Anchored = false; // Just in case. + _transformSystem.Unanchor((args.Target, xform)); _physics.SetBodyType(args.Target, BodyType.Dynamic, body: physics); _physics.SetBodyStatus(args.Target, physics, BodyStatus.InAir); diff --git a/Content.Server/Atmos/EntitySystems/PipeRestrictOverlapSystem.cs b/Content.Server/Atmos/EntitySystems/PipeRestrictOverlapSystem.cs index c2ff87ca79..032e863893 100644 --- a/Content.Server/Atmos/EntitySystems/PipeRestrictOverlapSystem.cs +++ b/Content.Server/Atmos/EntitySystems/PipeRestrictOverlapSystem.cs @@ -40,7 +40,7 @@ public sealed class PipeRestrictOverlapSystem : EntitySystem if (HasComp(ent) && CheckOverlap(ent)) { _popup.PopupEntity(Loc.GetString("pipe-restrict-overlap-popup-blocked", ("pipe", ent.Owner)), ent); - _xform.Unanchor(ent, Transform(ent)); + _xform.Unanchor((ent, Transform(ent))); } } diff --git a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs index 2c86a5590a..9a8480dd3a 100644 --- a/Content.Server/Cargo/Systems/CargoSystem.Orders.cs +++ b/Content.Server/Cargo/Systems/CargoSystem.Orders.cs @@ -522,7 +522,7 @@ namespace Content.Server.Cargo.Systems var item = Spawn(order.ProductId, spawn); // Ensure the item doesn't start anchored - _transformSystem.Unanchor(item, Transform(item)); + _transformSystem.Unanchor((item, Transform(item))); // Create a sheet of paper to write the order details on var printed = EntityManager.SpawnEntity(paperProto, spawn); diff --git a/Content.Server/Construction/Completions/SetAnchor.cs b/Content.Server/Construction/Completions/SetAnchor.cs index 989ecc99bd..b82db0339b 100644 --- a/Content.Server/Construction/Completions/SetAnchor.cs +++ b/Content.Server/Construction/Completions/SetAnchor.cs @@ -11,8 +11,8 @@ namespace Content.Server.Construction.Completions public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager) { - var transform = entityManager.GetComponent(uid); - transform.Anchored = Value; + var transformSystem = entityManager.System(); + transformSystem.TrySetAnchor(uid, Value); } } } diff --git a/Content.Server/Construction/ConstructionSystem.Graph.cs b/Content.Server/Construction/ConstructionSystem.Graph.cs index 4c73cef703..fb513b6f6b 100644 --- a/Content.Server/Construction/ConstructionSystem.Graph.cs +++ b/Content.Server/Construction/ConstructionSystem.Graph.cs @@ -364,7 +364,7 @@ namespace Content.Server.Construction var newTransform = Transform(newUid); TransformSystem.AttachToGridOrMap(newUid, newTransform); // in case in hands or a container newTransform.LocalRotation = transform.LocalRotation; - newTransform.Anchored = transform.Anchored; + TransformSystem.SetAnchor((newUid, newTransform), transform.Anchored); // Container transferring. if (containerManager != null) diff --git a/Content.Server/Defusable/Systems/DefusableSystem.cs b/Content.Server/Defusable/Systems/DefusableSystem.cs index 1e9caece94..58a08bf91d 100644 --- a/Content.Server/Defusable/Systems/DefusableSystem.cs +++ b/Content.Server/Defusable/Systems/DefusableSystem.cs @@ -133,7 +133,7 @@ public sealed class DefusableSystem : SharedDefusableSystem var xform = Transform(uid); if (!xform.Anchored) - _transform.AnchorEntity(uid, xform); + _transform.AnchorEntity((uid, xform)); SetBolt(comp, true); SetActivated(comp, true); @@ -203,7 +203,7 @@ public sealed class DefusableSystem : SharedDefusableSystem comp.Bolted = false; if (xform.Anchored) - _transform.Unanchor(uid, xform); + _transform.Unanchor((uid, xform)); _appearance.SetData(uid, DefusableVisuals.Active, comp.Activated); } diff --git a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs index 53f6dfacf8..8db161eeb6 100644 --- a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs +++ b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs @@ -149,7 +149,7 @@ namespace Content.Server.Explosion.EntitySystems if (xform.Anchored) return; - _transformSystem.AnchorEntity(uid, xform); + _transformSystem.AnchorEntity((uid, xform)); if (component.RemoveOnTrigger) RemCompDeferred(uid); diff --git a/Content.Server/Holosign/HolosignSystem.cs b/Content.Server/Holosign/HolosignSystem.cs index b63a545989..13886ac69f 100644 --- a/Content.Server/Holosign/HolosignSystem.cs +++ b/Content.Server/Holosign/HolosignSystem.cs @@ -54,7 +54,7 @@ public sealed class HolosignSystem : EntitySystem var holoUid = EntityManager.SpawnEntity(component.SignProto, args.ClickLocation.SnapToGrid(EntityManager)); var xform = Transform(holoUid); if (!xform.Anchored) - _transform.AnchorEntity(holoUid, xform); // anchor to prevent any tempering with (don't know what could even interact with it) + _transform.AnchorEntity((holoUid, xform)); // anchor to prevent any tempering with (don't know what could even interact with it) args.Handled = true; } diff --git a/Content.Server/Nuke/NukeSystem.cs b/Content.Server/Nuke/NukeSystem.cs index 84118931b1..9c0b14ea4e 100644 --- a/Content.Server/Nuke/NukeSystem.cs +++ b/Content.Server/Nuke/NukeSystem.cs @@ -181,7 +181,7 @@ public sealed class NukeSystem : EntitySystem var xform = Transform(uid); if (xform.Anchored) { - _transform.Unanchor(uid, xform); + _transform.Unanchor((uid, xform)); _itemSlots.SetLock(uid, component.DiskSlot, true); } else @@ -203,7 +203,7 @@ public sealed class NukeSystem : EntitySystem } _transform.SetCoordinates(uid, xform, xform.Coordinates.SnapToGrid()); - _transform.AnchorEntity(uid, xform); + _transform.AnchorEntity((uid, xform)); _itemSlots.SetLock(uid, component.DiskSlot, false); } @@ -490,7 +490,7 @@ public sealed class NukeSystem : EntitySystem if (!nukeXform.Anchored) { // Admin command shenanigans, just make sure. - _transform.AnchorEntity(uid, nukeXform); + _transform.AnchorEntity((uid, nukeXform)); } component.Status = NukeStatus.ARMED; diff --git a/Content.Server/Procedural/DungeonJob/DungeonJob.PostGenBiome.cs b/Content.Server/Procedural/DungeonJob/DungeonJob.PostGenBiome.cs index 9e5f3bdcfc..4f419110d5 100644 --- a/Content.Server/Procedural/DungeonJob/DungeonJob.PostGenBiome.cs +++ b/Content.Server/Procedural/DungeonJob/DungeonJob.PostGenBiome.cs @@ -31,7 +31,7 @@ public sealed partial class DungeonJob if (reservedTiles.Contains(node)) continue; - + if (dunGen.TileMask is not null) { if (!dunGen.TileMask.Contains(((ContentTileDefinition) _tileDefManager[tileRef.Value.Tile.TypeId]).ID)) @@ -59,7 +59,7 @@ public sealed partial class DungeonJob if (!xform.Comp.Anchored) { - _transform.AnchorEntity(ent, xform); + _transform.AnchorEntity((ent, xform)); } // TODO: Engine bug with SpawnAtPosition diff --git a/Content.Server/Procedural/DungeonJob/DungeonJob.PostGenBiomeMarkerLayer.cs b/Content.Server/Procedural/DungeonJob/DungeonJob.PostGenBiomeMarkerLayer.cs index fb0eaa0157..cf6a4e1794 100644 --- a/Content.Server/Procedural/DungeonJob/DungeonJob.PostGenBiomeMarkerLayer.cs +++ b/Content.Server/Procedural/DungeonJob/DungeonJob.PostGenBiomeMarkerLayer.cs @@ -94,7 +94,7 @@ public sealed partial class DungeonJob var xform = xformQuery.Get(ent); if (!xform.Comp.Anchored) - _transform.AnchorEntity(ent, xform); + _transform.AnchorEntity((ent, xform)); await SuspendDungeon(); if (!ValidateResume()) diff --git a/Content.Server/Procedural/DungeonSystem.Rooms.cs b/Content.Server/Procedural/DungeonSystem.Rooms.cs index f74868bb52..09aad2de1f 100644 --- a/Content.Server/Procedural/DungeonSystem.Rooms.cs +++ b/Content.Server/Procedural/DungeonSystem.Rooms.cs @@ -195,7 +195,7 @@ public sealed partial class DungeonSystem if (anchored && !childXform.Anchored) _transform.AnchorEntity((ent, childXform), (gridUid, grid)); else if (!anchored && childXform.Anchored) - _transform.Unanchor(ent, childXform); + _transform.Unanchor((ent, childXform)); } // Load decals diff --git a/Content.Server/Rotatable/RotatableSystem.cs b/Content.Server/Rotatable/RotatableSystem.cs index 63b5e44c3d..d516560ab9 100644 --- a/Content.Server/Rotatable/RotatableSystem.cs +++ b/Content.Server/Rotatable/RotatableSystem.cs @@ -21,6 +21,7 @@ namespace Content.Server.Rotatable [Dependency] private readonly PopupSystem _popup = default!; [Dependency] private readonly ActionBlockerSystem _actionBlocker = default!; [Dependency] private readonly SharedInteractionSystem _interaction = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Initialize() { @@ -112,7 +113,7 @@ namespace Content.Server.Rotatable var entity = EntityManager.SpawnEntity(component.MirrorEntity, oldTransform.Coordinates); var newTransform = EntityManager.GetComponent(entity); newTransform.LocalRotation = oldTransform.LocalRotation; - newTransform.Anchored = false; + _transform.Unanchor((entity, newTransform)); EntityManager.DeleteEntity(uid); } diff --git a/Content.Shared/Blocking/BlockingSystem.cs b/Content.Shared/Blocking/BlockingSystem.cs index 594d1baf6c..47f137032a 100644 --- a/Content.Shared/Blocking/BlockingSystem.cs +++ b/Content.Shared/Blocking/BlockingSystem.cs @@ -189,7 +189,7 @@ public sealed partial class BlockingSystem : EntitySystem } //Don't allow someone to block if they're somehow not anchored. - _transformSystem.AnchorEntity(user, xform); + _transformSystem.AnchorEntity((user, xform)); if (!xform.Anchored) { CantBlockError(user); @@ -259,7 +259,7 @@ public sealed partial class BlockingSystem : EntitySystem && TryComp(user, out var physicsComponent)) { if (xform.Anchored) - _transformSystem.Unanchor(user, xform); + _transformSystem.Unanchor((user, xform)); _actionsSystem.SetToggled(component.BlockingToggleActionEntity, false); _fixtureSystem.DestroyFixture(user, BlockingComponent.BlockFixtureID, body: physicsComponent); diff --git a/Content.Shared/Construction/EntitySystems/AnchorableSystem.cs b/Content.Shared/Construction/EntitySystems/AnchorableSystem.cs index 9c3d6fc9fb..183727775e 100644 --- a/Content.Shared/Construction/EntitySystems/AnchorableSystem.cs +++ b/Content.Shared/Construction/EntitySystems/AnchorableSystem.cs @@ -114,7 +114,7 @@ public sealed partial class AnchorableSystem : EntitySystem var xform = Transform(uid); RaiseLocalEvent(uid, new BeforeUnanchoredEvent(args.User, used)); - _transformSystem.Unanchor(uid, xform); + _transformSystem.Unanchor((uid, xform)); RaiseLocalEvent(uid, new UserUnanchoredEvent(args.User, used)); _popup.PopupClient(Loc.GetString("anchorable-unanchored"), uid, args.User); @@ -165,7 +165,7 @@ public sealed partial class AnchorableSystem : EntitySystem RaiseLocalEvent(uid, new BeforeAnchoredEvent(args.User, used)); if (!xform.Anchored) - _transformSystem.AnchorEntity(uid, xform); + _transformSystem.AnchorEntity((uid, xform)); RaiseLocalEvent(uid, new UserAnchoredEvent(args.User, used)); diff --git a/Content.Shared/Construction/SharedConstructionSystem.cs b/Content.Shared/Construction/SharedConstructionSystem.cs index a2b647ae92..6d09b131d4 100644 --- a/Content.Shared/Construction/SharedConstructionSystem.cs +++ b/Content.Shared/Construction/SharedConstructionSystem.cs @@ -8,7 +8,7 @@ namespace Content.Shared.Construction { public abstract class SharedConstructionSystem : EntitySystem { - [Dependency] private readonly IMapManager _mapManager = default!; + [Dependency] protected readonly IMapManager MapManager = default!; [Dependency] protected readonly IPrototypeManager PrototypeManager = default!; [Dependency] protected readonly SharedTransformSystem TransformSystem = default!; @@ -20,7 +20,7 @@ namespace Content.Shared.Construction if (!canBuildInImpassable) return null; - if (!_mapManager.TryFindGridAt(coords, out _, out var grid)) + if (!MapManager.TryFindGridAt(coords, out _, out var grid)) return null; var ignored = grid.GetAnchoredEntities(coords).ToHashSet(); diff --git a/Content.Shared/Magic/SharedMagicSystem.cs b/Content.Shared/Magic/SharedMagicSystem.cs index 0be5646f4b..35eef77be3 100644 --- a/Content.Shared/Magic/SharedMagicSystem.cs +++ b/Content.Shared/Magic/SharedMagicSystem.cs @@ -546,7 +546,7 @@ public abstract class SharedMagicSystem : EntitySystem var xform = Transform(ev.Target); var fixture = fixtures.Fixtures.First(); - _transform.Unanchor(ev.Target); + _transform.Unanchor((ev.Target, xform)); _physics.SetCanCollide(ev.Target, true, true, false, fixtures, physics); _physics.SetCollisionMask(ev.Target, fixture.Key, fixture.Value, (int)CollisionGroup.FlyingMobMask, fixtures, physics); _physics.SetCollisionLayer(ev.Target, fixture.Key, fixture.Value, (int)CollisionGroup.FlyingMobLayer, fixtures, physics); diff --git a/Content.Shared/Polymorph/Systems/SharedChameleonProjectorSystem.cs b/Content.Shared/Polymorph/Systems/SharedChameleonProjectorSystem.cs index 99737996b0..0d2641ae6b 100644 --- a/Content.Shared/Polymorph/Systems/SharedChameleonProjectorSystem.cs +++ b/Content.Shared/Polymorph/Systems/SharedChameleonProjectorSystem.cs @@ -146,7 +146,7 @@ public abstract class SharedChameleonProjectorSystem : EntitySystem var xform = Transform(uid); if (xform.Anchored) - _xform.Unanchor(uid, xform); + _xform.Unanchor((uid, xform)); else _xform.AnchorEntity((uid, xform)); @@ -241,7 +241,7 @@ public abstract class SharedChameleonProjectorSystem : EntitySystem var xform = Transform(ent); xform.NoLocalRotation = false; - _xform.Unanchor(ent, xform); + _xform.Unanchor((ent, xform)); Del(ent.Comp.Disguise); RemComp(ent); diff --git a/Content.Shared/Security/Systems/DeployableBarrierSystem.cs b/Content.Shared/Security/Systems/DeployableBarrierSystem.cs index 622edc4b62..4aed7b8730 100644 --- a/Content.Shared/Security/Systems/DeployableBarrierSystem.cs +++ b/Content.Shared/Security/Systems/DeployableBarrierSystem.cs @@ -43,13 +43,13 @@ public sealed class DeployableBarrierSystem : EntitySystem if (isDeployed && transform.GridUid != null) { - _transform.AnchorEntity(uid, transform); + _transform.AnchorEntity((uid, transform)); if (fixture != null) _physics.SetHard(uid, fixture, true); } else { - _transform.Unanchor(uid, transform); + _transform.Unanchor((uid, transform)); if (fixture != null) _physics.SetHard(uid, fixture, false); } diff --git a/Content.Shared/Weapons/Melee/MeleeThrowOnHitSystem.cs b/Content.Shared/Weapons/Melee/MeleeThrowOnHitSystem.cs index 7886356233..20857770c7 100644 --- a/Content.Shared/Weapons/Melee/MeleeThrowOnHitSystem.cs +++ b/Content.Shared/Weapons/Melee/MeleeThrowOnHitSystem.cs @@ -47,7 +47,7 @@ public sealed class MeleeThrowOnHitSystem : EntitySystem if (comp.UnanchorOnHit && HasComp(hit)) { - _transform.Unanchor(hit, Transform(hit)); + _transform.Unanchor((hit, Transform(hit))); } RemComp(hit); diff --git a/Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs b/Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs index 3d7f9df458..49096bfbdc 100644 --- a/Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs +++ b/Content.Shared/Weapons/Misc/SharedTetherGunSystem.cs @@ -207,7 +207,7 @@ public abstract partial class SharedTetherGunSystem : EntitySystem _appearance.SetData(gunUid, ToggleableLightVisuals.Enabled, true, appearance); // Target updates - TransformSystem.Unanchor(target, targetXform); + TransformSystem.Unanchor((target, targetXform)); component.Tethered = target; var tethered = EnsureComp(target); _physics.SetBodyStatus(target, targetPhysics, BodyStatus.InAir, false);