コード例 #1
0
        private static void EquipmentConvertHook()
        {
            Chat.onChatChanged += delegate()
            {
                if (!NetworkServer.active)
                {
                    return;
                }

                if (!Configuration.AspectEquipmentConversion.Value)
                {
                    return;
                }

                string message = Chat.readOnlyLog.DefaultIfEmpty(null).Last();
                if (message == null)
                {
                    return;
                }
                Chat.UserChatMessage userChatMessage = ReconstructMessage(message);
                if (userChatMessage == null)
                {
                    return;
                }

                if (userChatMessage.text.ToLower() == "convertaspect")
                {
                    CharacterMaster master = userChatMessage.sender.GetComponent <NetworkUser>().master;
                    if (!master)
                    {
                        return;
                    }

                    Inventory inventory = master.inventory;
                    if (inventory)
                    {
                        ItemIndex itemIndex = Catalog.ItemizeEliteEquipment(inventory.currentEquipmentIndex);
                        if (itemIndex != ItemIndex.None)
                        {
                            inventory.GiveItem(itemIndex);
                            inventory.SetEquipmentIndex(EquipmentIndex.None);
                        }
                    }
                }
            };
        }
コード例 #2
0
        private string UserChatMessage_ConstructChatString(On.RoR2.Chat.UserChatMessage.orig_ConstructChatString orig, Chat.UserChatMessage self)
        {
            if (!AllAgree && (self.text.ToLower().Trim().Equals("tlc_aye") || self.text.ToLower().Trim().Equals("tic_aye")))
            {
                NetworkUser networkUser = self.sender.GetComponent <NetworkUser>();
                if (networkUser)
                {
                    var steamID = networkUser.id.steamId;
                    for (int i = 0; i < SteamPlayers.Count; i++)
                    {
                        if (SteamPlayers[i].steamID == steamID)
                        {
                            SteamPlayers[i].isReady = true;
                            break;
                        }
                    }
                    bool checkAllReady = true;
                    for (int i = 0; i < SteamPlayers.Count; i++)
                    {
                        if (!SteamPlayers[i].isReady)
                        {
                            checkAllReady = false;
                            break;
                        }
                    }
                    if (checkAllReady)
                    {
                        //Time.timeScale = 1f;
                        AllAgree = true;
                        RemoveLunarCoins();
                        UnfreezePlayers();
                    }
                }
            }

            return(orig(self));
        }
コード例 #3
0
        private string UserChatMessage_ConstructChatString(On.RoR2.Chat.UserChatMessage.orig_ConstructChatString orig, Chat.UserChatMessage self)
        {
            if (!NetworkServer.active)
            {
                return(orig(self));
            }

            List <string> split       = new List <string>(self.text.Split(Char.Parse(" ")));
            string        commandName = ArgsHelper.GetValue(split, 0);

            if (commandName.Equals("spawn_as", StringComparison.OrdinalIgnoreCase))
            {
                string bodyString = ArgsHelper.GetValue(split, 1);
                string userString = ArgsHelper.GetValue(split, 2);


                SpawnAs(self.sender.GetComponent <NetworkUser>(), bodyString, userString);
            }
            return(orig(self));
        }
コード例 #4
0
        private static void ExecuteCommand(Chat.UserChatMessage message)
        {
            var callString = message.text.TrimStart(_commandPrefix.Value[0]);

            if (callString.Length == 0)
            {
                return;
            }

            var           user = message.sender.GetComponent <NetworkUser>();
            List <string> args;

            try {
                args = ParseCommand(callString, message.sender);
            }
            catch (System.Exception ex) {
                ShowResponse($"Command \"{callString}\" could not be parsed: {ex}", true);
                return;
            }

            var cmd = args[0];

            args.RemoveAt(0);

            try
            {
                var isCmd = _catalog.Contains(cmd);
                if (!isCmd && _console.FindConVar(cmd) == null)
                {
                    throw new ConCommandException("Command is not registered.");
                }

                var flags = isCmd
                    ? _catalog[cmd].GetFieldValue <ConVarFlags>("flags")
                    : _console.FindConVar(cmd).flags;

                if ((flags & ConVarFlags.SenderMustBeServer) != ConVarFlags.None &&
                    !NetworkServer.active)
                {
                    throw new ConCommandException("Command is only usable by the host.");
                }

                if ((flags & ConVarFlags.Cheat) != ConVarFlags.None && !RoR2Application.cvCheats.boolValue)
                {
                    throw new ConCommandException("Command cannot be used while cheats are disabled.");
                }

                if ((flags & ConVarFlags.ExecuteOnServer) != ConVarFlags.None &&
                    !NetworkServer.active)
                {
                    _console.InvokeMethod("ForwardCmdToServer", new ConCommandArgs
                    {
                        sender      = user,
                        commandName = cmd,
                        userArgs    = args
                    });
                    ShowResponse($"Command \"{cmd}\" sent to server.");
                    return;
                }

                if (isCmd)
                {
                    var command = _catalog[cmd].GetFieldValue <Console.ConCommandDelegate>("action");

                    _listening = true;
                    command(new ConCommandArgs
                    {
                        sender      = user,
                        commandName = cmd,
                        userArgs    = args
                    });
                    _listening = false;
                    foreach (var log in _queue)
                    {
                        ShowResponse(log.message, log.logType == LogType.Error);
                    }
                    _queue.Clear();

                    ShowResponse($"Command \"{cmd}\" executed successfully.");
                }
                else
                {
                    _console.FindConVar(cmd).SetString(args[0]);

                    ShowResponse($"Variable \"{cmd}\" set to \"{args[0]}\".");
                }
            }
            catch (ConCommandException ex)
            {
                ShowResponse($"Command \"{cmd}\" failed: {ex.Message}", true);
            }
        }
コード例 #5
0
 private string UserChatMessage_ConstructChatString(On.RoR2.Chat.UserChatMessage.orig_ConstructChatString orig, Chat.UserChatMessage self)
 {
     if (self.sender)
     {
         NetworkUser component = self.sender.GetComponent <NetworkUser>();
         if (component)
         {
             if (self.text.StartsWith(">"))
             {
                 return(string.Format(CultureInfo.InvariantCulture, "{0}: <color=#789922>{1}</color>", Util.EscapeRichTextForTextMeshPro(component.userName), Util.EscapeRichTextForTextMeshPro(self.text)));
             }
             else if (self.text.EndsWith("<"))
             {
                 return(string.Format(CultureInfo.InvariantCulture, "{0}: <color=#E0727F>{1}</color>", Util.EscapeRichTextForTextMeshPro(component.userName), Util.EscapeRichTextForTextMeshPro(self.text)));
             }
             return(orig(self));
         }
     }
     return(null);
 }