Example #1
0
        internal static void ChangeToGameMode(GameMode mode)
        {
            Selected = mode;
            Selected.OnSelect();

            PlayerHudManager.AppendedPingText =
                $"\nMode: {Functions.ColorPurple}{ Selected.GameModeName }[]\n" + Selected.ModNotice +
                $">> {Functions.ColorGreen}Cheep-YT.com[] <<";

            RpcManager.SendRpc((byte)CustomRpcCalls.ChangeGameMode, mode.GameModeId);
        }
Example #2
0
        internal static void Start()
        {
            #region ---------- Ping Text ----------
            PlayerHudManager.AppendedPingText =
                $"\nMode: {Functions.ColorPurple}{ Selected.GameModeName }[]\n" + Selected.ModNotice +
                $">> {Functions.ColorGreen}Cheep-YT.com[] <<";

            PlayerHudManager.IsPingTextCentered = true;
            #endregion

            #region ---------- Changed GameMode ----------
            RpcManager.RpcReceived += RpcManager_RpcReceived;
            #endregion

            #region -------------------- Game Mode Execution --------------------

            #region ---------- Game Started ----------
            GameStartedEvent.Listener += () =>
            {
                if (CheepsAmongUsMod.IsDecidingClient)
                {
                    RpcManager.SendRpc((byte)CustomRpcCalls.ChangeGameMode, Selected.GameModeId);
                }

                Selected.OnStart();

                foreach (var gm in ActiveGameModes)
                {
                    gm.OnStart();
                }
            };
            #endregion

            #region ---------- Set Infected ----------
            SetInfectedEvent.Listener += () =>
            {
                Selected.OnSetInfected();

                foreach (var gm in ActiveGameModes)
                {
                    gm.OnSetInfected();
                }
            };
            #endregion

            #region ---------- Game Running ----------
            HudUpdateEvent.Listener += () =>
            {
                Selected.Loop();

                foreach (var gm in ActiveGameModes)
                {
                    gm.Loop();
                }
            };
            #endregion

            #region ---------- Game Ended ----------
            GameEndedEvent.Listener += () =>
            {
                Selected.OnEnd();

                foreach (var gm in ActiveGameModes)
                {
                    gm.OnEnd();
                }
            };
            #endregion

            #region ---------- Reset Values ----------
            LobbyBehaviourStartedEvent.Listener += () =>
            {
                Selected.ResetValues();

                foreach (var gm in ActiveGameModes)
                {
                    gm.ResetValues();
                }
            };
            #endregion

            #region ---------- Sync Settings ----------
            SyncedSettingsEvent.Listener += () =>
            {
                RpcManager.SendRpc((byte)CustomRpcCalls.ChangeGameMode, Selected.GameModeId);

                Selected.SyncSettings();

                foreach (var gm in ActiveGameModes)
                {
                    gm.SyncSettings();
                }
            };
            #endregion

            #endregion
        }