From ab07944af8a2371432dad739e6ccdcdee870aaff Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Tue, 3 Jan 2023 17:45:18 +1100 Subject: [PATCH] Remove IPhysBody (#13297) --- Content.Client/Suspicion/TraitorOverlay.cs | 3 ++- Content.IntegrationTests/Tests/Doors/AirlockTest.cs | 5 +++-- .../Tests/GameObjects/Components/Movement/ClimbUnitTest.cs | 2 +- Content.Server/Abilities/Mime/MimePowersSystem.cs | 3 ++- Content.Server/Administration/Commands/WarpCommand.cs | 3 ++- Content.Server/Atmos/EntitySystems/FlammableSystem.cs | 4 ++-- .../Disposal/Tube/Components/DisposalRouterComponent.cs | 3 ++- .../Disposal/Unit/Components/DisposalHolderComponent.cs | 3 ++- Content.Server/Rotatable/RotatableSystem.cs | 5 +++-- .../Storage/EntitySystems/EntityStorageSystem.cs | 3 ++- .../Temperature/Components/TemperatureComponent.cs | 3 ++- Content.Shared/Movement/Systems/SharedMoverController.cs | 2 +- Content.Shared/Pulling/Events/PullAttemptEvent.cs | 4 ++-- Content.Shared/Pulling/Events/PullMessage.cs | 7 ++++--- Content.Shared/Pulling/Events/PullStartedMessage.cs | 4 ++-- Content.Shared/Pulling/Events/PullStoppedMessage.cs | 4 ++-- .../Pulling/Systems/SharedPullingSystem.Actions.cs | 2 +- Content.Shared/Throwing/ThrownItemSystem.cs | 2 +- 18 files changed, 36 insertions(+), 26 deletions(-) diff --git a/Content.Client/Suspicion/TraitorOverlay.cs b/Content.Client/Suspicion/TraitorOverlay.cs index d932b9e44e..88486ba105 100644 --- a/Content.Client/Suspicion/TraitorOverlay.cs +++ b/Content.Client/Suspicion/TraitorOverlay.cs @@ -9,6 +9,7 @@ using Robust.Shared.IoC; using Robust.Shared.Localization; using Robust.Shared.Maths; using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; namespace Content.Client.Suspicion { @@ -52,7 +53,7 @@ namespace Content.Client.Suspicion continue; } - if (!_entityManager.TryGetComponent(ally, out IPhysBody? physics)) + if (!_entityManager.TryGetComponent(ally, out PhysicsComponent? physics)) { continue; } diff --git a/Content.IntegrationTests/Tests/Doors/AirlockTest.cs b/Content.IntegrationTests/Tests/Doors/AirlockTest.cs index 7d50ce2a33..33dc418832 100644 --- a/Content.IntegrationTests/Tests/Doors/AirlockTest.cs +++ b/Content.IntegrationTests/Tests/Doors/AirlockTest.cs @@ -7,6 +7,7 @@ using NUnit.Framework; using Robust.Shared.GameObjects; using Robust.Shared.Map; using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; namespace Content.IntegrationTests.Tests.Doors { @@ -114,7 +115,7 @@ namespace Content.IntegrationTests.Tests.Doors var mapManager = server.ResolveDependency(); var entityManager = server.ResolveDependency(); - IPhysBody physBody = null; + PhysicsComponent physBody = null; EntityUid physicsDummy = default; EntityUid airlock = default; DoorComponent doorComponent = null; @@ -145,7 +146,7 @@ namespace Content.IntegrationTests.Tests.Doors for (var i = 0; i < 240; i += 10) { // Keep the airlock awake so they collide - await server.WaitPost(() => entityManager.GetComponent(airlock).WakeBody()); + await server.WaitPost(() => entityManager.GetComponent(airlock).WakeBody()); await server.WaitRunTicks(10); await server.WaitIdleAsync(); diff --git a/Content.IntegrationTests/Tests/GameObjects/Components/Movement/ClimbUnitTest.cs b/Content.IntegrationTests/Tests/GameObjects/Components/Movement/ClimbUnitTest.cs index 3897a149a5..60cd158037 100644 --- a/Content.IntegrationTests/Tests/GameObjects/Components/Movement/ClimbUnitTest.cs +++ b/Content.IntegrationTests/Tests/GameObjects/Components/Movement/ClimbUnitTest.cs @@ -59,7 +59,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Movement // // Now let's make the player enter a climbing transitioning state. // climbing.IsClimbing = true; // EntitySystem.Get().MoveEntityToward(human, table, climbing:climbing); - // var body = entityManager.GetComponent(human); + // var body = entityManager.GetComponent(human); // // TODO: Check it's climbing // // // Force the player out of climb state. It should immediately remove the ClimbController. diff --git a/Content.Server/Abilities/Mime/MimePowersSystem.cs b/Content.Server/Abilities/Mime/MimePowersSystem.cs index b7a0c2cc98..b219826711 100644 --- a/Content.Server/Abilities/Mime/MimePowersSystem.cs +++ b/Content.Server/Abilities/Mime/MimePowersSystem.cs @@ -9,6 +9,7 @@ using Content.Shared.Maps; using Content.Shared.MobState.Components; using Robust.Shared.Player; using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; using Robust.Shared.Timing; namespace Content.Server.Abilities.Mime @@ -74,7 +75,7 @@ namespace Content.Server.Abilities.Mime // Check there are no walls or mobs there foreach (var entity in coords.GetEntitiesInTile()) { - IPhysBody? physics = null; // We use this to check if it's impassable + PhysicsComponent? physics = null; // We use this to check if it's impassable if ((HasComp(entity) && entity != uid) || // Is it a mob? ((Resolve(entity, ref physics, false) && (physics.CollisionLayer & (int) CollisionGroup.Impassable) != 0) // Is it impassable? && !(TryComp(entity, out var door) && door.State != DoorState.Closed))) // Is it a door that's open and so not actually impassable? diff --git a/Content.Server/Administration/Commands/WarpCommand.cs b/Content.Server/Administration/Commands/WarpCommand.cs index 22ede58269..be40591490 100644 --- a/Content.Server/Administration/Commands/WarpCommand.cs +++ b/Content.Server/Administration/Commands/WarpCommand.cs @@ -8,6 +8,7 @@ using Robust.Shared.Console; using Robust.Shared.Enums; using Robust.Shared.Map; using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; namespace Content.Server.Administration.Commands { @@ -121,7 +122,7 @@ namespace Content.Server.Administration.Commands var xform = entMan.GetComponent(playerEntity); xform.Coordinates = coords; xform.AttachToGridOrMap(); - if (entMan.TryGetComponent(playerEntity, out IPhysBody? physics)) + if (entMan.TryGetComponent(playerEntity, out PhysicsComponent? physics)) { physics.LinearVelocity = Vector2.Zero; } diff --git a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs index 321217222e..3575412b7d 100644 --- a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs +++ b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs @@ -274,7 +274,7 @@ namespace Content.Server.Atmos.EntitySystems _timer -= UpdateTime; // TODO: This needs cleanup to take off the crust from TemperatureComponent and shit. - foreach (var (flammable, physics, transform) in EntityManager.EntityQuery()) + foreach (var (flammable, physics, transform) in EntityManager.EntityQuery()) { var uid = flammable.Owner; @@ -335,7 +335,7 @@ namespace Content.Server.Atmos.EntitySystems continue; } - var otherPhysics = EntityManager.GetComponent(uid); + var otherPhysics = EntityManager.GetComponent(uid); // TODO: Sloth, please save our souls! if (!physics.GetWorldAABB().Intersects(otherPhysics.GetWorldAABB())) diff --git a/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs b/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs index 491010ecdc..1cfcbe7b6e 100644 --- a/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs +++ b/Content.Server/Disposal/Tube/Components/DisposalRouterComponent.cs @@ -4,6 +4,7 @@ using Content.Server.UserInterface; using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; using Robust.Shared.Player; using static Content.Shared.Disposal.Components.SharedDisposalRouterComponent; @@ -23,7 +24,7 @@ namespace Content.Server.Disposal.Tube.Components [ViewVariables] public bool Anchored => - !_entMan.TryGetComponent(Owner, out IPhysBody? physics) || + !_entMan.TryGetComponent(Owner, out PhysicsComponent? physics) || physics.BodyType == BodyType.Static; [ViewVariables] public BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalRouterUiKey.Key); diff --git a/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs b/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs index 43f735bc77..d6aa84b9b3 100644 --- a/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs +++ b/Content.Server/Disposal/Unit/Components/DisposalHolderComponent.cs @@ -4,6 +4,7 @@ using Content.Shared.Body.Components; using Content.Shared.Item; using Robust.Shared.Containers; using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; namespace Content.Server.Disposal.Unit.Components { @@ -82,7 +83,7 @@ namespace Content.Server.Disposal.Unit.Components return false; } - if (_entMan.TryGetComponent(entity, out IPhysBody? physics)) + if (_entMan.TryGetComponent(entity, out PhysicsComponent? physics)) { physics.CanCollide = false; } diff --git a/Content.Server/Rotatable/RotatableSystem.cs b/Content.Server/Rotatable/RotatableSystem.cs index abfa4c53b3..0816fedc36 100644 --- a/Content.Server/Rotatable/RotatableSystem.cs +++ b/Content.Server/Rotatable/RotatableSystem.cs @@ -2,6 +2,7 @@ using Content.Shared.Popups; using Content.Shared.Rotatable; using Content.Shared.Verbs; using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; namespace Content.Server.Rotatable { @@ -38,7 +39,7 @@ namespace Content.Server.Rotatable // Check if the object is anchored, and whether we are still allowed to rotate it. if (!component.RotateWhileAnchored && - EntityManager.TryGetComponent(component.Owner, out IPhysBody? physics) && + EntityManager.TryGetComponent(component.Owner, out PhysicsComponent? physics) && physics.BodyType == BodyType.Static) return; @@ -82,7 +83,7 @@ namespace Content.Server.Rotatable /// public void TryFlip(FlippableComponent component, EntityUid user) { - if (EntityManager.TryGetComponent(component.Owner, out IPhysBody? physics) && + if (EntityManager.TryGetComponent(component.Owner, out PhysicsComponent? physics) && physics.BodyType == BodyType.Static) { component.Owner.PopupMessage(user, Loc.GetString("flippable-component-try-flip-is-stuck")); diff --git a/Content.Server/Storage/EntitySystems/EntityStorageSystem.cs b/Content.Server/Storage/EntitySystems/EntityStorageSystem.cs index 9108591835..dc24f7ea35 100644 --- a/Content.Server/Storage/EntitySystems/EntityStorageSystem.cs +++ b/Content.Server/Storage/EntitySystems/EntityStorageSystem.cs @@ -18,6 +18,7 @@ using Robust.Server.Containers; using Robust.Shared.Containers; using Robust.Shared.Map; using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; using Robust.Shared.Player; namespace Content.Server.Storage.EntitySystems; @@ -320,7 +321,7 @@ public sealed class EntityStorageSystem : EntitySystem if (toAdd == container) return false; - if (TryComp(toAdd, out var phys)) + if (TryComp(toAdd, out var phys)) { if (component.MaxSize < phys.GetWorldAABB().Size.X || component.MaxSize < phys.GetWorldAABB().Size.Y) return false; diff --git a/Content.Server/Temperature/Components/TemperatureComponent.cs b/Content.Server/Temperature/Components/TemperatureComponent.cs index 1915c317b2..df81387d08 100644 --- a/Content.Server/Temperature/Components/TemperatureComponent.cs +++ b/Content.Server/Temperature/Components/TemperatureComponent.cs @@ -2,6 +2,7 @@ using Content.Shared.Atmos; using Content.Shared.Damage; using Content.Shared.FixedPoint; using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; namespace Content.Server.Temperature.Components { @@ -51,7 +52,7 @@ namespace Content.Server.Temperature.Components { get { - if (IoCManager.Resolve().TryGetComponent(Owner, out var physics) && physics.FixturesMass != 0) + if (IoCManager.Resolve().TryGetComponent(Owner, out var physics) && physics.FixturesMass != 0) { return SpecificHeat * physics.FixturesMass; } diff --git a/Content.Shared/Movement/Systems/SharedMoverController.cs b/Content.Shared/Movement/Systems/SharedMoverController.cs index 6773fe316f..66a716487d 100644 --- a/Content.Shared/Movement/Systems/SharedMoverController.cs +++ b/Content.Shared/Movement/Systems/SharedMoverController.cs @@ -363,7 +363,7 @@ namespace Content.Shared.Movement.Systems /// /// Used for weightlessness to determine if we are near a wall. /// - private bool IsAroundCollider(SharedPhysicsSystem broadPhaseSystem, TransformComponent transform, MobMoverComponent mover, IPhysBody collider) + private bool IsAroundCollider(SharedPhysicsSystem broadPhaseSystem, TransformComponent transform, MobMoverComponent mover, PhysicsComponent collider) { var enlargedAABB = collider.GetWorldAABB().Enlarged(mover.GrabRangeVV); diff --git a/Content.Shared/Pulling/Events/PullAttemptEvent.cs b/Content.Shared/Pulling/Events/PullAttemptEvent.cs index 3956637fca..6296dc2f14 100644 --- a/Content.Shared/Pulling/Events/PullAttemptEvent.cs +++ b/Content.Shared/Pulling/Events/PullAttemptEvent.cs @@ -1,10 +1,10 @@ -using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; namespace Content.Shared.Physics.Pull { public sealed class PullAttemptEvent : PullMessage { - public PullAttemptEvent(IPhysBody puller, IPhysBody pulled) : base(puller, pulled) { } + public PullAttemptEvent(PhysicsComponent puller, PhysicsComponent pulled) : base(puller, pulled) { } public bool Cancelled { get; set; } } diff --git a/Content.Shared/Pulling/Events/PullMessage.cs b/Content.Shared/Pulling/Events/PullMessage.cs index 422f2c20c1..24a8cdae56 100644 --- a/Content.Shared/Pulling/Events/PullMessage.cs +++ b/Content.Shared/Pulling/Events/PullMessage.cs @@ -1,13 +1,14 @@ using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; namespace Content.Shared.Physics.Pull { public abstract class PullMessage : EntityEventArgs { - public readonly IPhysBody Puller; - public readonly IPhysBody Pulled; + public readonly PhysicsComponent Puller; + public readonly PhysicsComponent Pulled; - protected PullMessage(IPhysBody puller, IPhysBody pulled) + protected PullMessage(PhysicsComponent puller, PhysicsComponent pulled) { Puller = puller; Pulled = pulled; diff --git a/Content.Shared/Pulling/Events/PullStartedMessage.cs b/Content.Shared/Pulling/Events/PullStartedMessage.cs index 30c7891eeb..0ede284bb0 100644 --- a/Content.Shared/Pulling/Events/PullStartedMessage.cs +++ b/Content.Shared/Pulling/Events/PullStartedMessage.cs @@ -1,10 +1,10 @@ -using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; namespace Content.Shared.Physics.Pull { public sealed class PullStartedMessage : PullMessage { - public PullStartedMessage(IPhysBody puller, IPhysBody pulled) : + public PullStartedMessage(PhysicsComponent puller, PhysicsComponent pulled) : base(puller, pulled) { } diff --git a/Content.Shared/Pulling/Events/PullStoppedMessage.cs b/Content.Shared/Pulling/Events/PullStoppedMessage.cs index d77873b7c1..afcbcb7074 100644 --- a/Content.Shared/Pulling/Events/PullStoppedMessage.cs +++ b/Content.Shared/Pulling/Events/PullStoppedMessage.cs @@ -1,10 +1,10 @@ -using Robust.Shared.Physics; +using Robust.Shared.Physics.Components; namespace Content.Shared.Physics.Pull { public sealed class PullStoppedMessage : PullMessage { - public PullStoppedMessage(IPhysBody puller, IPhysBody pulled) : base(puller, pulled) + public PullStoppedMessage(PhysicsComponent puller, PhysicsComponent pulled) : base(puller, pulled) { } } diff --git a/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs b/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs index 780bdc3263..6f624cb7a0 100644 --- a/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs +++ b/Content.Shared/Pulling/Systems/SharedPullingSystem.Actions.cs @@ -39,7 +39,7 @@ namespace Content.Shared.Pulling return false; } - if (!EntityManager.TryGetComponent(pulled, out var physics)) + if (!EntityManager.TryGetComponent(pulled, out var physics)) { return false; } diff --git a/Content.Shared/Throwing/ThrownItemSystem.cs b/Content.Shared/Throwing/ThrownItemSystem.cs index 3d2e3f0976..caf290084c 100644 --- a/Content.Shared/Throwing/ThrownItemSystem.cs +++ b/Content.Shared/Throwing/ThrownItemSystem.cs @@ -143,7 +143,7 @@ namespace Content.Shared.Throwing /// /// Raises collision events on the thrown and target entities. /// - public void ThrowCollideInteraction(EntityUid? user, IPhysBody thrown, IPhysBody target) + public void ThrowCollideInteraction(EntityUid? user, PhysicsComponent thrown, PhysicsComponent target) { if (user is not null) _adminLogger.Add(LogType.ThrowHit, LogImpact.Low,