private static void Vote(MeetingHud __instance, PlayerVoteArea area2, int num, Component origin, bool isMayor = false) { ////System.Console.WriteLine(PlayerControl.GameOptions.AnonymousVotes); var playerById = GameData.Instance.GetPlayerById((byte)area2.TargetPlayerId); var renderer = UnityEngine.Object.Instantiate(__instance.PlayerVotePrefab); if (PlayerControl.GameOptions.AnonymousVotes || CustomGameOptions.MayorAnonymous && isMayor ) //Should be AnonymousVotes but weird { //System.Console.WriteLine("ANONS"); PlayerControl.SetPlayerMaterialColors(Palette.DisabledGrey, renderer); } else { //System.Console.WriteLine("NONANONS"); PlayerControl.SetPlayerMaterialColors(playerById.ColorId, renderer); } var transform = renderer.transform; transform.SetParent(origin.transform); transform.localPosition = __instance.CounterOrigin + new Vector3(__instance.CounterOffsets.x * num, 0f, 0f); transform.localScale = Vector3.zero; __instance.StartCoroutine(Effects.Bloop(num * 0.5f, transform, 1f, 0.5f)); }
private static void PopulateResults(MeetingHud __instance, byte[] states, byte[] votes) { __instance.TitleText.text = TranslationController.Instance.GetString(StringNames.MeetingVotingResults, Array.Empty <Il2CppSystem.Object>()); int num = 0; for (int i = 0; i < __instance.playerStates.Length; i++) { PlayerVoteArea playerVoteArea = __instance.playerStates[i]; playerVoteArea.ClearForResults(); int num2 = 0; for (int j = 0; j < states.Length; j++) { if ((states[j] & 128) == 0) // !isDead { GameData.PlayerInfo playerById = GameData.Instance.GetPlayerById((byte)__instance.playerStates[j].TargetPlayerId); int votedFor = (sbyte)votes[j]; SpriteRenderer spriteRenderer = Object.Instantiate(__instance.PlayerVotePrefab); if (PlayerControl.GameOptions.AnonymousVotes) { PlayerControl.SetPlayerMaterialColors(Palette.DisabledGrey, spriteRenderer); } else { PlayerControl.SetPlayerMaterialColors(playerById.ColorId, spriteRenderer); } spriteRenderer.transform.localScale = Vector3.zero; if (playerVoteArea.TargetPlayerId == votedFor) { Transform transform; (transform = spriteRenderer.transform).SetParent(playerVoteArea.transform); transform.localPosition = __instance.CounterOrigin + new Vector3(__instance.CounterOffsets.x * num2, 0f, 0f); __instance.StartCoroutine(Effects.Bloop(num2 * 0.5f, transform, 1f, 0.5f)); num2++; } else if (i == 0 && votedFor == -1) { Transform transform; (transform = spriteRenderer.transform).SetParent(__instance.SkippedVoting.transform); transform.localPosition = __instance.CounterOrigin + new Vector3(__instance.CounterOffsets.x * num, 0f, 0f); __instance.StartCoroutine(Effects.Bloop(num * 0.5f, transform, 1f, 0.5f)); num++; } } } } }
static bool Prefix(MeetingHud __instance, [HarmonyArgument(0)] Il2CppStructArray <byte> states) { // Swapper swap votes PlayerVoteArea swapped1 = null; PlayerVoteArea swapped2 = null; foreach (PlayerVoteArea playerVoteArea in __instance.playerStates) { if (playerVoteArea.TargetPlayerId == Swapper.playerId1) { swapped1 = playerVoteArea; } if (playerVoteArea.TargetPlayerId == Swapper.playerId2) { swapped2 = playerVoteArea; } } bool doSwap = swapped1 != null && swapped2 != null; float delay = 0f; if (doSwap) { delay = 2f; __instance.StartCoroutine(Effects.Slide3D(swapped1.transform, swapped1.transform.localPosition, swapped2.transform.localPosition, 2f)); __instance.StartCoroutine(Effects.Slide3D(swapped2.transform, swapped2.transform.localPosition, swapped1.transform.localPosition, 2f)); } float votesXOffset = 0f; float votesFinalSize = 1f; if (__instance.playerStates.Length > 10) { votesXOffset = 0.1f; votesFinalSize = scale; } // Mayor display vote twice __instance.TitleText.text = DestroyableSingleton <TranslationController> .Instance.GetString(StringNames.MeetingVotingResults, new Il2CppReferenceArray <Il2CppSystem.Object>(0)); int num = 0; for (int i = 0; i < __instance.playerStates.Length; i++) { PlayerVoteArea playerVoteArea = __instance.playerStates[i]; playerVoteArea.ClearForResults(); int num2 = 0; bool mayorFirstVoteDisplayed = false; for (int j = 0; j < __instance.playerStates.Length; j++) { PlayerVoteArea playerVoteArea2 = __instance.playerStates[j]; byte self = states[(int)playerVoteArea2.TargetPlayerId]; if (!((self & 128) > 0)) { GameData.PlayerInfo playerById = GameData.Instance.GetPlayerById((byte)playerVoteArea2.TargetPlayerId); int votedFor = (int)PlayerVoteArea.GetVotedFor(self); if (votedFor == (int)playerVoteArea.TargetPlayerId) { SpriteRenderer spriteRenderer = UnityEngine.Object.Instantiate <SpriteRenderer>(__instance.PlayerVotePrefab); if (PlayerControl.GameOptions.AnonymousVotes) { PlayerControl.SetPlayerMaterialColors(Palette.DisabledGrey, spriteRenderer); } else { PlayerControl.SetPlayerMaterialColors((int)playerById.ColorId, spriteRenderer); } spriteRenderer.transform.SetParent(playerVoteArea.transform); spriteRenderer.transform.localPosition = __instance.CounterOrigin + new Vector3(votesXOffset + __instance.CounterOffsets.x * (float)(num2), 0f, 0f); spriteRenderer.transform.localScale = Vector3.zero; spriteRenderer.transform.SetParent(playerVoteArea.transform.parent); // Reparent votes so they don't move with their playerVoteArea __instance.StartCoroutine(Effects.Bloop((float)(num2) * 0.5f + delay, spriteRenderer.transform, votesFinalSize, 0.5f)); num2++; } else if (i == 0 && votedFor == -1) { SpriteRenderer spriteRenderer2 = UnityEngine.Object.Instantiate <SpriteRenderer>(__instance.PlayerVotePrefab); if (PlayerControl.GameOptions.AnonymousVotes) { PlayerControl.SetPlayerMaterialColors(Palette.DisabledGrey, spriteRenderer2); } else { PlayerControl.SetPlayerMaterialColors((int)playerById.ColorId, spriteRenderer2); } spriteRenderer2.transform.SetParent(__instance.SkippedVoting.transform); spriteRenderer2.transform.localPosition = __instance.CounterOrigin + new Vector3(votesXOffset + __instance.CounterOffsets.x * (float)(num), 0f, 0f); spriteRenderer2.transform.localScale = Vector3.zero; spriteRenderer2.transform.SetParent(playerVoteArea.transform.parent); // Reparent votes so they don't move with their playerVoteArea __instance.StartCoroutine(Effects.Bloop((float)num * 0.5f + delay, spriteRenderer2.transform, votesFinalSize, 0.5f)); num++; } // Major vote, redo this iteration to place a second vote if (Mayor.mayor != null && playerVoteArea2.TargetPlayerId == (sbyte)Mayor.mayor.PlayerId && !mayorFirstVoteDisplayed) { mayorFirstVoteDisplayed = true; j--; } } } } return(false); }
public static bool Prefix([HarmonyArgument(0)] Il2CppStructArray <byte> states) { AbilityBlackmail[] blackmailAbilities = Ability.GetAllAbilities <AbilityBlackmail>(); MeetingHud.Instance.TitleText.text = DestroyableSingleton <TranslationController> .Instance.GetString(StringNames.MeetingVotingResults, new Il2CppReferenceArray <Il2CppSystem.Object>(0)); var num = 0; for (var i = 0; i < MeetingHud.Instance.playerStates.Length; i++) { PlayerVoteArea playerVoteArea = MeetingHud.Instance.playerStates[i]; playerVoteArea.ClearForResults(); var num2 = 0; var hasShownMayorVote = false; for (var j = 0; j < MeetingHud.Instance.playerStates.Count; j++) { PlayerVoteArea playerVoteArea2 = MeetingHud.Instance.playerStates[j]; // Blackmailer Skip Vote if (blackmailAbilities.Any(blackmail => blackmail.BlackmailedPlayer?.PlayerId == playerVoteArea2.TargetPlayerId)) { continue; } byte self = states[playerVoteArea2.TargetPlayerId]; if (global::Extensions.HasAnyBit(self, (byte)128)) { continue; } GameData.PlayerInfo playerById = GameData.Instance.GetPlayerById((byte)playerVoteArea2.TargetPlayerId); int votedFor = PlayerVoteArea.GetVotedFor(self); if (votedFor == playerVoteArea.TargetPlayerId) { SpriteRenderer spriteRenderer = Object.Instantiate(MeetingHud.Instance.PlayerVotePrefab, playerVoteArea.transform, true); if (PlayerControl.GameOptions.AnonymousVotes) { PlayerControl.SetPlayerMaterialColors(Palette.DisabledGrey, spriteRenderer); } else { PlayerControl.SetPlayerMaterialColors(playerById.ColorId, spriteRenderer); } Transform transform = spriteRenderer.transform; transform.localPosition = MeetingHud.Instance.CounterOrigin + new Vector3(MeetingHud.Instance.CounterOffsets.x * num2, 0f, 0f); transform.localScale = Vector3.zero; MeetingHud.Instance.StartCoroutine(Effects.Bloop(num2 * 0.5f, transform, 1f, 0.5f)); num2++; } else if (i == 0 && votedFor == -1) { SpriteRenderer spriteRenderer2 = Object.Instantiate(MeetingHud.Instance.PlayerVotePrefab, MeetingHud.Instance.SkippedVoting.transform, true); if (PlayerControl.GameOptions.AnonymousVotes) { PlayerControl.SetPlayerMaterialColors(Palette.DisabledGrey, spriteRenderer2); } else { PlayerControl.SetPlayerMaterialColors(playerById.ColorId, spriteRenderer2); } Transform transform = spriteRenderer2.transform; transform.localPosition = MeetingHud.Instance.CounterOrigin + new Vector3(MeetingHud.Instance.CounterOffsets.x * num, 0f, 0f); transform.localScale = Vector3.zero; MeetingHud.Instance.StartCoroutine(Effects.Bloop(num * 0.5f, transform, 1f, 0.5f)); num++; } // Mayor Add Extra Vote if (!TryGetSpecialRole(out Mayor mayor) || !mayor.hasRevealed || playerVoteArea2.TargetPlayerId != (sbyte)mayor.Owner.PlayerId || hasShownMayorVote) { continue; } hasShownMayorVote = true; j--; } } return(false); }