Exemple #1
0
    public Chunk(ChunkSaveData data)
    {
        Id = data.Id;
        if (current_id <= data.Id)
        {
            current_id = data.Id + 1;
        }
        X            = data.X;
        Z            = data.Z;
        Blocks       = new List <Block>();
        Block_Groups = new List <BlockGroup>();
        GameObject   = new GameObject(string.Format("Chunk_({0},{1})#{2}", X, Z, Id));
        GameObject.transform.parent = Map.Instance.Block_Container.transform;
        GameObject.SetActive(true);
        Average_Elevation = 0;

        foreach (BlockSaveData block_data in data.Blocks)
        {
            Block block = Block.Load(block_data, GameObject);
            block.Chunk = this;
            Blocks.Add(block);
        }

        foreach (BlockGroupSaveData group_data in data.Block_Groups)
        {
            BlockGroup group = BlockGroup.Load(group_data, this);
            Block_Groups.Add(group);
        }
    }