From d9b3512fa3bbac204e20537b0ca26ecc8e30f8ad Mon Sep 17 00:00:00 2001 From: fox Date: Wed, 17 Jan 2024 17:19:51 +0300 Subject: [PATCH] Feex --- Content.Server/Hands/Systems/HandsSystem.cs | 12 +++++++++++- Content.Shared/Hands/Components/HandsComponent.cs | 6 ++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Content.Server/Hands/Systems/HandsSystem.cs b/Content.Server/Hands/Systems/HandsSystem.cs index e3e66995373..cb5a9f421f4 100644 --- a/Content.Server/Hands/Systems/HandsSystem.cs +++ b/Content.Server/Hands/Systems/HandsSystem.cs @@ -23,6 +23,7 @@ using Robust.Shared.Input.Binding; using Robust.Shared.Map; using Robust.Shared.Player; +using Robust.Shared.Timing; using Robust.Shared.Utility; namespace Content.Server.Hands.Systems @@ -39,6 +40,7 @@ public sealed class HandsSystem : SharedHandsSystem [Dependency] private readonly PullingSystem _pullingSystem = default!; [Dependency] private readonly ThrowingSystem _throwingSystem = default!; [Dependency] private readonly StorageSystem _storageSystem = default!; + [Dependency] private readonly IGameTiming _timing = default!; // Frontier public override void Initialize() { @@ -163,7 +165,7 @@ private bool HandleThrowItem(ICommonSession? playerSession, EntityCoordinates co if (playerSession == null) return false; - if (playerSession.AttachedEntity is not {Valid: true} player || + if (playerSession.AttachedEntity is not { Valid: true } player || !Exists(player) || ContainerSystem.IsEntityInContainer(player) || !TryComp(player, out HandsComponent? hands) || @@ -171,6 +173,14 @@ hands.ActiveHandEntity is not { } throwEnt || !_actionBlockerSystem.CanThrow(player, throwEnt)) return false; + // Frontier: limit amount of items thrown per second + if (hands.NextThrowAfter > _timing.CurTime) + { + hands.NextThrowAfter = _timing.CurTime + TimeSpan.FromSeconds(0.67); // Punishment + return false; + } + hands.NextThrowAfter = _timing.CurTime + TimeSpan.FromSeconds(0.25); // Up to 4 throws per second. + if (EntityManager.TryGetComponent(throwEnt, out StackComponent? stack) && stack.Count > 1 && stack.ThrowIndividually) { var splitStack = _stackSystem.Split(throwEnt, 1, EntityManager.GetComponent(player).Coordinates, stack); diff --git a/Content.Shared/Hands/Components/HandsComponent.cs b/Content.Shared/Hands/Components/HandsComponent.cs index 0bece1d141a..d5d1a73d807 100644 --- a/Content.Shared/Hands/Components/HandsComponent.cs +++ b/Content.Shared/Hands/Components/HandsComponent.cs @@ -57,6 +57,12 @@ public sealed partial class HandsComponent : Component /// Used by the client. /// public readonly Dictionary> RevealedLayers = new(); + + // Frontier + /// + /// The moment in time until which another item cannot be thrown. + /// + public TimeSpan NextThrowAfter; } [Serializable, NetSerializable]