Skip to content

Commit 47bbefa

Browse files
committed
EntityRegistry Lua bindings
1 parent 0c74486 commit 47bbefa

5 files changed

Lines changed: 35 additions & 21 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,9 @@ include_directories (${SUPERNOVA_ROOT}/engine/core/object/audio)
458458
include_directories (${SUPERNOVA_ROOT}/engine/core/object/ui)
459459
include_directories (${SUPERNOVA_ROOT}/engine/core/object/environment)
460460
include_directories (${SUPERNOVA_ROOT}/engine/core/object/physics)
461+
include_directories (${SUPERNOVA_ROOT}/engine/core/pool)
462+
include_directories (${SUPERNOVA_ROOT}/engine/core/registry)
463+
include_directories (${SUPERNOVA_ROOT}/engine/core/render)
461464
include_directories (${SUPERNOVA_ROOT}/engine/core/script)
462465
include_directories (${SUPERNOVA_ROOT}/engine/core/shader)
463466
include_directories (${SUPERNOVA_ROOT}/engine/core/subsystem)

engine/core/Supernova.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@
142142
#include "pool/TextureDataPool.h"
143143
#include "pool/TexturePool.h"
144144

145+
#include "registry/EntityRegistry.h"
146+
145147
#include "render/BufferRender.h"
146148
#include "render/CameraRender.h"
147149
#include "render/FramebufferRender.h"
@@ -177,7 +179,6 @@
177179
//#include "util/Box2DAux.h"
178180
#include "util/Color.h"
179181
//#include "util/DefaultFont.h"
180-
#include "util/EntityRegistry.h"
181182
#include "util/SpriteFrameData.h"
182183
#include "util/FunctionSubscribe.h"
183184
//#include "util/JoltPhysicsAux.h"
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,14 @@ Entity EntityRegistry::createEntity() {
161161
return entityManager.createEntity();
162162
}
163163

164-
bool EntityRegistry::recreateEntity(Entity entity) {
165-
return entityManager.recreateEntity(entity);
166-
}
167-
168164
bool EntityRegistry::isEntityCreated(Entity entity) const {
169165
return entityManager.isCreated(entity);
170166
}
171167

168+
bool EntityRegistry::recreateEntity(Entity entity) {
169+
return entityManager.recreateEntity(entity);
170+
}
171+
172172
void EntityRegistry::destroyEntity(Entity entity) {
173173
onEntityDestroyed(entity, entityManager.getSignature(entity));
174174

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,8 @@ namespace Supernova {
7373

7474
//Entity methods
7575

76-
bool recreateEntity(Entity entity); // for internal editor use only
77-
7876
Entity createEntity();
77+
bool recreateEntity(Entity entity); // for internal editor use only
7978

8079
bool isEntityCreated(Entity entity) const;
8180

engine/core/script/binding/CoreClassesLua.cpp

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,31 @@ void LuaBinding::registerCoreClasses(lua_State *L){
467467
.endClass();
468468

469469
luabridge::getGlobalNamespace(L)
470-
.beginClass<Scene>("Scene")
470+
.beginClass<EntityRegistry>("EntityRegistry")
471+
.addConstructor <void (*) (void)> ()
472+
.addFunction("createEntity", &EntityRegistry::createEntity)
473+
//.addFunction("recreateEntity", &EntityRegistry::recreateEntity)
474+
.addFunction("isEntityCreated", &EntityRegistry::isEntityCreated)
475+
.addFunction("destroyEntity", &EntityRegistry::destroyEntity)
476+
.addFunction("addEntityChild", &EntityRegistry::addEntityChild)
477+
//.addFunction("moveChildToIndex", &EntityRegistry::moveChildToIndex)
478+
.addFunction("moveChildToTop", &EntityRegistry::moveChildToTop)
479+
.addFunction("moveChildUp", &EntityRegistry::moveChildUp)
480+
.addFunction("moveChildDown", &EntityRegistry::moveChildDown)
481+
.addFunction("moveChildToBottom", &EntityRegistry::moveChildToBottom)
482+
.addFunction("getSignature", &EntityRegistry::getSignature)
483+
.addFunction("getEntityName", &EntityRegistry::getEntityName)
484+
.addFunction("setEntityName", &EntityRegistry::setEntityName)
485+
.addFunction("findOldestParent", &EntityRegistry::findOldestParent)
486+
.addFunction("isParentOf", &EntityRegistry::isParentOf)
487+
.addFunction("findBranchLastIndex", &EntityRegistry::findBranchLastIndex)
488+
.addFunction("getLastEntity", &EntityRegistry::getLastEntity)
489+
.addFunction("getEntityList", &EntityRegistry::getEntityList)
490+
.addFunction("clear", &EntityRegistry::clear)
491+
.endClass();
492+
493+
luabridge::getGlobalNamespace(L)
494+
.deriveClass<Scene, EntityRegistry>("Scene")
471495
.addConstructor <void (*) (void)> ()
472496
.addFunction("load", &Scene::load)
473497
.addFunction("destroy", &Scene::destroy)
@@ -489,19 +513,6 @@ void LuaBinding::registerCoreClasses(lua_State *L){
489513
.addFunction("setGlobalIllumination", (void (Scene::*)(float, Vector3))&Scene::setGlobalIllumination)
490514
.addFunction("canReceiveUIEvents", &Scene::canReceiveUIEvents)
491515
.addProperty("enableUIEvents", &Scene::isEnableUIEvents, &Scene::setEnableUIEvents)
492-
.addFunction("findOldestParent", &Scene::findOldestParent)
493-
.addFunction("isParentOf", &Scene::isParentOf)
494-
.addFunction("findBranchLastIndex", &Scene::findBranchLastIndex)
495-
.addFunction("createEntity", &Scene::createEntity)
496-
.addFunction("destroyEntity", &Scene::destroyEntity)
497-
.addFunction("addEntityChild", &Scene::addEntityChild)
498-
.addFunction("moveChildToTop", &Scene::moveChildToTop)
499-
.addFunction("moveChildUp", &Scene::moveChildUp)
500-
.addFunction("moveChildDown", &Scene::moveChildDown)
501-
.addFunction("moveChildToBottom", &Scene::moveChildToBottom)
502-
.addFunction("getSignature", &Scene::getSignature)
503-
.addFunction("getEntityName", &Scene::getEntityName)
504-
.addFunction("setEntityName", &Scene::setEntityName)
505516
.addFunction("getActionSystem", [] (Scene* self, lua_State* L) { return self->getSystem<ActionSystem>().get(); })
506517
.addFunction("getAudioSystem", [] (Scene* self, lua_State* L) { return self->getSystem<AudioSystem>().get(); })
507518
.addFunction("getMeshSystem", [] (Scene* self, lua_State* L) { return self->getSystem<MeshSystem>().get(); })

0 commit comments

Comments
 (0)