2
0

ScriptEvent.h 1009 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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/Scene/Events/Event.h>
  7. #include <AnKi/Resource/Forward.h>
  8. #include <AnKi/Script/ScriptEnvironment.h>
  9. namespace anki {
  10. /// @addtogroup scene
  11. /// @{
  12. /// A generic event that uses scripts. The script should contain something like this:
  13. /// @code
  14. /// function update(event, prevTime, crntTime)
  15. /// -- Do something
  16. /// end
  17. ///
  18. /// function onKilled(event, prevTime, crntTime)
  19. /// -- Do something
  20. /// end
  21. /// @endcode
  22. class ScriptEvent : public Event
  23. {
  24. public:
  25. ScriptEvent(Second startTime, Second duration, CString script);
  26. ~ScriptEvent();
  27. void update(Second prevUpdateTime, Second crntTime) override;
  28. void onKilled(Second prevUpdateTime, Second crntTime) override;
  29. private:
  30. ScriptResourcePtr m_scriptRsrc;
  31. SceneString m_script;
  32. ScriptEnvironment m_env;
  33. };
  34. /// @}
  35. } // end namespace anki