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

Arbitrary data attached to tile #143

Open
thorlucas opened this issue Apr 5, 2021 · 4 comments
Open

Arbitrary data attached to tile #143

thorlucas opened this issue Apr 5, 2021 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@thorlucas
Copy link

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

In games, tiles often need to store extra data. For example, in Minecraft, blocks have block states and block entity data.

Describe the solution would you like?

I would like Tilemap and Tile to be generic over T, allowing us to attach additional data T to each Tile. This could be something like this:

struct Tile<T> where T: ... {
    ...
    data: T,
}

Describe the alternative(s) you've considered?

While this could be stored separately, it would require implementing an additional system that functions pretty much identically to the existing Tilemap for spawning / despawning / etc.

@thorlucas thorlucas added the enhancement New feature or request label Apr 5, 2021
@joshuajbouw
Copy link
Owner

I had thought about doing this. I know it has been requested before. I was initially worried about arbitrary data only being useful for few. There may be a better solution to this with having a seperate database of this data.

@thorlucas
Copy link
Author

I had thought about doing this. I know it has been requested before. I was initially worried about arbitrary data only being useful for few. There may be a better solution to this with having a seperate database of this data.

Perhaps some Tilemap component with a sparse representation? This could be similar to a mirror of the original tilemap but with all sparse layers. I'm not sure how tiles are stored internally, but I assume it could be stored similar to the sparse tilemap layers.

fn my_sys(mut data: Query<&mut TileData>) {
    ...
}

@joshuajbouw
Copy link
Owner

Yeah, sort of like data layers that are entirely optional and modular, that would be better then there is less null space if someone chooses not to use it.

@joshuajbouw joshuajbouw added good first issue Good for newcomers help wanted Extra attention is needed labels Apr 8, 2021
@thorlucas
Copy link
Author

I've added some discussion about solutions to this on #151.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants