From f9600bc9061866afeaf47f1e54176d48b86de6f2 Mon Sep 17 00:00:00 2001 From: XtraCube <72575280+XtraCube@users.noreply.github.com> Date: Sat, 17 May 2025 23:27:14 -0400 Subject: [PATCH] fix chameleon role again --- MiraAPI.Example/Roles/ChameleonRole.cs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/MiraAPI.Example/Roles/ChameleonRole.cs b/MiraAPI.Example/Roles/ChameleonRole.cs index 69880d9..c1d7779 100644 --- a/MiraAPI.Example/Roles/ChameleonRole.cs +++ b/MiraAPI.Example/Roles/ChameleonRole.cs @@ -1,4 +1,5 @@ using AmongUs.GameOptions; +using MiraAPI.Patches.Stubs; using MiraAPI.Roles; using Reactor.Utilities; using TMPro; @@ -14,6 +15,8 @@ public class ChameloenRole : CrewmateRole, ICustomRole public Color RoleColor => Palette.AcceptedGreen; public ModdedRoleTeams Team => ModdedRoleTeams.Crewmate; + private bool _shouldHide; + public CustomRoleConfiguration Configuration => new(this) { OptionsScreenshot = ExampleAssets.Banner, @@ -22,13 +25,14 @@ public class ChameloenRole : CrewmateRole, ICustomRole public override void Initialize(PlayerControl player) { - Player = player; Logger.Info("Initializing ChamelonRole for player: " + player.PlayerId); + RoleBehaviourStubs.Initialize(this, player); + _shouldHide = true; } public void FixedUpdate() { - if (!Player) + if (!Player || !_shouldHide) { return; } @@ -58,4 +62,17 @@ public class ChameloenRole : CrewmateRole, ICustomRole } } } + + public override void Deinitialize(PlayerControl targetPlayer) + { + Logger.Info("Deinitializing ChamelonRole for player: " + targetPlayer.PlayerId); + RoleBehaviourStubs.Deinitialize(this, targetPlayer); + _shouldHide = false; + foreach (var cosmetic in Player.cosmetics.transform.GetComponentsInChildren(true)) + { + cosmetic.color = Color.white; + } + Player.cosmetics.currentBodySprite.BodySprite.color = Color.white; + Player.cosmetics.nameText.color = Color.white; + } }