Remove IPhysBody (#13297)

This commit is contained in:
metalgearsloth
2023-01-03 17:45:18 +11:00
committed by GitHub
parent 99eab08b6d
commit ab07944af8
18 changed files with 36 additions and 26 deletions

View File

@@ -9,6 +9,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Maths; using Robust.Shared.Maths;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
namespace Content.Client.Suspicion namespace Content.Client.Suspicion
{ {
@@ -52,7 +53,7 @@ namespace Content.Client.Suspicion
continue; continue;
} }
if (!_entityManager.TryGetComponent(ally, out IPhysBody? physics)) if (!_entityManager.TryGetComponent(ally, out PhysicsComponent? physics))
{ {
continue; continue;
} }

View File

@@ -7,6 +7,7 @@ using NUnit.Framework;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
namespace Content.IntegrationTests.Tests.Doors namespace Content.IntegrationTests.Tests.Doors
{ {
@@ -114,7 +115,7 @@ namespace Content.IntegrationTests.Tests.Doors
var mapManager = server.ResolveDependency<IMapManager>(); var mapManager = server.ResolveDependency<IMapManager>();
var entityManager = server.ResolveDependency<IEntityManager>(); var entityManager = server.ResolveDependency<IEntityManager>();
IPhysBody physBody = null; PhysicsComponent physBody = null;
EntityUid physicsDummy = default; EntityUid physicsDummy = default;
EntityUid airlock = default; EntityUid airlock = default;
DoorComponent doorComponent = null; DoorComponent doorComponent = null;
@@ -145,7 +146,7 @@ namespace Content.IntegrationTests.Tests.Doors
for (var i = 0; i < 240; i += 10) for (var i = 0; i < 240; i += 10)
{ {
// Keep the airlock awake so they collide // Keep the airlock awake so they collide
await server.WaitPost(() => entityManager.GetComponent<IPhysBody>(airlock).WakeBody()); await server.WaitPost(() => entityManager.GetComponent<PhysicsComponent>(airlock).WakeBody());
await server.WaitRunTicks(10); await server.WaitRunTicks(10);
await server.WaitIdleAsync(); await server.WaitIdleAsync();

View File

@@ -59,7 +59,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Movement
// // Now let's make the player enter a climbing transitioning state. // // Now let's make the player enter a climbing transitioning state.
// climbing.IsClimbing = true; // climbing.IsClimbing = true;
// EntitySystem.Get<ClimbSystem>().MoveEntityToward(human, table, climbing:climbing); // EntitySystem.Get<ClimbSystem>().MoveEntityToward(human, table, climbing:climbing);
// var body = entityManager.GetComponent<IPhysBody>(human); // var body = entityManager.GetComponent<PhysicsComponent>(human);
// // TODO: Check it's climbing // // TODO: Check it's climbing
// //
// // Force the player out of climb state. It should immediately remove the ClimbController. // // Force the player out of climb state. It should immediately remove the ClimbController.

View File

@@ -9,6 +9,7 @@ using Content.Shared.Maps;
using Content.Shared.MobState.Components; using Content.Shared.MobState.Components;
using Robust.Shared.Player; using Robust.Shared.Player;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Timing; using Robust.Shared.Timing;
namespace Content.Server.Abilities.Mime namespace Content.Server.Abilities.Mime
@@ -74,7 +75,7 @@ namespace Content.Server.Abilities.Mime
// Check there are no walls or mobs there // Check there are no walls or mobs there
foreach (var entity in coords.GetEntitiesInTile()) 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<MobStateComponent>(entity) && entity != uid) || // Is it a mob? if ((HasComp<MobStateComponent>(entity) && entity != uid) || // Is it a mob?
((Resolve(entity, ref physics, false) && (physics.CollisionLayer & (int) CollisionGroup.Impassable) != 0) // Is it impassable? ((Resolve(entity, ref physics, false) && (physics.CollisionLayer & (int) CollisionGroup.Impassable) != 0) // Is it impassable?
&& !(TryComp<DoorComponent>(entity, out var door) && door.State != DoorState.Closed))) // Is it a door that's open and so not actually impassable? && !(TryComp<DoorComponent>(entity, out var door) && door.State != DoorState.Closed))) // Is it a door that's open and so not actually impassable?

View File

@@ -8,6 +8,7 @@ using Robust.Shared.Console;
using Robust.Shared.Enums; using Robust.Shared.Enums;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
namespace Content.Server.Administration.Commands namespace Content.Server.Administration.Commands
{ {
@@ -121,7 +122,7 @@ namespace Content.Server.Administration.Commands
var xform = entMan.GetComponent<TransformComponent>(playerEntity); var xform = entMan.GetComponent<TransformComponent>(playerEntity);
xform.Coordinates = coords; xform.Coordinates = coords;
xform.AttachToGridOrMap(); xform.AttachToGridOrMap();
if (entMan.TryGetComponent(playerEntity, out IPhysBody? physics)) if (entMan.TryGetComponent(playerEntity, out PhysicsComponent? physics))
{ {
physics.LinearVelocity = Vector2.Zero; physics.LinearVelocity = Vector2.Zero;
} }

View File

@@ -274,7 +274,7 @@ namespace Content.Server.Atmos.EntitySystems
_timer -= UpdateTime; _timer -= UpdateTime;
// TODO: This needs cleanup to take off the crust from TemperatureComponent and shit. // TODO: This needs cleanup to take off the crust from TemperatureComponent and shit.
foreach (var (flammable, physics, transform) in EntityManager.EntityQuery<FlammableComponent, IPhysBody, TransformComponent>()) foreach (var (flammable, physics, transform) in EntityManager.EntityQuery<FlammableComponent, PhysicsComponent, TransformComponent>())
{ {
var uid = flammable.Owner; var uid = flammable.Owner;
@@ -335,7 +335,7 @@ namespace Content.Server.Atmos.EntitySystems
continue; continue;
} }
var otherPhysics = EntityManager.GetComponent<IPhysBody>(uid); var otherPhysics = EntityManager.GetComponent<PhysicsComponent>(uid);
// TODO: Sloth, please save our souls! // TODO: Sloth, please save our souls!
if (!physics.GetWorldAABB().Intersects(otherPhysics.GetWorldAABB())) if (!physics.GetWorldAABB().Intersects(otherPhysics.GetWorldAABB()))

View File

@@ -4,6 +4,7 @@ using Content.Server.UserInterface;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player; using Robust.Shared.Player;
using static Content.Shared.Disposal.Components.SharedDisposalRouterComponent; using static Content.Shared.Disposal.Components.SharedDisposalRouterComponent;
@@ -23,7 +24,7 @@ namespace Content.Server.Disposal.Tube.Components
[ViewVariables] [ViewVariables]
public bool Anchored => public bool Anchored =>
!_entMan.TryGetComponent(Owner, out IPhysBody? physics) || !_entMan.TryGetComponent(Owner, out PhysicsComponent? physics) ||
physics.BodyType == BodyType.Static; physics.BodyType == BodyType.Static;
[ViewVariables] public BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalRouterUiKey.Key); [ViewVariables] public BoundUserInterface? UserInterface => Owner.GetUIOrNull(DisposalRouterUiKey.Key);

View File

@@ -4,6 +4,7 @@ using Content.Shared.Body.Components;
using Content.Shared.Item; using Content.Shared.Item;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
namespace Content.Server.Disposal.Unit.Components namespace Content.Server.Disposal.Unit.Components
{ {
@@ -82,7 +83,7 @@ namespace Content.Server.Disposal.Unit.Components
return false; return false;
} }
if (_entMan.TryGetComponent(entity, out IPhysBody? physics)) if (_entMan.TryGetComponent(entity, out PhysicsComponent? physics))
{ {
physics.CanCollide = false; physics.CanCollide = false;
} }

View File

@@ -2,6 +2,7 @@ using Content.Shared.Popups;
using Content.Shared.Rotatable; using Content.Shared.Rotatable;
using Content.Shared.Verbs; using Content.Shared.Verbs;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
namespace Content.Server.Rotatable 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. // Check if the object is anchored, and whether we are still allowed to rotate it.
if (!component.RotateWhileAnchored && if (!component.RotateWhileAnchored &&
EntityManager.TryGetComponent(component.Owner, out IPhysBody? physics) && EntityManager.TryGetComponent(component.Owner, out PhysicsComponent? physics) &&
physics.BodyType == BodyType.Static) physics.BodyType == BodyType.Static)
return; return;
@@ -82,7 +83,7 @@ namespace Content.Server.Rotatable
/// </summary> /// </summary>
public void TryFlip(FlippableComponent component, EntityUid user) 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) physics.BodyType == BodyType.Static)
{ {
component.Owner.PopupMessage(user, Loc.GetString("flippable-component-try-flip-is-stuck")); component.Owner.PopupMessage(user, Loc.GetString("flippable-component-try-flip-is-stuck"));

View File

@@ -18,6 +18,7 @@ using Robust.Server.Containers;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
using Robust.Shared.Player; using Robust.Shared.Player;
namespace Content.Server.Storage.EntitySystems; namespace Content.Server.Storage.EntitySystems;
@@ -320,7 +321,7 @@ public sealed class EntityStorageSystem : EntitySystem
if (toAdd == container) if (toAdd == container)
return false; return false;
if (TryComp<IPhysBody>(toAdd, out var phys)) if (TryComp<PhysicsComponent>(toAdd, out var phys))
{ {
if (component.MaxSize < phys.GetWorldAABB().Size.X || component.MaxSize < phys.GetWorldAABB().Size.Y) if (component.MaxSize < phys.GetWorldAABB().Size.X || component.MaxSize < phys.GetWorldAABB().Size.Y)
return false; return false;

View File

@@ -2,6 +2,7 @@ using Content.Shared.Atmos;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.FixedPoint; using Content.Shared.FixedPoint;
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
namespace Content.Server.Temperature.Components namespace Content.Server.Temperature.Components
{ {
@@ -51,7 +52,7 @@ namespace Content.Server.Temperature.Components
{ {
get get
{ {
if (IoCManager.Resolve<IEntityManager>().TryGetComponent<IPhysBody?>(Owner, out var physics) && physics.FixturesMass != 0) if (IoCManager.Resolve<IEntityManager>().TryGetComponent<PhysicsComponent?>(Owner, out var physics) && physics.FixturesMass != 0)
{ {
return SpecificHeat * physics.FixturesMass; return SpecificHeat * physics.FixturesMass;
} }

View File

@@ -363,7 +363,7 @@ namespace Content.Shared.Movement.Systems
/// <summary> /// <summary>
/// Used for weightlessness to determine if we are near a wall. /// Used for weightlessness to determine if we are near a wall.
/// </summary> /// </summary>
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); var enlargedAABB = collider.GetWorldAABB().Enlarged(mover.GrabRangeVV);

View File

@@ -1,10 +1,10 @@
using Robust.Shared.Physics; using Robust.Shared.Physics.Components;
namespace Content.Shared.Physics.Pull namespace Content.Shared.Physics.Pull
{ {
public sealed class PullAttemptEvent : PullMessage 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; } public bool Cancelled { get; set; }
} }

View File

@@ -1,13 +1,14 @@
using Robust.Shared.Physics; using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
namespace Content.Shared.Physics.Pull namespace Content.Shared.Physics.Pull
{ {
public abstract class PullMessage : EntityEventArgs public abstract class PullMessage : EntityEventArgs
{ {
public readonly IPhysBody Puller; public readonly PhysicsComponent Puller;
public readonly IPhysBody Pulled; public readonly PhysicsComponent Pulled;
protected PullMessage(IPhysBody puller, IPhysBody pulled) protected PullMessage(PhysicsComponent puller, PhysicsComponent pulled)
{ {
Puller = puller; Puller = puller;
Pulled = pulled; Pulled = pulled;

View File

@@ -1,10 +1,10 @@
using Robust.Shared.Physics; using Robust.Shared.Physics.Components;
namespace Content.Shared.Physics.Pull namespace Content.Shared.Physics.Pull
{ {
public sealed class PullStartedMessage : PullMessage public sealed class PullStartedMessage : PullMessage
{ {
public PullStartedMessage(IPhysBody puller, IPhysBody pulled) : public PullStartedMessage(PhysicsComponent puller, PhysicsComponent pulled) :
base(puller, pulled) base(puller, pulled)
{ {
} }

View File

@@ -1,10 +1,10 @@
using Robust.Shared.Physics; using Robust.Shared.Physics.Components;
namespace Content.Shared.Physics.Pull namespace Content.Shared.Physics.Pull
{ {
public sealed class PullStoppedMessage : PullMessage public sealed class PullStoppedMessage : PullMessage
{ {
public PullStoppedMessage(IPhysBody puller, IPhysBody pulled) : base(puller, pulled) public PullStoppedMessage(PhysicsComponent puller, PhysicsComponent pulled) : base(puller, pulled)
{ {
} }
} }

View File

@@ -39,7 +39,7 @@ namespace Content.Shared.Pulling
return false; return false;
} }
if (!EntityManager.TryGetComponent<IPhysBody>(pulled, out var physics)) if (!EntityManager.TryGetComponent<PhysicsComponent>(pulled, out var physics))
{ {
return false; return false;
} }

View File

@@ -143,7 +143,7 @@ namespace Content.Shared.Throwing
/// <summary> /// <summary>
/// Raises collision events on the thrown and target entities. /// Raises collision events on the thrown and target entities.
/// </summary> /// </summary>
public void ThrowCollideInteraction(EntityUid? user, IPhysBody thrown, IPhysBody target) public void ThrowCollideInteraction(EntityUid? user, PhysicsComponent thrown, PhysicsComponent target)
{ {
if (user is not null) if (user is not null)
_adminLogger.Add(LogType.ThrowHit, LogImpact.Low, _adminLogger.Add(LogType.ThrowHit, LogImpact.Low,