Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix instant glass throwing #889

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Content.Server/Hands/Systems/HandsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
{
Expand Down Expand Up @@ -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<TransformComponent>(player).Coordinates, stack);
Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/Hands/Components/HandsComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public sealed partial class HandsComponent : Component
/// Used by the client.
/// </summary>
public readonly Dictionary<HandLocation, HashSet<string>> RevealedLayers = new();

// Frontier
/// <summary>
/// The moment in time until which another item cannot be thrown.
/// </summary>
public TimeSpan NextThrowAfter;
}

[Serializable, NetSerializable]
Expand Down
Loading