private IEnumerator DelayKeyTurn(bool restoreBombTimer, bool causeStrikeIfWrongTime = true, bool bypassSettings = false) { Animator keyAnimator = (Animator)KeyAnimatorField.GetValue(Module.BombComponent.GetComponent(ComponentType)); KMAudio keyAudio = (KMAudio)KeyAudioField.GetValue(Module.BombComponent.GetComponent(ComponentType)); int time = (int)TargetTimeField.GetValue(Module.BombComponent.GetComponent(ComponentType)); if (!restoreBombTimer) { Module.Bomb.CurrentTimer = time + 0.5f + Time.deltaTime; yield return(null); } else if (causeStrikeIfWrongTime && time != (int)Mathf.Floor(Module.Bomb.CurrentTimer)) { Module.BombComponent.GetComponent <KMBombModule>().HandleStrike(); keyAnimator.SetTrigger("WrongTurn"); keyAudio.PlaySoundAtTransform("WrongKeyTurnFK", Module.transform); yield return(null); if (!(TwitchPlaySettings.data.AllowTurnTheKeyEarlyLate || bypassSettings) || (bool)SolvedField.GetValue(Module.BombComponent.GetComponent(ComponentType))) { yield break; } } Module.BombComponent.GetComponent <KMBombModule>().HandlePass(); KeyUnlockedField.SetValue(Module.BombComponent.GetComponent(ComponentType), true); SolvedField.SetValue(Module.BombComponent.GetComponent(ComponentType), true); keyAnimator.SetBool("IsUnlocked", true); keyAudio.PlaySoundAtTransform("TurnTheKeyFX", Module.transform); yield return(null); }
private IEnumerator HandleInteraction() { // We set _solved to true, which stops the module's own interactions. SolvedField.SetValue(Module.BombComponent.GetComponent(ComponentType), true); LocalAppreciationReqTime = (float)AppreciationTimeRequiredField.GetValue(Module.BombComponent.GetComponent(ComponentType)); while (true) { if (IsBeingZoomed) { // Camera is zoomed, appreciate if (!LocalStartTime.HasValue) { // Just started appreciating StartAppreciateMethod.Invoke(Module.BombComponent.GetComponent(ComponentType), null); LocalStartTime = Time.time; } else if (Time.time - LocalStartTime >= LocalAppreciationReqTime) { // Appreciation time sufficient EnlightenMethod.Invoke(Module.BombComponent.GetComponent(ComponentType), null); yield break; } } else if (LocalStartTime.HasValue) { // Not enough appreciation and zoom has ended StopAppreciateMethod.Invoke(Module.BombComponent.GetComponent(ComponentType), null); LocalStartTime = null; } yield return(null); } }
private void OnActivate() { string serial = Module.Bomb.QueryWidgets <string>(KMBombInfo.QUERYKEY_GET_SERIAL_NUMBER).First()["serial"]; TextMesh textMesh = (TextMesh)DisplayField.GetValue(Module.BombComponent.GetComponent(ComponentType)); ActivatedField.SetValue(Module.BombComponent.GetComponent(ComponentType), true); if (string.IsNullOrEmpty(_previousSerialNumber) || !_previousSerialNumber.Equals(serial) || _keyTurnTimes.Count == 0) { if (!string.IsNullOrEmpty(_previousSerialNumber) && _previousSerialNumber.Equals(serial)) { Animator keyAnimator = (Animator)KeyAnimatorField.GetValue(Module.BombComponent.GetComponent(ComponentType)); KMAudio keyAudio = (KMAudio)KeyAudioField.GetValue(Module.BombComponent.GetComponent(ComponentType)); AttemptedForcedSolve = true; PrepareSilentSolve(); Module.BombComponent.GetComponent <KMBombModule>().HandlePass(); KeyUnlockedField.SetValue(Module.BombComponent.GetComponent(ComponentType), true); SolvedField.SetValue(Module.BombComponent.GetComponent(ComponentType), true); keyAnimator.SetBool("IsUnlocked", true); keyAudio.PlaySoundAtTransform("TurnTheKeyFX", Module.transform); textMesh.text = "88:88"; return; } _keyTurnTimes.Clear(); for (int i = OtherModes.Unexplodable ? 45 : 3; i < (OtherModes.Unexplodable ? 3600 : Module.Bomb.CurrentTimer - 45); i += 3) { _keyTurnTimes.Add(i); } if (_keyTurnTimes.Count == 0) { _keyTurnTimes.Add((int)(Module.Bomb.CurrentTimer / 2f)); } _keyTurnTimes = _keyTurnTimes.Shuffle().ToList(); _previousSerialNumber = serial; } TargetTimeField.SetValue(Module.BombComponent.GetComponent(ComponentType), _keyTurnTimes[0]); string display = $"{_keyTurnTimes[0] / 60:00}:{_keyTurnTimes[0] % 60:00}"; _keyTurnTimes.RemoveAt(0); textMesh.text = display; }