ScriptComponent.h 907 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright (C) 2009-2021, 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/Components/SceneComponent.h>
  7. #include <AnKi/Resource/Forward.h>
  8. #include <AnKi/Script/ScriptEnvironment.h>
  9. namespace anki {
  10. /// @addtogroup scene
  11. /// @{
  12. /// Component of scripts.
  13. class ScriptComponent : public SceneComponent
  14. {
  15. ANKI_SCENE_COMPONENT(ScriptComponent)
  16. public:
  17. ScriptComponent(SceneNode* node);
  18. ~ScriptComponent();
  19. ANKI_USE_RESULT Error loadScriptResource(CString fname);
  20. ANKI_USE_RESULT Error update(SceneNode& node, Second prevTime, Second crntTime, Bool& updated) override;
  21. Bool isEnabled() const
  22. {
  23. return m_script.isCreated();
  24. }
  25. private:
  26. SceneNode* m_node;
  27. ScriptResourcePtr m_script;
  28. ScriptEnvironment* m_env = nullptr;
  29. };
  30. /// @}
  31. } // end namespace anki