Files
tbd-station-14/Content.Shared/Mindshield/FakeMindShield/SharedFakeMindshieldSystem.cs
beck-thompson 05fac53de6 Chameleon controller implant (Clothing fast switch) (#33887)
* Add the chameleon controller implant

* address the issues (Git please dont kill me)

* Address the review and fix some merge conflicts!

* Cleanup

* Add use delay

* Silly mistakes

* Making a PR at 2 am: Gone wrong

* Predict use delay and disable the buttons until you can choose another

* First phase custom clothing

* Better system, now relays to agent id and mindshield. Chameleon loadouts are a lot better to work with as well

* Address the review! No more evil goto

* Slams way is better I should have read more closely xD

* Some of the jobs

* Add to Cargo, CentComm, Service, Passenger, Ninja, Cluwne, Wizard + Minor changes to existing; Add chameleon to bandanas, medals, jugsuits and HUDs

* Add everything else

* Fix test

* Job name

* This looks better

* Add department organization

* Minor cleanup

* Added some mindshields

* Remove redudent comment and change funcion name to be clearer

* Fix cluwne outfit

* fix merge conflicts

---------

Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
2025-05-30 12:07:25 +02:00

77 lines
2.7 KiB
C#

using Content.Shared.Actions;
using Content.Shared.Actions.Components;
using Content.Shared.Implants;
using Content.Shared.Mindshield.Components;
using Content.Shared.Tag;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
namespace Content.Shared.Mindshield.FakeMindShield;
public sealed class SharedFakeMindShieldSystem : EntitySystem
{
[Dependency] private readonly SharedActionsSystem _actions = default!;
[Dependency] private readonly TagSystem _tag = default!;
[Dependency] private readonly IGameTiming _timing = default!;
// This tag should be placed on the fake mindshield action so there is a way to easily identify it.
private static readonly ProtoId<TagPrototype> FakeMindShieldImplantTag = "FakeMindShieldImplant";
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<FakeMindShieldComponent, FakeMindShieldToggleEvent>(OnToggleMindshield);
SubscribeLocalEvent<FakeMindShieldComponent, ChameleonControllerOutfitSelectedEvent>(OnChameleonControllerOutfitSelected);
}
private void OnToggleMindshield(EntityUid uid, FakeMindShieldComponent comp, FakeMindShieldToggleEvent toggleEvent)
{
comp.IsEnabled = !comp.IsEnabled;
Dirty(uid, comp);
}
private void OnChameleonControllerOutfitSelected(EntityUid uid, FakeMindShieldComponent component, ChameleonControllerOutfitSelectedEvent args)
{
if (component.IsEnabled == args.ChameleonOutfit.HasMindShield)
return;
// This assumes there is only one fake mindshield action per entity (This is currently enforced)
if (!TryComp<ActionsComponent>(uid, out var actionsComp))
return;
// In case the fake mindshield ever doesn't have an action.
var actionFound = false;
foreach (var action in actionsComp.Actions)
{
if (!_tag.HasTag(action, FakeMindShieldImplantTag))
continue;
if (!TryComp<ActionComponent>(action, out var actionComp))
continue;
actionFound = true;
if (_actions.IsCooldownActive(actionComp, _timing.CurTime))
continue;
component.IsEnabled = args.ChameleonOutfit.HasMindShield;
Dirty(uid, component);
if (actionComp.UseDelay != null)
_actions.SetCooldown(action, actionComp.UseDelay.Value);
return;
}
// If they don't have the action for some reason, still set it correctly.
if (!actionFound)
{
component.IsEnabled = args.ChameleonOutfit.HasMindShield;
Dirty(uid, component);
}
}
}
public sealed partial class FakeMindShieldToggleEvent : InstantActionEvent;