Landing velocity threshold (#4606)
* landing threshold * on bodystatus change Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -52,9 +52,10 @@ namespace Content.Server.Throwing
|
||||
return;
|
||||
}
|
||||
|
||||
var comp = entity.EnsureComponent<ThrownItemComponent>();
|
||||
if (entity.HasComponent<ItemComponent>())
|
||||
{
|
||||
entity.EnsureComponent<ThrownItemComponent>().Thrower = user;
|
||||
comp.Thrower = user;
|
||||
// Give it a l'il spin.
|
||||
if (!entity.HasTag("NoSpinOnThrow"))
|
||||
{
|
||||
@@ -71,7 +72,7 @@ namespace Content.Server.Throwing
|
||||
|
||||
var impulseVector = direction.Normalized * strength * physicsComponent.Mass;
|
||||
physicsComponent.ApplyLinearImpulse(impulseVector);
|
||||
|
||||
|
||||
// Estimate time to arrival so we can apply OnGround status and slow it much faster.
|
||||
var time = (direction / strength).Length;
|
||||
|
||||
@@ -87,6 +88,7 @@ namespace Content.Server.Throwing
|
||||
{
|
||||
if (physicsComponent.Deleted) return;
|
||||
physicsComponent.BodyStatus = BodyStatus.OnGround;
|
||||
EntitySystem.Get<ThrownItemSystem>().LandComponent(comp);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,12 @@ namespace Content.Shared.CCVar
|
||||
* Ambience
|
||||
*/
|
||||
|
||||
/// <summary>
|
||||
/// Whether the basic 'hum' ambience will be enabled.
|
||||
/// </summary>
|
||||
public static readonly CVarDef<bool> AmbienceBasicEnabled =
|
||||
CVarDef.Create("ambience.basic_enabled", true, CVar.ARCHIVE | CVar.CLIENTONLY);
|
||||
|
||||
/// <summary>
|
||||
/// How long we'll wait until re-sampling nearby objects for ambience.
|
||||
/// </summary>
|
||||
@@ -225,13 +231,6 @@ namespace Content.Shared.CCVar
|
||||
public static readonly CVarDef<bool> MobPushing =
|
||||
CVarDef.Create("physics.mob_pushing", true, CVar.REPLICATED);
|
||||
|
||||
/*
|
||||
* Ambience
|
||||
*/
|
||||
|
||||
public static readonly CVarDef<bool> AmbienceBasicEnabled =
|
||||
CVarDef.Create("ambience.basicenabled", true, CVar.ARCHIVE | CVar.CLIENTONLY);
|
||||
|
||||
/*
|
||||
* Lobby music
|
||||
*/
|
||||
|
||||
@@ -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