protected void CheckButtons(ModMachineEntity e) { var actions = buttonActions.Where(a => Input.GetButtonDown(a.Item1)); if (actions.Count() == 0) { return; } int keymask = 0; if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)) { keymask |= MOD_SHIFT; } if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(KeyCode.RightAlt)) { keymask |= MOD_ALT; } if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) { keymask |= MOD_CTRL; } foreach (var v in actions.Where(a => a.Item2 == keymask)) { ModLoader.log("Invoking button action for {0} with mods {1}", v.Item1, v.Item2); v.Item3(); } }
public HotKeyBehavior(ModMachineEntity e) { e.HoverEvent += CheckButtons; }
public HoverBehavior(ModMachineEntity e, long lingerTimeInMS) { e.HoverEvent += SetActive; this.lingerTimeInMS = lingerTimeInMS; }
public void SetActive(ModMachineEntity sender) { viewUntil = ModMachineEntity.Now + lingerTimeInMS; }
public HoverBehavior(ModMachineEntity e) : this(e, 100) { }