From 409bd06a70a8a7fea6ba63efc1671ad3b2ce9a14 Mon Sep 17 00:00:00 2001 From: vanx <#vanxxxx> Date: Wed, 28 Aug 2024 16:12:43 +0300 Subject: [PATCH] stop breaking the game !!!!!!!! --- .../Melee/Events/MeleeAttemptedEvent.cs | 37 +++++++++++++++++++ .../Weapons/Melee/SharedMeleeWeaponSystem.cs | 4 +- .../Weapons/Ranged/Systems/SharedGunSystem.cs | 7 ++-- 3 files changed, 43 insertions(+), 5 deletions(-) create mode 100644 Content.Shared/Weapons/Melee/Events/MeleeAttemptedEvent.cs diff --git a/Content.Shared/Weapons/Melee/Events/MeleeAttemptedEvent.cs b/Content.Shared/Weapons/Melee/Events/MeleeAttemptedEvent.cs new file mode 100644 index 0000000000..bc82a9a96c --- /dev/null +++ b/Content.Shared/Weapons/Melee/Events/MeleeAttemptedEvent.cs @@ -0,0 +1,37 @@ +namespace Content.Shared.Weapons.Melee.Events; + +/// +/// Raised on a melee when someone is attempting to attack with it. +/// Cancel this event to prevent it from attacking. +/// +[ByRefEvent] +public record struct MeleeAttemptedEvent +{ + /// + /// The user attempting to attack with the weapon. + /// + public EntityUid User; + + /// + /// The weapon being used. + /// + public EntityUid Used; + + public bool Cancelled { get; private set; } + + /// + /// Prevent the weapon from attacking + /// + public void Cancel() + { + Cancelled = true; + } + + /// + /// Allow the weapon to attack again, only use if you know what you are doing + /// + public void Uncancel() + { + Cancelled = false; + } +} diff --git a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs index b5a537b7e1..cf7566af91 100644 --- a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs +++ b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs @@ -62,7 +62,7 @@ public override void Initialize() base.Initialize(); SubscribeLocalEvent(OnMeleeSelected); - SubscribeLocalEvent(OnMeleeShotAttempted); + SubscribeLocalEvent(OnMeleeAttempted); SubscribeLocalEvent(OnMeleeShot); SubscribeLocalEvent(OnGetBonusMeleeDamage); SubscribeLocalEvent(OnGetBonusHeavyDamageModifier); @@ -86,7 +86,7 @@ private void OnMapInit(EntityUid uid, MeleeWeaponComponent component, MapInitEve #endif } - private void OnMeleeShotAttempted(EntityUid uid, MeleeWeaponComponent comp, ref ShotAttemptedEvent args) + private void OnMeleeAttempted(EntityUid uid, MeleeWeaponComponent comp, ref MeleeAttemptedEvent args) { if (comp.NextAttack > Timing.CurTime) args.Cancel(); diff --git a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs index 3c5e5c7984..0e61518a4a 100644 --- a/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs +++ b/Content.Shared/Weapons/Ranged/Systems/SharedGunSystem.cs @@ -76,7 +76,7 @@ public override void Initialize() { SubscribeAllEvent(OnShootRequest); SubscribeAllEvent(OnStopShootRequest); - SubscribeLocalEvent(OnGunMelee); + //SubscribeLocalEvent(OnGunMelee); // Ammo providers InitializeBallistic(); @@ -110,7 +110,8 @@ private void OnMapInit(Entity gun, ref MapInitEvent args) RefreshModifiers((gun, gun)); } - private void OnGunMelee(EntityUid uid, GunComponent component, MeleeHitEvent args) + // Sets the gun cooldown to the melee attack cooldown on attack. Removed since it felt very unintuitive. + /*private void OnGunMelee(EntityUid uid, GunComponent component, MeleeHitEvent args) { if (!TryComp(uid, out var melee)) return; @@ -120,7 +121,7 @@ private void OnGunMelee(EntityUid uid, GunComponent component, MeleeHitEvent arg component.NextFire = melee.NextAttack; Dirty(component); } - } + }*/ private void OnShootRequest(RequestShootEvent msg, EntitySessionEventArgs args) {