diff --git a/Content.Server/Throwing/ThrowHelper.cs b/Content.Server/Throwing/ThrowHelper.cs index ae4ec3d96d..0d019be009 100644 --- a/Content.Server/Throwing/ThrowHelper.cs +++ b/Content.Server/Throwing/ThrowHelper.cs @@ -52,9 +52,10 @@ namespace Content.Server.Throwing return; } + var comp = entity.EnsureComponent(); if (entity.HasComponent()) { - entity.EnsureComponent().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().LandComponent(comp); }); } diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs index 8f19ee2b0b..2a9d7335d4 100644 --- a/Content.Shared/CCVar/CCVars.cs +++ b/Content.Shared/CCVar/CCVars.cs @@ -11,6 +11,12 @@ namespace Content.Shared.CCVar * Ambience */ + /// + /// Whether the basic 'hum' ambience will be enabled. + /// + public static readonly CVarDef AmbienceBasicEnabled = + CVarDef.Create("ambience.basic_enabled", true, CVar.ARCHIVE | CVar.CLIENTONLY); + /// /// How long we'll wait until re-sampling nearby objects for ambience. /// @@ -225,13 +231,6 @@ namespace Content.Shared.CCVar public static readonly CVarDef MobPushing = CVarDef.Create("physics.mob_pushing", true, CVar.REPLICATED); - /* - * Ambience - */ - - public static readonly CVarDef AmbienceBasicEnabled = - CVarDef.Create("ambience.basicenabled", true, CVar.ARCHIVE | CVar.CLIENTONLY); - /* * Lobby music */ diff --git a/Content.Shared/Throwing/ThrownItemSystem.cs b/Content.Shared/Throwing/ThrownItemSystem.cs index 8a3d645ae0..10f5dbf391 100644 --- a/Content.Shared/Throwing/ThrownItemSystem.cs +++ b/Content.Shared/Throwing/ThrownItemSystem.cs @@ -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 /// 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(HandlePullStarted); } - public override void Update(float frameTime) - { - base.Update(frameTime); - - var toRemove = new RemQueue(); - - // 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()) - { - 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); }