the big refactor + extracted data classes from coders/json to data/dynamic
This commit is contained in:
@@ -69,7 +69,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->indices->getBlockDef(vox->id);
|
||||
const Block* def = level->content->getIndices()->getBlockDef(vox->id);
|
||||
if (def->grounded && !chunks->isSolidBlock(x, y-1, z)) {
|
||||
breakBlock(nullptr, def, x, y, z);
|
||||
return;
|
||||
@@ -89,7 +89,7 @@ void BlocksController::randomTick(int tickid, int parts) {
|
||||
// timeutil::ScopeLogTimer timer(5000+tickid);
|
||||
const int w = chunks->w;
|
||||
const int d = chunks->d;
|
||||
auto indices = level->content->indices;
|
||||
auto indices = level->content->getIndices();
|
||||
for (uint z = padding; z < d-padding; z++){
|
||||
for (uint x = padding; x < w-padding; x++){
|
||||
int index = z * w + x;
|
||||
|
||||
@@ -204,7 +204,7 @@ void PlayerController::updateControls(float delta){
|
||||
}
|
||||
|
||||
void PlayerController::updateInteraction(){
|
||||
auto contentIds = level->content->indices;
|
||||
auto indices = level->content->getIndices();
|
||||
Chunks* chunks = level->chunks;
|
||||
Player* player = level->player;
|
||||
Lighting* lighting = level->lighting;
|
||||
@@ -239,8 +239,8 @@ void PlayerController::updateInteraction(){
|
||||
int z = iend.z;
|
||||
uint8_t states = 0;
|
||||
|
||||
ItemDef* item = contentIds->getItemDef(player->getChosenItem());
|
||||
Block* def = contentIds->getBlockDef(item->rt.placingBlock);
|
||||
ItemDef* item = indices->getItemDef(player->getChosenItem());
|
||||
Block* def = indices->getBlockDef(item->rt.placingBlock);
|
||||
if (def && def->rotatable){
|
||||
const std::string& name = def->rotations.name;
|
||||
if (name == "pipe") {
|
||||
@@ -270,7 +270,7 @@ void PlayerController::updateInteraction(){
|
||||
}
|
||||
}
|
||||
|
||||
Block* target = contentIds->getBlockDef(vox->id);
|
||||
Block* target = indices->getBlockDef(vox->id);
|
||||
if (lclick && target->breakable){
|
||||
blocksController->breakBlock(player, target, x, y, z);
|
||||
}
|
||||
@@ -292,7 +292,7 @@ void PlayerController::updateInteraction(){
|
||||
}
|
||||
vox = chunks->get(x, y, z);
|
||||
blockid_t chosenBlock = def->rt.id;
|
||||
if (vox && (target = contentIds->getBlockDef(vox->id))->replaceable) {
|
||||
if (vox && (target = indices->getBlockDef(vox->id))->replaceable) {
|
||||
if (!level->physics->isBlockInside(x,y,z, player->hitbox.get())
|
||||
|| !def->obstacle){
|
||||
if (def->grounded && !chunks->isSolidBlock(x, y-1, z)) {
|
||||
@@ -310,7 +310,7 @@ void PlayerController::updateInteraction(){
|
||||
}
|
||||
}
|
||||
if (Events::jactive(BIND_PLAYER_PICK)){
|
||||
Block* block = contentIds->getBlockDef(chunks->get(x,y,z)->id);
|
||||
Block* block = indices->getBlockDef(chunks->get(x,y,z)->id);
|
||||
player->setChosenItem(block->rt.pickingItem);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -107,7 +107,8 @@ static const luaL_Reg playerlib [] = {
|
||||
/* == blocks-related functions == */
|
||||
static int l_block_name(lua_State* L) {
|
||||
int id = lua_tointeger(L, 1);
|
||||
lua_pushstring(L, scripting::content->indices->getBlockDef(id)->name.c_str());
|
||||
auto def = scripting::content->getIndices()->getBlockDef(id);
|
||||
lua_pushstring(L, def->name.c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -121,7 +122,7 @@ static int l_is_solid_at(lua_State* L) {
|
||||
}
|
||||
|
||||
static int l_blocks_count(lua_State* L) {
|
||||
lua_pushinteger(L, scripting::content->indices->countBlockDefs());
|
||||
lua_pushinteger(L, scripting::content->getIndices()->countBlockDefs());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -163,7 +164,7 @@ static int l_get_block_x(lua_State* L) {
|
||||
if (vox == nullptr) {
|
||||
return lua_pushivec3(L, 1, 0, 0);
|
||||
}
|
||||
const Block* def = scripting::level->content->indices->getBlockDef(vox->id);
|
||||
auto def = scripting::level->content->getIndices()->getBlockDef(vox->id);
|
||||
if (!def->rotatable) {
|
||||
return lua_pushivec3(L, 1, 0, 0);
|
||||
} else {
|
||||
@@ -180,7 +181,7 @@ static int l_get_block_y(lua_State* L) {
|
||||
if (vox == nullptr) {
|
||||
return lua_pushivec3(L, 0, 1, 0);
|
||||
}
|
||||
const Block* def = scripting::level->content->indices->getBlockDef(vox->id);
|
||||
auto def = scripting::level->content->getIndices()->getBlockDef(vox->id);
|
||||
if (!def->rotatable) {
|
||||
return lua_pushivec3(L, 0, 1, 0);
|
||||
} else {
|
||||
@@ -197,7 +198,7 @@ static int l_get_block_z(lua_State* L) {
|
||||
if (vox == nullptr) {
|
||||
return lua_pushivec3(L, 0, 0, 1);
|
||||
}
|
||||
const Block* def = scripting::level->content->indices->getBlockDef(vox->id);
|
||||
auto def = scripting::level->content->getIndices()->getBlockDef(vox->id);
|
||||
if (!def->rotatable) {
|
||||
return lua_pushivec3(L, 0, 0, 1);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user