Zay-ES Entity System questions

So, using pspeed’s MonkeyTrap example as reference material, I’ve created some basic systems with Zay-ES.

However, now I come to the point of my project that is tough to implement - user-based custom JSON files.

I have the components I want, and now I need to be able to store them in some manner that makes sense.

to that end, the specific behavior I want is something like this:

  1. create JSON file with component data (eg HealthComponent with 100 starting / max health, 0.4 regeneration speed)
  2. Put JSON file into folder that it applies to
  3. Program ought to go into folder, take the file, and create an EntityPrefab using the file’s data.
  4. This EntityPrefab can now create as many Entities of that kind as the game will ever need - they’re basically blueprints

That’s all well and good, but the real question here is: how can I store entity data in a manner that befits such a process?

I’m thinking for the EntityPrefab class that there will be a HashMap of relevant data (eg. the “health” key will store a float variable that represents a monster’s base health) but I’m uncertain on how to take an Entity and convert it to the necessary data and vice-versa.

any tips/pointers/requests for more information that you might need on this?

My templates are actually entities as well.

I have a Template component, containing a boolean if it is an entry point. (more later on this)

For example I have a car body entity, beinga template entrypoint
I have stuff like wheels, with a @TemplateFollow annotation And a Template component without entrypoint

Now I have a Templatefactory (System)
I can tell it to instanciate a Entity wich is a template with entrypoint.

It then scans for all entitys wich are templates and reference it (eg the wheels) This is done via reflection and the annotation, (eg searches for all ID’s wheels reference)
creates a new Entity for every found one. (could be cahed so scanning onl occurs once)
-> applies all components, and adds an addition FromTemplate(with uuid to templated entity).

Benefit I have all clabject logic inside the Entity system []
(btw the mentioned professor is at my university so I grabed some ideas in his courses for this)

Benefit 2 I basically have a LML modeling compatible system (with all benefits) this boils mostly down to this:
-> instances have acces to template information, eg a player wich is injured might have reduced maxhealth in health component, but can acces the template when it is cured to get the original maxhealth.
-> I can have layered templates eg multiple inhreitances and depth, instead of a simple template -> instance, since instances can also be Templates.
-> I could update instances, when changing the template, eg i define now that cars have 5 instead of 4 wheels.
I can easily find all cars based on that template due to their link, and redefine them.

Note that I use a own ES, but I think this probably works in ZayEs as well.

Yep, you could do similar in Zay-ES… and I do that sort of thing for more complicated stuff. It wasn’t really necessary for MonkeyTrap.