TheBoneJarmer / TiledCS

TiledCS is a dotnet library for loading Tiled tilesets and maps
MIT License
139 stars 51 forks source link

Feature Request: Template Support #89

Closed TheBigPrince closed 2 years ago

TheBigPrince commented 2 years ago

I'm fairly new to using TiledCS and Tiled. Currently using it with Monogame and it has saved me a tonne of work so thanks for that!

If it's not already on the agenda, I would love to see support for Tiled Templates. Using templates can save a bunch a time in Tiled so it would be a very welcome addition.

Currently when I cycle through objects in a layer, if that object was created from a tiled template, all values other than id and position are null.

image

I think it would be useful if the data from the template was populated into the object and then overriden if the data was changed on the object instance itself.

For example the properties of template 'PlayerSpawn.tx': image

and the properties of the object instance created from the template: image

I would hope to get an object that had the all the template data and the changed object data, so in the case above:

ID: 19 Name: Player Spawn Instanced X: 512.00 Y: 800.00

TheBigPrince commented 2 years ago

and I just realised that you can select the "Detach Templates" option under Preferences/Export Options in Tiled, then re-export your map to bypass this issue completely.

image

Might be worth adding that to the Readme so people new to Tiled & TiledCS (like me) don't stumble into this issue.

Closing this because this option is fine for me, and again thank you for your work on this!

TheBoneJarmer commented 2 years ago

Hey @TheBigPrince

At this moment there is no template support and to be fair it was not on the agenda either. However! Tiled happens to come with new features over time and this was one that did not existed at the time I started with TiledCS. And truth to be told, I never used them before so it would have to dive a bit deeper in the matter.

That said, it is nice to know it can be bypassed. And so far templates only seemed interesting for well, within the Tiled editor itself. Not so much for exporting. I personally also think that would complicate things. Which is why I am fairly certain Björn added such export option. So I think I will update the README for now and decide later about supporting this feature or not.

In any case, thanks for sharing those screenshots and info! Because of your clear explanation it is most likely I will simply link this issue in the README rather than explaining it all by myself.

With kind regards, TheBoneJarmer