-
|
I'm new in game programming, and sorry for my poor English:(, In my conprehension, if we want to create an entity whose component is specified by a file, the only way we can do is, for example if (json_file contains key:vel) if(contains key:pos), checks every struct we had defined. then use registry.emplace.... , could it be better or not? Please give me some advice or a place that can find the answer , your advice mean a lot to me! I can't find the answer in detailed:(
-prase(for example) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
You can use a reflection system (i.e. meta in EnTT) and load objects from JSON directly, without many |
Beta Was this translation helpful? Give feedback.
You can use a reflection system (i.e. meta in EnTT) and load objects from JSON directly, without many
ifs or the like.You use the item name in the JSON to construct the right component by means of its meta type. Then you iterate the members for that object and pass the values to the meta members.
It requires some glue code, but it's much better, flexible and transparent than what you have right now. 👍