Landing velocity threshold (#4606)
* landing threshold * on bodystatus change Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Collections;
|
||||
using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Physics.Pull;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -19,6 +21,7 @@ namespace Content.Shared.Throwing
|
||||
/// </summary>
|
||||
public class ThrownItemSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly SharedBroadphaseSystem _broadphaseSystem = default!;
|
||||
|
||||
private const string ThrowingFixture = "throw-fixture";
|
||||
@@ -33,27 +36,6 @@ namespace Content.Shared.Throwing
|
||||
SubscribeLocalEvent<PullStartedMessage>(HandlePullStarted);
|
||||
}
|
||||
|
||||
public override void Update(float frameTime)
|
||||
{
|
||||
base.Update(frameTime);
|
||||
|
||||
var toRemove = new RemQueue<ThrownItemComponent>();
|
||||
|
||||
// We can't just use sleeping unfortunately because there's a delay of the sleep timer. ThrownItemComponent
|
||||
// is transient while the entity is thrown so this shouldn't be too bad.
|
||||
foreach (var (thrown, physics) in ComponentManager.EntityQuery<ThrownItemComponent, PhysicsComponent>())
|
||||
{
|
||||
if (!physics.LinearVelocity.Equals(Vector2.Zero)) continue;
|
||||
toRemove.Add(thrown);
|
||||
}
|
||||
|
||||
foreach (var comp in toRemove)
|
||||
{
|
||||
if (comp.Deleted) continue;
|
||||
LandComponent(comp);
|
||||
}
|
||||
}
|
||||
|
||||
private void ThrowItem(EntityUid uid, ThrownItemComponent component, ThrownEvent args)
|
||||
{
|
||||
if (!component.Owner.TryGetComponent(out PhysicsComponent? physicsComponent) ||
|
||||
@@ -98,7 +80,7 @@ namespace Content.Shared.Throwing
|
||||
LandComponent(thrownItem);
|
||||
}
|
||||
|
||||
private void LandComponent(ThrownItemComponent thrownItem)
|
||||
public void LandComponent(ThrownItemComponent thrownItem)
|
||||
{
|
||||
if (thrownItem.Owner.Deleted) return;
|
||||
|
||||
@@ -125,7 +107,8 @@ namespace Content.Shared.Throwing
|
||||
var coordinates = landing.Transform.Coordinates;
|
||||
|
||||
var landMsg = new LandEvent(user, landing, coordinates);
|
||||
RaiseLocalEvent(landing.Uid, landMsg);
|
||||
RaiseLocalEvent(landing.Uid, landMsg, false);
|
||||
|
||||
ComponentManager.RemoveComponent(landing.Uid, thrownItem);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user