Skip to content

Commit

Permalink
Update Role Texts
Browse files Browse the repository at this point in the history
  • Loading branch information
mxyx0412 committed Sep 15, 2024
1 parent 1c52c75 commit 03767d6
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions TheOtherRoles/Patches/IntroPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ class SetUpRoleTextPatch
public static void SetRoleTexts(IntroCutscene __instance)
{
// Don't override the intro of the vanilla roles
List<RoleInfo> infos = RoleInfo.getRoleInfoForPlayer(CachedPlayer.LocalPlayer.PlayerControl);
RoleInfo roleInfo = infos.Where(info => !info.isModifier).FirstOrDefault();
RoleInfo modifierInfo = infos.Where(info => info.isModifier).FirstOrDefault();
var infos = RoleInfo.getRoleInfoForPlayer(CachedPlayer.LocalPlayer.PlayerControl);
var roleInfo = infos.Where(info => !info.isModifier).FirstOrDefault();
var modifierInfo = infos.Where(info => info.isModifier).FirstOrDefault();

if (EventUtility.isEnabled)
{
Expand All @@ -280,13 +280,29 @@ public static void SetRoleTexts(IntroCutscene __instance)
}

__instance.RoleBlurbText.text = "";

if (roleInfo != null)
{
__instance.RoleText.text = roleInfo.name;
__instance.RoleText.color = roleInfo.color;
__instance.RoleBlurbText.text = roleInfo.introDescription;
__instance.RoleBlurbText.color = roleInfo.color;
}

if (Deputy.knowsSheriff && Deputy.deputy != null && Sheriff.sheriff != null)
{
if (infos.Any(info => info.roleId == RoleId.Sheriff))
__instance.RoleBlurbText.text = cs(Sheriff.color, $"\nYour Deputy is {Deputy.deputy?.Data?.PlayerName ?? ""}");
else if (infos.Any(info => info.roleId == RoleId.Deputy))
__instance.RoleBlurbText.text = cs(Sheriff.color, $"\nYour Sheriff is {Sheriff.sheriff?.Data?.PlayerName ?? ""}");
}
else if (Lawyer.lawyer != null && Lawyer.target != null && infos.Any(info => info.roleId == RoleId.Lawyer))
{
__instance.RoleBlurbText.text = Lawyer.isProsecutor
? cs(Lawyer.color, $"\nVote {Lawyer.target?.Data?.PlayerName ?? " Out!"}")
: cs(Lawyer.color, $"\nYour target is {Lawyer.target?.Data?.PlayerName ?? ""}");
}

if (modifierInfo != null)
{
if (modifierInfo.roleId != RoleId.Lover)
Expand All @@ -297,13 +313,6 @@ public static void SetRoleTexts(IntroCutscene __instance)
__instance.RoleBlurbText.text += cs(Lovers.color, $"\n♥ You are in love with {otherLover?.Data?.PlayerName ?? ""} ♥");
}
}
if (Deputy.knowsSheriff && Deputy.deputy != null && Sheriff.sheriff != null)
{
if (infos.Any(info => info.roleId == RoleId.Sheriff))
__instance.RoleBlurbText.text += cs(Sheriff.color, $"\nYour Deputy is {Deputy.deputy?.Data?.PlayerName ?? ""}");
else if (infos.Any(info => info.roleId == RoleId.Deputy))
__instance.RoleBlurbText.text += cs(Sheriff.color, $"\nYour Sheriff is {Sheriff.sheriff?.Data?.PlayerName ?? ""}");
}
}
public static bool Prefix(IntroCutscene __instance)
{
Expand Down

0 comments on commit 03767d6

Please sign in to comment.