Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SlamBamActionman committed Feb 5, 2025
1 parent fdb1447 commit 51d4e3e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
20 changes: 0 additions & 20 deletions Content.Server/Hands/Systems/HandsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
using Content.Shared.Movement.Pulling.Systems;
using Content.Shared.Stacks;
using Content.Shared.Throwing;
using Content.Shared.Weapons.Melee;
using Content.Shared.Weapons.Melee.Events;
using Robust.Shared.GameStates;
using Robust.Shared.Input.Binding;
using Robust.Shared.Map;
Expand Down Expand Up @@ -55,8 +53,6 @@ public override void Initialize()

SubscribeLocalEvent<HandsComponent, BeforeExplodeEvent>(OnExploded);

SubscribeLocalEvent<HandsComponent, MeleeAttackEvent>(OnMeleeAttack);

CommandBinds.Builder
.Bind(ContentKeyFunctions.ThrowItemInHand, new PointerInputCmdHandler(HandleThrowItem))
.Register<HandsSystem>();
Expand Down Expand Up @@ -232,22 +228,6 @@ hands.ActiveHandEntity is not { } throwEnt ||
return true;
}

/// <summary>
/// Fires when a melee weapon is swung and delays the throw timer.
/// Makes an exception for when the entity is the weapon itself, i.e. unarmed attacks.
/// </summary>
private void OnMeleeAttack(Entity<HandsComponent> ent, ref MeleeAttackEvent args)
{
if (ent.Owner == args.Weapon)
return;

if (!TryComp<MeleeWeaponComponent>(args.Weapon, out var melee))
return;

if (ent.Comp.NextThrowTime < melee.NextAttack)
ent.Comp.NextThrowTime = melee.NextAttack;
}

#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
using Content.Shared.Interaction;
using Content.Shared.Inventory.VirtualItem;
using Content.Shared.Localizations;
using Content.Shared.Weapons.Melee;
using Content.Shared.Weapons.Melee.Events;
using Robust.Shared.Input.Binding;
using Robust.Shared.Map;
using Robust.Shared.Player;
Expand All @@ -26,6 +28,7 @@ private void InitializeInteractions()

SubscribeLocalEvent<HandsComponent, GetUsedEntityEvent>(OnGetUsedEntity);
SubscribeLocalEvent<HandsComponent, ExaminedEvent>(HandleExamined);
SubscribeLocalEvent<HandsComponent, MeleeAttackEvent>(OnMeleeAttack);

CommandBinds.Builder
.Bind(ContentKeyFunctions.UseItemInHand, InputCmdHandler.FromDelegate(HandleUseItem, handle: false, outsidePrediction: false))
Expand Down Expand Up @@ -213,4 +216,20 @@ private void HandleExamined(EntityUid examinedUid, HandsComponent handsComp, Exa
args.PushMarkup(Loc.GetString(locKey, locUser, locItems));
}
}

/// <summary>
/// Fires when a melee weapon is swung and delays the throw timer.
/// Makes an exception for when the entity is the weapon itself, i.e. unarmed attacks.
/// </summary>
private void OnMeleeAttack(Entity<HandsComponent> ent, ref MeleeAttackEvent args)
{
if (ent.Owner == args.Weapon)
return;

if (!TryComp<MeleeWeaponComponent>(args.Weapon, out var melee))
return;

if (ent.Comp.NextThrowTime < melee.NextAttack)
ent.Comp.NextThrowTime = melee.NextAttack;
}
}

0 comments on commit 51d4e3e

Please sign in to comment.