#include "hello_module.h" #include #include namespace extra2d { HelloModule::HelloModule() : Module() , config_() , time_(0.0f) { } HelloModule::~HelloModule() { if (isInitialized()) { destroyModule(); } } void HelloModule::setupModule() { if (isInitialized()) { return; } if (config_.greeting.empty()) { config_.greeting = "Hello, Extra2D!"; } if (config_.repeatCount <= 0) { config_.repeatCount = 1; } setInitialized(true); E2D_LOG_INFO("HelloModule initialized"); E2D_LOG_INFO(" Greeting: {}", config_.greeting); E2D_LOG_INFO(" Repeat Count: {}", config_.repeatCount); E2D_LOG_INFO(" Logging Enabled: {}", config_.enableLogging); sayHello(); } void HelloModule::destroyModule() { if (!isInitialized()) { return; } if (config_.enableLogging) { E2D_LOG_INFO("HelloModule shutdown - Goodbye!"); } setInitialized(false); } void HelloModule::onUpdate(UpdateContext& ctx) { if (!isInitialized()) { ctx.next(); return; } time_ += ctx.getDeltaTime(); if (time_ >= 5.0f) { sayHello(); time_ = 0.0f; } ctx.next(); } void HelloModule::sayHello() const { if (!config_.enableLogging) { return; } for (int i = 0; i < config_.repeatCount; ++i) { E2D_LOG_INFO("[HelloModule] {}", config_.greeting); } } } // namespace extra2d E2D_MODULE(HelloModule, 1000)