예제 #1
0
        // Copy debris and dust
        public static void CopyParticles(RayfireRigid source, RayfireRigid target)
        {
            // Copy debris
            if (source.HasDebris == true)
            {
                for (int i = 0; i < source.debrisList.Count; i++)
                {
                    RayfireDebris targetDebris = target.gameObject.AddComponent <RayfireDebris>();
                    targetDebris.CopyFrom(source.debrisList[i]);

                    if (source.debrisList[i].children == null)
                    {
                        source.debrisList[i].children = new List <RayfireDebris>();
                    }
                    source.debrisList[i].children.Add(targetDebris);
                }
            }

            // Copy dust
            if (source.HasDust == true)
            {
                for (int i = 0; i < source.dustList.Count; i++)
                {
                    RayfireDust targetDust = target.gameObject.AddComponent <RayfireDust>();
                    targetDust.CopyFrom(source.dustList[i]);

                    if (source.dustList[i].children == null)
                    {
                        source.dustList[i].children = new List <RayfireDust>();
                    }
                    source.dustList[i].children.Add(targetDust);
                }
            }
        }
예제 #2
0
        // Copy debris and dust
        public static void CopyRootMeshParticles(RayfireRigid source, List <RayfireRigid> targets)
        {
            // Copy debris. only initialized debris in this list
            if (source.HasDebris == true)
            {
                for (int d = 0; d < source.debrisList.Count; d++)
                {
                    // Set max amount
                    int maxAmount = targets.Count;
                    if (source.debrisList[d].limitations.percentage < 100)
                    {
                        maxAmount = targets.Count * source.debrisList[d].limitations.percentage / 100;
                    }

                    // Copy component
                    for (int i = 0; i < targets.Count; i++)
                    {
                        // Max amount reached
                        if (maxAmount <= 0)
                        {
                            break;
                        }

                        // TODO consider size threshold

                        // Filter by percentage
                        if (Random.Range(0, 100) > source.debrisList[d].limitations.percentage)
                        {
                            continue;
                        }

                        // Copy
                        RayfireDebris targetDebris = targets[i].gameObject.AddComponent <RayfireDebris>();
                        targetDebris.CopyFrom(source.debrisList[d]);
                        targetDebris.rigid = targets[i];

                        // Collect debris for Rigid
                        if (targets[i].debrisList == null)
                        {
                            targets[i].debrisList = new List <RayfireDebris>();
                        }
                        targets[i].debrisList.Add(targetDebris);

                        // Collect debris for parent debris
                        if (source.debrisList[d].children == null)
                        {
                            source.debrisList[d].children = new List <RayfireDebris>();
                        }
                        source.debrisList[d].children.Add(targetDebris);

                        maxAmount--;
                    }

                    // Get amount list
                    SetDebrisFinalAmount(source.debrisList[d].children, source.debrisList[d].emission.burstType, source.debrisList[d].emission.burstAmount);
                }
            }

            // Copy dust
            if (source.HasDust == true)
            {
                for (int d = 0; d < source.dustList.Count; d++)
                {
                    // Set max amount
                    int maxAmount = targets.Count;
                    if (source.dustList[d].limitations.percentage < 100)
                    {
                        maxAmount = targets.Count * source.dustList[d].limitations.percentage / 100;
                    }

                    for (int i = 0; i < targets.Count; i++)
                    {
                        // Max amount reached
                        if (maxAmount <= 0)
                        {
                            break;
                        }

                        // Filter by percentage
                        if (Random.Range(0, 100) > source.dustList[d].limitations.percentage)
                        {
                            continue;
                        }

                        // Copy
                        RayfireDust targetDust = targets[i].gameObject.AddComponent <RayfireDust>();
                        targetDust.CopyFrom(source.dustList[d]);
                        targetDust.rigid = targets[i];

                        // Collect debris for Rigid
                        if (targets[i].dustList == null)
                        {
                            targets[i].dustList = new List <RayfireDust>();
                        }
                        targets[i].dustList.Add(targetDust);

                        // Collect debris for parent debris
                        if (source.dustList[d].children == null)
                        {
                            source.dustList[d].children = new List <RayfireDust>();
                        }
                        source.dustList[d].children.Add(targetDust);

                        maxAmount--;
                    }

                    // Get amount list
                    SetDustFinalAmount(source.dustList[d].children, source.dustList[d].emission.burstType, source.dustList[d].emission.burstAmount);
                }
            }
        }