@@ -41,7 +41,7 @@ CameraControl::CameraControl(
|
||||
const std::shared_ptr<Player>& player, const CameraSettings& settings
|
||||
)
|
||||
: player(player),
|
||||
camera(player->camera),
|
||||
camera(player->fpCamera),
|
||||
settings(settings),
|
||||
offset(0.0f, 0.7f, 0.0f) {
|
||||
}
|
||||
@@ -353,7 +353,7 @@ static void pick_block(
|
||||
voxel* PlayerController::updateSelection(float maxDistance) {
|
||||
auto indices = level->content->getIndices();
|
||||
auto chunks = level->chunks.get();
|
||||
auto camera = player->camera.get();
|
||||
auto camera = player->fpCamera.get();
|
||||
auto& selection = player->selection;
|
||||
|
||||
glm::vec3 end;
|
||||
@@ -416,7 +416,7 @@ voxel* PlayerController::updateSelection(float maxDistance) {
|
||||
void PlayerController::processRightClick(const Block& def, const Block& target) {
|
||||
const auto& selection = player->selection;
|
||||
auto chunks = level->chunks.get();
|
||||
auto camera = player->camera.get();
|
||||
auto camera = player->fpCamera.get();
|
||||
|
||||
blockstate state {};
|
||||
state.rotation = determine_rotation(&def, selection.normal, camera->dir);
|
||||
|
||||
@@ -10,55 +10,71 @@ static const ItemDef* get_item_def(lua::State* L, int idx) {
|
||||
return indices->items.get(id);
|
||||
}
|
||||
|
||||
static int l_item_name(lua::State* L) {
|
||||
static int l_name(lua::State* L) {
|
||||
if (auto def = get_item_def(L, 1)) {
|
||||
return lua::pushstring(L, def->name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_item_index(lua::State* L) {
|
||||
static int l_index(lua::State* L) {
|
||||
auto name = lua::require_string(L, 1);
|
||||
return lua::pushinteger(L, content->items.require(name).rt.id);
|
||||
}
|
||||
|
||||
static int l_item_stack_size(lua::State* L) {
|
||||
static int l_stack_size(lua::State* L) {
|
||||
if (auto def = get_item_def(L, 1)) {
|
||||
return lua::pushinteger(L, def->stackSize);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_item_defs_count(lua::State* L) {
|
||||
static int l_defs_count(lua::State* L) {
|
||||
return lua::pushinteger(L, indices->items.count());
|
||||
}
|
||||
|
||||
static int l_item_get_icon(lua::State* L) {
|
||||
static int l_get_icon(lua::State* L) {
|
||||
if (auto def = get_item_def(L, 1)) {
|
||||
switch (def->iconType) {
|
||||
case item_icon_type::none:
|
||||
case ItemIconType::NONE:
|
||||
return 0;
|
||||
case item_icon_type::sprite:
|
||||
case ItemIconType::SPRITE:
|
||||
return lua::pushstring(L, def->icon);
|
||||
case item_icon_type::block:
|
||||
case ItemIconType::BLOCK:
|
||||
return lua::pushstring(L, "block-previews:" + def->icon);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_item_caption(lua::State* L) {
|
||||
static int l_caption(lua::State* L) {
|
||||
if (auto def = get_item_def(L, 1)) {
|
||||
return lua::pushstring(L, def->caption);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_placing_block(lua::State* L) {
|
||||
if (auto def = get_item_def(L, 1)) {
|
||||
return lua::pushinteger(L, def->rt.placingBlock);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_model_name(lua::State* L) {
|
||||
if (auto def = get_item_def(L, 1)) {
|
||||
return lua::pushstring(L, def->modelName);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const luaL_Reg itemlib[] = {
|
||||
{"index", lua::wrap<l_item_index>},
|
||||
{"name", lua::wrap<l_item_name>},
|
||||
{"stack_size", lua::wrap<l_item_stack_size>},
|
||||
{"defs_count", lua::wrap<l_item_defs_count>},
|
||||
{"icon", lua::wrap<l_item_get_icon>},
|
||||
{"caption", lua::wrap<l_item_caption>},
|
||||
{"index", lua::wrap<l_index>},
|
||||
{"name", lua::wrap<l_name>},
|
||||
{"stack_size", lua::wrap<l_stack_size>},
|
||||
{"defs_count", lua::wrap<l_defs_count>},
|
||||
{"icon", lua::wrap<l_get_icon>},
|
||||
{"caption", lua::wrap<l_caption>},
|
||||
{"placing_block", lua::wrap<l_placing_block>},
|
||||
{"model_name", lua::wrap<l_model_name>},
|
||||
{NULL, NULL}};
|
||||
|
||||
@@ -85,7 +85,7 @@ static int l_set_rot(lua::State* L) {
|
||||
|
||||
static int l_get_dir(lua::State* L) {
|
||||
if (auto player = get_player(L, 1)) {
|
||||
return lua::pushvec3(L, player->camera->front);
|
||||
return lua::pushvec3(L, player->fpCamera->front);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user