Skip to content
This repository has been archived by the owner on May 7, 2022. It is now read-only.

Quality of Life Improvements for Procedural Tilemap Generation #171

Open
huhlig opened this issue Aug 8, 2021 · 0 comments
Open

Quality of Life Improvements for Procedural Tilemap Generation #171

huhlig opened this issue Aug 8, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@huhlig
Copy link

huhlig commented Aug 8, 2021

What problem does this solve or what need does it fill?

The following list of features is designed to address some Quality of Life challenges the current implementation has for dealing with procedurally generated tilemaps of potentially enormous size.

  1. TilemapChunkEvent Spawn & Despawn currently only include the point which triggered a spawn/despawn and not the extents of the chunk or wether or not the chunk was loaded back into the tilemap from cache.
  2. Tilemap should optionally call a populate method on a trait object or call a function pointer with a provided user data reference such that when a new chunk not in cache is needed, the method can be called such that the chunk can be populated.

Describe the solution would you like?

  1. Adding some metadata to the TilemapChunkEvent.
pub enum TilemapChunkEvent {
    Spawned {
        point: Point2,
        extents: (Point2, Point2),
        cached: bool,
    },
    Modified {
        point: Point2,
        extents: (Point2, Point2),
    },
    Despawned {
        point: Point2,
        extents: (Point2, Point2),
    },
    AddLayer {
        layer_kind: LayerKind,
        sprite_layer: usize,
    },
    RemoveLayer {
        sprite_layer: usize,
    },
}```

2. Add an Option<TilemapPopulator> parameter to TilemapBuilder::auto_spawn() 

```rust
pub trait TilemapPopulator {
    fn populate(tilemap: &mut Tilemap, extents: (Point2, Point2))
}

pub fn auto_spawn(self, width: u32, height: u32, populator: TilemapPopulator) -> Self {/* ... */}

Describe the alternative(s) you've considered?

Using the existing event system with a is_none check for a point in the spawned chunk.

@huhlig huhlig added the enhancement New feature or request label Aug 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant