Fixtures (again) (#5636)
This commit is contained in:
@@ -17,11 +17,11 @@ namespace Content.Shared.Throwing
|
||||
/// <summary>
|
||||
/// Handles throwing landing and collisions.
|
||||
/// </summary>
|
||||
public class ThrownItemSystem : EntitySystem
|
||||
public sealed class ThrownItemSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly SharedBroadphaseSystem _broadphaseSystem = default!;
|
||||
[Dependency] private readonly SharedContainerSystem _containerSystem = default!;
|
||||
[Dependency] private readonly SharedAdminLogSystem _adminLogSystem = default!;
|
||||
[Dependency] private readonly FixtureSystem _fixtures = default!;
|
||||
|
||||
private const string ThrowingFixture = "throw-fixture";
|
||||
|
||||
@@ -56,14 +56,14 @@ namespace Content.Shared.Throwing
|
||||
if (!component.Owner.TryGetComponent(out PhysicsComponent? physicsComponent) ||
|
||||
physicsComponent.Fixtures.Count != 1) return;
|
||||
|
||||
if (physicsComponent.GetFixture(ThrowingFixture) != null)
|
||||
if (_fixtures.GetFixtureOrNull(physicsComponent, ThrowingFixture) != null)
|
||||
{
|
||||
Logger.Error($"Found existing throwing fixture on {component.Owner}");
|
||||
return;
|
||||
}
|
||||
|
||||
var shape = physicsComponent.Fixtures[0].Shape;
|
||||
_broadphaseSystem.CreateFixture(physicsComponent, new Fixture(physicsComponent, shape) {CollisionLayer = (int) CollisionGroup.ThrownItem, Hard = false, ID = ThrowingFixture});
|
||||
_fixtures.CreateFixture(physicsComponent, new Fixture(physicsComponent, shape) {CollisionLayer = (int) CollisionGroup.ThrownItem, Hard = false, ID = ThrowingFixture});
|
||||
}
|
||||
|
||||
private void HandleCollision(EntityUid uid, ThrownItemComponent component, StartCollideEvent args)
|
||||
@@ -99,11 +99,11 @@ namespace Content.Shared.Throwing
|
||||
{
|
||||
if (EntityManager.TryGetComponent(uid, out PhysicsComponent? physicsComponent))
|
||||
{
|
||||
var fixture = physicsComponent.GetFixture(ThrowingFixture);
|
||||
var fixture = _fixtures.GetFixtureOrNull(physicsComponent, ThrowingFixture);
|
||||
|
||||
if (fixture != null)
|
||||
{
|
||||
_broadphaseSystem.DestroyFixture(physicsComponent, fixture);
|
||||
_fixtures.DestroyFixture(physicsComponent, fixture);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user