I had an idea for a cube world (i'm writing in C#) that would make creating new types of cubes simple and dynamic. Here is how I imagine it:
1.Text file stores everything including block name, texture path, 'hp',light output, and simple scripting for events. Here's an example:
BlockName=<block name>
Texture=<Texture Image Path>
SeeThrough=<True/False>
Element=<Normal/Fire/Ice/Water/Light/Dark/Earth/Quintessence/Void>
State=<Solid/Liquid/Gas>
Inventory=<slots for inventory>
MaxHP=<0 = Infinite>
Armor=<armor level>
EnergyIn=<amount of energy required>
EnergyInDirection=<[Top/Bottom/Front/Back/Left/Right/All]
EnergyStorage=<amount of energy that can be stored>
EnergyOut=<amount of energy given>
EnergyOutDirection=<[Top/Bottom/Front/Back/Left/Right/All]
LightIntensity=<level of light output>
LightDirection=[Top/Bottom/Front/Back/Left/Right/All]
[Events]
onTouch{
Damage.Give(10);
}
onClick{
}
onBreak{
}
onTimer(Time-in-ms){
}
switchOn{
}
switchOff{
}
An internal class would read all valid block files from the folder and create a list of block types, internally assigning ID numbers for each type of block. The specific world would store a dictionary of ID values and block names so that no matter how the block files are read, the saved world will always attribute the same ID number to the same block.
A look-ahead system in the CubeCaching service would identify all block types in existing chunks and in cached chunks and store only those cubes in memory. When a new chunk enters the cache, it will run through the types of blocks in its structure and the world class would then push all chunk blocktype amounts to the cache, where it would determine if a new type of block needed to be cached or not. Likewise, at that point the cubecache would also determine if all currently stored blocktypes still exist, and erase from memory any that no longer exist.
My goal is to chew as little memory as possible on block information and only make available the information that is necessary.
Here's my question: am I worrying about memory use too much? Is step 3 a good idea, or should I go ahead and just load and store all block types found without worrying about its memory use?
To clarify, i'm trying to figure out if it makes more sense to either load all block information and store it in a block-type list, or if I should include logic to only load the block information that exists?
Also to be clear: I am not storing all of this information for every single block. The information is only stored for the block TYPE, and would then be referenced for action based on an integer array in the chunk.
