Ejemplo n.º 1
0
            static bool Prefix(ChatController __instance)
            {
                string text    = __instance.TextArea.text;
                bool   handled = false;

                if (AmongUsClient.Instance.GameState != InnerNet.InnerNetClient.GameStates.Started)
                {
                    if (text.ToLower().StartsWith("/size "))                                  // Unfortunately server holds this - need to do more trickery
                    {
                        if (AmongUsClient.Instance.AmHost && AmongUsClient.Instance.CanBan()) // checking both just cause
                        {
                            handled = true;
                            if (!Int32.TryParse(text.Substring(6), out LobbyLimit))
                            {
                                __instance.AddChat(PlayerControl.LocalPlayer, "Invalid Size\nUsage: /size {amount}");
                            }
                            else
                            {
                                LobbyLimit = Math.Clamp(LobbyLimit, 4, 15);
                                if (LobbyLimit != PlayerControl.GameOptions.MaxPlayers)
                                {
                                    PlayerControl.GameOptions.MaxPlayers = LobbyLimit;
                                    DestroyableSingleton <GameStartManager> .Instance.LastPlayerCount = LobbyLimit;
                                    PlayerControl.LocalPlayer.RpcSyncSettings(PlayerControl.GameOptions);
                                    __instance.AddChat(PlayerControl.LocalPlayer, $"Lobby Size changed to {LobbyLimit} players");
                                }
                                else
                                {
                                    __instance.AddChat(PlayerControl.LocalPlayer, $"Lobby Size is already {LobbyLimit}");
                                }
                            }
                        }
                    }
                }
                if (handled)
                {
                    __instance.TextArea.Clear();
                    __instance.quickChatMenu.ResetGlyphs();
                }
                return(!handled);
            }
Ejemplo n.º 2
0
        private int Setup()
        {
            // Arrange
            ChatController controller = new ChatController();

            controller.Request       = new HttpRequestMessage();
            controller.Configuration = new HttpConfiguration();

            var     response   = controller.AddChat("tester", "This is an unit test", 2000);
            var     jsonString = response.Content.ReadAsStringAsync();
            JObject json       = JObject.Parse(jsonString.Result);

            response.Dispose();
            return((int)json["id"]);
        }
Ejemplo n.º 3
0
        public static bool Prefix(ChatController __instance)
        {
            if (ShipStatus.Instance == null)
            {
                return(true);
            }
            if (!__instance.TextArea.text.Equals("-help"))
            {
                return(true);
            }

            __instance.AddChat(LocalPlayer, LocalRole.Description);
            __instance.TextArea.Clear();
            return(false);
        }
Ejemplo n.º 4
0
        public void OpenMenu()
        {
            MenuObject = ChatController.Instantiate(HudManager.Instance.Chat);

            MenuObject.transform.SetParent(Camera.main.transform);
            MenuObject.SetVisible(true);
            MenuObject.Toggle();

            MenuObject.TextBubble.enabled = false;
            MenuObject.TextBubble.gameObject.SetActive(false);

            MenuObject.TextArea.enabled = false;
            MenuObject.TextArea.gameObject.SetActive(false);

            MenuObject.BanButton.enabled = false;
            MenuObject.BanButton.gameObject.SetActive(false);

            MenuObject.CharCount.enabled = false;
            MenuObject.CharCount.gameObject.SetActive(false);

            MenuObject.BackgroundImage.enabled = false;

            foreach (SpriteRenderer rend in MenuObject.Content.GetComponentsInChildren <SpriteRenderer>())
            {
                if (rend.name == "SendButton" || rend.name == "QuickChatButton" || rend.name == "QuickChatIcon")
                {
                    rend.enabled = false;
                    rend.gameObject.SetActive(false);
                }
            }

            foreach (PoolableBehavior bubble in MenuObject.chatBubPool.activeChildren)
            {
                bubble.enabled = false;
                bubble.gameObject.SetActive(false);
            }
            MenuObject.chatBubPool.activeChildren.Clear();

            foreach (PlayerControl player in PlayerControl.AllPlayerControls.ToArray().Where(x => x != PlayerControl.LocalPlayer && !x.Data.IsDead && !x.Data.IsImpostor))
            {
                MenuObject.AddChat(player, "");
            }
        }
Ejemplo n.º 5
0
 public void Send(string Message)
 {
     Controller.AddChat(Message);
 }
Ejemplo n.º 6
0
        public static void AddChat(this ChatController Controller, string Message)
        {
            var Stamp = DateTime.Now.ToString("HH:mm:ss");

            Controller.AddChat(PlayerControl.LocalPlayer, $"({Stamp}) {Message}");
        }
Ejemplo n.º 7
0
 public static void AddSimpleChat(this ChatController Controller, string Message)
 {
     Controller.AddChat(PlayerControl.LocalPlayer, Message);
 }
Ejemplo n.º 8
0
            static bool Prefix(ChatController __instance)
            {
                string text    = __instance.TextArea.text;
                bool   handled = false;

                if (AmongUsClient.Instance.GameState != InnerNet.InnerNetClient.GameStates.Started)
                {
                    if (text.ToLower().StartsWith("/kick "))
                    {
                        string        playerName = text.Substring(6);
                        PlayerControl target     = PlayerControl.AllPlayerControls.ToArray().ToList().FirstOrDefault(x => x.Data.PlayerName.Equals(playerName));
                        if (target != null && AmongUsClient.Instance != null && AmongUsClient.Instance.CanBan())
                        {
                            var client = AmongUsClient.Instance.GetClient(target.OwnerId);
                            if (client != null)
                            {
                                AmongUsClient.Instance.KickPlayer(client.Id, false);
                                handled = true;
                            }
                        }
                    }
                    else if (text.ToLower().StartsWith("/ban "))
                    {
                        string        playerName = text.Substring(5);
                        PlayerControl target     = PlayerControl.AllPlayerControls.ToArray().ToList().FirstOrDefault(x => x.Data.PlayerName.Equals(playerName));
                        if (target != null && AmongUsClient.Instance != null && AmongUsClient.Instance.CanBan())
                        {
                            var client = AmongUsClient.Instance.GetClient(target.OwnerId);
                            if (client != null)
                            {
                                AmongUsClient.Instance.KickPlayer(client.Id, true);
                                handled = true;
                            }
                        }
                    }
                }

                if (AmongUsClient.Instance.GameMode == GameModes.FreePlay)
                {
                    if (text.ToLower().Equals("/murder"))
                    {
                        PlayerControl.LocalPlayer.Exiled();
                        HudManager.Instance.KillOverlay.ShowKillAnimation(PlayerControl.LocalPlayer.Data, PlayerControl.LocalPlayer.Data);
                        handled = true;
                    }
                    else if (text.ToLower().StartsWith("/color "))
                    {
                        handled = true;
                        int col;
                        if (!Int32.TryParse(text.Substring(7), out col))
                        {
                            __instance.AddChat(PlayerControl.LocalPlayer, "Unable to parse color id\nUsage: /color {id}");
                        }
                        col = Math.Clamp(col, 0, Palette.PlayerColors.Length - 1);
                        PlayerControl.LocalPlayer.SetColor(col);
                        __instance.AddChat(PlayerControl.LocalPlayer, "Changed color successfully");;
                    }
                }

                if (text.ToLower().StartsWith("/tp ") && PlayerControl.LocalPlayer.Data.IsDead)
                {
                    string        playerName = text.Substring(4).ToLower();
                    PlayerControl target     = PlayerControl.AllPlayerControls.ToArray().ToList().FirstOrDefault(x => x.Data.PlayerName.ToLower().Equals(playerName));
                    if (target != null)
                    {
                        PlayerControl.LocalPlayer.transform.position = target.transform.position;
                        handled = true;
                    }
                }

                if (handled)
                {
                    __instance.TextArea.Clear();
                    __instance.quickChatMenu.ResetGlyphs();
                }
                return(!handled);
            }