public VoxelChunksObjectExplosionCore(VoxelBaseExplosion target) : base(target)
        {
            explosionObject = target as VoxelChunksObjectExplosion;

            voxelBase     = voxelObject = target.GetComponent <VoxelChunksObject>();
            voxelBaseCore = voxelObjectCore = new VoxelChunksObjectCore(voxelObject);

            voxelBaseCore.Initialize();

            if (voxelObject != null)
            {
                var chunkObjects = voxelObject.chunks;
                explosionObject.chunksExplosion = new VoxelChunksObjectChunkExplosion[chunkObjects.Length];
                for (int i = 0; i < chunkObjects.Length; i++)
                {
                    if (chunkObjects[i] == null)
                    {
                        explosionObject.chunksExplosion[i] = null;
                        continue;
                    }
                    explosionObject.chunksExplosion[i] = chunkObjects[i].gameObject.GetComponent <VoxelChunksObjectChunkExplosion>();
                    if (explosionObject.chunksExplosion[i] == null)
                    {
                        explosionObject.chunksExplosion[i] = Undo.AddComponent <VoxelChunksObjectChunkExplosion>(chunkObjects[i].gameObject);
                    }
                }
            }
        }
Esempio n. 2
0
        public VoxelObjectExplosionCore(VoxelBaseExplosion target) : base(target)
        {
            explosionObject = target as VoxelObjectExplosion;

            voxelBase     = voxelObject = target.GetComponent <VoxelObject>();
            voxelBaseCore = voxelObjectCore = new VoxelObjectCore(voxelObject);

            voxelBaseCore.Initialize();
        }
        public static void StaticForceGenerate(VoxelBaseExplosion voxelBase)
        {
            VoxelBaseExplosionCore voxelCore = null;

            if (voxelBase is VoxelObjectExplosion)
            {
                voxelCore = new VoxelObjectExplosionCore(voxelBase);
            }
            else if (voxelBase is VoxelChunksObjectExplosion)
            {
                voxelCore = new VoxelChunksObjectExplosionCore(voxelBase);
            }
            else if (voxelBase is VoxelFrameAnimationObjectExplosion)
            {
                voxelCore = new VoxelFrameAnimationObjectExplosionCore(voxelBase);
            }
            else if (voxelBase is VoxelSkinnedAnimationObjectExplosion)
            {
                voxelCore = new VoxelSkinnedAnimationObjectExplosionCore(voxelBase);
            }
            else
            {
                Assert.IsTrue(false);
            }
            if (voxelCore == null)
            {
                return;
            }

            voxelCore.ResetAllAssets();
            voxelCore.Generate();

            #region Extra
            if (voxelCore is VoxelSkinnedAnimationObjectExplosionCore)
            {
                var voxelCoreEx = voxelCore as VoxelSkinnedAnimationObjectExplosionCore;
                if (voxelCoreEx.explosionObject.meshes != null &&
                    voxelCoreEx.explosionObject.meshes.Count > 0 &&
                    voxelCoreEx.explosionObject.meshes[0].bakeMesh != null)
                {
                    voxelCoreEx.Bake();
                }
            }
            #endregion
        }
 public VoxelBaseExplosionCore(VoxelBaseExplosion target)
 {
     explosionBase = target;
     voxelBase     = target.GetComponent <VoxelBase>();
 }