ScriptExecutor.h 805 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. * 2D Game Engine
  3. * ScriptExecutor.h:
  4. * Based on pikuma.com 2D game engine in C++ and Lua course
  5. * Copyright (c) 2021 986-Studio. All rights reserved.
  6. *
  7. * Created by Manoël Trapier on 01/03/2021.
  8. */
  9. #ifndef IMGUI_SOURCE_INCLUDE_SYSTEMS_SCRIPTEXECUTOR_H
  10. #define IMGUI_SOURCE_INCLUDE_SYSTEMS_SCRIPTEXECUTOR_H
  11. #include <sol/sol.hpp>
  12. #include <ECS.h>
  13. #include <Components/Script.h>
  14. class ScriptExecutorSystem : public System
  15. {
  16. public:
  17. ScriptExecutorSystem()
  18. {
  19. this->requireComponent<ScriptComponent>();
  20. }
  21. void update()
  22. {
  23. for(auto entity : this->getSystemEntities())
  24. {
  25. const auto script = entity.getComponent<ScriptComponent>();
  26. script.func();
  27. }
  28. }
  29. };
  30. #endif /* IMGUI_SOURCE_INCLUDE_SYSTEMS_SCRIPTEXECUTOR_H */