-
I've made a procedure that serializes all active entities and components... but I don't know how to do the reverse. The problem I'm having is adding the components to entities properly. My first thought once I obtained each deserialized component was to call entity.add, but it turns out that it interprets the added component as "Any" instead of its actual type. I deduced that in order for that to work it would probably need to know the type of component it's adding a compile time, but I don't feel like writing a huge switch statement for each component type or a macro to auto-generate it. I am willing to use reflection though. So far the best idea I've thought of is obtaining the correct ComponentStorage class specialization based off the type string but I haven't figured out how to do that. Is there a way to achieve deserialization? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I have figured out how to obtain the correct ComponentStorage class by iterating through the private |
Beta Was this translation helpful? Give feedback.
-
Good timing! As it happens, I've been trying to improve how Echoes works without macros, so I was happy to add 3cc08da. If you run into any other hiccups, please mention them. Currently, I'm considering how to implement |
Beta Was this translation helpful? Give feedback.
I have figured out how to obtain the correct ComponentStorage class by iterating through the private
Echoes.componentStorage
field (using the@:access
metadata). But it would be nice if there was a way to do this through the public interface.