Ejemplo n.º 1
0
    public WorldChunk RequestChunk(int sceneId, System.Action <WorldChunk> callback = null)
    {
        // Try get chunk size
        AtlasWorld world = WorldAtlas.current.GetWorld(sceneId); //this naming convention is awful

        if (world != null)
        {
            int        width = world.width, height = world.height;
            int        chunk    = FindChunk(width, height);
            int        chunkX   = chunk % numColumns;
            int        chunkY   = chunk / numColumns;
            WorldChunk chunkObj = new WorldChunk()
            {
                x            = chunkX,
                y            = chunkY,
                width        = width,
                height       = height,
                chunkSceneId = sceneId,
                world        = world
            };

            if (!chunkRefs.ContainsKey(sceneId))
            {
                chunkRefs[sceneId] = new List <WorldChunk>()
                {
                    chunkObj
                };
            }
            else
            {
                chunkRefs[sceneId].Add(chunkObj);
            }

            for (int w = 0; w < width; w++)
            {
                for (int h = 0; h < height; h++)
                {
                    allChunks[w + chunkX][h + chunkY] = chunkObj;
                }
            }

            // callback(chunkObj);
            waitingChunk      = chunkObj;
            chunkObj.callback = callback;

            ServerSceneLoader.LoadScene(sceneId);

            return(chunkObj);
        }
        else
        {
            Debug.LogError("Scene " + sceneId + " has no attached AtlasWorld");
            return(null);
        }
    }
Ejemplo n.º 2
0
 public void Awake()
 {
     i = this;
 }