* start of space ninja midround antag * suit has powercell, can be upgraded only (not replaced with equal or worse battery) * add doorjacking to ninja gloves, power cell, doorjack objective (broken), tweaks * 💀 * add basic suit power display that uses stamina rsi * add draining apc/sub/smes - no wires yet * add research downloading * ninja starts implanted, move some stuff to yaml * add Automated field to OnUseTimerTrigger * implement spider charge and objective * fix client crash when taking suit off, some refactor * add survive condition and tweak locale * add comms console icon for objective * add calling in a threat - currently revenant and dragon * combine all glove abilities * locale * spark sounds when draining, refactoring * toggle is actually toggle now * prevent crash if disabling stealth with outline * add antag ctrl for ninja, hopefully show greentext * fix greentext and some other things * disabling gloves if taken off or suit taken off * basic energy katana, change ninja loadout * recallable katana, refactoring * start of dash - not done yet * katana dashing ability * merge upstream + compiling, make AutomatedTimer its own component * docs and stuff * partial refactor of glove abilities, still need to move handling * make dooremaggedevent by ref * move bunch of stuff to shared - broken * clean ninja antag verb * doc * mark rule config fields as required * fix client crash * wip systems refactor * big refactor of systems * fuck * make TryDoElectrocution callable from shared * finish refactoring? * no guns * start with internals on * clean up glove abilities, add range check * create soap, in place of ninja throwing stars * add emp suit ability * able to eat chefs stolen food in space * stuff, tell client when un/cloaked but there is bug with gloves * fix prediction breaking gloves on client * ninja soap despawns after a minute * ninja spawns outside the station now, with gps + station coords to navigate * add cooldown to stun ability * cant use glove abilities in combat mode * require empty hand to use glove abilities * use ghost role spawner * Update Content.Server/Ninja/Systems/NinjaSuitSystem.cs Co-authored-by: keronshb <54602815+keronshb@users.noreply.github.com> * some review changes * show powercell charge on examine * new is needed * address some reviews * ninja starts with jetpack, i hope * partial feedback * uhh * pro * remove pirate from threats list * use doafter refactor * pro i gave skeleton jetpack * some stuff * use auto gen state * mr handy * use EntityQueryEnumerator * cleanup * spider charge target anti-troll * mmmmmm --------- Co-authored-by: deltanedas <deltanedas@laptop> Co-authored-by: deltanedas <user@zenith> Co-authored-by: deltanedas <@deltanedas:kde.org> Co-authored-by: keronshb <54602815+keronshb@users.noreply.github.com>
152 lines
5.3 KiB
C#
152 lines
5.3 KiB
C#
using Content.Shared.Actions;
|
|
using Content.Shared.Inventory.Events;
|
|
using Content.Shared.Ninja.Components;
|
|
using Content.Shared.Stealth;
|
|
using Content.Shared.Stealth.Components;
|
|
using Content.Shared.Timing;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Serialization;
|
|
|
|
namespace Content.Shared.Ninja.Systems;
|
|
|
|
public abstract class SharedNinjaSuitSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly SharedNinjaGlovesSystem _gloves = default!;
|
|
[Dependency] protected readonly SharedNinjaSystem _ninja = default!;
|
|
[Dependency] private readonly SharedStealthSystem _stealth = default!;
|
|
[Dependency] protected readonly UseDelaySystem _useDelay = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<NinjaSuitComponent, GotEquippedEvent>(OnEquipped);
|
|
SubscribeLocalEvent<NinjaSuitComponent, GetItemActionsEvent>(OnGetItemActions);
|
|
SubscribeLocalEvent<NinjaSuitComponent, GotUnequippedEvent>(OnUnequipped);
|
|
|
|
SubscribeNetworkEvent<SetCloakedMessage>(OnSetCloakedMessage);
|
|
}
|
|
|
|
private void OnEquipped(EntityUid uid, NinjaSuitComponent comp, GotEquippedEvent args)
|
|
{
|
|
var user = args.Equipee;
|
|
if (!TryComp<NinjaComponent>(user, out var ninja))
|
|
return;
|
|
|
|
NinjaEquippedSuit(uid, comp, user, ninja);
|
|
}
|
|
|
|
private void OnGetItemActions(EntityUid uid, NinjaSuitComponent comp, GetItemActionsEvent args)
|
|
{
|
|
args.Actions.Add(comp.TogglePhaseCloakAction);
|
|
args.Actions.Add(comp.RecallKatanaAction);
|
|
// TODO: ninja stars instead of soap, when embedding is a thing
|
|
// The cooldown should also be reduced from 10 to 1 or so
|
|
args.Actions.Add(comp.CreateSoapAction);
|
|
args.Actions.Add(comp.KatanaDashAction);
|
|
args.Actions.Add(comp.EmpAction);
|
|
}
|
|
|
|
private void OnUnequipped(EntityUid uid, NinjaSuitComponent comp, GotUnequippedEvent args)
|
|
{
|
|
UserUnequippedSuit(uid, comp, args.Equipee);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called when a suit is equipped by a space ninja.
|
|
/// In the future it might be changed to an explicit activation toggle/verb like gloves are.
|
|
/// </summary>
|
|
protected virtual void NinjaEquippedSuit(EntityUid uid, NinjaSuitComponent comp, EntityUid user, NinjaComponent ninja)
|
|
{
|
|
// mark the user as wearing this suit, used when being attacked among other things
|
|
_ninja.AssignSuit(ninja, uid);
|
|
|
|
// initialize phase cloak
|
|
EnsureComp<StealthComponent>(user);
|
|
SetCloaked(user, comp.Cloaked);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Force uncloak the user, disables suit abilities if the bool is set.
|
|
/// </summary>
|
|
public void RevealNinja(EntityUid uid, NinjaSuitComponent comp, EntityUid user, bool disableAbilities = false)
|
|
{
|
|
if (comp.Cloaked)
|
|
{
|
|
comp.Cloaked = false;
|
|
SetCloaked(user, false);
|
|
// TODO: add the box open thing its funny
|
|
|
|
if (disableAbilities)
|
|
_useDelay.BeginDelay(uid);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Returns the power used by a suit
|
|
/// </summary>
|
|
public float SuitWattage(NinjaSuitComponent suit)
|
|
{
|
|
float wattage = suit.PassiveWattage;
|
|
if (suit.Cloaked)
|
|
wattage += suit.CloakWattage;
|
|
return wattage;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets the stealth effect for a ninja cloaking.
|
|
/// Does not update suit Cloaked field, has to be done yourself.
|
|
/// </summary>
|
|
protected void SetCloaked(EntityUid user, bool cloaked)
|
|
{
|
|
if (!TryComp<StealthComponent>(user, out var stealth) || stealth.Deleted)
|
|
return;
|
|
|
|
// slightly visible, but doesn't change when moving so it's ok
|
|
var visibility = cloaked ? stealth.MinVisibility + 0.25f : stealth.MaxVisibility;
|
|
_stealth.SetVisibility(user, visibility, stealth);
|
|
_stealth.SetEnabled(user, cloaked, stealth);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Called when a suit is unequipped, not necessarily by a space ninja.
|
|
/// In the future it might be changed to also have explicit deactivation via toggle.
|
|
/// </summary>
|
|
protected virtual void UserUnequippedSuit(EntityUid uid, NinjaSuitComponent comp, EntityUid user)
|
|
{
|
|
// mark the user as not wearing a suit
|
|
if (TryComp<NinjaComponent>(user, out var ninja))
|
|
{
|
|
_ninja.AssignSuit(ninja, null);
|
|
// disable glove abilities
|
|
if (ninja.Gloves != null && TryComp<NinjaGlovesComponent>(ninja.Gloves.Value, out var gloves))
|
|
_gloves.DisableGloves(gloves, user);
|
|
}
|
|
|
|
// force uncloak the user
|
|
comp.Cloaked = false;
|
|
SetCloaked(user, false);
|
|
RemComp<StealthComponent>(user);
|
|
}
|
|
|
|
private void OnSetCloakedMessage(SetCloakedMessage msg)
|
|
{
|
|
if (TryComp<NinjaComponent>(msg.User, out var ninja) && TryComp<NinjaSuitComponent>(ninja.Suit, out var suit))
|
|
{
|
|
suit.Cloaked = msg.Cloaked;
|
|
SetCloaked(msg.User, msg.Cloaked);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Calls SetCloaked on the client from the server, along with updating the suit Cloaked bool.
|
|
/// </summary>
|
|
[Serializable, NetSerializable]
|
|
public sealed class SetCloakedMessage : EntityEventArgs
|
|
{
|
|
public EntityUid User;
|
|
public bool Cloaked;
|
|
}
|