Fixes ninja not being able to use abilities (#23748)
* Fixes ninja not being able to use abilities * This was for testing
This commit is contained in:
@@ -1,14 +1,13 @@
|
|||||||
using Content.Server.Emp;
|
using Content.Server.Emp;
|
||||||
using Content.Server.Ninja.Events;
|
using Content.Server.Ninja.Events;
|
||||||
using Content.Server.Popups;
|
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
using Content.Server.PowerCell;
|
using Content.Server.PowerCell;
|
||||||
using Content.Shared.Clothing.EntitySystems;
|
using Content.Shared.Clothing.EntitySystems;
|
||||||
using Content.Shared.Hands.EntitySystems;
|
using Content.Shared.Hands.EntitySystems;
|
||||||
using Content.Shared.Ninja.Components;
|
using Content.Shared.Ninja.Components;
|
||||||
using Content.Shared.Ninja.Systems;
|
using Content.Shared.Ninja.Systems;
|
||||||
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.PowerCell.Components;
|
using Content.Shared.PowerCell.Components;
|
||||||
using Content.Shared.Timing;
|
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
|
|
||||||
namespace Content.Server.Ninja.Systems;
|
namespace Content.Server.Ninja.Systems;
|
||||||
@@ -21,7 +20,6 @@ public sealed class NinjaSuitSystem : SharedNinjaSuitSystem
|
|||||||
[Dependency] private readonly EmpSystem _emp = default!;
|
[Dependency] private readonly EmpSystem _emp = default!;
|
||||||
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
[Dependency] private readonly SharedHandsSystem _hands = default!;
|
||||||
[Dependency] private readonly SpaceNinjaSystem _ninja = default!;
|
[Dependency] private readonly SpaceNinjaSystem _ninja = default!;
|
||||||
[Dependency] private readonly PopupSystem _popup = default!;
|
|
||||||
[Dependency] private readonly PowerCellSystem _powerCell = default!;
|
[Dependency] private readonly PowerCellSystem _powerCell = default!;
|
||||||
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
[Dependency] private readonly SharedTransformSystem _transform = default!;
|
||||||
|
|
||||||
@@ -93,10 +91,16 @@ public sealed class NinjaSuitSystem : SharedNinjaSuitSystem
|
|||||||
// need 1 second of charge to turn on stealth
|
// need 1 second of charge to turn on stealth
|
||||||
var chargeNeeded = SuitWattage(uid, comp);
|
var chargeNeeded = SuitWattage(uid, comp);
|
||||||
// being attacked while cloaked gives no power message since it overloads the power supply or something
|
// 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
|
if (!_ninja.GetNinjaBattery(user, out _, out var battery) || battery.CurrentCharge < chargeNeeded)
|
||||||
|| !TryComp(user, out UseDelayComponent? useDelay) || UseDelay.IsDelayed((user, useDelay)))
|
|
||||||
{
|
{
|
||||||
_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();
|
args.Cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -108,10 +112,15 @@ public sealed class NinjaSuitSystem : SharedNinjaSuitSystem
|
|||||||
{
|
{
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
var user = args.Performer;
|
var user = args.Performer;
|
||||||
if (!_ninja.TryUseCharge(user, comp.ThrowingStarCharge)
|
if (!_ninja.TryUseCharge(user, comp.ThrowingStarCharge))
|
||||||
|| !TryComp(user, out UseDelayComponent? useDelay) || UseDelay.IsDelayed((user, useDelay)))
|
|
||||||
{
|
{
|
||||||
_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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,11 +139,16 @@ public sealed class NinjaSuitSystem : SharedNinjaSuitSystem
|
|||||||
var katana = ninja.Katana.Value;
|
var katana = ninja.Katana.Value;
|
||||||
var coords = _transform.GetWorldPosition(katana);
|
var coords = _transform.GetWorldPosition(katana);
|
||||||
var distance = (_transform.GetWorldPosition(user) - coords).Length();
|
var distance = (_transform.GetWorldPosition(user) - coords).Length();
|
||||||
var chargeNeeded = (float) distance * comp.RecallCharge;
|
var chargeNeeded = distance * comp.RecallCharge;
|
||||||
if (!_ninja.TryUseCharge(user, chargeNeeded)
|
if (!_ninja.TryUseCharge(user, chargeNeeded))
|
||||||
|| !TryComp(user, out UseDelayComponent? useDelay) || UseDelay.IsDelayed((user, useDelay)))
|
|
||||||
{
|
{
|
||||||
_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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,17 +156,22 @@ public sealed class NinjaSuitSystem : SharedNinjaSuitSystem
|
|||||||
var message = _hands.TryPickupAnyHand(user, katana)
|
var message = _hands.TryPickupAnyHand(user, katana)
|
||||||
? "ninja-katana-recalled"
|
? "ninja-katana-recalled"
|
||||||
: "ninja-hands-full";
|
: "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)
|
private void OnEmp(EntityUid uid, NinjaSuitComponent comp, NinjaEmpEvent args)
|
||||||
{
|
{
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
var user = args.Performer;
|
var user = args.Performer;
|
||||||
if (!_ninja.TryUseCharge(user, comp.EmpCharge)
|
if (!_ninja.TryUseCharge(user, comp.EmpCharge))
|
||||||
|| !TryComp(user, out UseDelayComponent? useDelay) || UseDelay.IsDelayed((user, useDelay)))
|
|
||||||
{
|
{
|
||||||
_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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
using Content.Server.Administration.Commands;
|
|
||||||
using Content.Server.Communications;
|
using Content.Server.Communications;
|
||||||
using Content.Server.Chat.Managers;
|
using Content.Server.Chat.Managers;
|
||||||
using Content.Server.GameTicking;
|
|
||||||
using Content.Server.GameTicking.Rules.Components;
|
using Content.Server.GameTicking.Rules.Components;
|
||||||
using Content.Server.Power.Components;
|
using Content.Server.Power.Components;
|
||||||
using Content.Server.Power.EntitySystems;
|
using Content.Server.Power.EntitySystems;
|
||||||
@@ -15,18 +13,13 @@ using Content.Shared.Clothing.EntitySystems;
|
|||||||
using Content.Shared.Doors.Components;
|
using Content.Shared.Doors.Components;
|
||||||
using Content.Shared.IdentityManagement;
|
using Content.Shared.IdentityManagement;
|
||||||
using Content.Shared.Mind;
|
using Content.Shared.Mind;
|
||||||
using Content.Shared.Mind.Components;
|
|
||||||
using Content.Shared.Ninja.Components;
|
using Content.Shared.Ninja.Components;
|
||||||
using Content.Shared.Ninja.Systems;
|
using Content.Shared.Ninja.Systems;
|
||||||
using Content.Shared.Popups;
|
using Content.Shared.Popups;
|
||||||
using Content.Shared.Rounding;
|
using Content.Shared.Rounding;
|
||||||
using Robust.Shared.Audio;
|
|
||||||
using Robust.Shared.Player;
|
|
||||||
using Robust.Shared.Random;
|
using Robust.Shared.Random;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using System.Linq;
|
|
||||||
using Content.Server.Objectives.Components;
|
using Content.Server.Objectives.Components;
|
||||||
using Robust.Shared.Audio.Systems;
|
|
||||||
|
|
||||||
namespace Content.Server.Ninja.Systems;
|
namespace Content.Server.Ninja.Systems;
|
||||||
|
|
||||||
@@ -43,13 +36,10 @@ public sealed class SpaceNinjaSystem : SharedSpaceNinjaSystem
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly AlertsSystem _alerts = default!;
|
[Dependency] private readonly AlertsSystem _alerts = default!;
|
||||||
[Dependency] private readonly BatterySystem _battery = 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 IChatManager _chatMan = default!;
|
||||||
[Dependency] private readonly IRobustRandom _random = default!;
|
[Dependency] private readonly IRobustRandom _random = default!;
|
||||||
[Dependency] private readonly PowerCellSystem _powerCell = default!;
|
[Dependency] private readonly PowerCellSystem _powerCell = default!;
|
||||||
[Dependency] private readonly RoleSystem _role = default!;
|
[Dependency] private readonly RoleSystem _role = default!;
|
||||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
||||||
[Dependency] private readonly SharedMindSystem _mind = default!;
|
[Dependency] private readonly SharedMindSystem _mind = default!;
|
||||||
[Dependency] private readonly StealthClothingSystem _stealthClothing = default!;
|
[Dependency] private readonly StealthClothingSystem _stealthClothing = default!;
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using Robust.Shared.Audio;
|
|||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
|
||||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||||
using Robust.Shared.Utility;
|
using Robust.Shared.Utility;
|
||||||
|
|
||||||
@@ -35,12 +36,18 @@ public sealed partial class NinjaSuitComponent : Component
|
|||||||
public SoundSpecifier RevealSound = new SoundPathSpecifier("/Audio/Effects/chime.ogg");
|
public SoundSpecifier RevealSound = new SoundPathSpecifier("/Audio/Effects/chime.ogg");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// How long to disable all abilities for when revealed.
|
/// How long to disable all abilities when revealed.
|
||||||
/// This adds a UseDelay to the ninja so it should not be set by anything else.
|
/// Normally, ninjas are revealed when attacking or getting damaged.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[DataField("disableTime")]
|
[DataField("disableTime")]
|
||||||
public TimeSpan DisableTime = TimeSpan.FromSeconds(5);
|
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>
|
/// <summary>
|
||||||
/// The action id for creating throwing stars.
|
/// The action id for creating throwing stars.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ using Content.Shared.Clothing.Components;
|
|||||||
using Content.Shared.Clothing.EntitySystems;
|
using Content.Shared.Clothing.EntitySystems;
|
||||||
using Content.Shared.Inventory.Events;
|
using Content.Shared.Inventory.Events;
|
||||||
using Content.Shared.Ninja.Components;
|
using Content.Shared.Ninja.Components;
|
||||||
using Content.Shared.Timing;
|
using Content.Shared.Popups;
|
||||||
using Robust.Shared.Audio.Systems;
|
using Robust.Shared.Audio.Systems;
|
||||||
|
using Robust.Shared.Timing;
|
||||||
|
|
||||||
namespace Content.Shared.Ninja.Systems;
|
namespace Content.Shared.Ninja.Systems;
|
||||||
|
|
||||||
@@ -13,22 +14,25 @@ namespace Content.Shared.Ninja.Systems;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class SharedNinjaSuitSystem : EntitySystem
|
public abstract class SharedNinjaSuitSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
[Dependency] protected readonly IGameTiming GameTiming = default!;
|
||||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||||
[Dependency] private readonly SharedNinjaGlovesSystem _gloves = default!;
|
[Dependency] private readonly SharedNinjaGlovesSystem _gloves = default!;
|
||||||
[Dependency] private readonly SharedSpaceNinjaSystem _ninja = 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] private readonly ActionContainerSystem _actionContainer = default!;
|
||||||
|
[Dependency] protected readonly SharedPopupSystem Popup = default!;
|
||||||
|
[Dependency] protected readonly StealthClothingSystem StealthClothing = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
base.Initialize();
|
base.Initialize();
|
||||||
|
|
||||||
|
SubscribeLocalEvent<NinjaSuitComponent, MapInitEvent>(OnMapInit);
|
||||||
|
SubscribeLocalEvent<NinjaSuitComponent, EntityUnpausedEvent>(OnEntityUnpaused);
|
||||||
|
|
||||||
SubscribeLocalEvent<NinjaSuitComponent, GotEquippedEvent>(OnEquipped);
|
SubscribeLocalEvent<NinjaSuitComponent, GotEquippedEvent>(OnEquipped);
|
||||||
SubscribeLocalEvent<NinjaSuitComponent, GetItemActionsEvent>(OnGetItemActions);
|
SubscribeLocalEvent<NinjaSuitComponent, GetItemActionsEvent>(OnGetItemActions);
|
||||||
SubscribeLocalEvent<NinjaSuitComponent, AddStealthActionEvent>(OnAddStealthAction);
|
SubscribeLocalEvent<NinjaSuitComponent, AddStealthActionEvent>(OnAddStealthAction);
|
||||||
SubscribeLocalEvent<NinjaSuitComponent, GotUnequippedEvent>(OnUnequipped);
|
SubscribeLocalEvent<NinjaSuitComponent, GotUnequippedEvent>(OnUnequipped);
|
||||||
SubscribeLocalEvent<NinjaSuitComponent, MapInitEvent>(OnMapInit);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMapInit(EntityUid uid, NinjaSuitComponent component, MapInitEvent args)
|
private void OnMapInit(EntityUid uid, NinjaSuitComponent component, MapInitEvent args)
|
||||||
@@ -39,6 +43,11 @@ public abstract class SharedNinjaSuitSystem : EntitySystem
|
|||||||
Dirty(uid, component);
|
Dirty(uid, component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnEntityUnpaused(Entity<NinjaSuitComponent> ent, ref EntityUnpausedEvent args)
|
||||||
|
{
|
||||||
|
ent.Comp.DisableCooldown += args.PausedTime;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Call the shared and serverside code for when a ninja equips the suit.
|
/// Call the shared and serverside code for when a ninja equips the suit.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -110,10 +119,8 @@ public abstract class SharedNinjaSuitSystem : EntitySystem
|
|||||||
|
|
||||||
// previously cloaked, disable abilities for a short time
|
// previously cloaked, disable abilities for a short time
|
||||||
_audio.PlayPredicted(comp.RevealSound, uid, user);
|
_audio.PlayPredicted(comp.RevealSound, uid, user);
|
||||||
// all abilities check for a usedelay on the ninja
|
Popup.PopupClient(Loc.GetString("ninja-revealed"), user, user, PopupType.MediumCaution);
|
||||||
var useDelay = EnsureComp<UseDelayComponent>(user);
|
comp.DisableCooldown = GameTiming.CurTime + comp.DisableTime;
|
||||||
UseDelay.SetDelay((user, useDelay), comp.DisableTime);
|
|
||||||
UseDelay.TryResetDelay((user, useDelay));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: modify PowerCellDrain
|
// TODO: modify PowerCellDrain
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
ninja-no-power = Not enough charge in suit battery!
|
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-fail = No new research nodes were stolen...
|
||||||
ninja-research-steal-success = Stole {$count} new nodes from {THE($server)}.
|
ninja-research-steal-success = Stole {$count} new nodes from {THE($server)}.
|
||||||
|
|||||||
Reference in New Issue
Block a user