mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-06 11:31:49 +00:00
change: skeletons are assets now, not content units
This commit is contained in:
parent
587c140a6b
commit
42c4716be2
17 changed files with 144 additions and 120 deletions
|
|
@ -1,6 +1,7 @@
|
|||
#include "objects/rigging.hpp"
|
||||
#include "libentity.hpp"
|
||||
|
||||
#include "engine/Engine.hpp"
|
||||
#include "graphics/render/WorldRenderer.hpp"
|
||||
#include "graphics/render/NamedSkeletons.hpp"
|
||||
|
||||
|
|
@ -21,11 +22,14 @@ static int index_range_check(
|
|||
}
|
||||
|
||||
static rigging::Skeleton* get_skeleton(lua::State* L) {
|
||||
if (scripting::engine->isHeadless()) {
|
||||
return nullptr;
|
||||
}
|
||||
if (lua::isstring(L, 1)) {
|
||||
return scripting::renderer->skeletons->getSkeleton(lua::tostring(L, 1));
|
||||
}
|
||||
if (auto entity = get_entity(L, 1)) {
|
||||
return &entity->getSkeleton();
|
||||
return entity->getSkeleton();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "libentity.hpp"
|
||||
|
||||
#include "assets/Assets.hpp"
|
||||
#include "content/Content.hpp"
|
||||
#include "content/ContentPack.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
|
|
@ -82,7 +83,11 @@ static int l_despawn(lua::State* L) {
|
|||
|
||||
static int l_get_skeleton(lua::State* L) {
|
||||
if (auto entity = get_entity(L, 1)) {
|
||||
return lua::pushstring(L, entity->getSkeleton().config->getName());
|
||||
auto skeleton = entity->getSkeleton();
|
||||
if (skeleton == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
return lua::pushstring(L, skeleton->config->getName());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -97,9 +102,13 @@ static int l_get_player(lua::State* L) {
|
|||
}
|
||||
|
||||
static int l_set_skeleton(lua::State* L) {
|
||||
auto assets = engine->getAssets();
|
||||
if (assets == nullptr) {
|
||||
return 0;
|
||||
}
|
||||
if (auto entity = get_entity(L, 1)) {
|
||||
std::string skeletonName = lua::require_string(L, 2);
|
||||
auto rigConfig = content->getSkeleton(skeletonName);
|
||||
auto rigConfig = assets->get<rigging::SkeletonConfig>(skeletonName);
|
||||
if (rigConfig == nullptr) {
|
||||
throw std::runtime_error(
|
||||
"skeleton not found '" + skeletonName + "'"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue