From: deltanedas <39013340+deltanedas@users.noreply.github.com>
Date: Wed, 11 Oct 2023 02:55:53 +0000 (+0100)
Subject: uncloak ninja after attacking (#20892)
X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=6db534ef86765e12b56ac0880158d3d0a0ba226b;p=space-station-14.git
uncloak ninja after attacking (#20892)
* raise MeleeAttackEvent on the user after swinging
* add disable bool to RevealNinja
* uncloak ninja after attacking
---------
Co-authored-by: deltanedas <@deltanedas:kde.org>
---
diff --git a/Content.Shared/Ninja/Systems/SharedNinjaSuitSystem.cs b/Content.Shared/Ninja/Systems/SharedNinjaSuitSystem.cs
index 6bcd3432a9..473e29cc94 100644
--- a/Content.Shared/Ninja/Systems/SharedNinjaSuitSystem.cs
+++ b/Content.Shared/Ninja/Systems/SharedNinjaSuitSystem.cs
@@ -96,7 +96,7 @@ public abstract class SharedNinjaSuitSystem : EntitySystem
///
/// Force uncloaks the user and disables suit abilities.
///
- public void RevealNinja(EntityUid uid, EntityUid user, NinjaSuitComponent? comp = null, StealthClothingComponent? stealthClothing = null)
+ public void RevealNinja(EntityUid uid, EntityUid user, bool disable = true, NinjaSuitComponent? comp = null, StealthClothingComponent? stealthClothing = null)
{
if (!Resolve(uid, ref comp, ref stealthClothing))
return;
@@ -104,6 +104,9 @@ public abstract class SharedNinjaSuitSystem : EntitySystem
if (!StealthClothing.SetEnabled(uid, user, false, stealthClothing))
return;
+ if (!disable)
+ return;
+
// previously cloaked, disable abilities for a short time
_audio.PlayPredicted(comp.RevealSound, uid, user);
// all abilities check for a usedelay on the ninja
diff --git a/Content.Shared/Ninja/Systems/SharedSpaceNinjaSystem.cs b/Content.Shared/Ninja/Systems/SharedSpaceNinjaSystem.cs
index fbcb4efe48..522f29fe42 100644
--- a/Content.Shared/Ninja/Systems/SharedSpaceNinjaSystem.cs
+++ b/Content.Shared/Ninja/Systems/SharedSpaceNinjaSystem.cs
@@ -19,6 +19,7 @@ public abstract class SharedSpaceNinjaSystem : EntitySystem
base.Initialize();
SubscribeLocalEvent(OnNinjaAttacked);
+ SubscribeLocalEvent(OnNinjaAttack);
SubscribeLocalEvent(OnShotAttempted);
}
@@ -74,7 +75,19 @@ public abstract class SharedSpaceNinjaSystem : EntitySystem
{
if (comp.Suit != null && TryComp(comp.Suit, out var stealthClothing) && stealthClothing.Enabled)
{
- Suit.RevealNinja(comp.Suit.Value, uid, null, stealthClothing);
+ Suit.RevealNinja(comp.Suit.Value, uid, true, null, stealthClothing);
+ }
+ }
+
+ ///
+ /// Handle revealing ninja if cloaked when attacking.
+ /// Only reveals, there is no cooldown.
+ ///
+ private void OnNinjaAttack(EntityUid uid, SpaceNinjaComponent comp, ref MeleeAttackEvent args)
+ {
+ if (comp.Suit != null && TryComp(comp.Suit, out var stealthClothing) && stealthClothing.Enabled)
+ {
+ Suit.RevealNinja(comp.Suit.Value, uid, false, null, stealthClothing);
}
}
diff --git a/Content.Shared/Weapons/Melee/Events/MeleeAttackEvent.cs b/Content.Shared/Weapons/Melee/Events/MeleeAttackEvent.cs
new file mode 100644
index 0000000000..9530b0e655
--- /dev/null
+++ b/Content.Shared/Weapons/Melee/Events/MeleeAttackEvent.cs
@@ -0,0 +1,7 @@
+namespace Content.Shared.Weapons.Melee.Events;
+
+///
+/// Event raised on the user after attacking with a melee weapon, regardless of whether it hit anything.
+///
+[ByRefEvent]
+public record struct MeleeAttackEvent(EntityUid Weapon);
diff --git a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs
index ebe1a21e67..4259706ba8 100644
--- a/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs
+++ b/Content.Shared/Weapons/Melee/SharedMeleeWeaponSystem.cs
@@ -426,6 +426,9 @@ public abstract class SharedMeleeWeaponSystem : EntitySystem
DoLungeAnimation(user, weapon.Angle, GetCoordinates(attack.Coordinates).ToMap(EntityManager, TransformSystem), weapon.Range, animation);
}
+ var attackEv = new MeleeAttackEvent(weaponUid);
+ RaiseLocalEvent(user, ref attackEv);
+
weapon.Attacking = true;
return true;
}