Esempio n. 1
0
            private static bool HandleMessage(InnerNetClient __instance, [HarmonyArgument(0)] MessageReader reader)
            {
                if (reader.Tag != 8 || __instance.GameId != reader.ReadInt32() || __instance.GameState == InnerNetClient.GameStates.Ended)
                {
                    return(true);
                }

                __instance.GameState = InnerNetClient.GameStates.Ended;
                lock (__instance.allClients)
                {
                    __instance.allClients.Clear();
                }

                var  reason = (GameOverReason)reader.ReadSByte();
                bool showAd = reader.ReadBoolean();

                if (reason.IsCustom())
                {
                    CustomGameOverReasonManager.EndReason = CustomGameOverReason.Deserialize(reader);
                }

                lock (__instance.Dispatcher)
                {
                    __instance.Dispatcher.Add((Action)(() => __instance.OnGameEnd(reason, showAd)));
                    return(false);
                }
            }
Esempio n. 2
0
        /// <summary>
        /// Send EndGame with custom registered (!) <see cref="CustomGameOverReason"/><br/>
        /// Can be done only by host
        /// </summary>
        /// <param name="sender">LocalPlayer who is a host</param>
        /// <param name="reason">Game over reason</param>
        public static void RpcCustomEndGame(this PlayerControl sender, CustomGameOverReason reason)
        {
            if (sender.OwnerId != AmongUsClient.Instance.HostId)
            {
                return;
            }

            CustomGameOverReasonManager.EndReason = reason;
            ShipStatus.RpcEndGame(reason, true);
        }