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.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;
|
||||
@@ -21,7 +20,6 @@ public sealed class NinjaSuitSystem : SharedNinjaSuitSystem
|
||||
[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!;
|
||||
|
||||
@@ -93,10 +91,16 @@ public sealed class NinjaSuitSystem : SharedNinjaSuitSystem
|
||||
// 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;
|
||||
}
|
||||
@@ -108,10 +112,15 @@ public sealed class NinjaSuitSystem : SharedNinjaSuitSystem
|
||||
{
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -130,11 +139,16 @@ public sealed class NinjaSuitSystem : SharedNinjaSuitSystem
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -142,17 +156,22 @@ public sealed class NinjaSuitSystem : SharedNinjaSuitSystem
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
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;
|
||||
@@ -15,18 +13,13 @@ using Content.Shared.Clothing.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;
|
||||
|
||||
@@ -43,13 +36,10 @@ public sealed class SpaceNinjaSystem : SharedSpaceNinjaSystem
|
||||
{
|
||||
[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!;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user