Ejemplo n.º 1
0
        /// /////////////////////////////////////////////////////////
        /// Static
        /// /////////////////////////////////////////////////////////

        // Cache velocity for fragments
        public IEnumerator DemolishableCor(RayfireRigid scr)
        {
            while (scr.demolitionType != DemolitionType.None)
            {
                // Max depth reached
                if (scr.limitations.depth > 0 && scr.limitations.currentDepth >= scr.limitations.depth)
                {
                    scr.demolitionType = DemolitionType.None;
                }

                // Init demolition
                if (scr.limitations.demolitionShould == true)
                {
                    scr.Demolish();
                }

                // Check for slicing planes and init slicing
                else if (scr.limitations.sliceByBlade == true && scr.limitations.slicePlanes.Count > 1)
                {
                    scr.Slice();
                }

                yield return(null);
            }
        }
Ejemplo n.º 2
0
        // Apply damage
        public static bool ApplyDamage(RayfireRigid scr, float damageValue, Vector3 damagePoint, float damageRadius = 0f)
        {
            // Initialize if not
            if (scr.initialized == false)
            {
                scr.Initialize();
            }

            // Already demolished or should be
            if (scr.limitations.demolished == true || scr.limitations.demolitionShould == true)
            {
                return(false);
            }

            // Apply damage and get demolition state
            bool demolitionState = Apply(scr, damageValue);

            // TODO demolish first to activate only demolished fragments AND activate if object can't be demolished

            // Set demolition info
            if (demolitionState == true)
            {
                // Demolition available check
                if (scr.DemolitionState() == false)
                {
                    return(false);
                }

                // Set damage position
                scr.limitations.contactVector3     = damagePoint;
                scr.clusterDemolition.damageRadius = damageRadius;

                // Demolish object
                scr.limitations.demolitionShould = true;

                // Demolish
                scr.Demolish();

                // Was demolished
                if (scr.limitations.demolished == true)
                {
                    return(true);
                }
            }

            // Check for activation
            if (scr.activation.byDamage > 0 && scr.damage.currentDamage > scr.activation.byDamage)
            {
                scr.Activate();
            }

            return(false);
        }
Ejemplo n.º 3
0
        /// /////////////////////////////////////////////////////////
        /// Demolition
        /// /////////////////////////////////////////////////////////

        // Demolish
        void Demolish(GameObject targetObject)
        {
            // Check tag
            if (tagFilter != "Untagged" && targetObject.tag != tagFilter)
            {
                return;
            }

            // Check layer
            if (LayerCheck(targetObject.layer) == false)
            {
                return;
            }

            // Get RayFire script
            RayfireRigid rfScr = targetObject.GetComponent <RayfireRigid>();

            // No Rayfire Rigid script
            if (rfScr == null)
            {
                return;
            }

            // No demolition allowed
            if (rfScr.demolitionType == DemolitionType.None)
            {
                return;
            }

            // Available for demolition
            if (rfScr.State() == false)
            {
                return;
            }

            // Demolish
            rfScr.Demolish();
        }