Landing velocity threshold (#4606)

* landing threshold

* on bodystatus change

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
mirrorcult
2021-09-15 03:58:45 -07:00
committed by GitHub
parent 03260c2de7
commit 7cee263955
3 changed files with 16 additions and 32 deletions

View File

@@ -52,9 +52,10 @@ namespace Content.Server.Throwing
return; return;
} }
var comp = entity.EnsureComponent<ThrownItemComponent>();
if (entity.HasComponent<ItemComponent>()) if (entity.HasComponent<ItemComponent>())
{ {
entity.EnsureComponent<ThrownItemComponent>().Thrower = user; comp.Thrower = user;
// Give it a l'il spin. // Give it a l'il spin.
if (!entity.HasTag("NoSpinOnThrow")) if (!entity.HasTag("NoSpinOnThrow"))
{ {
@@ -87,6 +88,7 @@ namespace Content.Server.Throwing
{ {
if (physicsComponent.Deleted) return; if (physicsComponent.Deleted) return;
physicsComponent.BodyStatus = BodyStatus.OnGround; physicsComponent.BodyStatus = BodyStatus.OnGround;
EntitySystem.Get<ThrownItemSystem>().LandComponent(comp);
}); });
} }

View File

@@ -11,6 +11,12 @@ namespace Content.Shared.CCVar
* Ambience * 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> /// <summary>
/// How long we'll wait until re-sampling nearby objects for ambience. /// How long we'll wait until re-sampling nearby objects for ambience.
/// </summary> /// </summary>
@@ -225,13 +231,6 @@ namespace Content.Shared.CCVar
public static readonly CVarDef<bool> MobPushing = public static readonly CVarDef<bool> MobPushing =
CVarDef.Create("physics.mob_pushing", true, CVar.REPLICATED); 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 * Lobby music
*/ */

View File

@@ -1,9 +1,11 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Content.Shared.CCVar;
using Content.Shared.Collections; using Content.Shared.Collections;
using Content.Shared.Hands.Components; using Content.Shared.Hands.Components;
using Content.Shared.Physics; using Content.Shared.Physics;
using Content.Shared.Physics.Pull; using Content.Shared.Physics.Pull;
using Robust.Shared.Configuration;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
using Robust.Shared.IoC; using Robust.Shared.IoC;
@@ -19,6 +21,7 @@ namespace Content.Shared.Throwing
/// </summary> /// </summary>
public class ThrownItemSystem : EntitySystem public class ThrownItemSystem : EntitySystem
{ {
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly SharedBroadphaseSystem _broadphaseSystem = default!; [Dependency] private readonly SharedBroadphaseSystem _broadphaseSystem = default!;
private const string ThrowingFixture = "throw-fixture"; private const string ThrowingFixture = "throw-fixture";
@@ -33,27 +36,6 @@ namespace Content.Shared.Throwing
SubscribeLocalEvent<PullStartedMessage>(HandlePullStarted); 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) private void ThrowItem(EntityUid uid, ThrownItemComponent component, ThrownEvent args)
{ {
if (!component.Owner.TryGetComponent(out PhysicsComponent? physicsComponent) || if (!component.Owner.TryGetComponent(out PhysicsComponent? physicsComponent) ||
@@ -98,7 +80,7 @@ namespace Content.Shared.Throwing
LandComponent(thrownItem); LandComponent(thrownItem);
} }
private void LandComponent(ThrownItemComponent thrownItem) public void LandComponent(ThrownItemComponent thrownItem)
{ {
if (thrownItem.Owner.Deleted) return; if (thrownItem.Owner.Deleted) return;
@@ -125,7 +107,8 @@ namespace Content.Shared.Throwing
var coordinates = landing.Transform.Coordinates; var coordinates = landing.Transform.Coordinates;
var landMsg = new LandEvent(user, landing, coordinates); var landMsg = new LandEvent(user, landing, coordinates);
RaiseLocalEvent(landing.Uid, landMsg); RaiseLocalEvent(landing.Uid, landMsg, false);
ComponentManager.RemoveComponent(landing.Uid, thrownItem); ComponentManager.RemoveComponent(landing.Uid, thrownItem);
} }