protected void LateUpdate() { if (checkForLongPress) { if (spellMenuPressed) { if ((Time.time - lastSpellMenuPress) > module.longPressTime) { // Long Press Detected if (module.longPressToEject) { MagazineRelease(); } CancelLongPress(); } } else { // Long Press Self Cancelled (released button before time) // Short Press Detected CancelLongPress(); if (!module.longPressToEject) { MagazineRelease(); } } } if (!mainHandleHeldLeft && !mainHandleHeldRight) { triggerPressed = false; if (slideController != null) { slideController.LockSlide(); } } if ((slideObject.transform.localPosition.z <= PULL_THRESHOLD) && !isPulledBack) { if (slideController != null) { if (slideController.IsHeld()) { // Entered PulledBack position if (pullbackSound != null) { pullbackSound.Play(); } isPulledBack = true; isRacked = false; playSoundOnNext = true; if (!roundChambered) { chamberRoundOnNext = true; UpdateAmmoCounter(); } else { FrameworkCore.ShootProjectile(item, module.ammoID, shellEjectionPoint, null, module.shellEjectionForce, 1.0f, false, slideCapsuleStabilizer); roundChambered = false; chamberRoundOnNext = true; } slideController.ChamberRoundVisible(false); } } } if ((slideObject.transform.localPosition.z > (PULL_THRESHOLD - RACK_THRESHOLD)) && isPulledBack) { // Show chamber ammo if (CountAmmoFromMagazine() > 0) { slideController.ChamberRoundVisible(true); } } if ((slideObject.transform.localPosition.z >= RACK_THRESHOLD) && !isRacked) { // Entered Rack position" isRacked = true; isPulledBack = false; if (chamberRoundOnNext) { if (ConsumeOneFromMagazine()) { slideController.ChamberRoundVisible(true); chamberRoundOnNext = false; roundChambered = true; } } if (playSoundOnNext) { if (rackforwardSound != null) { rackforwardSound.Play(); } playSoundOnNext = false; } UpdateAmmoCounter(); } if (slideController != null) { slideController.FixCustomComponents(); } else { return; // TODO: Remove this return, so we initialize even if we don't fix custom components } if (slideController.initialCheck) { return; } try { if (mainHandleHeldRight || mainHandleHeldLeft) { slideController.UnlockSlide(); slideController.initialCheck = true; } } catch { Debug.Log("[Fisher-ModularFirearms] Slide EXCEPTION"); } }
//public void TouchActionEvent(Interactable interactable, Interactable.Action action) //{ // if (action == Interactable.Action.Ungrab) // { // Debug.Log("[ModularFirearmsFramework] Ungrab: " + interactable.interactableId); // if (interactable.interactableId == gunGrip.interactableId) // { // // Debug.Log("[ModularFirearmsFramework] GunGrip Ungrabbed!"); // if (interactor.playerHand == Player.local.handRight) gunGripHeldRight = false; // if (interactor.playerHand == Player.local.handLeft) gunGripHeldLeft = false; // if ((!gunGripHeldRight && !gunGripHeldLeft) && (slideController != null)) // { // slideHandle.data.positionDamperMultiplier = 1.0f; // slideHandle.data.positionSpringMultiplier = 1.0f; // slideHandle.data.rotationDamperMultiplier = 1.0f; // slideHandle.data.rotationSpringMultiplier = 1.0f; // slideController.LockSlide(); // } // } // if (handle.name.Equals(slideHandle.name)) // { // // Debug.Log("[ModularFirearmsFramework] Slide Ungrabbed!"); // if (interactor.playerHand == Player.local.handRight) slideGripHeldRight = false; // if (interactor.playerHand == Player.local.handLeft) slideGripHeldLeft = false; // slideController.SetHeld(false); // // DumpRigidbodyToLog(slideController.rb); // } // } //} public void OnHeldAction(RagdollHand interactor, Handle handle, Interactable.Action action) { if (action == Interactable.Action.AlternateUseStart) { if (attachedLight != null) { attachedLight.enabled = !attachedLight.enabled; if (emptySound != null) { emptySound.Play(); } } } // Trigger Action if (handle.name.Equals(slideHandle.name)) { if (((action == Interactable.Action.UseStart) || (action == Interactable.Action.AlternateUseStart)) && (!holdingSlideTrigger)) { holdingSlideTrigger = true; slideController.LockSlide(false); if (emptySound != null) { emptySound.Play(); } } if (((action == Interactable.Action.UseStop) || (action == Interactable.Action.AlternateUseStop)) && (holdingSlideTrigger)) { holdingSlideTrigger = false; slideController.UnlockSlide(false); // if (emptySound != null) emptySound.Play(); } if (action == Interactable.Action.Ungrab) { if (holdingSlideTrigger) { holdingSlideTrigger = false; slideController.UnlockSlide(); } if (interactor.playerHand == Player.local.handRight) { slideGripHeldRight = false; } if (interactor.playerHand == Player.local.handLeft) { slideGripHeldLeft = false; } slideController.SetHeld(false); //DumpRigidbodyToLog(slideController.rb); } if (action == Interactable.Action.Grab) { if (interactor.playerHand == Player.local.handRight) { slideGripHeldRight = true; } if (interactor.playerHand == Player.local.handLeft) { slideGripHeldLeft = true; } slideController.SetHeld(true); //DumpRigidbodyToLog(slideController.rb); } } if (handle.Equals(gunGrip)) { if (action == Interactable.Action.Grab) { if ((gunGripHeldRight || gunGripHeldLeft) && (slideController != null)) { slideController.UnlockSlide(); } } if (action == Interactable.Action.Ungrab) { if (slideController != null) { slideController.LockSlide(); } try { slideHandle.Release(); } catch { } } if (action == Interactable.Action.UseStart) { // Begin Firing triggerPressed = true; if (!holdingSlideTrigger) { slideController.LockSlide(false); } if (!TrackedFire()) { if (emptySound != null) { emptySound.Play(); } } //if (!isFiring) StartCoroutine(FirearmFunctions.GeneralFire(TrackedFire, TriggerIsPressed, fireModeSelection, module.fireRate, module.burstNumber, emptySound, SetFiringFlag)); } if (action == Interactable.Action.UseStop) { // End Firing triggerPressed = false; if (!holdingSlideTrigger) { slideController.UnlockSlide(false); } } //"Spell-Menu" Action //if (action == Interactable.Action.AlternateUseStart) //{ //} } }