diff options
author | JAROWMR <jarorutjes07@gmail.com> | 2024-11-22 16:11:39 +0100 |
---|---|---|
committer | JAROWMR <jarorutjes07@gmail.com> | 2024-11-22 16:11:39 +0100 |
commit | bcf57e81f68913049f84cabb66871931c8f47b2b (patch) | |
tree | 5f04d161a85bbea27ca9ad8e000a9129a447e88a | |
parent | 3f63143b4005936da446fb2cdbbd1072b47fc8c1 (diff) |
script fix
-rw-r--r-- | src/crepe/api/Config.h | 2 | ||||
-rw-r--r-- | src/crepe/api/LoopManager.cpp | 1 | ||||
-rw-r--r-- | src/example/game.cpp | 6 | ||||
-rw-r--r-- | src/test/CollisionTest.cpp | 7 |
4 files changed, 9 insertions, 7 deletions
diff --git a/src/crepe/api/Config.h b/src/crepe/api/Config.h index 13eabd1..b6c2ccf 100644 --- a/src/crepe/api/Config.h +++ b/src/crepe/api/Config.h @@ -33,7 +33,7 @@ public: * * Only messages with equal or higher priority than this value will be logged. */ - Log::Level level = Log::Level::INFO; + Log::Level level = Log::Level::DEBUG; /** * \brief Colored log output * diff --git a/src/crepe/api/LoopManager.cpp b/src/crepe/api/LoopManager.cpp index 10b59c8..ff8b90e 100644 --- a/src/crepe/api/LoopManager.cpp +++ b/src/crepe/api/LoopManager.cpp @@ -35,6 +35,7 @@ void LoopManager::start() { void LoopManager::set_running(bool running) { this->game_running = running; } void LoopManager::fixed_update() { + this->get_system<ScriptSystem>().update(); this->get_system<PhysicsSystem>().update(); this->get_system<CollisionSystem>().update(); } diff --git a/src/example/game.cpp b/src/example/game.cpp index f6b580a..991d2ec 100644 --- a/src/example/game.cpp +++ b/src/example/game.cpp @@ -17,12 +17,14 @@ using namespace crepe; using namespace std; class MyScript : public Script { - static bool oncollision(const CollisionEvent& test) { + bool oncollision(const CollisionEvent& test) { Log::logf("Box {} script on_collision()", test.info.first.collider.game_object_id); return true; } void init() { - EventManager::get_instance().subscribe<CollisionEvent>(oncollision, 0); + subscribe<CollisionEvent>([this](const CollisionEvent& ev) -> bool { + return this->oncollision(ev); + }); } void update() { // Retrieve component from the same GameObject this script is on diff --git a/src/test/CollisionTest.cpp b/src/test/CollisionTest.cpp index c175eb4..bbf6348 100644 --- a/src/test/CollisionTest.cpp +++ b/src/test/CollisionTest.cpp @@ -25,7 +25,6 @@ using namespace testing; class CollisionHandler : public Script { public: int box_id; - EventManager & evmgr = EventManager::get_instance(); function<void(const CollisionEvent& ev)> test_fn = [](const CollisionEvent & ev) { }; CollisionHandler(int box_id) { @@ -42,9 +41,9 @@ public: //Log::logf("Box {} script init()", box_id); // TODO: this should be built into script - evmgr.subscribe<CollisionEvent>([this](const CollisionEvent & ev) { - return this->on_collision(ev); - }, this->get_game_object_id()); + subscribe<CollisionEvent>([](const CollisionEvent&) -> bool { + return true; + }); } }; |