Просмотр исходного кода

world: add collision_end() script component callback

Daniele Bartolini 4 месяцев назад
Родитель
Сommit
026ab5bb84
2 измененных файлов с 13 добавлено и 0 удалено
  1. 1 0
      docs/changelog.rst
  2. 12 0
      src/world/script_world.cpp

+ 1 - 0
docs/changelog.rst

@@ -32,6 +32,7 @@ Changelog
 
 	The affected components will now read the initial pose from the unit's transform.
 * Lua: added ``World.destroy_level``.
+* Lua: added ``collision_end()`` script component callback.
 
 **Fixes**
 

+ 12 - 0
src/world/script_world.cpp

@@ -178,6 +178,18 @@ namespace script_world
 					}
 					break;
 
+				case PhysicsCollisionEvent::TOUCH_END:
+					lua_getfield(stack.L, -1, "collision_end");
+					if (!lua_isnil(stack.L, -1)) {
+						int status = sw._lua_environment->call(0, 0);
+						if (status != LUA_OK) {
+							report(stack.L, status);
+							device()->pause();
+						}
+						stack.pop(1);
+					}
+					break;
+
 				default:
 					CE_FATAL("Unknown physics collision event");
 					break;