コード例 #1
0
        public override void OnInitialize()
        {
            Console.WriteLine("OnInitialize from event system!");

            HotkeyCore.RegisterHotkey(() =>
            {
                CORE.Print("HEEEEELLLLLOPOO!");
            }, Keys.E);
        }
コード例 #2
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");
        }
コード例 #3
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));
 }
コード例 #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
        static void Main(string[] args)
        {
            Console.WindowWidth  = 120;
            Console.WindowHeight = 42;
            print(assemblyTitle + "\n" + assemblyCopyright + "\n");

            HotkeyCore.RegisterHotkey(() =>
            {
                Console.WriteLine("HELLO!");
            }, new Hotkey(Keys.Delete));

            Initialize();
            print("[press 'ctrl+c' to stop!]");
            while (true)
            {
                Update();
                HotkeyCore.Process();
                System.Threading.Thread.Sleep(250);
                if (Keyboard.IsKeyDown(Keys.LeftAlt))
                {
                    break;
                }
                if (Keyboard.IsKeyDown(Keys.Space))
                {
                    break;
                }
            }

            print("---");
            PluginTest.DoTest();
            print("---");
            StructTest.DoTest();

            print("\nDone!");
            if (isPauseAfterExit)
            {
                Console.ReadKey(true);
            }
        }
コード例 #7
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));
        }
コード例 #8
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);
        }
コード例 #9
0
        public HelpfulHotkeys()
        {
            string section = GetType().Name;

            HotkeyCore.RegisterHotkey(() =>
            {
                Player player = Main.player[Main.myPlayer];

                if (player.inventory[49].type != 0)
                {
                    _originalSelectedItem   = player.selectedItem;
                    _autoRevertSelectedItem = true;
                    player.selectedItem     = 49;
                    player.controlUseItem   = true;
                    player.ItemCheck(Main.myPlayer);
                }
            }, DNMT.Config.Get(section, "QuickUse50", new Hotkey(Keys.Q), true));

            HotkeyCore.RegisterHotkey(() =>
            {
                Player player = Main.player[Main.myPlayer];

                if (player.inventory[48].type != 0)
                {
                    _originalSelectedItem   = player.selectedItem;
                    _autoRevertSelectedItem = true;
                    player.selectedItem     = 48;
                    player.controlUseItem   = true;
                    player.ItemCheck(Main.myPlayer);
                }
            }, DNMT.Config.Get(section, "QuickUse49", new Hotkey(Keys.C), true));

            HotkeyCore.RegisterHotkey(() =>
            {
                Player player = Main.player[Main.myPlayer];

                if (player.inventory[47].type != 0)
                {
                    _originalSelectedItem   = player.selectedItem;
                    _autoRevertSelectedItem = true;
                    player.selectedItem     = 47;
                    player.controlUseItem   = true;
                    player.ItemCheck(Main.myPlayer);
                }
            }, DNMT.Config.Get(section, "QuickUse48", new Hotkey(Keys.X), true));

            HotkeyCore.RegisterHotkey(() =>
            {
                Player player = Main.player[Main.myPlayer];

                if (player.inventory[46].type != 0)
                {
                    _originalSelectedItem   = player.selectedItem;
                    _autoRevertSelectedItem = true;
                    player.selectedItem     = 46;
                    player.controlUseItem   = true;
                    player.ItemCheck(Main.myPlayer);
                }
            }, DNMT.Config.Get(section, "QuickUse47", new Hotkey(Keys.Z), true));

            HotkeyCore.RegisterHotkey(() =>
            {
                Player player = Main.player[Main.myPlayer];
                for (int i = 0; i < player.inventory.Length; i++)
                {
                    if (player.inventory[i].createTile == 4)
                    {
                        _originalSelectedItem   = player.selectedItem;
                        _autoRevertSelectedItem = true;
                        player.selectedItem     = i;
                        player.controlUseItem   = true;
                        Player.tileTargetX      = (int)(player.Center.X / 16f);
                        Player.tileTargetY      = (int)(player.Center.Y / 16f);
                        int stack      = player.inventory[player.selectedItem].stack;
                        float distance = -3.40282347E+38f;
                        bool flag;
                        do
                        {
                            float lastDistance = 3.40282347E+38f;
                            flag = false;
                            for (int x = -Player.tileRangeX - player.blockRange + (int)(player.position.X / 16f);
                                 x <= Player.tileRangeX + player.blockRange - 1 + (int)((player.position.X + (float)player.width) / 16f); x++)
                            {
                                for (int y = -Player.tileRangeY - player.blockRange + (int)(player.position.Y / 16f);
                                     y <= Player.tileRangeY + player.blockRange - 2 + (int)((player.position.Y + (float)player.height) / 16f); y++)
                                {
                                    float currentDistance = Vector2.Distance(Main.MouseWorld, new Vector2((float)(x * 16), (float)(y * 16)));
                                    if (lastDistance > currentDistance && distance < currentDistance)
                                    {
                                        flag               = true;
                                        lastDistance       = currentDistance;
                                        Player.tileTargetX = x;
                                        Player.tileTargetY = y;
                                    }
                                }
                            }
                            distance = lastDistance;
                            player.ItemCheck(Main.myPlayer);
                        }while (flag && stack == player.inventory[player.selectedItem].stack);
                        break;
                    }
                }
            }, DNMT.Config.Get(section, "AutoTorch", new Hotkey(Keys.F), true));
        }