Mob spawns can be broken down into a list of conditions that need to be met, plus actions to actually run the spawn. This seems like a good use of Geary's existing system for actions and conditions. Additionally, spawn regions are just bundles of information which just screams entities!
The current spawn system is divided into the following steps:
Gather information on mob caps
Combine players into player groups, calculate max mob caps based on how many groups there are.
Find a random chunk around player groups that is no closer than x chunks from any player.
Find a random vertical line of blocks within the chunk.
Subdivide it into gaps and pick a gap with weighted random favouring larger gaps.
For this gap, find all possible mob spawns defined in the WorldGuard region.
Run a list of checks based on the deserialized spawn objects.
Make a weighted random choice from all the possible spawns based on their priority.
Attempt to spawn the entities as defined by this spawn.
New system outline
Gather global information and package into components (ex mob type caps). Add these to one entity.
Same from finding player groups until finding a list of all possible mob spawns defined in WorldGuard region.
Once a specific spawn region is picked, gather information specific to this region, for instance light level or world time.
Another Geary entity gets created which holds this data, as well as marking the global information as its prefab so the components are merged.
Potential problems include that we would like different information based on whether entities would like to spawn on ground or air. Could either evaluate several objects based on type and filter from there or pick which type of spawn we want ahead of time and only attempt spawns of that type.
Pick a random spawn from the list and check if its conditions are met, if they are not met, remove it from the list and pick another until all conditions are met.
Conditions are now GearyConditions which will be run against the spawn region entity.
Run a list of GearyActions against the spawn region entity. Spawning multiple entities can be described by nested actions.
Mob spawns can be broken down into a list of conditions that need to be met, plus actions to actually run the spawn. This seems like a good use of Geary's existing system for actions and conditions. Additionally, spawn regions are just bundles of information which just screams entities!
The current spawn system is divided into the following steps:
New system outline
GearyCondition
s which will be run against the spawn region entity.GearyAction
s against the spawn region entity. Spawning multiple entities can be described by nested actions.