Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Tiled crate and related example to 0.11.0 #425

Merged
merged 1 commit into from
May 13, 2023

Conversation

Bushstar
Copy link
Contributor

@Bushstar Bushstar commented May 6, 2023

  • Updated the Tiled crate to 0.11.0.
  • Creates BytesResourceReader and implemented the ResourceReader trait for the new tiled::Loader behaviour.
  • Renames TileLayer to Tiles.

@rparrett
Copy link
Collaborator

rparrett commented May 6, 2023

There's another (abandoned?) implementation here: #405 but I prefer yours because of the limited scope and error handling.

The other PR goes through the effort of bypassing Tiled's cache with a NoopResourceCache which I suspect is the right thing to do but I haven't looked closely at the issue. Tilemaps can be pretty large though and I would guess that not holding them in memory in more places than we have to would be worthwhile.

@Bushstar
Copy link
Contributor Author

Bushstar commented May 6, 2023

Note that the the cache is not a new addition to Loader and defaulted to DefaultResourceCache before, this PR does not affect cache behaviour. You can review the changes to Tiled here where a Reader was added to Loader in the link below. I'd be inclined to leave this as is and leave users to explicitly change this behaviour if required.

mapeditor/rs-tiled@e176b4b

@rparrett
Copy link
Collaborator

rparrett commented May 6, 2023

Makes sense to me.

@Bushstar
Copy link
Contributor Author

Bushstar commented May 7, 2023

When and if this PR gets merged I'd like to create a new PR based on the changes in this one to support TMX maps with TSX tilesets. The changes are shown in the commit below.

Bushstar@ef9d876

The problem with Bevy and TSX tile maps seems to be that when rs-tiled tries to load the TMX map and comes across the TSX file it will try to read it from the bytes again and will then error as those bytes are the same TMX file just read.

In the above commit I've updated the code to check the Path, if it includes a .tsx extension then it should try and load from disk using the same path provided by Bevy via the LoadContext argument.

Spoke to the rs-tiled developer about this and it sounds like at some point it will be updated to allow loading dependencies separately from their parents, but until then we need something like the above commit. That conversation can be found here where I initially asked if the error I encountered was a bug.

mapeditor/rs-tiled#265 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants