1234567891011121314151617181920212223242526272829303132333435363738 |
- /*
- * 2D Game Engine
- * ScriptExecutor.h:
- * Based on pikuma.com 2D game engine in C++ and Lua course
- * Copyright (c) 2021 986-Studio. All rights reserved.
- *
- * Created by Manoël Trapier on 01/03/2021.
- */
- #ifndef IMGUI_SOURCE_INCLUDE_SYSTEMS_SCRIPTEXECUTOR_H
- #define IMGUI_SOURCE_INCLUDE_SYSTEMS_SCRIPTEXECUTOR_H
- #include <sol/sol.hpp>
- #include <ECS.h>
- #include <Components/Script.h>
- class ScriptExecutorSystem : public System
- {
- public:
- ScriptExecutorSystem()
- {
- this->requireComponent<ScriptComponent>();
- }
- void update()
- {
- for(auto entity : this->getSystemEntities())
- {
- const auto script = entity.getComponent<ScriptComponent>();
- script.func();
- }
- }
- };
- #endif /* IMGUI_SOURCE_INCLUDE_SYSTEMS_SCRIPTEXECUTOR_H */
|