Example #1
0
        public static bool Prefix(MeetingHud __instance, [HarmonyArgument(0)] byte srcPlayerId,
                                  [HarmonyArgument(1)] sbyte suspectPlayerId)
        {
            if (Utils.Mayor == null || srcPlayerId != Utils.Mayor.PlayerId)
            {
                return(true);
            }

            var num  = AreaIndexOf(__instance, (sbyte)srcPlayerId);
            var area = __instance.playerStates[num];

            if (area.isDead)
            {
                return(false);
            }
            if (PlayerControl.LocalPlayer.PlayerId == srcPlayerId || AmongUsClient.Instance.GameMode != GameModes.LocalGame)
            {
                SoundManager.Instance.PlaySound(__instance.VoteLockinSound, false, 1f);
            }

            var isFirstVote = SetVote(area, suspectPlayerId);

            __instance.Cast <InnerNetObject>().Method_8(1U << num);
            __instance.CheckForEndVoting();
            if (isFirstVote)
            {
                PlayerControl.LocalPlayer.RpcSendChatNote(srcPlayerId, ChatNoteTypes.DidVote);
            }

            return(false);
        }
Example #2
0
            public static bool Prefix(MeetingHud __instance, [HarmonyArgument(0)] byte srcPlayerId,
                                      [HarmonyArgument(1)] byte suspectPlayerId)
            {
                var player = PlayerControl.AllPlayerControls.ToArray().FirstOrDefault(x => x.PlayerId == srcPlayerId);

                if (!player.Is(RoleEnum.Mayor))
                {
                    return(true);
                }

                var playerVoteArea = __instance.playerStates.ToArray().First(pv => pv.TargetPlayerId == srcPlayerId);

                if (playerVoteArea.AmDead)
                {
                    return(false);
                }

                if (PlayerControl.LocalPlayer.PlayerId == srcPlayerId || AmongUsClient.Instance.GameMode != GameModes.LocalGame)
                {
                    SoundManager.Instance.PlaySound(__instance.VoteLockinSound, false, 1f);
                }

                var role = Role.GetRole <Mayor>(player);

                if (playerVoteArea.DidVote)
                {
                    role.ExtraVotes.Add(suspectPlayerId);
                }
                else
                {
                    playerVoteArea.SetVote(suspectPlayerId);
                    playerVoteArea.Flag.enabled = true;
                    PlayerControl.LocalPlayer.RpcSendChatNote(srcPlayerId, ChatNoteTypes.DidVote);
                }
                __instance.Cast <InnerNetObject>().SetDirtyBit(1U);
                __instance.CheckForEndVoting();

                return(false);
            }
Example #3
0
            public static bool Prefix(MeetingHud __instance, [HarmonyArgument(0)] byte srcPlayerId,
                                      [HarmonyArgument(1)] sbyte suspectPlayerId)
            {
                var player = PlayerControl.AllPlayerControls.ToArray().FirstOrDefault(x => x.PlayerId == srcPlayerId);

                if (!player.Is(RoleEnum.Mayor))
                {
                    return(true);
                }

                var role = Role.GetRole <Mayor>(player);

                var num  = AreaIndexOf(__instance, (sbyte)srcPlayerId);
                var area = __instance.playerStates[num];

                if (area.isDead)
                {
                    return(false);
                }
                if (PlayerControl.LocalPlayer.PlayerId == srcPlayerId ||
                    AmongUsClient.Instance.GameMode != GameModes.LocalGame)
                {
                    SoundManager.Instance.PlaySound(__instance.VoteLockinSound, false, 1f);
                }

                var isFirstVote = SetVote(area, suspectPlayerId, role);

                __instance.Cast <InnerNetObject>().SetDirtyBit(1U << num);
                __instance.CheckForEndVoting();
                if (isFirstVote)
                {
                    PlayerControl.LocalPlayer.RpcSendChatNote(srcPlayerId, ChatNoteTypes.DidVote);
                }

                return(false);
            }