tModLoader v0.11.8.9
A mod to make and play Terraria mods
ModHotkey.cs
Go to the documentation of this file.
1using System.Collections.Generic;
2using Terraria.GameInput;
3
4// Thanks to Yoraiz0r for the useful Properties approach.
5
6namespace Terraria.ModLoader
7{
11 public class ModHotKey
12 {
13 internal readonly Mod mod;
14 internal readonly string name; // name from modder: "Random Buff"
15 internal readonly string uniqueName; // eg: "Example Mod: Random Buff" (currently also display name)
16 internal readonly string defaultKey; // from mod.Load
17
18 internal ModHotKey(Mod mod, string name, string defaultKey) {
19 this.mod = mod;
20 this.name = name;
21 this.defaultKey = defaultKey;
22 this.uniqueName = mod.Name + ": " + name;
23 }
24
30 public List<string> GetAssignedKeys(InputMode mode = InputMode.Keyboard) {
31 return PlayerInput.CurrentProfile.InputModes[mode].KeyStatus[uniqueName];
32 }
33
34 public bool RetroCurrent {
35 get {
36 if (Main.drawingPlayerChat || Main.player[Main.myPlayer].talkNPC != -1 || Main.player[Main.myPlayer].sign != -1) return false;
37 return Current;
38 }
39 }
40
44 public bool Current => PlayerInput.Triggers.Current.KeyStatus[uniqueName];
45
49 public bool JustPressed => PlayerInput.Triggers.JustPressed.KeyStatus[uniqueName];
50
54 public bool JustReleased => PlayerInput.Triggers.JustReleased.KeyStatus[uniqueName];
55
59 public bool Old => PlayerInput.Triggers.Old.KeyStatus[uniqueName];
60 }
61}
Represents a loaded hotkey. It is suggested to access the hotkey status only in ModPlayer....
Definition: ModHotkey.cs:12
bool JustReleased
Returns true if this hotkey was just released this update.
Definition: ModHotkey.cs:54
bool JustPressed
Returns true if this hotkey was just released this update. This is a fire-once-per-press behavior.
Definition: ModHotkey.cs:49
bool Current
Returns true if this hotkey is pressed currently. Useful for createing a behavior that relies on the ...
Definition: ModHotkey.cs:44
bool Old
Returns true if this hotkey was pressed the previous update.
Definition: ModHotkey.cs:59
List< string > GetAssignedKeys(InputMode mode=InputMode.Keyboard)
Gets the currently assigned keybindings. Useful for prompts, tooltips, informing users.
Definition: ModHotkey.cs:30
Mod is an abstract class that you will override. It serves as a central place from which the mod's co...
Definition: Mod.cs:25