Пример #1
0
 public static void OnChatCommand(string command, string[] args)
 {
     try
     {
         foreach (var e in _pluginEventMap[(int)PluginEvent.OnChatCommand])
         {
             e.OnChatCommand(command, args);
         }
     }
     catch (System.Exception ex)
     {
         DNMT.LogWarning(ex.Message);
     }
 }
Пример #2
0
 public static object OnUpdate(object rv, object obj, params object[] args)
 {
     try
     {
         foreach (var e in _pluginEventMap[(int)PluginEvent.OnUpdate])
         {
             e.OnUpdate();
         }
     }
     catch (System.Exception ex)
     {
         DNMT.LogWarning(ex.Message);
     }
     return(null);
 }
Пример #3
0
        public static object OnNetMessageSendData(object rv, object obj, params object[] args)
        {
            var msgType      = (int)args[0];
            var remoteClient = (int)args[1];
            var ignoreClient = (int)args[2];
            var text         = (string)args[3];
            var number       = (int)args[4];

            bool ret = false;

            try
            {
                foreach (var e in _pluginEventMap[(int)PluginEvent.OnNetMessageSendData])
                {
                    ret = ret || e.OnNetMessageSendData(msgType, remoteClient, ignoreClient, text, number,
                                                        (float)args[5], (float)args[6], (float)args[7], (int)args[8], (int)args[9], (int)args[10]);
                }

                if (msgType == 25 && number == Main.myPlayer && !string.IsNullOrEmpty(text) && text[0] == '.')
                {
                    ret = true;
                    var split   = text.Substring(1).Split(new[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries);
                    var cmd     = split[0].ToLower();
                    var cmdArgs = split.Length > 1 ? split[1].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries) : new string[0];
                    if (cmd == "plugins")
                    {
                        CORE.Print("Loaded plugins:", Color.Green);
                        CORE.Print(string.Join(", ", _pluginList.Select(plugin => plugin.GetType().Name)));
                        //pluginList.ForEach(plugin => { CORE.Print("   " + plugin.GetType().Name); });
                    }
                    else
                    {
                        foreach (var e in _pluginEventMap[(int)PluginEvent.OnChatCommand])
                        {
                            e.OnChatCommand(cmd, cmdArgs);
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                DNMT.LogWarning(ex.Message);
            }
            return(ret ? (object)true : null);
        }
Пример #4
0
        public static void OnUpdateControlInput()
        {
            try
            {
                KeyboardState stateKeyboard = Keyboard.GetState();
                MouseState    stateMouse    = Mouse.GetState();
                GamePadState  stateGamePad  = GamePad.GetState(Game1.playerOneIndex);

                foreach (var e in _pluginEventMap[(int)PluginEvent.OnUpdateControlInput])
                {
                    e.OnUpdateControlInput(stateKeyboard, stateMouse, stateGamePad);
                }
            }
            catch (System.Exception ex)
            {
                DNMT.LogWarning(ex.Message);
            }
        }
Пример #5
0
        public static object OnPlayerKillMe(object rv, object obj, params object[] args)
        {
            bool ret = false;

            try
            {
                foreach (var e in _pluginEventMap[(int)PluginEvent.OnPlayerKillMe])
                {
                    ret = ret || e.OnPlayerKillMe((Player)obj, (PlayerDeathReason)args[0], (double)args[1], (int)args[2], (bool)args[3]);
                }
            }
            catch (System.Exception ex)
            {
                DNMT.LogWarning(ex.Message);
            }

            return(ret ? (object)true : null);
        }
Пример #6
0
 public static object OnPreUpdate(object rv, object obj, params object[] args)
 {
     try
     {
         if (CORE.IsCanUseHotKeys())
         {
             HotkeyCore.Process();
         }
         foreach (var e in _pluginEventMap[(int)PluginEvent.OnPreUpdate])
         {
             e.OnPreUpdate();
         }
     }
     catch (System.Exception ex)
     {
         DNMT.LogWarning(ex.Message);
     }
     return(null);
 }
Пример #7
0
        static HotkeyCore()
        {
            // Load hotkey binds
            var result = DNMT.Config.EnumerateKeys("HotkeyBinds");

            foreach (var k in result)
            {
                Hotkey key;
                string command;
                if (DNMT.Config.TryGet("HotkeyBinds", k, out command) && Hotkey.TryParse(k, out key) && command.StartsWith("."))
                {
                    RegisterHotkey(command, key);
                }
                else
                {
                    DNMT.LogWarning("Invalid record in [HotkeyBinds]: " + k + ".");
                }
            }
        }
Пример #8
0
        public static object OnLightingGetColor(object rv, object obj, params object[] args)
        {
            bool ret    = false;
            var  result = Color.White;

            try
            {
                foreach (var e in _pluginEventMap[(int)PluginEvent.OnLightingGetColor])
                {
                    Color temp;
                    if (e.OnLightingGetColor((int)args[0], (int)args[1], out temp))
                    {
                        ret    = true;
                        result = temp;
                    }
                }
            }
            catch (System.Exception ex)
            {
                DNMT.LogWarning(ex.Message);
            }
            return(ret ? (object)result : null);
        }
Пример #9
0
        public static object OnPlayerHurt(object rv, object obj, params object[] args)
        {
            double result = 0.0;
            bool   ret    = false;

            try
            {
                foreach (var e in _pluginEventMap[(int)PluginEvent.OnPlayerHurt])
                {
                    double temp;
                    if (e.OnPlayerHurt((Player)obj, (PlayerDeathReason)args[0], (int)args[1], (int)args[2], (bool)args[3], (bool)args[4], (bool)args[5], (int)args[6], out temp))
                    {
                        result = temp;
                        ret    = true;
                    }
                }
            }
            catch (System.Exception ex)
            {
                DNMT.LogWarning(ex.Message);
            }
            return(ret ? (object)result : null);
        }