예제 #1
0
        static bool Prefix(MeetingHud __instance, Il2CppStructArray <byte> GNKPMAGJLNC)
        {
            // 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;

            if (doSwap)
            {
                Reactor.Coroutines.Start(Helpers.Slide2D(swapped1.transform, swapped1.transform.localPosition, swapped2.transform.localPosition, 2f));
                Reactor.Coroutines.Start(Helpers.Slide2D(swapped2.transform, swapped2.transform.localPosition, swapped1.transform.localPosition, 2f));
            }

            // Mayor display vote twice
            __instance.TitleText.Text = DestroyableSingleton <TranslationController> .Instance.GetString(StringNames.MeetingVotingResults, new Il2CppReferenceArray <Il2CppSystem.Object>(0));

            int num = doSwap ? 4 : 0; // Delay animaton if swapping

            for (int i = 0; i < __instance.playerStates.Length; i++)
            {
                PlayerVoteArea playerVoteArea = __instance.playerStates[i];
                playerVoteArea.ClearForResults();
                int  num2 = doSwap ? 4 : 0; // Delay animaton if swapping
                bool mayorFirstVoteDisplayed = false;

                for (int j = 0; j < __instance.playerStates.Length; j++)
                {
                    PlayerVoteArea playerVoteArea2 = __instance.playerStates[j];
                    byte           self            = GNKPMAGJLNC[(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(__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, spriteRenderer.transform, 1f, 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(__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, spriteRenderer2.transform, 1f, 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);
        }