Beispiel #1
0
        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"); }
        }
        protected void LateUpdate()
        {
            if ((slideObject.transform.localPosition.z <= PULL_THRESHOLD) && !isPulledBack)
            {
                if (slideController != null)
                {
                    if (slideController.IsHeld())
                    {
                        //currentSlideState = false;
                        if (pullbackSound != null)
                        {
                            pullbackSound.Play();
                        }
                        isPulledBack    = true;
                        isRacked        = false;
                        playSoundOnNext = true;
                        slideController.LockedBackState();
                        FrameworkCore.Animate(Animations, module.openAnimationRef);
                        shellReceiver.data.disableTouch = false;
                        //if (shellReceiver.data.locked && (currentReceiverAmmo < module.maxReceiverAmmo))
                        //{
                        //    shellReceiver.data.locked = false;
                        //}
                        if (roundChambered)
                        {
                            if (roundSpent)
                            {
                                FrameworkCore.ShootProjectile(item, module.shellID, shellEjectionPoint, null, module.shellEjectionForce, 1.0f, false, slideCapsuleStabilizer);
                            }
                            else
                            {
                                FrameworkCore.ShootProjectile(item, module.ammoID, shellEjectionPoint, null, module.shellEjectionForce, 1.0f, false, slideCapsuleStabilizer);
                            }
                            roundChambered = false;
                            slideController.ChamberRoundVisible(false);
                        }
                        if (CountAmmoFromReceiver() > 0)
                        {
                            chamberRoundOnNext = true;
                        }
                    }
                }
            }
            if ((slideObject.transform.localPosition.z > (PULL_THRESHOLD - RACK_THRESHOLD)) && isPulledBack)
            {
                if (CountAmmoFromReceiver() > 0)
                {
                    slideController.ChamberRoundVisible(true);
                }
            }
            if ((slideObject.transform.localPosition.z >= RACK_THRESHOLD) && !isRacked)
            {
                //currentSlideState = true;
                isRacked     = true;
                isPulledBack = false;
                shellReceiver.data.disableTouch = true;
                slideController.ForwardState();
                FrameworkCore.Animate(Animations, module.closeAnimationRef);
                if (playSoundOnNext)
                {
                    if (rackforwardSound != null)
                    {
                        rackforwardSound.Play();
                    }
                    playSoundOnNext = false;
                }

                if (chamberRoundOnNext)
                {
                    if (!ConsumeOneFromReceiver())
                    {
                        return;
                    }
                    slideController.ChamberRoundVisible(true);
                    chamberRoundOnNext = false;
                    roundChambered     = true;
                    roundSpent         = false;
                }
            }

            if (slideController != null)
            {
                slideController.FixCustomComponents();
            }
            else
            {
                return;
            }
            if (slideController.initialCheck)
            {
                return;
            }
            try
            {
                if (gunGripHeldRight || gunGripHeldLeft)
                {
                    slideController.UnlockSlide();
                    slideController.initialCheck = true;
                }
            }
            catch { Debug.Log("[ModularFirearmsFramework] Slide EXCEPTION"); }
        }