Пример #1
0
        public Navigator()
        {
            string section = GetType().Name;

            List <int>            items     = new List <int>();
            Dictionary <int, int> valuables = new Dictionary <int, int>();

            for (int i = 0; i < Main.tileValue.Length; i++)
            {
                if (Main.tileValue[i] > 0)
                {
                    valuables.Add(i, Main.tileValue[i]);
                }
            }
            foreach (var item in valuables.OrderBy(key => key.Value))
            {
                items.Add(item.Key);
            }
            _valuableTiles = items.ToArray();

            HotkeyCore.RegisterHotkey(() =>
            {
                _navigatorMode++;
                if (_navigatorMode > 2)
                {
                    _navigatorMode = 0;
                }
                CORE.Print("Navigator mode - " + (_navigatorMode == 0 ? "off" : (_navigatorMode == 1 ? "metal detector" : "manual")));
                if (_navigatorMode == 1 && !Main.player[Main.myPlayer].accOreFinder)
                {
                    CORE.Print("   Warning, 'Metal Detector' not activated!");
                }
            }, DNMT.Config.Get(section, "Mode", new Hotkey(Keys.N), true));
            HotkeyCore.RegisterHotkey(() =>
            {
                _valuableIndex--;
                if (_valuableIndex < 0)
                {
                    _valuableIndex = _valuableTiles.Length - 1;
                }
                CORE.Print("Navigator - " + Lang.mapLegend[MapHelper.TileToLookup(_valuableTiles[_valuableIndex], 0)]);
            }, DNMT.Config.Get(section, "PrevItem", new Hotkey(Keys.OemOpenBrackets), true));
            HotkeyCore.RegisterHotkey(() =>
            {
                _valuableIndex++;
                if (_valuableIndex >= _valuableTiles.Length)
                {
                    _valuableIndex = 0;
                }
                CORE.Print("Navigator - " + Lang.mapLegend[MapHelper.TileToLookup(_valuableTiles[_valuableIndex], 0)]);
            }, DNMT.Config.Get(section, "NextItem", new Hotkey(Keys.OemCloseBrackets), true));

            _navigationArrow = CORE.GetTexture(@"navigator\NavigatorArrow");
        }
Пример #2
0
 public Teleport()
 {
     HotkeyCore.RegisterHotkey(() =>
     {
         if (CORE.IsOnCooldown())
         {
             return;
         }
         DoTeleport(Main.player[Main.myPlayer], Main.mouseX + Main.screenPosition.X, Main.mouseY + Main.screenPosition.Y);
         CORE.BeginCooldown(30);
     }, DNMT.Config.Get("Teleport", "Key", new Hotkey(Keys.T), true));
 }
Пример #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 BuildAndCraft()
        {
            string section = GetType().Name;

            HotkeyCore.RegisterHotkey(() =>
            {
                _grid = !_grid;
                CORE.Print("Building grid: " + (_grid ? "Enabled" : "Disabled"));
            }, DNMT.Config.Get(section, "BuildingGrid", new Hotkey(Keys.Decimal, alt: true), true));
            HotkeyCore.RegisterHotkey(() =>
            {
                _rulerLine = !_rulerLine;
                CORE.Print("Building ruler line: " + (_rulerLine ? "Enabled" : "Disabled"));
            }, DNMT.Config.Get(section, "RulerLine", new Hotkey(Keys.Delete), true));
            HotkeyCore.RegisterHotkey(() =>
            {
                _wires = !_wires;
                CORE.Print("Show wires: " + (_wires ? "Enabled" : "Disabled"));
            }, DNMT.Config.Get(section, "ShowWires", new Hotkey(Keys.Decimal, control: true), true));
            HotkeyCore.RegisterHotkey(() =>
            {
                _rangeBuild = !_rangeBuild;
                if (!_rangeBuild)
                {
                    Player.tileRangeX = _initialTileRangeX;
                    Player.tileRangeY = _initialTileRangeY;
                }
                CORE.Print("Build range: " + (_rangeBuild ? "Enabled" : "Disabled"));
            }, DNMT.Config.Get(section, "BuildRange", new Hotkey(Keys.Add, alt: true), true));
            HotkeyCore.RegisterHotkey(() =>
            {
                _rangeLoot = !_rangeLoot;
                if (!_rangeLoot)
                {
                    Player.defaultItemGrabRange = _initialDefaultItemGrabRange;
                }
                CORE.Print("Loot range: " + (_rangeLoot ? "Enabled" : "Disabled"));
            }, DNMT.Config.Get(section, "LootRange", new Hotkey(Keys.Add, shift: true), true));
            HotkeyCore.RegisterHotkey(() =>
            {
                _craft = !_craft;
                CORE.Print("Craft anything: " + (_craft ? "Enabled" : "Disabled"));
            }, DNMT.Config.Get(section, "CraftAnything", new Hotkey(Keys.Add, control: true), true));
        }
Пример #5
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);
 }
Пример #6
0
        public InfoHUD()
        {
            string section = GetType().Name;
            bool   control = false, shift = true, alt = true;

            HotkeyCore.RegisterHotkey(() =>
            {
                _nfoWatch++;
                if (_nfoWatch > 3)
                {
                    _nfoWatch = 0;
                }
                CORE.Print("Info - watch: " + (_nfoWatch > 0 ? "Enabled - mode " + _nfoWatch.ToString() : "Disabled"), Color.Green);
            }, DNMT.Config.Get(section, "Watch", new Hotkey(Keys.OemTilde, control, shift, alt), true));
            HotkeyCore.RegisterHotkey(() =>
            {
                _nfoOreFinder = !_nfoOreFinder;
                CORE.Print("Info - ore finder: " + (_nfoOreFinder ? "Enabled" : "Disabled"), Color.Green);
            }, DNMT.Config.Get(section, "OreFinder", new Hotkey(Keys.D1, control, shift, alt), true));
            HotkeyCore.RegisterHotkey(() =>
            {
                _nfoFishFinder = !_nfoFishFinder;
                CORE.Print("Info - fish finder: " + (_nfoFishFinder ? "Enabled" : "Disabled"), Color.Green);
            }, DNMT.Config.Get(section, "FishFinder", new Hotkey(Keys.D2, control, shift, alt), true));
            HotkeyCore.RegisterHotkey(() =>
            {
                _nfoCompassAndDepthMeter = !_nfoCompassAndDepthMeter;
                CORE.Print("Info - compass and depth meter: " + (_nfoCompassAndDepthMeter ? "Enabled" : "Disabled"), Color.Green);
            }, DNMT.Config.Get(section, "CompassAndDepthMeter", new Hotkey(Keys.D3, control, shift, alt), true));
            HotkeyCore.RegisterHotkey(() =>
            {
                _nfoCritterGuide = !_nfoCritterGuide;
                CORE.Print("Info - critter guide: " + (_nfoCritterGuide ? "Enabled" : "Disabled"), Color.Green);
            }, DNMT.Config.Get(section, "CritterGuide", new Hotkey(Keys.D4, control, shift, alt), true));
            HotkeyCore.RegisterHotkey(() =>
            {
                _nfoThirdEye = !_nfoThirdEye;
                CORE.Print("Info - third eye: " + (_nfoThirdEye ? "Enabled" : "Disabled"), Color.Green);
            }, DNMT.Config.Get(section, "ThirdEye", new Hotkey(Keys.D5, control, shift, alt), true));
            HotkeyCore.RegisterHotkey(() =>
            {
                _nfoWeatherRadio = !_nfoWeatherRadio;
                CORE.Print("Info - weather radio: " + (_nfoWeatherRadio ? "Enabled" : "Disabled"), Color.Green);
            }, DNMT.Config.Get(section, "WeatherRadio", new Hotkey(Keys.D6, control, shift, alt), true));
            HotkeyCore.RegisterHotkey(() =>
            {
                _nfoCalendar = !_nfoCalendar;
                CORE.Print("Info - calendar: " + (_nfoCalendar ? "Enabled" : "Disabled"), Color.Green);
            }, DNMT.Config.Get(section, "Calendar", new Hotkey(Keys.D7, control, shift, alt), true));
            HotkeyCore.RegisterHotkey(() =>
            {
                _nfoJarOfSouls = !_nfoJarOfSouls;
                CORE.Print("Info - jar of souls: " + (_nfoJarOfSouls ? "Enabled" : "Disabled"), Color.Green);
            }, DNMT.Config.Get(section, "JarOfSouls", new Hotkey(Keys.D8, control, shift, alt), true));
            HotkeyCore.RegisterHotkey(() =>
            {
                _nfoDreamCatcher = !_nfoDreamCatcher;
                CORE.Print("Info - dream catcher: " + (_nfoDreamCatcher ? "Enabled" : "Disabled"), Color.Green);
            }, DNMT.Config.Get(section, "DreamCatcher", new Hotkey(Keys.D9, control, shift, alt), true));
            HotkeyCore.RegisterHotkey(() =>
            {
                _nfoStopwatch = !_nfoStopwatch;
                CORE.Print("Info - stopwatch: " + (_nfoStopwatch ? "Enabled" : "Disabled"), Color.Green);
            }, DNMT.Config.Get(section, "Stopwatch", new Hotkey(Keys.D0, control, shift, alt), true));
        }
Пример #7
0
        public override void OnUpdate()
        {
            if (!CORE.IsCanUseHotKeys() || CORE.IsOnCooldown())
            {
                return;
            }
            Player player = Main.player[Main.myPlayer];

            if (Main.mapFullscreen && Main.mouseRight && HotkeyCore.IsAltModifierKeyDown()) //  Main.keyState.IsKeyDown(Keys.LeftAlt)
            {
                int     num    = Main.maxTilesX * 16;
                int     num2   = Main.maxTilesY * 16;
                Vector2 vector = new Vector2((float)Main.mouseX, (float)Main.mouseY);
                vector.X -= (float)(Main.screenWidth / 2);
                vector.Y -= (float)(Main.screenHeight / 2);
                Vector2 mapFullscreenPos = Main.mapFullscreenPos;
                Vector2 vector2          = mapFullscreenPos;
                vector    /= 16f;
                vector    *= 16f / Main.mapFullscreenScale;
                vector2   += vector;
                vector2   *= 16f;
                vector2.Y -= (float)player.height;
                if (vector2.X < 0f)
                {
                    vector2.X = 0f;
                }
                else if (vector2.X + (float)player.width > (float)num)
                {
                    vector2.X = (float)(num - player.width);
                }
                if (vector2.Y < 0f)
                {
                    vector2.Y = 0f;
                }
                else if (vector2.Y + (float)player.height > (float)num2)
                {
                    vector2.Y = (float)(num2 - player.height);
                }

                DoTeleport(player, vector2.X, vector2.Y);
                CORE.BeginCooldown(30);
                return;
            }

            int slotActive = -1;

            for (int i = 0; i < _slotHotKeys.Length; i++)
            {
                if (Main.keyState.IsKeyDown(_slotHotKeys[i]))
                {
                    slotActive = i;
                    break;
                }
            }
            if (slotActive == -1)
            {
                return;
            }

            if (_positions == null)
            {
                _positions = new Vector2[_slotHotKeys.Length];
                for (int i = 0; i < _slotHotKeys.Length; i++)
                {
                    float x, y;
                    if (DNMT.Config.TryGet("Teleport", "Slot-" + i.ToString() + "-X", out x) &&
                        DNMT.Config.TryGet("Teleport", "Slot-" + i.ToString() + "-Y", out y))
                    {
                        _positions[i] = new Vector2(x, y);
                    }
                    else
                    {
                        _positions[i] = new Vector2(player.position.X, player.position.Y);
                    }
                }
            }

            if (HotkeyCore.IsAltModifierKeyDown())
            {
                _positions[slotActive] = new Vector2(player.position.X, player.position.Y);
                CORE.Print("Teleport position stored! [" + slotActive + "](" +
                           player.position.X.ToString() + ", " + player.position.Y.ToString() + ")");
                DNMT.Config.Set("Teleport", "Slot-" + slotActive.ToString() + "-X", _positions[slotActive].X);
                DNMT.Config.Set("Teleport", "Slot-" + slotActive.ToString() + "-Y", _positions[slotActive].Y);
            }
            else
            {
                CORE.Print("Teleport to slot [" + slotActive + "]!");
                DoTeleport(player, _positions[slotActive].X, _positions[slotActive].Y);
            }
            CORE.BeginCooldown(30);
        }