Beispiel #1
0
 public void init()
 {
     Loom.AddAsyncThread(WorldThreadName);
     Loom.AddAsyncThread(setBlockThreadName);
     Loom.AddAsyncThread(GrassThreadName);
     textureAtlas = new Texture2D(0, 0);
     AtlasUvs     = textureAtlas.PackTextures(AllCubeTextures, 1);
     AddBlockType(BaseType.air, "Air", new int[] { -1, -1, -1, -1, -1, -1 }, null);
     AddBlockType(BaseType.solid, "Grass", new int[] { 0, 0, 0, 0, 0, 0 }, null);
     AddBlockType(BaseType.solid, "Rock", new int[] { 1, 1, 1, 1, 1, 1 }, null);
     AddBlockType(BaseType.solid, "Dirt", new int[] { 2, 2, 2, 2, 2, 2 }, null);
     AddBlockType(BaseType.solid, "Brick", new int[] { 3, 3, 3, 3, 3, 3 }, null);
     if (VoxelSettings.randomSeed)
     {
         VoxelSettings.seed = UnityEngine.Random.Range(int.MinValue, int.MaxValue);
     }
     else
     {
         VoxelSettings.seed = seed;
     }
     //TestSmooth();
     //SpawnChunksLinear();
     GameManager.Status = "Loading...";
     //Action action = new Action(OnRenderComplete);
     GenerateSpherical(_generateArroundChunk, null);
 }
Beispiel #2
0
 // Use this for initialization
 void Start()
 {
     Loom.AddAsyncThread(WorldThreadName);
     Loom.AddAsyncThread(genThreadName);
     Loom.AddAsyncThread(setBlockThreadName);
     textureAtlas = new Texture2D(0, 0);
     AtlasUvs     = textureAtlas.PackTextures(AllCubeTextures, 10);
     MapTexture   = new Texture2D(0, 0);
     AddBlockType(BaseType.air, "air", new int[] { -1, -1, -1, -1, -1, -1 }, null);
     AddBlockType(BaseType.solid, "Black", new int[] { 0, 0, 0, 0, 0, 0 }, null);
     AddBlockType(BaseType.solid, "White", new int[] { 1, 1, 1, 1, 1, 1 }, null);
 }
Beispiel #3
0
 public void GenerateExplosion(Vector3 postion, int radius)
 {
     System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
     watch.Start();
     Loom.AddAsyncThread("Explosion");
     Loom.QueueAsyncTask("Explosion", () =>
     {
         Dictionary <Vector3Int, List <Chunk.BlockChange> > changes = new Dictionary <Vector3Int, List <Chunk.BlockChange> >();
         Vector3Int voxelPos = VoxelConversions.WorldToVoxel(postion);
         for (int x = voxelPos.x - radius; x <= voxelPos.x + radius; x++)
         {
             for (int y = voxelPos.y - radius; y <= voxelPos.y + radius; y++)
             {
                 for (int z = voxelPos.z - radius; z <= voxelPos.z + radius; z++)
                 {
                     Vector3Int voxel = new Vector3Int(x, y, z);
                     Vector3Int chunk = VoxelConversions.VoxelToChunk(voxel);
                     if (IsInSphere(voxelPos, radius, voxel))
                     {
                         if (!changes.ContainsKey(chunk))
                         {
                             changes.Add(chunk, new List <Chunk.BlockChange>());
                         }
                         changes[chunk].Add(new Chunk.BlockChange(VoxelConversions.GlobalVoxToLocalChunkVoxCoord(chunk, voxel), 0));
                         //ChangeBlock(new Chunk.BlockChange(voxel, 0));
                     }
                 }
             }
         }
         //Debug.Log("Iterated through exploded blocks: " + watch.Elapsed.ToString());
         Loom.QueueOnMainThread(() =>
         {
             foreach (Vector3Int chunkPos in changes.Keys)
             {
                 ChangeBlock(chunkPos, changes[chunkPos].ToArray());
             }
             watch.Stop();
             //Debug.Log("Blocks changes sent to chunk: " + watch.Elapsed.ToString());
         });
     });
 }
 public void init()
 {
     Loom.AddAsyncThread(WorldThreadName);
     Loom.AddAsyncThread(setBlockThreadName);
     Loom.AddAsyncThread(GrassThreadName);
     textureAtlas = new Texture2D(0, 0);
     AtlasUvs     = textureAtlas.PackTextures(AllCubeTextures, 1);
     AddBlockType(BaseType.air, "Air", new int[] { -1, -1, -1, -1, -1, -1 }, null);
     AddBlockType(BaseType.solid, "Grass", new int[] { 0, 0, 0, 0, 0, 0 }, null);
     AddBlockType(BaseType.solid, "Rock", new int[] { 1, 1, 1, 1, 1, 1 }, null);
     AddBlockType(BaseType.solid, "Dirt", new int[] { 2, 2, 2, 2, 2, 2 }, null);
     AddBlockType(BaseType.solid, "Brick", new int[] { 3, 3, 3, 3, 3, 3 }, null);
     if (VoxelSettings.randomSeed)
     {
         VoxelSettings.seed = UnityEngine.Random.Range(int.MinValue, int.MaxValue);
     }
     else
     {
         VoxelSettings.seed = seed;
     }
     GameManager.Status = "Loading...";
     GenerateLinearChunks();
 }
Beispiel #5
0
 // Use this for initialization
 public Pathfinder(string threadName)
 {
     this.threadName = threadName;
     Loom.AddAsyncThread(threadName);
 }