ScriptComponent.h 907 B

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