/// <summary>
/// Force uncloaks the user and disables suit abilities.
/// </summary>
- 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;
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
base.Initialize();
SubscribeLocalEvent<SpaceNinjaComponent, AttackedEvent>(OnNinjaAttacked);
+ SubscribeLocalEvent<SpaceNinjaComponent, MeleeAttackEvent>(OnNinjaAttack);
SubscribeLocalEvent<SpaceNinjaComponent, ShotAttemptedEvent>(OnShotAttempted);
}
{
if (comp.Suit != null && TryComp<StealthClothingComponent>(comp.Suit, out var stealthClothing) && stealthClothing.Enabled)
{
- Suit.RevealNinja(comp.Suit.Value, uid, null, stealthClothing);
+ Suit.RevealNinja(comp.Suit.Value, uid, true, null, stealthClothing);
+ }
+ }
+
+ /// <summary>
+ /// Handle revealing ninja if cloaked when attacking.
+ /// Only reveals, there is no cooldown.
+ /// </summary>
+ private void OnNinjaAttack(EntityUid uid, SpaceNinjaComponent comp, ref MeleeAttackEvent args)
+ {
+ if (comp.Suit != null && TryComp<StealthClothingComponent>(comp.Suit, out var stealthClothing) && stealthClothing.Enabled)
+ {
+ Suit.RevealNinja(comp.Suit.Value, uid, false, null, stealthClothing);
}
}
--- /dev/null
+namespace Content.Shared.Weapons.Melee.Events;
+
+/// <summary>
+/// Event raised on the user after attacking with a melee weapon, regardless of whether it hit anything.
+/// </summary>
+[ByRefEvent]
+public record struct MeleeAttackEvent(EntityUid Weapon);
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;
}