refactor Content

This commit is contained in:
MihailRis
2024-06-25 22:37:53 +03:00
parent f3c5afa1ab
commit ee9f1639e9
25 changed files with 180 additions and 209 deletions
+5 -5
View File
@@ -83,7 +83,7 @@ void BlocksController::updateBlock(int x, int y, int z) {
voxel* vox = chunks->get(x, y, z);
if (vox == nullptr)
return;
const Block* def = level->content->getIndices()->getBlockDef(vox->id);
auto def = level->content->getIndices()->blocks.get(vox->id);
if (def->grounded && !chunks->isSolidBlock(x, y-1, z)) {
breakBlock(nullptr, def, x, y, z);
return;
@@ -109,10 +109,10 @@ void BlocksController::onBlocksTick(int tickid, int parts) {
auto content = level->content;
auto indices = content->getIndices();
int tickRate = blocksTickClock.getTickRate();
for (size_t id = 0; id < indices->countBlockDefs(); id++) {
for (size_t id = 0; id < indices->blocks.count(); id++) {
if ((id + tickid) % parts != 0)
continue;
auto def = indices->getBlockDef(id);
auto def = indices->blocks.get(id);
auto interval = def->tickInterval;
if (def->rt.funcsset.onblockstick && tickid / parts % interval == 0) {
scripting::on_blocks_tick(def, tickRate / interval);
@@ -143,7 +143,7 @@ void BlocksController::randomTick(int tickid, int parts) {
int by = random.rand() % segheight + s * segheight;
int bz = random.rand() % CHUNK_D;
const voxel& vox = chunk->voxels[(by * CHUNK_D + bz) * CHUNK_W + bx];
Block* block = indices->getBlockDef(vox.id);
Block* block = indices->blocks.get(vox.id);
if (block->rt.funcsset.randupdate) {
scripting::random_update_block(
block,
@@ -167,7 +167,7 @@ int64_t BlocksController::createBlockInventory(int x, int y, int z) {
auto inv = chunk->getBlockInventory(lx, y, lz);
if (inv == nullptr) {
auto indices = level->content->getIndices();
auto def = indices->getBlockDef(chunk->voxels[vox_index(lx, y, lz)].id);
auto def = indices->blocks.get(chunk->voxels[vox_index(lx, y, lz)].id);
int invsize = def->inventorySize;
if (invsize == 0) {
return 0;