Beispiel #1
0
        public void SetTile(Vector3Int pos, GameObjectTile prefab)
        {
            if (!prefab)
            {
                RemoveTile(pos);
                return;
            }

            var(chunkPos, offset) = ChunkAt(pos);
            var tile = prefab.CreateInstance(chunkPos, offset, pos);

            SetTileInstance(pos, tile);
        }
Beispiel #2
0
        void SetTileInstance(Vector3Int pos, GameObjectTile tile)
        {
            var(chunkPos, offset) = ChunkAt(pos);
            var chunk = GetOrCreateChunk(chunkPos);

            tile.transform.SetParent(transform, false);
            tile.transform.localPosition = pos;
            if (!chunk.SetTile(offset, tile))
            {
                Count++;
                if (Count == 1)
                {
                    Bounds = new BoundsInt(pos, Vector3Int.one);
                }
                else
                {
                    Bounds = Bounds.Encapsulate(pos);
                }
            }
        }