Now root motion works much better; raft/boat climbing
This commit is contained in:
@@ -91,7 +91,7 @@ int LuaData::call_handler(const Ogre::String &event, flecs::entity e,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int luaLibraryLoader(lua_State *L)
|
||||
static int luaLibraryLoader(lua_State *L)
|
||||
{
|
||||
int i;
|
||||
if (!lua_isstring(L, 1)) {
|
||||
@@ -260,11 +260,11 @@ LuaData::LuaData()
|
||||
lua_setglobal(L, "main_menu");
|
||||
lua_pushcfunction(L, [](lua_State *L) -> int {
|
||||
OgreAssert(lua_gettop(L) == 3, "Invalid parameters");
|
||||
luaL_checktype(L, 1, LUA_TSTRING);
|
||||
luaL_checktype(L, 1, LUA_TNUMBER);
|
||||
luaL_checktype(L, 2, LUA_TSTRING);
|
||||
luaL_checktype(L, 3, LUA_TBOOLEAN);
|
||||
bool enable = lua_toboolean(L, 3);
|
||||
flecs::entity e = ECS::get().lookup(lua_tostring(L, 1));
|
||||
flecs::entity e = idmap.get_entity(lua_tointeger(L, 1));
|
||||
Ogre::String what = lua_tostring(L, 2);
|
||||
OgreAssert(e.is_valid(), "Invalid character");
|
||||
OgreAssert(e.has<Character>(), "Not a character");
|
||||
@@ -401,6 +401,24 @@ LuaData::LuaData()
|
||||
return 0;
|
||||
});
|
||||
lua_setglobal(L, "ecs_trigger_set_position");
|
||||
lua_pushcfunction(L, [](lua_State *L) -> int {
|
||||
luaL_checktype(L, 1, LUA_TNUMBER); // trigger
|
||||
int trigger = lua_tointeger(L, 1);
|
||||
flecs::entity trigger_e = idmap.get_entity(trigger);
|
||||
Ogre::SceneNode *node = trigger_e.get<EventTrigger>().node;
|
||||
Ogre::Any animationAny =
|
||||
node->getUserObjectBindings().getUserAny(
|
||||
"trigger_animation");
|
||||
if (animationAny.has_value()) {
|
||||
Ogre::String animation =
|
||||
Ogre::any_cast<Ogre::String>(animationAny);
|
||||
lua_pushstring(L, animation.c_str());
|
||||
return 1;
|
||||
}
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
});
|
||||
lua_setglobal(L, "ecs_trigger_get_animation");
|
||||
lua_pushcfunction(L, [](lua_State *L) -> int {
|
||||
OgreAssert(lua_gettop(L) == 5, "Invalid parameters");
|
||||
luaL_checktype(L, 1, LUA_TSTRING); // type
|
||||
@@ -472,6 +490,14 @@ LuaData::LuaData()
|
||||
return 0;
|
||||
});
|
||||
lua_setglobal(L, "ecs_character_physics_control");
|
||||
lua_pushcfunction(L, [](lua_State *L) -> int {
|
||||
luaL_checktype(L, 1, LUA_TNUMBER); // object
|
||||
int object = lua_tointeger(L, 1);
|
||||
flecs::entity object_e = idmap.get_entity(object);
|
||||
lua_pushboolean(L, object_e.has<Player>());
|
||||
return 1;
|
||||
});
|
||||
lua_setglobal(L, "ecs_character_is_player");
|
||||
lua_pushcfunction(L, [](lua_State *L) -> int {
|
||||
luaL_checktype(L, 1, LUA_TNUMBER); // object
|
||||
luaL_checktype(L, 2, LUA_TSTRING); // animation
|
||||
@@ -479,8 +505,10 @@ LuaData::LuaData()
|
||||
|
||||
int object = lua_tointeger(L, 1);
|
||||
flecs::entity object_e = idmap.get_entity(object);
|
||||
if (animation.length())
|
||||
object_e.set<CharacterInActuator>({ animation });
|
||||
object_e.set<CharacterVelocity>({ { 0, 0, 0 }, { 0, 0, 0 } });
|
||||
if (animation.length() > 0)
|
||||
object_e.set<CharacterInActuator>(
|
||||
{ animation, { 0, 0, 0 } });
|
||||
else
|
||||
object_e.remove<CharacterInActuator>();
|
||||
return 0;
|
||||
@@ -500,6 +528,13 @@ LuaData::LuaData()
|
||||
return 0;
|
||||
});
|
||||
lua_setglobal(L, "ecs_set_slot");
|
||||
lua_pushcfunction(L, [](lua_State *L) -> int {
|
||||
flecs::entity e = ECS::get().lookup("player");
|
||||
int result = idmap.add_entity(e);
|
||||
lua_pushinteger(L, result);
|
||||
return result;
|
||||
});
|
||||
lua_setglobal(L, "ecs_get_player_entity");
|
||||
lua_pushcfunction(L, [](lua_State *L) -> int {
|
||||
luaL_checktype(L, 1, LUA_TNUMBER); // entity id
|
||||
int id = lua_tointeger(L, 1);
|
||||
|
||||
Reference in New Issue
Block a user