Skip to content

Commit

Permalink
Feex
Browse files Browse the repository at this point in the history
  • Loading branch information
Mnemotechnician committed Jan 17, 2024
1 parent f53ea0e commit d9b3512
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 11 additions & 1 deletion 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 @@ -163,14 +165,22 @@ 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) ||
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

0 comments on commit d9b3512

Please sign in to comment.