Replaced Wieldable DoAfter with UseDelay (#18880)
Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -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]
|
||||
|
||||
@@ -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<WieldableComponent, UseInHandEvent>(OnUseInHand, before: new [] { typeof(SharedGunSystem) });
|
||||
SubscribeLocalEvent<WieldableComponent, WieldableDoAfterEvent>(OnDoAfter);
|
||||
SubscribeLocalEvent<WieldableComponent, UseInHandEvent>(OnUseInHand);
|
||||
SubscribeLocalEvent<WieldableComponent, ItemUnwieldedEvent>(OnItemUnwielded);
|
||||
SubscribeLocalEvent<WieldableComponent, GotUnequippedHandEvent>(OnItemLeaveHand);
|
||||
SubscribeLocalEvent<WieldableComponent, VirtualItemDeletedEvent>(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<InteractionVerb> args)
|
||||
@@ -157,7 +158,7 @@ public sealed class WieldableSystem : EntitySystem
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to wield an item, creating a DoAfter..
|
||||
/// Attempts to wield an item, starting a UseDelay after.
|
||||
/// </summary>
|
||||
/// <returns>True if the attempt wasn't blocked.</returns>
|
||||
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<ItemComponent>(used, out var item))
|
||||
{
|
||||
BreakOnUserMove = false,
|
||||
BreakOnDamage = true
|
||||
};
|
||||
component.OldInhandPrefix = item.HeldPrefix;
|
||||
_itemSystem.SetHeldPrefix(used, component.WieldedInhandPrefix, item);
|
||||
}
|
||||
|
||||
_doAfter.TryStartDoAfter(doargs);
|
||||
component.Wielded = true;
|
||||
|
||||
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<ItemComponent>(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);
|
||||
}
|
||||
|
||||
|
||||
@@ -45,3 +45,5 @@
|
||||
slots:
|
||||
- suitStorage
|
||||
- Belt
|
||||
- type: UseDelay
|
||||
delay: 1
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -58,6 +58,8 @@
|
||||
gun_chamber: !type:ContainerSlot
|
||||
- type: StaticPrice
|
||||
price: 500
|
||||
- type: UseDelay
|
||||
delay: 1
|
||||
|
||||
- type: entity
|
||||
name: L6 SAW
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
- type: Construction
|
||||
graph: WoodenBat
|
||||
node: bat
|
||||
- type: UseDelay
|
||||
delay: 1
|
||||
- type: Tag
|
||||
tags:
|
||||
- BaseballBat
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -81,3 +81,5 @@
|
||||
quickEquip: false
|
||||
slots:
|
||||
- back
|
||||
- type: UseDelay
|
||||
delay: 1
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
- type: TilePrying
|
||||
advanced: true
|
||||
- type: Prying
|
||||
- type: UseDelay
|
||||
delay: 1
|
||||
|
||||
- type: entity
|
||||
id: FireAxeFlaming
|
||||
|
||||
@@ -28,6 +28,8 @@
|
||||
- type: Item
|
||||
size: 80
|
||||
sprite: Objects/Weapons/Melee/pickaxe.rsi
|
||||
- type: UseDelay
|
||||
delay: 1
|
||||
|
||||
- type: entity
|
||||
name: mining drill
|
||||
|
||||
@@ -104,6 +104,8 @@
|
||||
damage:
|
||||
types:
|
||||
Blunt: 5
|
||||
- type: UseDelay
|
||||
delay: 1
|
||||
- type: Appearance
|
||||
- type: SolutionContainerVisuals
|
||||
maxFillLevels: 1
|
||||
|
||||
@@ -22,3 +22,6 @@
|
||||
damage:
|
||||
types:
|
||||
Blunt: 3
|
||||
- type: UseDelay
|
||||
delay: 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user