Example #1
0
        public void OnHeldAction(RagdollHand interactor, Handle handle, Interactable.Action action)
        {
            if (handle.Equals(mainHandle))
            {
                // Trigger Action
                if (action == Interactable.Action.UseStart)
                {
                    // Begin Firing
                    triggerPressed = true;
                    if (!isFiring)
                    {
                        StartCoroutine(FrameworkCore.GeneralFire(TrackedFire, TriggerIsPressed, fireModeSelection, module.fireRate, module.burstNumber, emptySound, SetFiringFlag, ProjectileIsSpawning));
                    }
                }
                if (action == Interactable.Action.UseStop)
                {
                    // End Firing
                    triggerPressed = false;
                }

                // "Spell-Menu" Action
                if (action == Interactable.Action.AlternateUseStart)
                {
                    spellMenuPressed = true;
                    if (SlideToggleLock())
                    {
                        return;
                    }

                    StartLongPress();
                }
                if (action == Interactable.Action.AlternateUseStop)
                {
                    spellMenuPressed = false;
                }
            }

            if (action == Interactable.Action.Grab)
            {
                if (handle.Equals(mainHandle))
                {
                    if (interactor.playerHand == Player.local.handRight)
                    {
                        mainHandleHeldRight = true;
                    }
                    if (interactor.playerHand == Player.local.handLeft)
                    {
                        mainHandleHeldLeft = true;
                    }

                    if ((mainHandleHeldRight || mainHandleHeldLeft) && (slideController != null))
                    {
                        slideController.UnlockSlide();
                    }
                }

                if (handle.Equals(slideHandle))
                {
                    if (interactor.playerHand == Player.local.handRight)
                    {
                        slideHandleHeldRight = true;
                    }
                    if (interactor.playerHand == Player.local.handLeft)
                    {
                        slideHandleHeldLeft = true;
                    }
                    if (slideController != null)
                    {
                        slideController.SetHeld(true);
                    }
                    slideController.ForwardState();
                }
            }

            if (action == Interactable.Action.Ungrab)
            {
                if (handle.Equals(mainHandle))
                {
                    if (interactor.playerHand == Player.local.handRight)
                    {
                        mainHandleHeldRight = false;
                    }
                    if (interactor.playerHand == Player.local.handLeft)
                    {
                        mainHandleHeldLeft = false;
                    }

                    if (!mainHandleHeldRight && !mainHandleHeldLeft)
                    {
                        if (interactor.playerHand == Player.local.handRight)
                        {
                            slideHandleHeldRight = false;
                        }
                        if (interactor.playerHand == Player.local.handLeft)
                        {
                            slideHandleHeldLeft = false;
                        }
                        if (((slideController != null)))
                        {
                            slideController.LockSlide();
                        }
                        ForceDrop();
                    }
                }

                if (handle.Equals(slideHandle))
                {
                    if (slideController != null)
                    {
                        slideController.SetHeld(false);
                    }
                }
            }
        }
        //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)
                //{

                //}
            }
        }