diff --git a/MiraAPI/Patches/IntroCutscenePatches.cs b/MiraAPI/Patches/IntroCutscenePatches.cs index b98c58e..415e9d6 100644 --- a/MiraAPI/Patches/IntroCutscenePatches.cs +++ b/MiraAPI/Patches/IntroCutscenePatches.cs @@ -32,25 +32,8 @@ public static class IntroCutscenePatches [HarmonyPrefix] [HarmonyPatch(nameof(IntroCutscene.BeginImpostor))] - public static void BeginImpostorPatch(IntroCutscene __instance) - { - if (PlayerControl.LocalPlayer.Data.Role is not ICustomRole customRole) - { - return; - } - - if (customRole.IntroConfiguration is { } introConfig) - { - __instance.BackgroundBar.material.SetColor(ShaderID.Color, introConfig.IntroTeamColor); - __instance.TeamTitle.color = introConfig.IntroTeamColor; - __instance.TeamTitle.text = introConfig.IntroTeamTitle; - __instance.ImpostorText.text = introConfig.IntroTeamDescription; - } - } - - [HarmonyPrefix] [HarmonyPatch(nameof(IntroCutscene.BeginCrewmate))] - public static bool BeginCrewmatePatch(IntroCutscene __instance) + public static bool BeginImpostorPatch(IntroCutscene __instance, [HarmonyArgument(0)] ref Il2CppSystem.Collections.Generic.List yourTeam) { if (PlayerControl.LocalPlayer.Data.Role is not ICustomRole customRole) { @@ -65,24 +48,7 @@ public static class IntroCutscenePatches __instance.ImpostorText.text = introConfig.IntroTeamDescription; } - if (customRole.Team is not ModdedRoleTeams.Custom) - { - return true; - } - - var barTransform = __instance.BackgroundBar.transform; - var position = barTransform.position; - position.y -= 0.25f; - barTransform.position = position; - - __instance.impostorScale = 1f; - - __instance.ourCrewmate = __instance.CreatePlayer( - 0, - Mathf.CeilToInt(7.5f), - PlayerControl.LocalPlayer.Data, - false); - return false; + return customRole.SetupIntroTeam(__instance, ref yourTeam); } /* diff --git a/MiraAPI/Roles/ICustomRole.cs b/MiraAPI/Roles/ICustomRole.cs index a452d1e..0adc386 100644 --- a/MiraAPI/Roles/ICustomRole.cs +++ b/MiraAPI/Roles/ICustomRole.cs @@ -158,6 +158,26 @@ public interface ICustomRole return (PlayerControl.LocalPlayer.Data.Role.IsImpostor && player.Data.Role.IsImpostor) || PlayerControl.LocalPlayer.Data.IsDead; } + /// + /// Allows the role to specify who is shown on the intro team screen. + /// + /// The intro cutscene instance. + /// The reference to the list of player in the team. + /// True to use the original team intro code, false to skip. + public virtual bool SetupIntroTeam(IntroCutscene instance, ref Il2CppSystem.Collections.Generic.List yourTeam) + { + if (Team == ModdedRoleTeams.Custom) + { + var team = new Il2CppSystem.Collections.Generic.List(); + + team.Add(PlayerControl.LocalPlayer); + + yourTeam = team; + } + + return true; + } + /// /// This method runs on the HudManager.Update method ONLY when the LOCAL player has this role. ///