using Content.Server.Emp;
using Content.Server.Ninja.Events;
-using Content.Server.Popups;
using Content.Server.Power.Components;
using Content.Server.PowerCell;
using Content.Shared.Clothing.EntitySystems;
using Content.Shared.Hands.EntitySystems;
using Content.Shared.Ninja.Components;
using Content.Shared.Ninja.Systems;
+using Content.Shared.Popups;
using Content.Shared.PowerCell.Components;
-using Content.Shared.Timing;
using Robust.Shared.Containers;
namespace Content.Server.Ninja.Systems;
[Dependency] private readonly EmpSystem _emp = default!;
[Dependency] private readonly SharedHandsSystem _hands = default!;
[Dependency] private readonly SpaceNinjaSystem _ninja = default!;
- [Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly PowerCellSystem _powerCell = default!;
[Dependency] private readonly SharedTransformSystem _transform = default!;
// need 1 second of charge to turn on stealth
var chargeNeeded = SuitWattage(uid, comp);
// being attacked while cloaked gives no power message since it overloads the power supply or something
- if (!_ninja.GetNinjaBattery(user, out var _, out var battery) || battery.CurrentCharge < chargeNeeded
- || !TryComp(user, out UseDelayComponent? useDelay) || UseDelay.IsDelayed((user, useDelay)))
+ if (!_ninja.GetNinjaBattery(user, out _, out var battery) || battery.CurrentCharge < chargeNeeded)
{
- _popup.PopupEntity(Loc.GetString("ninja-no-power"), user, user);
+ Popup.PopupEntity(Loc.GetString("ninja-no-power"), user, user);
+ args.Cancel();
+ return;
+ }
+
+ if (comp.DisableCooldown > GameTiming.CurTime)
+ {
+ Popup.PopupEntity(Loc.GetString("ninja-suit-cooldown"), user, user, PopupType.Medium);
args.Cancel();
return;
}
{
args.Handled = true;
var user = args.Performer;
- if (!_ninja.TryUseCharge(user, comp.ThrowingStarCharge)
- || !TryComp(user, out UseDelayComponent? useDelay) || UseDelay.IsDelayed((user, useDelay)))
+ if (!_ninja.TryUseCharge(user, comp.ThrowingStarCharge))
+ {
+ Popup.PopupEntity(Loc.GetString("ninja-no-power"), user, user);
+ return;
+ }
+
+ if (comp.DisableCooldown > GameTiming.CurTime)
{
- _popup.PopupEntity(Loc.GetString("ninja-no-power"), user, user);
+ Popup.PopupEntity(Loc.GetString("ninja-suit-cooldown"), user, user, PopupType.Medium);
return;
}
var katana = ninja.Katana.Value;
var coords = _transform.GetWorldPosition(katana);
var distance = (_transform.GetWorldPosition(user) - coords).Length();
- var chargeNeeded = (float) distance * comp.RecallCharge;
- if (!_ninja.TryUseCharge(user, chargeNeeded)
- || !TryComp(user, out UseDelayComponent? useDelay) || UseDelay.IsDelayed((user, useDelay)))
+ var chargeNeeded = distance * comp.RecallCharge;
+ if (!_ninja.TryUseCharge(user, chargeNeeded))
{
- _popup.PopupEntity(Loc.GetString("ninja-no-power"), user, user);
+ Popup.PopupEntity(Loc.GetString("ninja-no-power"), user, user);
+ return;
+ }
+
+ if (comp.DisableCooldown > GameTiming.CurTime)
+ {
+ Popup.PopupEntity(Loc.GetString("ninja-suit-cooldown"), user, user, PopupType.Medium);
return;
}
var message = _hands.TryPickupAnyHand(user, katana)
? "ninja-katana-recalled"
: "ninja-hands-full";
- _popup.PopupEntity(Loc.GetString(message), user, user);
+ Popup.PopupEntity(Loc.GetString(message), user, user);
}
private void OnEmp(EntityUid uid, NinjaSuitComponent comp, NinjaEmpEvent args)
{
args.Handled = true;
var user = args.Performer;
- if (!_ninja.TryUseCharge(user, comp.EmpCharge)
- || !TryComp(user, out UseDelayComponent? useDelay) || UseDelay.IsDelayed((user, useDelay)))
+ if (!_ninja.TryUseCharge(user, comp.EmpCharge))
+ {
+ Popup.PopupEntity(Loc.GetString("ninja-no-power"), user, user);
+ return;
+ }
+
+ if (comp.DisableCooldown > GameTiming.CurTime)
{
- _popup.PopupEntity(Loc.GetString("ninja-no-power"), user, user);
+ Popup.PopupEntity(Loc.GetString("ninja-suit-cooldown"), user, user, PopupType.Medium);
return;
}
-using Content.Server.Administration.Commands;
using Content.Server.Communications;
using Content.Server.Chat.Managers;
-using Content.Server.GameTicking;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Shared.Doors.Components;
using Content.Shared.IdentityManagement;
using Content.Shared.Mind;
-using Content.Shared.Mind.Components;
using Content.Shared.Ninja.Components;
using Content.Shared.Ninja.Systems;
using Content.Shared.Popups;
using Content.Shared.Rounding;
-using Robust.Shared.Audio;
-using Robust.Shared.Player;
using Robust.Shared.Random;
using System.Diagnostics.CodeAnalysis;
-using System.Linq;
using Content.Server.Objectives.Components;
-using Robust.Shared.Audio.Systems;
namespace Content.Server.Ninja.Systems;
{
[Dependency] private readonly AlertsSystem _alerts = default!;
[Dependency] private readonly BatterySystem _battery = default!;
- [Dependency] private readonly GameTicker _gameTicker = default!;
- [Dependency] private readonly GenericAntagSystem _genericAntag = default!;
[Dependency] private readonly IChatManager _chatMan = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly PowerCellSystem _powerCell = default!;
[Dependency] private readonly RoleSystem _role = default!;
- [Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedMindSystem _mind = default!;
[Dependency] private readonly StealthClothingSystem _stealthClothing = default!;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
+using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
using Robust.Shared.Utility;
public SoundSpecifier RevealSound = new SoundPathSpecifier("/Audio/Effects/chime.ogg");
/// <summary>
- /// How long to disable all abilities for when revealed.
- /// This adds a UseDelay to the ninja so it should not be set by anything else.
+ /// How long to disable all abilities when revealed.
+ /// Normally, ninjas are revealed when attacking or getting damaged.
/// </summary>
[DataField("disableTime")]
public TimeSpan DisableTime = TimeSpan.FromSeconds(5);
+ /// <summary>
+ /// Time at which we will be able to use our abilities again
+ /// </summary>
+ [DataField(customTypeSerializer: typeof(TimeOffsetSerializer))]
+ public TimeSpan DisableCooldown;
+
/// <summary>
/// The action id for creating throwing stars.
/// </summary>
using Content.Shared.Clothing.EntitySystems;
using Content.Shared.Inventory.Events;
using Content.Shared.Ninja.Components;
-using Content.Shared.Timing;
+using Content.Shared.Popups;
using Robust.Shared.Audio.Systems;
+using Robust.Shared.Timing;
namespace Content.Shared.Ninja.Systems;
/// </summary>
public abstract class SharedNinjaSuitSystem : EntitySystem
{
+ [Dependency] protected readonly IGameTiming GameTiming = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly SharedNinjaGlovesSystem _gloves = default!;
[Dependency] private readonly SharedSpaceNinjaSystem _ninja = default!;
- [Dependency] protected readonly StealthClothingSystem StealthClothing = default!;
- [Dependency] protected readonly UseDelaySystem UseDelay = default!;
[Dependency] private readonly ActionContainerSystem _actionContainer = default!;
+ [Dependency] protected readonly SharedPopupSystem Popup = default!;
+ [Dependency] protected readonly StealthClothingSystem StealthClothing = default!;
public override void Initialize()
{
base.Initialize();
+ SubscribeLocalEvent<NinjaSuitComponent, MapInitEvent>(OnMapInit);
+ SubscribeLocalEvent<NinjaSuitComponent, EntityUnpausedEvent>(OnEntityUnpaused);
+
SubscribeLocalEvent<NinjaSuitComponent, GotEquippedEvent>(OnEquipped);
SubscribeLocalEvent<NinjaSuitComponent, GetItemActionsEvent>(OnGetItemActions);
SubscribeLocalEvent<NinjaSuitComponent, AddStealthActionEvent>(OnAddStealthAction);
SubscribeLocalEvent<NinjaSuitComponent, GotUnequippedEvent>(OnUnequipped);
- SubscribeLocalEvent<NinjaSuitComponent, MapInitEvent>(OnMapInit);
}
private void OnMapInit(EntityUid uid, NinjaSuitComponent component, MapInitEvent args)
Dirty(uid, component);
}
+ private void OnEntityUnpaused(Entity<NinjaSuitComponent> ent, ref EntityUnpausedEvent args)
+ {
+ ent.Comp.DisableCooldown += args.PausedTime;
+ }
+
/// <summary>
/// Call the shared and serverside code for when a ninja equips the suit.
/// </summary>
// previously cloaked, disable abilities for a short time
_audio.PlayPredicted(comp.RevealSound, uid, user);
- // all abilities check for a usedelay on the ninja
- var useDelay = EnsureComp<UseDelayComponent>(user);
- UseDelay.SetDelay((user, useDelay), comp.DisableTime);
- UseDelay.TryResetDelay((user, useDelay));
+ Popup.PopupClient(Loc.GetString("ninja-revealed"), user, user, PopupType.MediumCaution);
+ comp.DisableCooldown = GameTiming.CurTime + comp.DisableTime;
}
// TODO: modify PowerCellDrain
ninja-no-power = Not enough charge in suit battery!
+ninja-revealed = You have been revealed!
+ninja-suit-cooldown = The suit needs time to recuperate from the last attack.
ninja-research-steal-fail = No new research nodes were stolen...
ninja-research-steal-success = Stole {$count} new nodes from {THE($server)}.