Make CuffableComponent and CuffableSystem not Crash (Hopefully) (#39123)

* This system is ancient

* Destroy that API

* Address reviews

* Destroy merge conflicts from orbit

* seems to work fine

---------

Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com>
This commit is contained in:
Princess Cheeseballs
2025-11-01 06:22:13 -07:00
committed by GitHub
parent 3d095c8eed
commit 04b71d8203
6 changed files with 89 additions and 58 deletions

View File

@@ -15,7 +15,7 @@ namespace Content.Server.Cuffs
SubscribeLocalEvent<CuffableComponent, ComponentGetState>(OnCuffableGetState);
}
private void OnCuffableGetState(EntityUid uid, CuffableComponent component, ref ComponentGetState args)
private void OnCuffableGetState(Entity<CuffableComponent> entity, ref ComponentGetState args)
{
// there are 2 approaches i can think of to handle the handcuff overlay on players
// 1 - make the current RSI the handcuff type that's currently active. all handcuffs on the player will appear the same.
@@ -23,12 +23,12 @@ namespace Content.Server.Cuffs
// approach #2 would be more difficult/time consuming to do and the payoff doesn't make it worth it.
// right now we're doing approach #1.
HandcuffComponent? cuffs = null;
if (component.CuffedHandCount > 0)
TryComp(component.LastAddedCuffs, out cuffs);
args.State = new CuffableComponentState(component.CuffedHandCount,
component.CanStillInteract,
if (TryGetLastCuff((entity, entity.Comp), out var cuff))
TryComp(cuff, out cuffs);
args.State = new CuffableComponentState(entity.Comp.CuffedHandCount,
entity.Comp.CanStillInteract,
cuffs?.CuffedRSI,
$"{cuffs?.BodyIconState}-{component.CuffedHandCount}",
$"{cuffs?.BodyIconState}-{entity.Comp.CuffedHandCount}",
cuffs?.Color);
// the iconstate is formatted as blah-2, blah-4, blah-6, etc.
// the number corresponds to how many hands are cuffed.