Add Check For Gravity On Thrown Items (#21647)

This commit is contained in:
Justin Pfeifler
2023-11-14 04:52:18 -06:00
committed by GitHub
parent ff7bce6e54
commit ec76958b51

View File

@@ -1,6 +1,7 @@
using System.Linq;
using Content.Shared.Administration.Logs;
using Content.Shared.Database;
using Content.Shared.Gravity;
using Content.Shared.Physics;
using Content.Shared.Physics.Pull;
using Robust.Shared.Physics;
@@ -21,6 +22,7 @@ namespace Content.Shared.Throwing
[Dependency] private readonly SharedBroadphaseSystem _broadphase = default!;
[Dependency] private readonly FixtureSystem _fixtures = default!;
[Dependency] private readonly SharedPhysicsSystem _physics = default!;
[Dependency] private readonly SharedGravitySystem _gravity = default!;
private const string ThrowingFixture = "throw-fixture";
@@ -111,13 +113,13 @@ namespace Content.Shared.Throwing
}
}
EntityManager.EventBus.RaiseLocalEvent(uid, new StopThrowEvent {User = thrownItemComponent.Thrower}, true);
EntityManager.EventBus.RaiseLocalEvent(uid, new StopThrowEvent { User = thrownItemComponent.Thrower }, true);
EntityManager.RemoveComponent<ThrownItemComponent>(uid);
}
public void LandComponent(EntityUid uid, ThrownItemComponent thrownItem, PhysicsComponent physics, bool playSound)
{
if (thrownItem.Landed || thrownItem.Deleted || Deleted(uid))
if (thrownItem.Landed || thrownItem.Deleted || _gravity.IsWeightless(uid) || Deleted(uid))
return;
thrownItem.Landed = true;