public void UnregisterCombination(IModInputCombination combination) { if (combination == null) { _console.WriteLine("Failed to unregister: null combination!"); return; } switch (SwapCombination(combination, true)) { case RegistrationCode.InvalidCombination: _console.WriteLine($"Failed to unregister \"{combination.FullName}\": invalid combination!"); return; case RegistrationCode.CombinationTooLong: _console.WriteLine($"Failed to unregister \"{combination.FullName}\": too long!"); return; case RegistrationCode.AllNormal: _logger.Log($"Successfully unregistered \"{combination.FullName}\""); return; default: return; } }
public bool WasTapped(IModInputCombination combination) { return(combination != null && !IsPressed(combination) && combination.PressDuration < TapDuration && combination.IsFirst); }
private RegistrationCode SwapCombination(IModInputCombination combination, bool toUnregister) { var isTaken = false; if (combination.Hashes.Count == 0) { return(RegistrationCode.InvalidCombination); } foreach (var hash in combination.Hashes) { if (toUnregister) { if (!_comboRegistry.ContainsKey(hash)) { continue; } _comboRegistry[hash].Remove(combination); if (_comboRegistry[hash].Count == 0) { _comboRegistry.Remove(hash); } continue; } if (_comboRegistry.ContainsKey(hash) || hash < ModInputLibrary.MaxUsefulKey && _gameBindingCounter[hash] > 0) { isTaken = true; } if (!_comboRegistry.ContainsKey(hash)) { _comboRegistry.Add(hash, new HashSet <IModInputCombination>()); } _comboRegistry[hash].Add(combination); } return(isTaken ? RegistrationCode.CombinationTaken : RegistrationCode.AllNormal); }
public bool IsPressedExact(IModInputCombination combination) { if (combination == null) { return(false); } UpdateCurrentCombinations(); return(_currentCombinations.Contains(combination)); }
public override void Configure(IModConfig config) { if (_crouchCombo != null) { ModHelper.Input.UnregisterCombination(_crouchCombo); } var combination = config.GetSettingsValue <string>("Crouch combination"); _crouchCombo = ModHelper.Input.RegisterCombination(this, "Crouch", combination) ?? TemporaryHack("Crouch"); }
private bool IsPressedSingle(IModInputCombination combination) { CleanupSinglesPressed(); if (_currentCombinations.Contains(combination)) { return(true); } var single = combination.Singles.FirstOrDefault(key => UnityEngine.Input.GetKey(key) && !IsPressedAndIgnored(key)); if (single == 0) { return(false); } _singlesPressed.Add(combination); combination.InternalSetPressed(); return(true); }
public bool WasNewlyReleased(IModInputCombination combination) { return(combination != null && !IsPressed(combination) && combination.IsFirst); }
public bool IsNewlyPressed(IModInputCombination combination) { return(combination != null && IsPressed(combination) && combination.IsFirst); }
public bool IsPressed(IModInputCombination combination) { return(combination != null && (IsPressedExact(combination) || IsPressedSingle(combination))); }