UseDelay + ItemCooldown merge (#22502)

This commit is contained in:
AJCM-git
2024-01-03 21:33:09 -04:00
committed by GitHub
parent 42ec9b2967
commit 9c522c8b19
80 changed files with 324 additions and 589 deletions

View File

@@ -1,27 +1,24 @@
using Content.Shared.DoAfter;
using Content.Shared.Hands;
using Content.Shared.Hands.Components;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Popups;
using Content.Shared.Timing;
using Content.Shared.Verbs;
using Content.Shared.Weapons.Melee;
using Content.Shared.Weapons.Melee.Events;
using Content.Shared.Weapons.Melee.Components;
using Content.Shared.Weapons.Melee.Events;
using Content.Shared.Weapons.Ranged.Components;
using Content.Shared.Weapons.Ranged.Systems;
using Content.Shared.Wieldable.Components;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Player;
using Content.Shared.Timing;
namespace Content.Shared.Wieldable;
public sealed class WieldableSystem : EntitySystem
{
[Dependency] private readonly SharedDoAfterSystem _doAfter = default!;
[Dependency] private readonly SharedHandVirtualItemSystem _virtualItemSystem = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly SharedItemSystem _itemSystem = default!;
@@ -120,18 +117,18 @@ public sealed class WieldableSystem : EntitySystem
if (args.Handled)
return;
if(!component.Wielded)
if (!component.Wielded)
args.Handled = TryWield(uid, component, args.User);
else
args.Handled = TryUnwield(uid, component, args.User);
}
public bool CanWield(EntityUid uid, WieldableComponent component, EntityUid user, bool quiet=false)
public bool CanWield(EntityUid uid, WieldableComponent component, EntityUid user, bool quiet = false)
{
// Do they have enough hands free?
if (!EntityManager.TryGetComponent<HandsComponent>(user, out var hands))
{
if(!quiet)
if (!quiet)
_popupSystem.PopupClient(Loc.GetString("wieldable-component-no-hands"), user, user);
return false;
}
@@ -190,10 +187,12 @@ public sealed class WieldableSystem : EntitySystem
_virtualItemSystem.TrySpawnVirtualItemInHand(used, user);
}
_delay.BeginDelay(used);
if (TryComp(used, out UseDelayComponent? useDelay)
&& !_delay.TryResetDelay((used, useDelay), true))
return false;
_popupSystem.PopupClient(Loc.GetString("wieldable-component-successful-wield", ("item", used)), user, user);
_popupSystem.PopupEntity(Loc.GetString("wieldable-component-successful-wield-other", ("user", user),("item", used)), user, Filter.PvsExcept(user), true);
_popupSystem.PopupEntity(Loc.GetString("wieldable-component-successful-wield-other", ("user", user), ("item", used)), user, Filter.PvsExcept(user), true);
var targEv = new ItemWieldedEvent();
RaiseLocalEvent(used, ref targEv);
@@ -224,6 +223,7 @@ public sealed class WieldableSystem : EntitySystem
{
if (args.User == null)
return;
if (!component.Wielded)
return;
@@ -255,6 +255,7 @@ public sealed class WieldableSystem : EntitySystem
{
if (!component.Wielded || uid != args.Unequipped)
return;
RaiseLocalEvent(uid, new ItemUnwieldedEvent(args.User, force: true), true);
}
@@ -268,6 +269,7 @@ public sealed class WieldableSystem : EntitySystem
{
if (!TryComp<WieldableComponent>(uid, out var wield))
return;
if (!wield.Wielded)
return;