This document is just scratch notes for a plugin for Bevy to manage a block-type world like in Minecraft.
This plugin, to be useful, must provide a number of things.
-
Ability to create, damage, and destroy blocks in an aligned grid.
These worlds are made by 1 meter cubes which have hardness, take damage, and are destroyed. Functionally, blocks must be placed in an aligned grid.
-
Automatic management of bloxel grid.
Massive, massive worlds can be built of cubes; but that's a lot of entities, a lot of objects to render, a lot of faces. It consumes tons of resources. Games like Minecraft and Dragon Quest Builders chunk the world: collections of blocks are internally merged into single objects, and cut out of those single objects when damaged or destroyed. To the player, this appears as if the blocks are all separate; to the programmer, this is a complex nightmare requiring the management of the world from two different models: one of 1 meter cubes and one of larger structures automatically created by analyzing the placement of 1 meter cubes. The programmer should not need to know about these background reduction tricks.
-
Ability to add objects that move and aren't on the grid.
Objects may be placed and pinned to a certain grid location, but may not be aligned to or on the grid. For example, NPCs and player characters walk around freely; debris fall; water may flow; and blocks or other objects may be animated to act as elevators or other machines. Besides placing a block to align to a grid, the programmer must be able to place an object misaligned to the grid and detect an object's misalignment readily.
-
Object and block damage and destruction.
Objects take damage. There must be a way to easily detect collisions, identify what hit a thing, and decide if it can damage it, how much damage it does, and if the thing breaks. Further, when the thing breaks, it must trigger consequences. This can include game events, but also just dropping debris for the player to add to their inventory.
Damage dealing can be generic and done by something else, and doesn't need to be tracked in this plugin; however, the damage must be dealt to the correct block, and collisions will happen to large objects acting as single hitboxes but representing multiple entities. The hit position must be detected and used to direct the damage or other interaction to a particular block. This translation should be transparent to the programmer.
-
Water fill detection?
Water has historically been lame in games like Minecraft and Dragon Quest Builders. Water comes as blocks that just pop into existence when nearby blocks have water, and have rules for flow. Dynamic water flow would be more interesting, and requires the ability to detect how full a particular cubic space is with a material such as water or grain or whatever it is that piles up. Whether water spills over or overflows can be based on these kinds of rules.
There are possibly better ways to do this.
-
Serialization and deserialization.
For saving and loading the world.