public static getRoleInfoForPlayer ( PlayerControl p, Array excludeRoles = null, bool includeHidden = false ) : List |
||
p | PlayerControl | |
excludeRoles | Array | |
includeHidden | bool | |
Résultat | List |
// Intro display role static void Postfix(IntroCutscene.CoBegin__d __instance) { RoleInfo roleInfo = RoleInfo.getRoleInfoForPlayer(PlayerControl.LocalPlayer); if (PlayerControl.LocalPlayer == Lovers.lover1 || PlayerControl.LocalPlayer == Lovers.lover2) { PlayerControl otherLover = PlayerControl.LocalPlayer == Lovers.lover1 ? Lovers.lover2 : Lovers.lover1; __instance.__this.Title.Text = PlayerControl.LocalPlayer.Data.IsImpostor ? "[FF1919FF]Imp[FC03BEFF]Lover" : "Lover"; __instance.__this.Title.Color = PlayerControl.LocalPlayer.Data.IsImpostor ? Color.white : Lovers.color; __instance.__this.ImpostorText.Text = "You are in [FC03BEFF]Love [FFFFFFFF] with [FC03BEFF]" + (otherLover?.Data?.PlayerName ?? ""); __instance.__this.ImpostorText.gameObject.SetActive(true); __instance.__this.BackgroundBar.material.color = Lovers.color; } else if (PlayerControl.LocalPlayer == BountyHunter.bountyHunter) { __instance.__this.Title.Text = "Bounty Hunter"; __instance.__this.Title.Color = BountyHunter.color; __instance.__this.ImpostorText.Text = "Hunt [ED653BFF]" + BountyHunter.target?.Data?.PlayerName + "[FFFFFFFF] down"; __instance.__this.BackgroundBar.material.color = BountyHunter.color; } else if (roleInfo.name == "Crewmate" || roleInfo.name == "Impostor") { } else { __instance.__this.Title.Text = roleInfo.name; __instance.__this.Title.Color = roleInfo.color; __instance.__this.ImpostorText.gameObject.SetActive(true); __instance.__this.ImpostorText.Text = roleInfo.introDescription; __instance.__this.BackgroundBar.material.color = roleInfo.color; } }
// Intro display role static void Postfix(IntroCutscene._CoBegin_d__11 __instance) { List <RoleInfo> infos = RoleInfo.getRoleInfoForPlayer(PlayerControl.LocalPlayer); if (infos.Count == 0) { return; } RoleInfo roleInfo = infos[0]; if (PlayerControl.LocalPlayer == Lovers.lover1 || PlayerControl.LocalPlayer == Lovers.lover2) { PlayerControl otherLover = PlayerControl.LocalPlayer == Lovers.lover1 ? Lovers.lover2 : Lovers.lover1; __instance.__4__this.Title.text = PlayerControl.LocalPlayer.Data.IsImpostor ? "<color=#FF1919FF>Imp</color><color=#FC03BEFF>Lover</color>" : "<color=#FC03BEFF>Lover</color>"; __instance.__4__this.Title.color = PlayerControl.LocalPlayer.Data.IsImpostor ? Color.white : Lovers.color; __instance.__4__this.ImpostorText.text = "You are in <color=#FC03BEFF>Love</color><color=#FFFFFFFF> with </color><color=#FC03BEFF>" + (otherLover?.Data?.PlayerName ?? "") + "</color>"; __instance.__4__this.ImpostorText.gameObject.SetActive(true); __instance.__4__this.BackgroundBar.material.color = Lovers.color; } else if (roleInfo.name == "Crewmate" || roleInfo.name == "Impostor") { } else { __instance.__4__this.Title.text = roleInfo.name; __instance.__4__this.Title.color = roleInfo.color; __instance.__4__this.ImpostorText.gameObject.SetActive(true); __instance.__4__this.ImpostorText.text = roleInfo.introDescription; __instance.__4__this.BackgroundBar.material.color = roleInfo.color; } }
// Intro display role static void Postfix(IntroCutscene.MDIMNFHLFBN __instance) { List <RoleInfo> infos = RoleInfo.getRoleInfoForPlayer(PlayerControl.LocalPlayer); if (infos.Count == 0) { return; } RoleInfo roleInfo = infos[0]; if (PlayerControl.LocalPlayer == Lovers.lover1 || PlayerControl.LocalPlayer == Lovers.lover2) { PlayerControl otherLover = PlayerControl.LocalPlayer == Lovers.lover1 ? Lovers.lover2 : Lovers.lover1; __instance.__4__this.Title.Text = PlayerControl.LocalPlayer.IDOFAMCIJKE.CIDDOFDJHJH ? "[FF1919FF]Imp[FC03BEFF]Lover" : "Lover"; __instance.__4__this.Title.Color = PlayerControl.LocalPlayer.IDOFAMCIJKE.CIDDOFDJHJH ? Color.white : Lovers.color; __instance.__4__this.ImpostorText.Text = "You are in [FC03BEFF]Love [FFFFFFFF] with [FC03BEFF]" + (otherLover?.IDOFAMCIJKE?.HGGCLJHCDBM ?? ""); __instance.__4__this.ImpostorText.gameObject.SetActive(true); __instance.__4__this.BackgroundBar.material.color = Lovers.color; } else if (roleInfo.name == "Crewmate" || roleInfo.name == "Impostor") { } else { __instance.__4__this.Title.Text = roleInfo.name; __instance.__4__this.Title.Color = roleInfo.color; __instance.__4__this.ImpostorText.gameObject.SetActive(true); __instance.__4__this.ImpostorText.Text = roleInfo.introDescription; __instance.__4__this.BackgroundBar.material.color = roleInfo.color; } }
public static void updateGhostInfo() { foreach (PlayerControl p in PlayerControl.AllPlayerControls) { if (p != PlayerControl.LocalPlayer && !PlayerControl.LocalPlayer.Data.IsDead) { continue; } Transform playerGhostInfoTransform = p.transform.FindChild("GhostInfo"); TMPro.TextMeshPro playerGhostInfo = playerGhostInfoTransform != null?playerGhostInfoTransform.GetComponent <TMPro.TextMeshPro>() : null; if (playerGhostInfo == null) { playerGhostInfo = UnityEngine.Object.Instantiate(p.nameText, p.nameText.transform.parent); playerGhostInfo.transform.localPosition += Vector3.up * 0.25f; playerGhostInfo.fontSize *= 0.75f; playerGhostInfo.gameObject.name = "GhostInfo"; } PlayerVoteArea playerVoteArea = MeetingHud.Instance?.playerStates?.FirstOrDefault(x => x.TargetPlayerId == p.PlayerId); Transform meetingGhostInfoTransform = playerVoteArea != null?playerVoteArea.transform.FindChild("GhostInfo") : null; TMPro.TextMeshPro meetingGhostInfo = meetingGhostInfoTransform != null?meetingGhostInfoTransform.GetComponent <TMPro.TextMeshPro>() : null; if (meetingGhostInfo == null && playerVoteArea != null) { meetingGhostInfo = UnityEngine.Object.Instantiate(playerVoteArea.NameText, playerVoteArea.NameText.transform.parent); meetingGhostInfo.transform.localPosition += Vector3.down * (MeetingHud.Instance.playerStates.Length > 10 ? 0.4f : 0.25f); meetingGhostInfo.fontSize *= 0.75f; meetingGhostInfo.gameObject.name = "GhostInfo"; } var(tasksCompleted, tasksTotal) = TasksHandler.taskInfo(p.Data); string roleNames = String.Join(", ", RoleInfo.getRoleInfoForPlayer(p).Select(x => Helpers.cs(x.color, x.name)).ToArray()); string taskInfo = tasksTotal > 0 ? $"<color=#FAD934FF>({tasksCompleted}/{tasksTotal})</color>" : ""; string info = ""; if (p == PlayerControl.LocalPlayer || (MapOptions.ghostsSeeRoles && MapOptions.ghostsSeeTasks)) { info = $"{roleNames} {taskInfo}".Trim(); } else if (MapOptions.ghostsSeeTasks) { info = $"{taskInfo}".Trim(); } else if (MapOptions.ghostsSeeRoles) { info = $"{roleNames}"; } playerGhostInfo.text = info; playerGhostInfo.gameObject.SetActive(p.Visible); if (meetingGhostInfo != null) { meetingGhostInfo.text = MeetingHud.Instance.state == MeetingHud.VoteStates.Results ? "" : info; } } }
public static void refreshRoleDescription(PlayerControl player) { if (player == null) { return; } List <RoleInfo> infos = RoleInfo.getRoleInfoForPlayer(player); var toRemove = new List <PlayerTask>(); foreach (PlayerTask t in player.myTasks) { var textTask = t.gameObject.GetComponent <ImportantTextTask>(); if (textTask != null) { var info = infos.FirstOrDefault(x => textTask.Text.StartsWith(x.name)); if (info != null) { infos.Remove(info); // TextTask for this RoleInfo does not have to be added, as it already exists } else { toRemove.Add(t); // TextTask does not have a corresponding RoleInfo and will hence be deleted } } } foreach (PlayerTask t in toRemove) { t.OnRemove(); player.myTasks.Remove(t); UnityEngine.Object.Destroy(t.gameObject); } // Add TextTask for remaining RoleInfos foreach (RoleInfo roleInfo in infos) { var task = new GameObject("RoleTask").AddComponent <ImportantTextTask>(); task.transform.SetParent(player.transform, false); if (roleInfo.name == "Jackal") { var getSidekickText = Jackal.canCreateSidekick ? " and recruit a Sidekick" : ""; task.Text = $"{roleInfo.colorHexString()}{roleInfo.name}: Kill everyone{getSidekickText}"; } else { task.Text = $"{roleInfo.colorHexString()}{roleInfo.name}: {roleInfo.shortDescription}"; } player.myTasks.Insert(0, task); } }
public static void seerReveal(byte targetId, byte targetOrMistakeId) { if (Seer.seer == null) { return; } PlayerControl target = Helpers.playerById(targetId); PlayerControl targetOrMistake = Helpers.playerById(targetOrMistakeId); if (target != null && targetOrMistake != null && !Seer.revealedPlayers.Keys.Any(p => p.Data.PlayerId == targetId)) { Seer.revealedPlayers.Add(target, targetOrMistake); if (PlayerControl.LocalPlayer == target && HudManager.Instance?.FullScreen != null) { RoleInfo si = RoleInfo.getRoleInfoForPlayer(target); // Use RoleInfo of target here, because we need the isGood of the targets role bool showNotification = false; if (Seer.playersWithNotification == 0) { showNotification = true; } else if (Seer.playersWithNotification == 1 && si.isGood) { showNotification = true; } else if (Seer.playersWithNotification == 2 && !si.isGood) { showNotification = true; } else if (Seer.playersWithNotification == 3) { showNotification = false; } if (showNotification) { HudManager.Instance.FullScreen.enabled = true; Reactor.Coroutines.Start(Helpers.CoFlashAndDisable( HudManager.Instance.FullScreen, 0.5f, new Color(42f / 255f, 187f / 255f, 245f / 255f, 0f), new Color(42f / 255f, 187f / 255f, 245f / 255f, 0.75f) )); } } } }
static void seerUpdate() { if (Seer.seer == null || Seer.seer != PlayerControl.LocalPlayer) { return; } // Update revealed players foreach (KeyValuePair <PlayerControl, PlayerControl> entry in Seer.revealedPlayers) { PlayerControl target = entry.Key; PlayerControl targetOrMistake = entry.Value; if (target == null || targetOrMistake == null) { continue; } // Update color and name regarding settings and given info string result = target.Data.PlayerName; RoleInfo si = RoleInfo.getRoleInfoForPlayer(targetOrMistake); if (Seer.kindOfInfo == 0) { result = target.Data.PlayerName + " (" + si.name + ")"; } else if (Seer.kindOfInfo == 1) { si.color = si.isGood ? new Color(250f / 255f, 217f / 255f, 52f / 255f, 1) : new Color(51f / 255f, 61f / 255f, 54f / 255f, 1); } // Set color and name target.nameText.Color = si.color; target.nameText.Text = result; if (MeetingHud.Instance != null) { foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { if (target.PlayerId == player.TargetPlayerId) { player.NameText.Text = result; player.NameText.Color = si.color; break; } } } } }
public static void Postfix(PlayerControl __instance) { if (PlayerControl.LocalPlayer == null) { return; } // Remove default ImportantTextTasks var toRemove = new List <PlayerTask>(); foreach (PlayerTask t in __instance.myTasks) { if (t.gameObject.GetComponent <ImportantTextTask>() != null) { toRemove.Add(t); } } foreach (PlayerTask t in toRemove) { __instance.RemoveTask(t); } // Add description RoleInfo roleInfo = RoleInfo.getRoleInfoForPlayer(__instance); var task = new GameObject("RoleTask").AddComponent <ImportantTextTask>(); task.transform.SetParent(__instance.transform, false); if (__instance == Jackal.jackal) { var getSidekickText = Jackal.canCreateSidekick ? " and recruit a Sidekick" : ""; task.Text = $"{roleInfo.colorHexString()}{roleInfo.name}: Kill everyone{getSidekickText}"; } else { task.Text = $"{roleInfo.colorHexString()}{roleInfo.name}: {roleInfo.shortDescription}"; } __instance.myTasks.Insert(0, task); }
public static void showInfoOverlay() { if (overlayShown || MapOptions.hideSettings) { return; } HudManager hudManager = DestroyableSingleton <HudManager> .Instance; if (ShipStatus.Instance == null || PlayerControl.LocalPlayer == null || hudManager == null || HudManager.Instance.IsIntroDisplayed || (!PlayerControl.LocalPlayer.CanMove && MeetingHud.Instance == null)) { return; } if (!initializeOverlays()) { return; } hideRoleOverlay(); if (MapBehaviour.Instance != null) { MapBehaviour.Instance.Close(); } hudManager.SetHudActive(false); overlayShown = true; Transform parent; if (MeetingHud.Instance != null) { parent = MeetingHud.Instance.transform; } else { parent = hudManager.transform; } infoUnderlay.transform.parent = parent; infoOverlayRules.transform.parent = parent; infoOverlayRoles.transform.parent = parent; infoUnderlay.sprite = colorBG; infoUnderlay.color = new Color(0.1f, 0.1f, 0.1f, 0.88f); infoUnderlay.transform.localScale = new Vector3(7.5f, 5f, 1f); infoUnderlay.enabled = true; TheOtherRolesPlugin.optionsPage = 0; GameOptionsData o = PlayerControl.GameOptions; List <string> gameOptions = o.ToString().Split("\n", StringSplitOptions.RemoveEmptyEntries).ToList().GetRange(2, 17); infoOverlayRules.text = string.Join("\n", gameOptions) + "\n\n" + GameOptionsDataPatch.optionsToString(CustomOptionHolder.specialOptions); infoOverlayRules.enabled = true; string rolesText = ""; foreach (RoleInfo r in RoleInfo.getRoleInfoForPlayer(PlayerControl.LocalPlayer)) { string roleOptions = r.roleOptions; string roleDesc = r.fullDescription; rolesText += $"<size=150%>{r.nameColored}</size>" + (roleDesc != "" ? $"\n{r.fullDescription}" : "") + "\n\n" + (roleOptions != "" ? $"{roleOptions}\n\n" : ""); } infoOverlayRoles.text = rolesText; infoOverlayRoles.enabled = true; var underlayTransparent = new Color(0.1f, 0.1f, 0.1f, 0.0f); var underlayOpaque = new Color(0.1f, 0.1f, 0.1f, 0.88f); HudManager.Instance.StartCoroutine(Effects.Lerp(0.2f, new Action <float>(t => { infoUnderlay.color = Color.Lerp(underlayTransparent, underlayOpaque, t); infoOverlayRules.color = Color.Lerp(Palette.ClearWhite, Palette.White, t); infoOverlayRoles.color = Color.Lerp(Palette.ClearWhite, Palette.White, t); }))); }
public static void divine(PlayerControl p) { // FortuneTeller.divine(p, resultIsCrewOrNot); string msgBase = ""; string msgInfo = ""; Color color = Color.white; if (divineResult == DivineResults.BlackWhite) { if (p.isCrew()) { msgBase = "divineMessageIsCrew"; color = Color.white; } else { msgBase = "divineMessageIsntCrew"; color = Palette.ImpostorRed; } } else if (divineResult == DivineResults.Team) { msgBase = "divineMessageTeam"; if (p.isCrew()) { msgInfo = ModTranslation.getString("divineCrew"); color = Color.white; } else if (p.isNeutral()) { msgInfo = ModTranslation.getString("divineNeutral"); color = Color.yellow; } else { msgInfo = ModTranslation.getString("divineImpostor"); color = Palette.ImpostorRed; } } else if (divineResult == DivineResults.Role) { msgBase = "divineMessageRole"; msgInfo = String.Join(" ", RoleInfo.getRoleInfoForPlayer(p).Select(x => Helpers.cs(x.color, x.name)).ToArray()); } string msg = string.Format(ModTranslation.getString(msgBase), p.name, msgInfo); if (!string.IsNullOrWhiteSpace(msg)) { FortuneTeller.fortuneTellerMessage(msg, 5f, color); } if (Constants.ShouldPlaySfx()) { SoundManager.Instance.PlaySound(DestroyableSingleton <HudManager> .Instance.TaskCompleteSound, false, 0.8f); } numUsed += 1; // 占いを実行したことで発火される処理を他クライアントに通知 MessageWriter writer = AmongUsClient.Instance.StartRpcImmediately(PlayerControl.LocalPlayer.NetId, (byte)CustomRPC.FortuneTellerUsedDivine, Hazel.SendOption.Reliable, -1); writer.Write(PlayerControl.LocalPlayer.PlayerId); writer.Write(p.PlayerId); AmongUsClient.Instance.FinishRpcImmediately(writer); RPCProcedure.fortuneTellerUsedDivine(PlayerControl.LocalPlayer.PlayerId, p.PlayerId); numUsed += 1; }
public static void refreshRoleDescription(PlayerControl player) { if (player == null) { return; } List <RoleInfo> infos = RoleInfo.getRoleInfoForPlayer(player); var toRemove = new List <PlayerTask>(); foreach (PlayerTask t in player.myTasks) { var textTask = t.gameObject.GetComponent <ImportantTextTask>(); if (textTask != null) { var info = infos.FirstOrDefault(x => textTask.Text.StartsWith(x.name)); if (info != null) { infos.Remove(info); // TextTask for this RoleInfo does not have to be added, as it already exists } else { toRemove.Add(t); // TextTask does not have a corresponding RoleInfo and will hence be deleted } } } foreach (PlayerTask t in toRemove) { t.OnRemove(); player.myTasks.Remove(t); UnityEngine.Object.Destroy(t.gameObject); } // Add TextTask for remaining RoleInfos foreach (RoleInfo roleInfo in infos) { var task = new GameObject("RoleTask").AddComponent <ImportantTextTask>(); task.transform.SetParent(player.transform, false); if (roleInfo.roleType == RoleType.Jackal) { if (Jackal.canCreateSidekick) { task.Text = cs(roleInfo.color, $"{roleInfo.name}: " + ModTranslation.getString("jackalWithSidekick")); } else { task.Text = cs(roleInfo.color, $"{roleInfo.name}: " + ModTranslation.getString("jackalShortDesc")); } } else { task.Text = cs(roleInfo.color, $"{roleInfo.name}: {roleInfo.shortDescription}"); } player.myTasks.Insert(0, task); } if (player.hasModifier(ModifierType.Madmate) || player.hasModifier(ModifierType.CreatedMadmate)) { var task = new GameObject("RoleTask").AddComponent <ImportantTextTask>(); task.transform.SetParent(player.transform, false); task.Text = cs(Madmate.color, $"{Madmate.fullName}: " + ModTranslation.getString("madmateShortDesc")); player.myTasks.Insert(0, task); } }