Exemple #1
0
 public void ForceDrop()
 {
     try { slideHandle.Release(); }
     catch { }
     if (slideController != null)
     {
         slideController.LockSlide();
     }
 }
        //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)
                //{

                //}
            }
        }