public InfiniteFlight() { HotkeyCore.RegisterHotkey(() => { _flight = !_flight; CORE.Print("Infinite Flight: " + (_flight ? "Enabled" : "Disabled"), Color.Green); }, DNMT.Config.Get("InfiniteFlight", "Key", new Hotkey(Keys.I), true)); }
public Time() { string section = GetType().Name; HotkeyCore.RegisterHotkey(() => ChangeTime(HotkeyCore.IsControlModifierKeyDown() ? "dusk" : "midnight"), DNMT.Config.Get(section, "Night", new Hotkey(Keys.OemComma, ignoreModifierKeys: true), true)); HotkeyCore.RegisterHotkey(() => ChangeTime(HotkeyCore.IsControlModifierKeyDown() ? "dawn" : "noon"), DNMT.Config.Get(section, "Day", new Hotkey(Keys.OemPeriod, ignoreModifierKeys: true), true)); }
private void UnbindHotkey(string hotkey) { var key = Hotkey.Parse(hotkey); if (key == null) { Main.NewText("Invalid hotkey binding!"); } else { DNMT.Config.Set("HotkeyBinds", hotkey, null); HotkeyCore.UnregisterHotkey(key); CORE.Print("Unbind " + hotkey); } }
private void BindHotkey(string hotkey, string cmd) { var key = Hotkey.Parse(hotkey); if (string.IsNullOrEmpty(cmd) || !cmd.StartsWith(".") || key == null) { Main.NewText("Invalid hotkey binding!"); } else { DNMT.Config.Set("HotkeyBinds", hotkey, cmd); HotkeyCore.RegisterHotkey(cmd, key); CORE.Print(hotkey + " set to " + cmd); } }
public override void OnPlayerUpdate(Player player) { // 0.7f, 1f, 0.8f - glowstick // 1f, 0.95f, 0.8f - torch // 1f, 1f, 1f - white if (HotkeyCore.IsAltModifierKeyDown() && _flashlight) { Lighting.AddLight((int)((Main.mouseX + Main.screenPosition.X) / 16), (int)((Main.mouseY + Main.screenPosition.Y) / 16), 1f, 0.95f, 0.8f); } if (_torch) { Lighting.AddLight((int)((player.position.X + ((float)player.width / 2)) / 16), (int)((player.position.Y + ((float)player.height / 2)) / 16), 1f, 0.95f, 0.8f); } }
public HotkeyBind() { // 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(".")) { HotkeyCore.RegisterHotkey(command, key); } else { DNMT.LogWarning("Invalid record in [HotkeyBinds]: " + k + "."); } } }
public LightingEx() { string section = GetType().Name; HotkeyCore.RegisterHotkey(() => { _flashlight = !_flashlight; CORE.Print("Flashlight: " + (_flashlight ? "Enabled" : "Disabled")); }, DNMT.Config.Get(section, "Flashlight", new Hotkey(Keys.Subtract, alt: true), true)); HotkeyCore.RegisterHotkey(() => { _torch = !_torch; CORE.Print("Torch: " + (_torch ? "Enabled" : "Disabled")); }, DNMT.Config.Get(section, "Torch", new Hotkey(Keys.Subtract, control: true), true)); HotkeyCore.RegisterHotkey(() => { _fullbright = !_fullbright; CORE.Print("Fullbright: " + (_fullbright ? "Enabled" : "Disabled")); }, DNMT.Config.Get(section, "Fullbright", new Hotkey(Keys.Subtract, shift: true), true)); }
public override void OnChatCommand(string command, string[] args) { if (command != "bind" && command != "unbind" && command != "listbinds") { return; } if ((command == "bind" && (args.Length <= 1 || args[0] == "help")) || (command == "unbind" && (args.Length <= 0 || args[0] == "help")) || (command == "listbinds" && args.Length > 0 && args[0] == "help")) { CORE.Print("Usage:"); CORE.Print(" .bind modifiers,hotkey command"); CORE.Print(" .unbind modifiers,hotkey"); CORE.Print(" .listbinds"); CORE.Print("Example:"); CORE.Print(" .bind Control,T .time dusk"); CORE.Print(" .unbind Control,T"); CORE.Print(" .bind Control,Shift,K .usetime"); return; } if (command == "bind") { BindHotkey(args[0], string.Join(" ", args.Skip(1))); } else if (command == "unbind") { UnbindHotkey(args[0]); } else if (command == "listbinds") { foreach (var hotkey in HotkeyCore.GetHotkeys().Where(hotkey => !string.IsNullOrEmpty(hotkey.Tag))) { Main.NewText(hotkey.ToString()); } } }
public GodMode() { string section = GetType().Name; _mode = DNMT.Config.Get(section, "Mode", Mode.Off, true); Action update = () => { DNMT.Config.Set <Mode>("GodMode", "Mode", _mode); CORE.Print("God Mode: " + _mode, Color.Green); }; HotkeyCore.RegisterHotkey(() => { if (_mode == Mode.God) { _mode = Mode.Off; } else { _mode++; } update(); }, DNMT.Config.Get(section, "KeySwitch", new Hotkey(Keys.G), true)); HotkeyCore.RegisterHotkey(() => { if (_mode == Mode.Off) { _mode = Mode.God; } else { _mode--; } update(); }, DNMT.Config.Get(section, "KeyDowngrade", new Hotkey(Keys.G, shift: true), true)); }
public TerrariaEvents() { var worldGen = Assembly.GetEntryAssembly().GetType("Terraria.WorldGen"); _triggerLunarApocalypse = worldGen.GetMethod("TriggerLunarApocalypse"); _spawnMeteor = worldGen.GetField("spawnMeteor"); _dropMeteor = worldGen.GetMethod("dropMeteor"); string section = GetType().Name; bool control = true, shift = true, alt = false; HotkeyCore.RegisterHotkey(() => { CORE.Print("EVENT: Goblin Army"); if (Main.invasionType > 0) { Main.invasionSize = 0; } else { Main.StartInvasion(1); } }, DNMT.Config.Get(section, "GoblinArmy", new Hotkey(Keys.D3, control, shift, alt), true)); HotkeyCore.RegisterHotkey(() => { CORE.Print("EVENT: Frost Legion"); if (Main.invasionType > 0) { Main.invasionSize = 0; } else { Main.StartInvasion(2); } }, DNMT.Config.Get(section, "FrostLegion", new Hotkey(Keys.D4, control, shift, alt), true)); HotkeyCore.RegisterHotkey(() => { CORE.Print("EVENT: Pirate Invasion"); if (Main.invasionType > 0) { Main.invasionSize = 0; } else { Main.StartInvasion(3); } }, DNMT.Config.Get(section, "PirateInvasion", new Hotkey(Keys.D5, control, shift, alt), true)); HotkeyCore.RegisterHotkey(() => { CORE.Print("EVENT: Martian Madness"); if (Main.invasionType > 0) { Main.invasionSize = 0; } else { Main.StartInvasion(4); } }, DNMT.Config.Get(section, "MartianMadness", new Hotkey(Keys.D9, control, shift, alt), true)); HotkeyCore.RegisterHotkey(() => { CORE.Print("EVENT: Pumpkin Moon"); if (Main.pumpkinMoon) { Main.stopMoonEvent(); } else { Main.startPumpkinMoon(); } }, DNMT.Config.Get(section, "PumpkinMoon", new Hotkey(Keys.D7, control, shift, alt), true)); HotkeyCore.RegisterHotkey(() => { CORE.Print("EVENT: Frost Moon"); if (Main.snowMoon) { Main.stopMoonEvent(); } else { Main.startSnowMoon(); } }, DNMT.Config.Get(section, "FrostMoon", new Hotkey(Keys.D8, control, shift, alt), true)); HotkeyCore.RegisterHotkey(() => { CORE.Print("EVENT: Lunar Apocalypse"); if (Terraria.NPC.LunarApocalypseIsUp || Terraria.NPC.AnyNPCs(398)) { StopLunarEvent(); } else { TriggerLunarApocalypse(); } }, DNMT.Config.Get(section, "LunarApocalypse", new Hotkey(Keys.D0, control, shift, alt), true)); HotkeyCore.RegisterHotkey(() => { CORE.Print("EVENT: Moon Lord"); if (Terraria.NPC.LunarApocalypseIsUp || Terraria.NPC.AnyNPCs(398)) { StopLunarEvent(); } else { SpawnMoonLord(); } }, DNMT.Config.Get(section, "MoonLord", new Hotkey(Keys.OemTilde, control, shift, alt), true)); HotkeyCore.RegisterHotkey(() => { CORE.Print("EVENT: Blood Moon"); if (Main.bloodMoon) { Main.bloodMoon = false; } else { TriggerBloodMoon(); } }, DNMT.Config.Get(section, "BloodMoon", new Hotkey(Keys.D2, control, shift, alt), true)); HotkeyCore.RegisterHotkey(() => { CORE.Print("EVENT: Solar Eclipse"); if (Main.eclipse) { Main.eclipse = false; } else { TriggerEclipse(); } }, DNMT.Config.Get(section, "SolarEclipse", new Hotkey(Keys.D6, control, shift, alt), true)); HotkeyCore.RegisterHotkey(() => { CORE.Print("EVENT: Meteor"); SpawnMeteor = false; DropMeteor(); }, DNMT.Config.Get(section, "Meteor", new Hotkey(Keys.D1, control, shift, alt), true)); }