-
Notifications
You must be signed in to change notification settings - Fork 19
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
Prefab style feature #34
Conversation
This update allows the user to have a pre-fab style workflow similar to Unity. Simply Call GetEntityDefinition<T> From the LDtkFile class to return an Entity instance with the default data set in the LDtk editor.
Hi thanks for the PR it probably makes more sense to generate the default class instance in the code generator project as it seems to be pretty static also the ldtkfile and full version are auto generated so if you make a change to it make sure its generated from the schema and not manually modified but if you go the generator route no changes should be necessary. |
Correct, I am currently using code generation. However if any of the other variables are altered then you wouldn't know which one is the "default one". This would just add an easier way to get the entity with default values. |
Your pr does not have any changes to LDtk.JsonSchema thats the project that generated the LDtkFile and LDtkFileFull this pr does not contain any changes to the code generation that I can see. https://github.com/IrishBruse/LDtkMonogame/blob/main/LDtk.Example/LDtkTypes/World/Entities/Enemy.cs
this way if you want to get it you just do Enemy.Default for the default instance if you wish to clone the default instance using something like ICloneable should work this way there is no need for heavy runtime reflection |
This is a great idea. Let me cook something up so it's created on the CodeGen side rather than using reflection at runtime. |
Here is an updated version with your idea. I've tested it out with my current workflow and have no issues. Not every type of variable can be initialized in LDtk. For example Arrays can only be assigned when an Entity instance is created in a level. So when pulling from entity definitions arrays will always be null. I don't necessarily foresee issues, but more testing will need to be done |
Great job thanks 😃 |
Release to test in 1.6.0-beta |
This update allows the user to have a pre-fab style workflow.
Simply Call GetEntityDefinition From the LDtkFile class to return an Entity instance with the default data that is set in the LDtk editor.