item toggling giga rework + full ninja refactor (#28039)
* item toggle refactoring and some new systems * add ToggleClothing component/system * unhardcode magboots gravity logic * make magboots and speedboots use ItemToggle and stuff * remove now useless clothing components * update client/server magboots systems * add note to use ItemToggledEvent in ToggleActionEvent doc * refactor PowerCellDraw to use ItemToggle for ui open/close control * add TryUseCharges, refactor charges system * update magboot trigger code * make borg use ItemToggle, network SelectedModule instead of now removed Activated * add AccessToggle for borg * the giga ninja refactor * update ninja yml * update ItemToggle usage for some stuff * fix activatableui requires power * random fixing * yaml fixing * nuke ItemToggleDisarmMalus * make defib use ItemToggle * make things that use power not turn on if missing use charge * pro * fix sound prediction * bruh * proximity detector use ItemToggle * oop * big idiot syndrome * fix ninja spawn rule and make it generic * fix ninja spawn rule yml * move loading profiles into AntagLoadProfileRule * more ninja refactor * ninja yml fixes * the dreaded copy paste ops * remove useless NinjaRuleComponent and ue AntagSelection for greeting * fix invisibility * move IsCompleted to SharedObjectivesSystem * ability fixes * oop fix powercell instantly draining itself * sentient speedboots gaming * make reflect use ItemToggle * fix other test * loadprofilerule moved into its own pr * remove conflict with dragon refactor * remove all GenericAntag code from ninja * ) * probably * remove old enabled * great language bravo vince * GREAT LANGUAGE * who made this language * because it stinks * reparent blood-red magboots to magboots probbbly works * most of the review stuff * hasGrav doesnt mean what i thought it did * make health analyzer use itemtoggle, not fail test * fix mag/speed boots being wacky * UNTROLL * add ItemToggle to the random health analyzers * a * remove unused obsolete borg func * untrolling * :trollface: * fix test * fix * g * untroll --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
@@ -2,7 +2,6 @@ using Content.Server.Communications;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.CriminalRecords.Systems;
|
||||
using Content.Server.GameTicking.Rules.Components;
|
||||
using Content.Server.GenericAntag;
|
||||
using Content.Server.Objectives.Components;
|
||||
using Content.Server.Objectives.Systems;
|
||||
using Content.Server.Power.Components;
|
||||
@@ -11,7 +10,6 @@ using Content.Server.PowerCell;
|
||||
using Content.Server.Research.Systems;
|
||||
using Content.Server.Roles;
|
||||
using Content.Shared.Alert;
|
||||
using Content.Shared.Clothing.EntitySystems;
|
||||
using Content.Shared.Doors.Components;
|
||||
using Content.Shared.IdentityManagement;
|
||||
using Content.Shared.Mind;
|
||||
@@ -26,11 +24,6 @@ using Robust.Shared.Audio.Systems;
|
||||
|
||||
namespace Content.Server.Ninja.Systems;
|
||||
|
||||
// TODO: when syndiborgs are a thing have a borg converter with 6 second doafter
|
||||
// engi -> saboteur
|
||||
// medi -> idk reskin it
|
||||
// other -> assault
|
||||
|
||||
/// <summary>
|
||||
/// Main ninja system that handles ninja setup, provides helper methods for the rest of the code to use.
|
||||
/// </summary>
|
||||
@@ -44,13 +37,11 @@ public sealed class SpaceNinjaSystem : SharedSpaceNinjaSystem
|
||||
[Dependency] private readonly RoleSystem _role = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
[Dependency] private readonly SharedMindSystem _mind = default!;
|
||||
[Dependency] private readonly StealthClothingSystem _stealthClothing = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<SpaceNinjaComponent, GenericAntagCreatedEvent>(OnNinjaCreated);
|
||||
SubscribeLocalEvent<SpaceNinjaComponent, EmaggedSomethingEvent>(OnDoorjack);
|
||||
SubscribeLocalEvent<SpaceNinjaComponent, ResearchStolenEvent>(OnResearchStolen);
|
||||
SubscribeLocalEvent<SpaceNinjaComponent, ThreatCalledInEvent>(OnThreatCalledIn);
|
||||
@@ -62,7 +53,7 @@ public sealed class SpaceNinjaSystem : SharedSpaceNinjaSystem
|
||||
var query = EntityQueryEnumerator<SpaceNinjaComponent>();
|
||||
while (query.MoveNext(out var uid, out var ninja))
|
||||
{
|
||||
UpdateNinja(uid, ninja, frameTime);
|
||||
SetSuitPowerAlert((uid, ninja));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,31 +71,13 @@ public sealed class SpaceNinjaSystem : SharedSpaceNinjaSystem
|
||||
return newCount - oldCount;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a ninja's gamerule config data.
|
||||
/// If the gamerule was not started then it will be started automatically.
|
||||
/// </summary>
|
||||
public NinjaRuleComponent? NinjaRule(EntityUid uid, GenericAntagComponent? comp = null)
|
||||
{
|
||||
if (!Resolve(uid, ref comp))
|
||||
return null;
|
||||
|
||||
// mind not added yet so no rule
|
||||
if (comp.RuleEntity == null)
|
||||
return null;
|
||||
|
||||
return CompOrNull<NinjaRuleComponent>(comp.RuleEntity);
|
||||
}
|
||||
|
||||
// TODO: can probably copy paste borg code here
|
||||
/// <summary>
|
||||
/// Update the alert for the ninja's suit power indicator.
|
||||
/// </summary>
|
||||
public void SetSuitPowerAlert(EntityUid uid, SpaceNinjaComponent? comp = null)
|
||||
public void SetSuitPowerAlert(Entity<SpaceNinjaComponent> ent)
|
||||
{
|
||||
if (!Resolve(uid, ref comp, false))
|
||||
return;
|
||||
|
||||
var (uid, comp) = ent;
|
||||
if (comp.Deleted || comp.Suit == null)
|
||||
{
|
||||
_alerts.ClearAlert(uid, comp.SuitPowerAlert);
|
||||
@@ -145,53 +118,6 @@ public sealed class SpaceNinjaSystem : SharedSpaceNinjaSystem
|
||||
return GetNinjaBattery(user, out var uid, out var battery) && _battery.TryUseCharge(uid.Value, charge, battery);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Set up everything for ninja to work and send the greeting message/sound.
|
||||
/// Objectives are added by <see cref="GenericAntagSystem"/>.
|
||||
/// </summary>
|
||||
private void OnNinjaCreated(EntityUid uid, SpaceNinjaComponent comp, ref GenericAntagCreatedEvent args)
|
||||
{
|
||||
var mindId = args.MindId;
|
||||
var mind = args.Mind;
|
||||
|
||||
if (mind.Session == null)
|
||||
return;
|
||||
|
||||
var config = NinjaRule(uid);
|
||||
if (config == null)
|
||||
return;
|
||||
|
||||
var role = new NinjaRoleComponent
|
||||
{
|
||||
PrototypeId = "SpaceNinja"
|
||||
};
|
||||
_role.MindAddRole(mindId, role, mind);
|
||||
_role.MindPlaySound(mindId, config.GreetingSound, mind);
|
||||
|
||||
var session = mind.Session;
|
||||
_audio.PlayGlobal(config.GreetingSound, Filter.Empty().AddPlayer(session), false, AudioParams.Default);
|
||||
_chatMan.DispatchServerMessage(session, Loc.GetString("ninja-role-greeting"));
|
||||
}
|
||||
|
||||
// TODO: PowerCellDraw, modify when cloak enabled
|
||||
/// <summary>
|
||||
/// Handle constant power drains from passive usage and cloak.
|
||||
/// </summary>
|
||||
private void UpdateNinja(EntityUid uid, SpaceNinjaComponent ninja, float frameTime)
|
||||
{
|
||||
if (ninja.Suit == null)
|
||||
return;
|
||||
|
||||
float wattage = Suit.SuitWattage(ninja.Suit.Value);
|
||||
|
||||
SetSuitPowerAlert(uid, ninja);
|
||||
if (!TryUseCharge(uid, wattage * frameTime))
|
||||
{
|
||||
// ran out of power, uncloak ninja
|
||||
_stealthClothing.SetEnabled(ninja.Suit.Value, uid, false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increment greentext when emagging a door.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user