Content update for ECS physics (#13291)
This commit is contained in:
@@ -60,7 +60,7 @@ public sealed class ThrowingSystem : EntitySystem
|
||||
comp.Thrower = user;
|
||||
// Give it a l'il spin.
|
||||
if (!_tagSystem.HasTag(uid, "NoSpinOnThrow"))
|
||||
_physics.ApplyAngularImpulse(physics, ThrowAngularImpulse);
|
||||
_physics.ApplyAngularImpulse(uid, ThrowAngularImpulse, body: physics);
|
||||
else
|
||||
{
|
||||
if (transform == null)
|
||||
@@ -75,7 +75,7 @@ public sealed class ThrowingSystem : EntitySystem
|
||||
_interactionSystem.ThrownInteraction(user.Value, uid);
|
||||
|
||||
var impulseVector = direction.Normalized * strength * physics.Mass;
|
||||
_physics.ApplyLinearImpulse(physics, impulseVector);
|
||||
_physics.ApplyLinearImpulse(uid, impulseVector, body: physics);
|
||||
|
||||
// Estimate time to arrival so we can apply OnGround status and slow it much faster.
|
||||
var time = (direction / strength).Length;
|
||||
@@ -109,7 +109,7 @@ public sealed class ThrowingSystem : EntitySystem
|
||||
RaiseLocalEvent(physics.Owner, msg);
|
||||
|
||||
if (!msg.Cancelled)
|
||||
_physics.ApplyLinearImpulse(userPhysics, -impulseVector * pushbackRatio);
|
||||
_physics.ApplyLinearImpulse(user.Value, -impulseVector * pushbackRatio, body: userPhysics);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,19 +55,16 @@ namespace Content.Shared.Throwing
|
||||
|
||||
private void ThrowItem(EntityUid uid, ThrownItemComponent component, ThrownEvent args)
|
||||
{
|
||||
if (!EntityManager.TryGetComponent(component.Owner, out FixturesComponent? fixturesComponent) ||
|
||||
fixturesComponent.Fixtures.Count != 1) return;
|
||||
if (!EntityManager.TryGetComponent(component.Owner, out PhysicsComponent? physicsComponent)) return;
|
||||
|
||||
if (fixturesComponent.Fixtures.ContainsKey(ThrowingFixture))
|
||||
if (!EntityManager.TryGetComponent(uid, out FixturesComponent? fixturesComponent) ||
|
||||
fixturesComponent.Fixtures.Count != 1 ||
|
||||
!TryComp<PhysicsComponent>(uid, out var body))
|
||||
{
|
||||
Logger.Error($"Found existing throwing fixture on {component.Owner}");
|
||||
return;
|
||||
}
|
||||
|
||||
var fixture = fixturesComponent.Fixtures.Values.First();
|
||||
var shape = fixture.Shape;
|
||||
var throwingFixture = new Fixture(physicsComponent, shape) { CollisionMask = (int) CollisionGroup.ThrownItem, Hard = false, ID = ThrowingFixture };
|
||||
_fixtures.TryCreateFixture(physicsComponent, throwingFixture, manager: fixturesComponent);
|
||||
_fixtures.TryCreateFixture(uid, shape, ThrowingFixture, hard: false, collisionMask: (int) CollisionGroup.ThrownItem, manager: fixturesComponent, body: body);
|
||||
}
|
||||
|
||||
private void HandleCollision(EntityUid uid, ThrownItemComponent component, ref StartCollideEvent args)
|
||||
@@ -104,13 +101,13 @@ namespace Content.Shared.Throwing
|
||||
|
||||
private void StopThrow(EntityUid uid, ThrownItemComponent thrownItemComponent)
|
||||
{
|
||||
if (EntityManager.TryGetComponent(uid, out PhysicsComponent? physicsComponent))
|
||||
if (EntityManager.TryGetComponent(uid, out FixturesComponent? manager))
|
||||
{
|
||||
var fixture = _fixtures.GetFixtureOrNull(physicsComponent, ThrowingFixture);
|
||||
var fixture = _fixtures.GetFixtureOrNull(uid, ThrowingFixture, manager: manager);
|
||||
|
||||
if (fixture != null)
|
||||
{
|
||||
_fixtures.DestroyFixture(physicsComponent, fixture);
|
||||
_fixtures.DestroyFixture(uid, fixture, manager: manager);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user