Esempio n. 1
0
            public InputFieldComponent OnTextChange(Action <string> callback, RustPlugin plugin)
            {
                var cmd = (Game.Rust.Libraries.Command)plugin.GetType().GetField("cmd", BindingFlags.Instance).GetValue(plugin);

                cmd.AddConsoleCommand($"gui_input_change_${_inputFieldNum}", plugin, (args) =>
                {
                    callback.Invoke(args.GetString(0));
                    OnStateChanged(args.Player());
                    return(true);
                });

                _inputFieldNum++;

                return(this);
            }
Esempio n. 2
0
            public ButtonComponent OnClick(Action <BasePlayer> callback, RustPlugin plugin)
            {
                var cmd = (Game.Rust.Libraries.Command)plugin.GetType().GetField("cmd", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(plugin);

                var commandName = $"gui_button_click_${_buttonNum}";

                Command = commandName;
                cmd.AddConsoleCommand(commandName, plugin, args =>
                {
                    callback?.Invoke(args.Player());
                    return(true);
                });

                _buttonNum++;

                return(this);
            }
Esempio n. 3
0
        /**
         *  Called when specified plugin has been loaded
         */
        private void OnPluginLoaded(RustPlugin pluginName)
        {
            string epicLanterns = "Oxide.Plugins.EpicLanterns";

            if (epicLanterns.Equals(pluginName.GetType().Name))
            {
                this._isLoaded = true;
                if (this._isInitialized)
                {
                    this.createLanternsCache();

                    // Calculate correct lanters state
                    int currentTime = Convert.ToInt16(Math.Floor(TOD_Sky.Instance.Cycle.Hour));

                    // Toggle on, because it is after time to turn on all lanterns
                    if (currentTime >= (int)Config["toggleOnAt"])
                    {
                        echo("Lanterns should light up.");
                        this._areTurnedOn = true;
                    }
                    // Toggle off, because it is after time to turn off all lanterns, but before time to turn them on
                    else if (currentTime >= (int)Config["toggleOffAt"] && currentTime < (int)Config["toggleOnAt"])
                    {
                        echo("Lanterns should not light up.");
                        this._areTurnedOn = false;
                    }
                    // If none of the above did not work, it means that currently it is time between toggling on and toggling off, so turn them on
                    else if (currentTime < (int)Config["toggleOffAt"])
                    {
                        echo("Lanterns should light up.");
                        this._areTurnedOn = true;
                    }

                    // Apply current state to all lanterns
                    smartToggleLanterns();
                }
            }
        }
Esempio n. 4
0
            public void RemoveOnClick(RustPlugin plugin)
            {
                var cmd = (Game.Rust.Libraries.Command)plugin.GetType().GetField("cmd", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(plugin);

                cmd.RemoveConsoleCommand(Command, plugin);
            }