diff --git a/Robust.Client/Debugging/DebugPhysicsSystem.cs b/Robust.Client/Debugging/DebugPhysicsSystem.cs index ab8734fc5..2ae323253 100644 --- a/Robust.Client/Debugging/DebugPhysicsSystem.cs +++ b/Robust.Client/Debugging/DebugPhysicsSystem.cs @@ -207,7 +207,7 @@ namespace Robust.Client.Debugging const float AlphaModifier = 0.2f; - foreach (var fixture in physBody.Fixtures) + foreach (var fixture in _entityManager.GetComponent(physBody.Owner).Fixtures.Values) { // Invalid shape - Box2D doesn't check for IsSensor if (physBody.BodyType == BodyType.Dynamic && fixture.Mass == 0f) @@ -274,7 +274,7 @@ namespace Robust.Client.Debugging const float AlphaModifier = 0.2f; Box2? aabb = null; - foreach (var fixture in physBody.Fixtures) + foreach (var fixture in _entityManager.GetComponent(physBody.Owner).Fixtures.Values) { for (var i = 0; i < fixture.Shape.ChildCount; i++) { diff --git a/Robust.Server/Console/Commands/TestbedCommand.cs b/Robust.Server/Console/Commands/TestbedCommand.cs index f9d738f15..16f942927 100644 --- a/Robust.Server/Console/Commands/TestbedCommand.cs +++ b/Robust.Server/Console/Commands/TestbedCommand.cs @@ -319,24 +319,19 @@ namespace Robust.Server.Console.Commands // TODO: Box2D just derefs, bleh shape structs someday var shape1 = new PolygonShape(); shape1.SetAsBox(0.5f, 10.0f, new Vector2(10.0f, 0.0f), 0.0f); - broadphaseSystem.CreateFixture(body, shape1, 20.0f); + broadphaseSystem.CreateFixture(body, shape1, 20.0f, 2, 0); var shape2 = new PolygonShape(); shape2.SetAsBox(0.5f, 10.0f, new Vector2(-10.0f, 0.0f), 0f); - broadphaseSystem.CreateFixture(body, shape2, 20.0f); + broadphaseSystem.CreateFixture(body, shape2, 20.0f, 2, 0); var shape3 = new PolygonShape(); shape3.SetAsBox(10.0f, 0.5f, new Vector2(0.0f, 10.0f), 0f); - broadphaseSystem.CreateFixture(body, shape3, 20.0f); + broadphaseSystem.CreateFixture(body, shape3, 20.0f, 2, 0); var shape4 = new PolygonShape(); shape4.SetAsBox(10.0f, 0.5f, new Vector2(0.0f, -10.0f), 0f); - broadphaseSystem.CreateFixture(body, shape4, 20.0f); - - foreach (var fixture in body.Fixtures) - { - fixture.CollisionLayer = 2; - } + broadphaseSystem.CreateFixture(body, shape4, 20.0f, 2, 0); var revolute = EntitySystem.Get().CreateRevoluteJoint(groundUid, bodyUid); revolute.LocalAnchorA = new Vector2(0f, 10f); @@ -363,9 +358,7 @@ namespace Robust.Server.Console.Commands box.FixedRotation = false; var shape = new PolygonShape(); shape.SetAsBox(0.125f, 0.125f); - broadphaseSystem.CreateFixture(box, shape, 0.0625f); - box.Fixtures[0].CollisionMask = 2; - box.Fixtures[0].CollisionLayer = 2; + broadphaseSystem.CreateFixture(box, shape, 0.0625f, 2, 2); }); } } diff --git a/Robust.Server/ServerStatus/StatusHost.cs b/Robust.Server/ServerStatus/StatusHost.cs index d8095191d..fafa654f7 100644 --- a/Robust.Server/ServerStatus/StatusHost.cs +++ b/Robust.Server/ServerStatus/StatusHost.cs @@ -79,10 +79,13 @@ namespace Robust.Server.ServerStatus public event Action? OnInfoRequest; + // TODO: Remove at some point in the future +#pragma warning disable CS0618 // Uses the obsolete StatusHostHandler. Exists for backwards compatibility public void AddHandler(StatusHostHandler handler) { _handlers.Add((ctx) => Task.FromResult(handler(ctx))); } +#pragma warning restore CS0618 public void AddHandler(StatusHostHandlerAsync handler) { diff --git a/Robust.Shared/GameObjects/Components/Collidable/PhysicsComponent.Physics.cs b/Robust.Shared/GameObjects/Components/Collidable/PhysicsComponent.Physics.cs index a0d835193..6edc820b7 100644 --- a/Robust.Shared/GameObjects/Components/Collidable/PhysicsComponent.Physics.cs +++ b/Robust.Shared/GameObjects/Components/Collidable/PhysicsComponent.Physics.cs @@ -306,7 +306,7 @@ namespace Robust.Shared.GameObjects var bounds = new Box2(transform.Position, transform.Position); - foreach (var fixture in Fixtures) + foreach (var fixture in _entMan.GetComponent(Owner).Fixtures.Values) { for (var i = 0; i < fixture.Shape.ChildCount; i++) { diff --git a/Robust.Shared/GameObjects/EntityManager.Components.cs b/Robust.Shared/GameObjects/EntityManager.Components.cs index c5eed7e24..2c6a3098e 100644 --- a/Robust.Shared/GameObjects/EntityManager.Components.cs +++ b/Robust.Shared/GameObjects/EntityManager.Components.cs @@ -293,7 +293,7 @@ namespace Robust.Shared.GameObjects { if (component == null) throw new ArgumentNullException(nameof(component)); - if (component.Owner == null || component.Owner != uid) + if (component.Owner != uid) throw new InvalidOperationException("Component is not owned by entity."); RemoveComponentImmediate((Component)component, uid, false); diff --git a/Robust.Shared/Physics/FixtureSystem.cs b/Robust.Shared/Physics/FixtureSystem.cs index 7158b1429..4e2a60685 100644 --- a/Robust.Shared/Physics/FixtureSystem.cs +++ b/Robust.Shared/Physics/FixtureSystem.cs @@ -146,6 +146,20 @@ namespace Robust.Shared.Physics CreateFixture(body, fixture); } + /// + /// Creates a from this shape and adds it to the specified with mass. + /// + public void CreateFixture(PhysicsComponent body, IPhysShape shape, float mass, int collisionLayer, int collisionMask) + { + // TODO: Make it take in density instead? + var fixture = new Fixture(body, shape) { + Mass = mass, + CollisionLayer = collisionLayer, + CollisionMask = collisionMask + }; + CreateFixture(body, fixture); + } + /// /// Attempts to get the with the specified ID for this body. /// diff --git a/Robust.Shared/Physics/SharedBroadphaseSystem.cs b/Robust.Shared/Physics/SharedBroadphaseSystem.cs index d4220a319..0216ee1e8 100644 --- a/Robust.Shared/Physics/SharedBroadphaseSystem.cs +++ b/Robust.Shared/Physics/SharedBroadphaseSystem.cs @@ -485,7 +485,7 @@ namespace Robust.Shared.Physics { var mapId = EntityManager.GetComponent(body.Owner).MapID; - foreach (var fixture in body.Fixtures) + foreach (var fixture in EntityManager.GetComponent(body.Owner).Fixtures.Values) { TouchProxies(mapId, broadphase, fixture); } diff --git a/Robust.UnitTesting/TestingModLoader.cs b/Robust.UnitTesting/TestingModLoader.cs index 4833f5cb2..58f626c4f 100644 --- a/Robust.UnitTesting/TestingModLoader.cs +++ b/Robust.UnitTesting/TestingModLoader.cs @@ -51,7 +51,8 @@ namespace Robust.UnitTesting { // Only used for ILVerify, not necessary. } - +#pragma warning disable CS0067 // Needed by interface public event ExtraModuleLoad? ExtraModuleLoaders; +#pragma warning restore CS0067 } }