mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-09 13:01:49 +00:00
Merge branch 'main' into animation
This commit is contained in:
commit
49e7f2c631
89 changed files with 1050 additions and 687 deletions
|
|
@ -27,7 +27,7 @@ ChunksController::ChunksController(Level& level)
|
|||
generator(std::make_unique<WorldGenerator>(
|
||||
level.content.generators.require(level.environment.generator),
|
||||
level.content,
|
||||
level.getWorld()->getSeed()
|
||||
level.getWorld().getSeed()
|
||||
)) {}
|
||||
|
||||
ChunksController::~ChunksController() = default;
|
||||
|
|
|
|||
|
|
@ -314,8 +314,8 @@ void EngineController::setLocalPlayer(int64_t player) {
|
|||
localPlayer = player;
|
||||
}
|
||||
|
||||
void EngineController::reopenWorld(World* world) {
|
||||
std::string name = world->wfile->getFolder().name();
|
||||
void EngineController::reopenWorld(World& world) {
|
||||
std::string name = world.wfile->getFolder().name();
|
||||
engine.onWorldClosed();
|
||||
openWorld(name, true);
|
||||
}
|
||||
|
|
@ -384,16 +384,16 @@ void EngineController::reconfigPacks(
|
|||
}
|
||||
} else {
|
||||
auto level = controller->getLevel();
|
||||
auto world = level->getWorld();
|
||||
auto& world = level->getWorld();
|
||||
controller->processBeforeQuit();
|
||||
controller->saveWorld();
|
||||
|
||||
auto names = PacksManager::getNames(world->getPacks());
|
||||
auto names = PacksManager::getNames(world.getPacks());
|
||||
auto& manager = contentControl.scan();
|
||||
reconfig_packs_inside(manager, names, packsToAdd, packsToRemove);
|
||||
|
||||
const auto& settings = engine.getSettings();
|
||||
auto& wfile = *world->wfile;
|
||||
auto& wfile = *world.wfile;
|
||||
if (!settings.debug.generatorTestMode.get()) {
|
||||
wfile.removeIndices(packsToRemove);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,5 +41,5 @@ public:
|
|||
|
||||
void setLocalPlayer(int64_t player);
|
||||
|
||||
void reopenWorld(World* world);
|
||||
void reopenWorld(World& world);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -140,16 +140,16 @@ void LevelController::processBeforeQuit() {
|
|||
}
|
||||
|
||||
void LevelController::saveWorld() {
|
||||
auto world = level->getWorld();
|
||||
if (world->isNameless()) {
|
||||
auto& world = level->getWorld();
|
||||
if (world.isNameless()) {
|
||||
logger.info() << "nameless world will not be saved";
|
||||
return;
|
||||
}
|
||||
logger.info() << "writing world '" << world->getName() << "'";
|
||||
world->wfile->createDirectories();
|
||||
logger.info() << "writing world '" << world.getName() << "'";
|
||||
world.wfile->createDirectories();
|
||||
scripting::on_world_save();
|
||||
level->onSave();
|
||||
level->getWorld()->write(*level);
|
||||
level->getWorld().write(*level);
|
||||
}
|
||||
|
||||
void LevelController::onWorldQuit() {
|
||||
|
|
|
|||
|
|
@ -340,6 +340,19 @@ static int determine_rotation(
|
|||
if (camDir.z > 0.0f) return BLOCK_DIR_SOUTH | verticalBit;
|
||||
if (camDir.z < 0.0f) return BLOCK_DIR_NORTH | verticalBit;
|
||||
}
|
||||
} else if (name == "ladder") {
|
||||
if (norm.x < 0.0f) return BLOCK_DIR_EAST;
|
||||
if (norm.x > 0.0f) return BLOCK_DIR_WEST;
|
||||
if (norm.z > 0.0f) return BLOCK_DIR_NORTH;
|
||||
if (norm.z < 0.0f) return BLOCK_DIR_SOUTH;
|
||||
if (abs(camDir.x) > abs(camDir.z)) {
|
||||
if (camDir.x > 0.0f) return BLOCK_DIR_EAST;
|
||||
if (camDir.x < 0.0f) return BLOCK_DIR_WEST;
|
||||
}
|
||||
if (abs(camDir.x) < abs(camDir.z)) {
|
||||
if (camDir.z > 0.0f) return BLOCK_DIR_SOUTH;
|
||||
if (camDir.z < 0.0f) return BLOCK_DIR_NORTH;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ static int l_get_model(lua::State* L) {
|
|||
auto& rigConfig = *skeleton->config;
|
||||
auto index = index_range_check(*skeleton, lua::tointeger(L, 2));
|
||||
const auto& modelOverride = skeleton->modelOverrides[index];
|
||||
if (!modelOverride.model.expired()) {
|
||||
if (modelOverride.model.expired()) {
|
||||
return lua::pushstring(L, modelOverride.name);
|
||||
}
|
||||
return lua::pushstring(L, rigConfig.getBones()[index]->model.name);
|
||||
|
|
|
|||
|
|
@ -1127,6 +1127,7 @@ static int l_gui_load_document(lua::State* L) {
|
|||
}
|
||||
|
||||
auto env = scripting::create_doc_environment(parentEnv, alias);
|
||||
auto envId = *env;
|
||||
// namespace extension
|
||||
if (lua::istable(L, 4)) {
|
||||
if (lua::get_from(L, "table", "extend")) {
|
||||
|
|
@ -1148,7 +1149,7 @@ static int l_gui_load_document(lua::State* L) {
|
|||
engine->requireAssets().store(std::move(documentPtr), alias);
|
||||
|
||||
scripting::on_ui_open(*document, {args});
|
||||
return 0;
|
||||
return lua::pushenv(L, envId);
|
||||
}
|
||||
|
||||
static int l_set_syntax_styles(lua::State* L) {
|
||||
|
|
|
|||
|
|
@ -149,6 +149,15 @@ static int l_get_second_inventory(lua::State* L) {
|
|||
}
|
||||
}
|
||||
|
||||
static int l_get_exchange_inventory(lua::State* L) {
|
||||
auto inventory = hud->getExchangeInventory();
|
||||
if (inventory == nullptr) {
|
||||
return lua::pushinteger(L, 0);
|
||||
} else {
|
||||
return lua::pushinteger(L, inventory->getId());
|
||||
}
|
||||
}
|
||||
|
||||
static int l_get_player(lua::State* L) {
|
||||
auto player = hud->getPlayer();
|
||||
return lua::pushinteger(L, player->getId());
|
||||
|
|
@ -216,6 +225,7 @@ const luaL_Reg hudlib[] = {
|
|||
{"show_overlay", wrap_hud<l_show_overlay>},
|
||||
{"get_block_inventory", wrap_hud<l_get_block_inventory>},
|
||||
{"get_second_inventory", wrap_hud<l_get_second_inventory>},
|
||||
{"get_exchange_inventory", wrap_hud<l_get_exchange_inventory>},
|
||||
{"close", wrap_hud<l_close>},
|
||||
{"pause", wrap_hud<l_pause>},
|
||||
{"resume", wrap_hud<l_resume>},
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "world/Level.hpp"
|
||||
#include "world/World.hpp"
|
||||
#include "world/Weather.hpp"
|
||||
|
||||
using namespace scripting;
|
||||
|
||||
|
|
@ -9,6 +10,11 @@ static Weather& require_weather() {
|
|||
if (level == nullptr) {
|
||||
throw std::runtime_error("world is not open");
|
||||
}
|
||||
if (renderer == nullptr) {
|
||||
throw std::runtime_error(
|
||||
"world frontend is not initialized yet (wait for on_hud_open event)"
|
||||
);
|
||||
}
|
||||
return renderer->getWeather();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ static Level& require_level() {
|
|||
}
|
||||
|
||||
static WorldInfo& require_world_info() {
|
||||
return require_level().getWorld()->getInfo();
|
||||
return require_level().getWorld().getInfo();
|
||||
}
|
||||
|
||||
static int l_is_open(lua::State* L) {
|
||||
|
|
@ -139,7 +139,7 @@ static int l_get_chunk_data(lua::State* L) {
|
|||
auto voxelData = std::make_unique<ubyte[]>(CHUNK_DATA_LEN);
|
||||
std::vector<ubyte> chunkData;
|
||||
if (chunk == nullptr) {
|
||||
auto& regions = level->getWorld()->wfile->getRegions();
|
||||
auto& regions = level->getWorld().wfile->getRegions();
|
||||
if (!regions.getVoxels(x, z, voxelData.get())) {
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -218,7 +218,7 @@ static int l_save_chunk_data(lua::State* L) {
|
|||
reinterpret_cast<const ubyte*>(buffer.data()),
|
||||
reinterpret_cast<const ubyte*>(buffer.data()) + buffer.size()
|
||||
),
|
||||
level->getWorld()->wfile->getRegions()
|
||||
level->getWorld().wfile->getRegions()
|
||||
);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -264,6 +264,12 @@ static std::unordered_map<std::string, lua_CFunction> methods {
|
|||
{"min", lua::wrap<l_binop_func<util::min>>},
|
||||
{"max", lua::wrap<l_binop_func<util::max>>},
|
||||
{"abs", lua::wrap<l_unaryop_func<util::abs>>},
|
||||
{"floor", lua::wrap<l_unaryop_func<util::floor>>},
|
||||
{"round", lua::wrap<l_unaryop_func<util::round>>},
|
||||
{"ceil", lua::wrap<l_unaryop_func<util::ceil>>},
|
||||
{"sin", lua::wrap<l_unaryop_func<util::sin>>},
|
||||
{"cos", lua::wrap<l_unaryop_func<util::cos>>},
|
||||
{"tan", lua::wrap<l_unaryop_func<util::tan>>},
|
||||
{"resize", lua::wrap<l_resize>},
|
||||
{"crop", lua::wrap<l_crop>},
|
||||
{"at", lua::wrap<l_at>},
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ void scripting::on_world_load(LevelController* controller) {
|
|||
for (auto& pack : content_control->getAllContentPacks()) {
|
||||
lua::emit_event(L, pack.id + ":.worldopen", [](auto L) {
|
||||
return lua::pushboolean(
|
||||
L, !scripting::level->getWorld()->getInfo().isLoaded
|
||||
L, !scripting::level->getWorld().getInfo().isLoaded
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue