Beispiel #1
0
    public void Ping(Vector3Int position)
    {
        var current = generators.Get(MathHelper.Anchor(position.x, position.y, position.z, REGION));

        chunkBlocks.Ping(position, radius, v =>
        {
            var coord = MathHelper.Anchor(v.x, v.y, v.z, REGION);
            if (!generators.TryGet(ref coord, out ChunkGenerator biome))
            {
                biome = current.Transitions[(int)(Random.value * (current.Transitions.Length))];
                generators.Set(coord, biome);
            }

            var chunk  = new ChunkBlocks(v.x, v.y, v.z, SIZE);
            var result = biome.Generate(v, chunk, SIZE);
            factory.Enqueue(result);
            return(result);
        });
Beispiel #2
0
    private void Start()
    {
        radius      = new Vector3Int(16, 3, 16);
        chunks      = new Space3D <Chunk>();
        generators  = new Space3D <ChunkGenerator>();
        chunkBlocks = new Space3D <ChunkBlocks>();
        factory     = new ChunkFactory();

        var chunk = player.Chunk();

        generators.Set(MathHelper.Anchor(chunk.x, chunk.y, chunk.z, REGION), start);

        Ping(player.Chunk());
        for (int i = 0; i < STARTUP_PROCESSED_CHUNKS; i++)
        {
            factory.Process(player.Chunk());
        }
    }
Beispiel #3
0
    public Vector3Int Chunk()
    {
        var position = transform.position;

        return(MathHelper.Anchor((int)position.x, (int)position.y, (int)position.z, World.SIZE));
    }