예제 #1
0
        private static void TelePingCmd(InCmdResult res, InCmdArgs args)
        {
            var ctrl = args.Sender.master.GetComponent <PingerController>();
            var tele = TeleporterInteraction.instance;

            PingerController.PingInfo pingInfo = new PingerController.PingInfo {
                active = true,
                origin = tele.transform.position,
                targetNetworkIdentity = ClientScene.objects[tele.netId],
            };
            typeof(PingerController).GetMethod("SetCurrentPing", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(ctrl, new object[] { pingInfo });
        }
예제 #2
0
        static void registerCmd(InCmd attr, InCmdDelegate cb)
        {
            object catalog        = Traverse.Create(console).Field("concommandCatalog").GetValue();
            var    conCommandType = typeof(RoR2.Console).GetNestedType("ConCommand", BindingFlags.NonPublic);
            var    conCommandCtor = conCommandType.GetConstructor(Type.EmptyTypes);

            var cmd = conCommandCtor.Invoke(new object[0]);

            conCommandType.GetField("flags").SetValue(cmd, attr.User ? ConVarFlags.None : ConVarFlags.ExecuteOnServer);
            conCommandType.GetField("action").SetValue(cmd, (RoR2.Console.ConCommandDelegate)((ConCommandArgs args) => {
                var res   = new InCmdResult();
                var cargs = new InCmdArgs()
                {
                    Args   = args.userArgs.ToArray(),
                    Sender = args.sender,
                    Target = args.sender,
                };
                try {
                    cb(res, cargs);
                } catch (Exception e) {
                    res.Error = e.ToString() + "\n" + e.StackTrace;
                }

                if (args.sender.localUser != null)
                {
                    Debug.Log(res.Result.Join(null, "\n"));
                    if (res.Error != null)
                    {
                        Debug.LogWarning(res.Error);
                    }
                }
                else
                {
                    // TODO: Support clients executing commands
                }
            }));
            conCommandType.GetField("helpText").SetValue(cmd, attr.Hint);

            catalog.GetType().GetProperty("Item").SetValue(catalog, cmd, new[] {
                attr.Name.ToLower(System.Globalization.CultureInfo.InvariantCulture)
            });
        }
예제 #3
0
        private static void CmdTeamMoney(InCmdResult res, InCmdArgs args)
        {
            var user = LocalUserManager.GetFirstLocalUser();

            if (user.currentNetworkUser == null)
            {
                res.Error = "Error: Not in-game";
                return;
            }

            if (args.Length != 1)
            {
                res.Error = "Error: One parameter expected";
                return;
            }

            var n = uint.Parse(args[0]);

            TeamManager.instance.GiveTeamMoney(TeamIndex.Player, n);
            res.Add("Gave all players $" + n);
        }
예제 #4
0
 private static void TeleExitCmd(InCmdResult res, InCmdArgs args)
 {
     TeleporterInteraction.instance.GetComponent <SceneExitController>().Begin();
 }