[17] Data Driven Entity Updates
01/29/2020, 09:41pm
I've been making improvements to entities, to make them more data-driven. Previously, if you placed an entity in the game world and wanted to customize some property on it, you would have to create a new and unique entity file. Obviously I can't build a whole game like that so I decided it was time to go back and work on this stuff.
Entities can now be given a property bag in the editor, by typing in some basic TOML. Here's an example of a tiny property bag that I gave to one of the new NPC spawners, to lower the default spawn count:
ent_res_name = "arachna-broodling"
max_spawned_ents = 4
What happens is the base entity will be constructed (the NPC spawner), then each component that belongs to that entity will have its fields overridden by any that are specified in the property bag. Not every field is overridable though! Those that are get specified by the developer when they are implementing the OverridableComponent trait for their component.
With that said, it's now trivial to place unique NPC and item spawners around the world. So, we got some new NPCs! It's all pretty rough right now.
shoutout to Cevvin for the giant spider model
Since there are more than one species inhabiting Antorum now, I also added the ability to define a maximum wander distance for an NPC. This way, packs of them wander around where they were placed, instead of wandering off to the far reaches of the world, never to be seen again. In the future, I'm also planning on making it possible to specify a "home tile type" for NPCs, which they would use as a guide for terrain to stay on when wandering. This would be useful for keeping NPCs like crabs localized to beaches, or even getting friendly NPCs to stick to paths and roads.
As much as I want to be writing more about the game and less about the editor, it's a necessary stage of development that I have to finish up. I'm sure I will continue to add features in the future if the game grows, but I am close to having everything needed to build the initial version of the world. For the next dev log, I have an important feature cooking up...