Пример #1
0
    private void LoadInSingleChunk(ChunkData data)
    {
        Debug.BeginDeepProfile("chunk_load");
        //Initiate chunk
        Vec2i chunk = new Vec2i(data.X, data.Z);

        if (LoadedChunks.ContainsKey(chunk))
        {
            return;
        }
        GameObject chunkObject = Instantiate(ResourceManager.ChunkPrefab);

        chunkObject.transform.parent = transform;
        chunkObject.name             = "Chunk " + chunk;

        //LoadedChunk loadedChunk = chunkObject.AddComponent<LoadedChunk>();
        LoadedChunk loadedChunk = chunkObject.GetComponent <LoadedChunk>();

        ChunkData[] neigh = { GetChunk(chunk.x, chunk.z + 1), GetChunk(chunk.x + 1, chunk.z + 1), GetChunk(chunk.x + 1, chunk.z) };

        //ChunkData[] neigh = { null, null, null };


        loadedChunk.SetChunkData(data, neigh);

        LoadedChunks.Add(chunk, loadedChunk);

        GameManager.EntityManager.LoadChunk(World.ChunkBases[chunk.x, chunk.z], chunk);
        Debug.EndDeepProfile("chunk_load");
    }
Пример #2
0
    private void LoadChunk(ChunkData c)
    {
        GameObject chunkObject = new GameObject(); //We create a new empty gameobject for the chunk

        chunkObject.transform.parent = transform;
        chunkObject.name             = "Chunk " + c;

        LoadedChunk loadedChunk = chunkObject.AddComponent <LoadedChunk>();

        loadedChunk.SetChunkData(c, new ChunkData[] { null, null, null });
    }
Пример #3
0
    public void LoadSubworldChunks(Subworld sub)
    {
        UnloadAllChunks();
        InSubworld = true;
        foreach (ChunkData c in sub.SubworldChunks)
        {
            int        x           = c.X;
            int        z           = c.Z;
            GameObject chunkObject = Instantiate(ResourceManager.ChunkPrefab);;  //We create a new empty gameobject for the chunk
            chunkObject.transform.parent = transform;
            chunkObject.name             = "sw" + sub.SubworldID + "_" + c.X + "_" + c.Z;
            LoadedChunk loadedChunk = chunkObject.AddComponent <LoadedChunk>();

            ChunkData[] neigh = { sub.GetChunkSafe(x, z + 1), sub.GetChunkSafe(x + 1, z + 1), sub.GetChunkSafe(x + 1, z) };

            loadedChunk.SetChunkData(c, neigh);
            SubworldChunks.Add(new Vec2i(x, z), loadedChunk);
        }
    }