//private void IgnoreMovingLayer()
        //{
        //    foreach (ColliderGroup colliderGroup in this.item.colliderGroups)
        //    {
        //        foreach (Collider collider in colliderGroup.colliders)
        //        {
        //            Physics.IgnoreLayerCollision(collider.gameObject.layer, GameManager.GetLayer(LayerName.MovingObject));
        //        }
        //    }
        //}

        protected void Start()
        {
            //IgnoreMovingLayer();

            /// 1) Create and Initialize configurable joint between the base and slide
            /// 2) Create and Initialize the slide controller object
            /// 3) Setup the slide controller into the default state
            /// 4) Spawn and Snap in the inital magazine
            /// 5) (optional) Set the firemode selection switch to the correct position

            num1 = slideHandle.data.positionDamperMultiplier;
            num2 = slideHandle.data.positionSpringMultiplier;
            num3 = slideHandle.data.rotationDamperMultiplier;
            num4 = slideHandle.data.rotationSpringMultiplier;
            InitializeConfigurableJoint(module.slideStabilizerRadius);

            slideController = new ChildRigidbodyController(item, module);
            slideController.InitializeSlide(slideObject);

            if (slideController == null)
            {
                Debug.LogError("[ModularFirearmsFramework] ERROR! CHILD SLIDE CONTROLLER WAS NULL");
            }
            else
            {
                slideController.SetupSlide();
            }

            shellReceiver.data.disableTouch = true;
            //LimitSlideInteraction(currentSlideState);

            return;
        }
Exemple #2
0
        void Start()
        {
            if (fireSound1 != null)
            {
                fireSound1.volume = module.soundVolume;
            }
            if (fireSound2 != null)
            {
                fireSound2.volume = module.soundVolume;
            }
            if (fireSound3 != null)
            {
                fireSound3.volume = module.soundVolume;
            }

            /// 1) Create and Initialize configurable joint between the base and slide
            /// 2) Create and Initialize the slide controller object
            /// 3) Setup the slide controller into the default state
            /// 4) Spawn and Snap in the inital magazine
            /// 5) (optional) Set the firemode selection switch to the correct position
            InitializeConfigurableJoint(module.slideStabilizerRadius);

            slideController = new ChildRigidbodyController(item, module);
            slideController.InitializeSlide(slideObject);

            if (slideController == null)
            {
                Debug.LogError("[Fisher-ModularFirearms] ERROR! CHILD SLIDE CONTROLLER WAS NULL");
            }
            else
            {
                slideController.SetupSlide();
            }

            var magazineData = Catalog.GetData <ItemData>(module.acceptedMagazineIDs[0], true);

            if (magazineData == null)
            {
                Debug.LogError("[Fisher-ModularFirearms][ERROR] No Magazine named " + module.acceptedMagazineIDs[0].ToString());
                return;
            }
            else
            {
                magazineData.SpawnAsync(i =>
                {
                    try
                    {
                        magazineHolder.Snap(i);
                        magazineHolder.data.disableTouch = !module.allowGrabMagazineFromGun;
                    }
                    catch
                    {
                        Debug.Log("[Fisher-ModularFirearms] EXCEPTION IN SNAPPING MAGAZINE ");
                    }
                },
                                        item.transform.position,
                                        Quaternion.Euler(item.transform.rotation.eulerAngles),
                                        null,
                                        false);
            }
        }