Events.h 769 B

1234567891011121314151617181920212223242526
  1. // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma once
  6. #include <AnKi/AnKi.h>
  7. using namespace anki;
  8. inline void createDestructionEvent(SceneNode* node, Second timeToKill)
  9. {
  10. constexpr CString script = R"(
  11. function update(event, prevTime, crntTime)
  12. -- Do nothing
  13. end
  14. function onKilled(event, prevTime, crntTime)
  15. logi(string.format("Will kill %s", event:getAssociatedSceneNodes():getAt(0):getName()))
  16. event:getAssociatedSceneNodes():getAt(0):markForDeletion()
  17. end
  18. )";
  19. ScriptEvent* event = SceneGraph::getSingleton().getEventManager().newEvent<ScriptEvent>(-1.0, timeToKill, script);
  20. event->addAssociatedSceneNode(node);
  21. }