From: stopbreaking <126102320+stopbreaking@users.noreply.github.com> Date: Sun, 22 Oct 2023 13:53:13 +0000 (-0400) Subject: Replaced Wieldable DoAfter with UseDelay (#18880) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=988bfa5c0961436256a5839ee0e0ca89742445e7;p=space-station-14.git Replaced Wieldable DoAfter with UseDelay (#18880) Co-authored-by: metalgearsloth --- diff --git a/Content.Shared/Wieldable/Components/WieldableComponent.cs b/Content.Shared/Wieldable/Components/WieldableComponent.cs index 050b638215..4a50b93072 100644 --- a/Content.Shared/Wieldable/Components/WieldableComponent.cs +++ b/Content.Shared/Wieldable/Components/WieldableComponent.cs @@ -30,9 +30,6 @@ public sealed partial class WieldableComponent : Component public string? WieldedInhandPrefix = "wielded"; public string? OldInhandPrefix = null; - - [DataField("wieldTime")] - public float WieldTime = 1.5f; } [Serializable, NetSerializable] diff --git a/Content.Shared/Wieldable/WieldableSystem.cs b/Content.Shared/Wieldable/WieldableSystem.cs index bf5aa1b723..ba87d54aa2 100644 --- a/Content.Shared/Wieldable/WieldableSystem.cs +++ b/Content.Shared/Wieldable/WieldableSystem.cs @@ -13,6 +13,7 @@ using Content.Shared.Weapons.Ranged.Components; using Content.Shared.Weapons.Ranged.Systems; using Content.Shared.Wieldable.Components; using Robust.Shared.Player; +using Content.Shared.Timing; namespace Content.Shared.Wieldable; @@ -25,13 +26,13 @@ public sealed class WieldableSystem : EntitySystem [Dependency] private readonly SharedPopupSystem _popupSystem = default!; [Dependency] private readonly SharedAudioSystem _audioSystem = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly UseDelaySystem _delay = default!; public override void Initialize() { base.Initialize(); - SubscribeLocalEvent(OnUseInHand, before: new [] { typeof(SharedGunSystem) }); - SubscribeLocalEvent(OnDoAfter); + SubscribeLocalEvent(OnUseInHand); SubscribeLocalEvent(OnItemUnwielded); SubscribeLocalEvent(OnItemLeaveHand); SubscribeLocalEvent(OnVirtualItemDeleted); @@ -76,7 +77,7 @@ public sealed class WieldableSystem : EntitySystem gun.MinAngle -= component.MinAngle; gun.MaxAngle -= component.MaxAngle; - Dirty(gun); + Dirty(uid, gun); } private void OnGunWielded(EntityUid uid, GunWieldBonusComponent component, ref ItemWieldedEvent args) @@ -86,7 +87,7 @@ public sealed class WieldableSystem : EntitySystem gun.MinAngle += component.MinAngle; gun.MaxAngle += component.MaxAngle; - Dirty(gun); + Dirty(uid, gun); } private void AddToggleWieldVerb(EntityUid uid, WieldableComponent component, GetVerbsEvent args) @@ -157,7 +158,7 @@ public sealed class WieldableSystem : EntitySystem } /// - /// Attempts to wield an item, creating a DoAfter.. + /// Attempts to wield an item, starting a UseDelay after. /// /// True if the attempt wasn't blocked. public bool TryWield(EntityUid used, WieldableComponent component, EntityUid user) @@ -171,13 +172,31 @@ public sealed class WieldableSystem : EntitySystem if (ev.Cancelled) return false; - var doargs = new DoAfterArgs(EntityManager, user, component.WieldTime, new WieldableDoAfterEvent(), used, used: used) + if (TryComp(used, out var item)) { - BreakOnUserMove = false, - BreakOnDamage = true - }; + component.OldInhandPrefix = item.HeldPrefix; + _itemSystem.SetHeldPrefix(used, component.WieldedInhandPrefix, item); + } + + component.Wielded = true; - _doAfter.TryStartDoAfter(doargs); + if (component.WieldSound != null) + _audioSystem.PlayPredicted(component.WieldSound, used, user); + + for (var i = 0; i < component.FreeHandsRequired; i++) + { + _virtualItemSystem.TrySpawnVirtualItemInHand(used, user); + } + + _delay.BeginDelay(used); + + _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); + + var targEv = new ItemWieldedEvent(); + RaiseLocalEvent(used, ref targEv); + + Dirty(used, component); return true; } @@ -199,38 +218,6 @@ public sealed class WieldableSystem : EntitySystem return true; } - private void OnDoAfter(EntityUid uid, WieldableComponent component, DoAfterEvent args) - { - if (args.Handled || args.Cancelled || !CanWield(uid, component, args.Args.User) || component.Wielded) - return; - - if (TryComp(uid, out var item)) - { - component.OldInhandPrefix = item.HeldPrefix; - _itemSystem.SetHeldPrefix(uid, component.WieldedInhandPrefix, item); - } - - component.Wielded = true; - - if (component.WieldSound != null) - _audioSystem.PlayPredicted(component.WieldSound, uid, args.User); - - for (var i = 0; i < component.FreeHandsRequired; i++) - { - _virtualItemSystem.TrySpawnVirtualItemInHand(uid, args.Args.User); - } - - _popupSystem.PopupClient(Loc.GetString("wieldable-component-successful-wield", ("item", uid)), args.Args.User, args.Args.User); - _popupSystem.PopupEntity(Loc.GetString("wieldable-component-successful-wield-other", ("user", args.Args.User),("item", uid)), args.Args.User, Filter.PvsExcept(args.Args.User), true); - - var ev = new ItemWieldedEvent(); - RaiseLocalEvent(uid, ref ev); - _appearance.SetData(uid, WieldableVisuals.Wielded, true); - - Dirty(component); - args.Handled = true; - } - private void OnItemUnwielded(EntityUid uid, WieldableComponent component, ItemUnwieldedEvent args) { if (args.User == null) @@ -258,7 +245,7 @@ public sealed class WieldableSystem : EntitySystem _appearance.SetData(uid, WieldableVisuals.Wielded, false); - Dirty(component); + Dirty(uid, component); _virtualItemSystem.DeleteInHandsMatching(args.User.Value, uid); } diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/base_pka.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/base_pka.yml index 7a8b9180e6..041cf446c1 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/base_pka.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Basic/base_pka.yml @@ -45,3 +45,5 @@ slots: - suitStorage - Belt + - type: UseDelay + delay: 1 diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Bow/bow.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Bow/bow.yml index 95282ee63a..88640f7812 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/Bow/bow.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/Bow/bow.yml @@ -14,9 +14,10 @@ slots: - Back - type: Wieldable - wieldTime: 0.5 wieldSound: path: /Audio/Items/bow_pull.ogg + - type: UseDelay + delay: 1 - type: GunRequiresWield - type: Gun minAngle: 0 diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml b/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml index 1d16d308e4..62142519bf 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Guns/LMGs/lmgs.yml @@ -58,6 +58,8 @@ gun_chamber: !type:ContainerSlot - type: StaticPrice price: 500 + - type: UseDelay + delay: 1 - type: entity name: L6 SAW diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Melee/baseball_bat.yml b/Resources/Prototypes/Entities/Objects/Weapons/Melee/baseball_bat.yml index e244647a13..c1fc668d59 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Melee/baseball_bat.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Melee/baseball_bat.yml @@ -30,6 +30,8 @@ - type: Construction graph: WoodenBat node: bat + - type: UseDelay + delay: 1 - type: Tag tags: - BaseballBat diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Melee/chainsaw.yml b/Resources/Prototypes/Entities/Objects/Weapons/Melee/chainsaw.yml index b0874bfaef..13f5191c10 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Melee/chainsaw.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Melee/chainsaw.yml @@ -5,7 +5,6 @@ description: A very large chainsaw. Usually you use this for cutting down trees... usually. components: - type: Wieldable - wieldTime: 1 wieldSound: !type:SoundPathSpecifier path: /Audio/Weapons/chainsawwield.ogg params: @@ -44,3 +43,5 @@ - ReagentId: WeldingFuel Quantity: 300 maxVol: 300 + - type: UseDelay + delay: 1 diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Melee/cult.yml b/Resources/Prototypes/Entities/Objects/Weapons/Melee/cult.yml index 833614105d..661ee379b2 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Melee/cult.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Melee/cult.yml @@ -81,3 +81,5 @@ quickEquip: false slots: - back + - type: UseDelay + delay: 1 diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Melee/e_sword.yml b/Resources/Prototypes/Entities/Objects/Weapons/Melee/e_sword.yml index 7cf02ad05c..0dd5d7c47c 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Melee/e_sword.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Melee/e_sword.yml @@ -171,7 +171,6 @@ description: Syndicate Command Interns thought that having one blade on the energy sword was not enough. This can be stored in pockets. components: - type: Wieldable - wieldTime: 0 - type: EnergySword litDamageBonus: types: @@ -205,3 +204,5 @@ enabled: true reflectProb: .75 spread: 75 + - type: UseDelay + delay: 1 diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Melee/fireaxe.yml b/Resources/Prototypes/Entities/Objects/Weapons/Melee/fireaxe.yml index 62a983cd4d..6d27e3e7d6 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Melee/fireaxe.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Melee/fireaxe.yml @@ -41,6 +41,8 @@ - type: TilePrying advanced: true - type: Prying + - type: UseDelay + delay: 1 - type: entity id: FireAxeFlaming diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Melee/pickaxe.yml b/Resources/Prototypes/Entities/Objects/Weapons/Melee/pickaxe.yml index 8d04fd316b..a0f497bd26 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Melee/pickaxe.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Melee/pickaxe.yml @@ -28,6 +28,8 @@ - type: Item size: 80 sprite: Objects/Weapons/Melee/pickaxe.rsi + - type: UseDelay + delay: 1 - type: entity name: mining drill diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Melee/spear.yml b/Resources/Prototypes/Entities/Objects/Weapons/Melee/spear.yml index f19b76b3e8..d34d29d5eb 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Melee/spear.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Melee/spear.yml @@ -104,6 +104,8 @@ damage: types: Blunt: 5 + - type: UseDelay + delay: 1 - type: Appearance - type: SolutionContainerVisuals maxFillLevels: 1 diff --git a/Resources/Prototypes/Entities/Objects/Weapons/Melee/white_cane.yml b/Resources/Prototypes/Entities/Objects/Weapons/Melee/white_cane.yml index 36ea58c111..c76ebf4d78 100644 --- a/Resources/Prototypes/Entities/Objects/Weapons/Melee/white_cane.yml +++ b/Resources/Prototypes/Entities/Objects/Weapons/Melee/white_cane.yml @@ -22,3 +22,6 @@ damage: types: Blunt: 3 + - type: UseDelay + delay: 1 +