Example #1
0
    // Token: 0x06000426 RID: 1062 RVA: 0x00014C84 File Offset: 0x00012E84
    private static bool GetCharacterStuff(ref global::ConsoleSystem.Arg args, out global::Character character, out global::CameraMount camera, out global::ItemRepresentation itemRep, out global::ArmorModelRenderer armor)
    {
        character = null;
        itemRep   = null;
        armor     = null;
        camera    = global::CameraMount.current;
        if (!camera)
        {
            args.ReplyWith("Theres no active camera mount.");
            return(false);
        }
        character = (IDBase.GetMain(camera) as global::Character);
        if (!character)
        {
            args.ReplyWith("theres no character for the current mounted camera");
            return(false);
        }
        armor = character.GetLocal <global::ArmorModelRenderer>();
        global::InventoryHolder local = character.GetLocal <global::InventoryHolder>();

        if (local)
        {
            itemRep = local.itemRepresentation;
        }
        return(true);
    }
 public static void time(ref global::ConsoleSystem.Arg arg)
 {
     if (!global::EnvironmentControlCenter.Singleton)
     {
         return;
     }
     arg.ReplyWith("Current Time: " + global::EnvironmentControlCenter.Singleton.GetTime().ToString());
 }
Example #3
0
    public static void load(ref global::ConsoleSystem.Arg arg)
    {
        string text    = global::config.ConfigName();
        string strFile = "\r\necho default config\r\ninput.bind Left A None\r\ninput.bind Right D None\r\ninput.bind Up W None\r\ninput.bind Down S None\r\ninput.bind Jump Space None\r\ninput.bind Duck LeftControl None\r\ninput.bind Sprint LeftShift None\r\ninput.bind Fire Mouse0 None\r\ninput.bind AltFire Mouse1 None\r\ninput.bind Reload R None\r\ninput.bind Use E None\r\ninput.bind Inventory Tab None\r\ninput.bind Flashlight F None\r\ninput.bind Laser G None\r\ninput.bind Voice V None\r\ninput.bind Chat Return T\r\nrender.update\r\n";

        if (File.Exists(text))
        {
            strFile = File.ReadAllText(text);
        }
        global::ConsoleSystem.RunFile(strFile);
        arg.ReplyWith("Loaded " + text);
    }
Example #4
0
    public static void save(ref global::ConsoleSystem.Arg arg)
    {
        if (!Directory.Exists("cfg"))
        {
            Directory.CreateDirectory("cfg");
        }
        string path     = global::config.ConfigName();
        string contents = global::ConsoleSystem.SaveToConfigString();

        File.WriteAllText(path, contents);
        arg.ReplyWith("Saved config.cfg");
    }
    // Token: 0x06000CCC RID: 3276 RVA: 0x0003161C File Offset: 0x0002F81C
    public static bool RunCommand(ref global::ConsoleSystem.Arg arg, bool bWantReply = true)
    {
        Type[] array = global::ConsoleSystem.FindTypes(arg.Class);
        if (array.Length == 0)
        {
            if (bWantReply)
            {
                arg.ReplyWith("Console class not found: " + arg.Class);
            }
            return(false);
        }
        if (bWantReply)
        {
            arg.ReplyWith(string.Concat(new string[]
            {
                "command ",
                arg.Class,
                ".",
                arg.Function,
                " was executed"
            }));
        }
        Type[] array2 = array;
        int    i      = 0;

        while (i < array2.Length)
        {
            Type       type   = array2[i];
            MethodInfo method = type.GetMethod(arg.Function);
            if (method != null && method.IsStatic)
            {
                if (!arg.CheckPermissions(method.GetCustomAttributes(true)))
                {
                    if (bWantReply)
                    {
                        arg.ReplyWith("No permission: " + arg.Class + "." + arg.Function);
                    }
                    return(false);
                }
                object[] array3 = new global::ConsoleSystem.Arg[]
                {
                    arg
                };
                try
                {
                    method.Invoke(null, array3);
                }
                catch (Exception ex)
                {
                    Debug.LogWarning(string.Concat(new string[]
                    {
                        "Error: ",
                        arg.Class,
                        ".",
                        arg.Function,
                        " - ",
                        ex.Message
                    }));
                    arg.ReplyWith(string.Concat(new string[]
                    {
                        "Error: ",
                        arg.Class,
                        ".",
                        arg.Function,
                        " - ",
                        ex.Message
                    }));
                    return(false);
                }
                arg = (array3[0] as global::ConsoleSystem.Arg);
                return(true);
            }
            else
            {
                FieldInfo field = type.GetField(arg.Function);
                if (field != null && field.IsStatic)
                {
                    if (!arg.CheckPermissions(field.GetCustomAttributes(true)))
                    {
                        if (bWantReply)
                        {
                            arg.ReplyWith("No permission: " + arg.Class + "." + arg.Function);
                        }
                        return(false);
                    }
                    Type fieldType = field.FieldType;
                    if (arg.HasArgs(1))
                    {
                        try
                        {
                            string str = field.GetValue(null).ToString();
                            if (fieldType == typeof(float))
                            {
                                field.SetValue(null, float.Parse(arg.Args[0]));
                            }
                            if (fieldType == typeof(int))
                            {
                                field.SetValue(null, int.Parse(arg.Args[0]));
                            }
                            if (fieldType == typeof(string))
                            {
                                field.SetValue(null, arg.Args[0]);
                            }
                            if (fieldType == typeof(bool))
                            {
                                field.SetValue(null, bool.Parse(arg.Args[0]));
                            }
                            if (bWantReply)
                            {
                                arg.ReplyWith(string.Concat(new string[]
                                {
                                    arg.Class,
                                    ".",
                                    arg.Function,
                                    ": changed ",
                                    Facepunch.Utility.String.QuoteSafe(str),
                                    " to ",
                                    Facepunch.Utility.String.QuoteSafe(field.GetValue(null).ToString()),
                                    " (",
                                    fieldType.Name,
                                    ")"
                                }));
                            }
                        }
                        catch (Exception)
                        {
                            if (bWantReply)
                            {
                                arg.ReplyWith("error setting value: " + arg.Class + "." + arg.Function);
                            }
                        }
                    }
                    else if (bWantReply)
                    {
                        arg.ReplyWith(string.Concat(new string[]
                        {
                            arg.Class,
                            ".",
                            arg.Function,
                            ": ",
                            Facepunch.Utility.String.QuoteSafe(field.GetValue(null).ToString()),
                            " (",
                            fieldType.Name,
                            ")"
                        }));
                    }
                    return(true);
                }
                else
                {
                    PropertyInfo property = type.GetProperty(arg.Function);
                    if (property != null && property.GetGetMethod().IsStatic&& property.GetSetMethod().IsStatic)
                    {
                        if (!arg.CheckPermissions(property.GetCustomAttributes(true)))
                        {
                            if (bWantReply)
                            {
                                arg.ReplyWith("No permission: " + arg.Class + "." + arg.Function);
                            }
                            return(false);
                        }
                        Type propertyType = property.PropertyType;
                        if (arg.HasArgs(1))
                        {
                            try
                            {
                                string str2 = property.GetValue(null, null).ToString();
                                if (propertyType == typeof(float))
                                {
                                    property.SetValue(null, float.Parse(arg.Args[0]), null);
                                }
                                if (propertyType == typeof(int))
                                {
                                    property.SetValue(null, int.Parse(arg.Args[0]), null);
                                }
                                if (propertyType == typeof(string))
                                {
                                    property.SetValue(null, arg.Args[0], null);
                                }
                                if (propertyType == typeof(bool))
                                {
                                    property.SetValue(null, bool.Parse(arg.Args[0]), null);
                                }
                                if (bWantReply)
                                {
                                    arg.ReplyWith(string.Concat(new string[]
                                    {
                                        arg.Class,
                                        ".",
                                        arg.Function,
                                        ": changed ",
                                        Facepunch.Utility.String.QuoteSafe(str2),
                                        " to ",
                                        Facepunch.Utility.String.QuoteSafe(property.GetValue(null, null).ToString()),
                                        " (",
                                        propertyType.Name,
                                        ")"
                                    }));
                                }
                            }
                            catch (Exception)
                            {
                                if (bWantReply)
                                {
                                    arg.ReplyWith("error setting value: " + arg.Class + "." + arg.Function);
                                }
                            }
                        }
                        else if (bWantReply)
                        {
                            arg.ReplyWith(string.Concat(new string[]
                            {
                                arg.Class,
                                ".",
                                arg.Function,
                                ": ",
                                Facepunch.Utility.String.QuoteSafe(property.GetValue(null, null).ToString()),
                                " (",
                                propertyType.Name,
                                ")"
                            }));
                        }
                        return(true);
                    }
                    else
                    {
                        i++;
                    }
                }
            }
        }
        if (bWantReply)
        {
            arg.ReplyWith("Command not found: " + arg.Class + "." + arg.Function);
        }
        return(false);
    }
    public static void find(ref global::ConsoleSystem.Arg arg)
    {
        if (!arg.HasArgs(1))
        {
            return;
        }
        string text  = arg.Args[0];
        string text2 = string.Empty;

        Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
        for (int i = 0; i < assemblies.Length; i++)
        {
            Type[] types = assemblies[i].GetTypes();
            for (int j = 0; j < types.Length; j++)
            {
                if (types[j].IsSubclassOf(typeof(global::ConsoleSystem)))
                {
                    MethodInfo[] methods = types[j].GetMethods();
                    for (int k = 0; k < methods.Length; k++)
                    {
                        if (methods[k].IsStatic)
                        {
                            if (!(text != "*") || types[j].Name.Contains(text) || methods[k].Name.Contains(text))
                            {
                                if (arg.CheckPermissions(methods[k].GetCustomAttributes(true)))
                                {
                                    string text3 = text2;
                                    text2 = string.Concat(new string[]
                                    {
                                        text3,
                                        types[j].Name,
                                        ".",
                                        global::global.BuildMethodString(ref methods[k]),
                                        "\n"
                                    });
                                }
                            }
                        }
                    }
                    FieldInfo[] fields = types[j].GetFields();
                    for (int l = 0; l < fields.Length; l++)
                    {
                        if (fields[l].IsStatic)
                        {
                            if (!(text != "*") || types[j].Name.Contains(text) || fields[l].Name.Contains(text))
                            {
                                if (arg.CheckPermissions(fields[l].GetCustomAttributes(true)))
                                {
                                    string text3 = text2;
                                    text2 = string.Concat(new string[]
                                    {
                                        text3,
                                        types[j].Name,
                                        ".",
                                        global::global.BuildFieldsString(ref fields[l]),
                                        "\n"
                                    });
                                }
                            }
                        }
                    }
                    PropertyInfo[] properties = types[j].GetProperties();
                    for (int m = 0; m < properties.Length; m++)
                    {
                        if (!(text != "*") || types[j].Name.Contains(text) || properties[m].Name.Contains(text))
                        {
                            if (arg.CheckPermissions(properties[m].GetCustomAttributes(true)))
                            {
                                string text3 = text2;
                                text2 = string.Concat(new string[]
                                {
                                    text3,
                                    types[j].Name,
                                    ".",
                                    global::global.BuildPropertyString(ref properties[m]),
                                    "\n"
                                });
                            }
                        }
                    }
                }
            }
        }
        arg.ReplyWith("Finding " + text + ":\n" + text2);
    }
 public static void echo(ref global::ConsoleSystem.Arg arg)
 {
     arg.ReplyWith(arg.ArgsStr);
 }