| 142 | // --------------------------------------------------------------------------- |
| 143 | |
| 144 | void WorldSystem::PreUpdate(float deltaTime) |
| 145 | { |
| 146 | // Apply any deferred scene transition requested by scripts last frame. |
| 147 | if (!m_PendingScene.empty()) |
| 148 | { |
| 149 | std::string path = std::move(m_PendingScene); |
| 150 | m_PendingScene.clear(); |
| 151 | |
| 152 | // Destroy the current world first so actors release IDs before |
| 153 | // LoadFromFile calls IDGenerator::Clear(). |
| 154 | if (m_CurrentWorld) |
| 155 | { |
| 156 | m_CurrentWorld->OnStop(); |
| 157 | m_CurrentWorld->OnShutdown(); |
| 158 | m_CurrentWorld.reset(); |
| 159 | } |
| 160 | m_IsPlaying = false; |
| 161 | |
| 162 | auto candidate = std::make_unique<World>(); |
| 163 | bool loaded = false; |
| 164 | try |
| 165 | { |
| 166 | candidate->LoadFromFile(path); |
| 167 | loaded = true; |
| 168 | } |
| 169 | catch (const std::exception&) {} |
| 170 | |
| 171 | if (loaded) |
| 172 | { |
| 173 | m_CurrentWorld = std::move(candidate); |
| 174 | // LoadFromFile already ran OnInit (Pass 3) — no second call needed. |
| 175 | m_IsPlaying = true; |
| 176 | m_CurrentWorld->OnPlay(); |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | if (m_CurrentWorld) |
| 181 | m_CurrentWorld->OnPreUpdate(deltaTime); |
| 182 | } |
| 183 | |
| 184 | void WorldSystem::Update(float deltaTime) |
| 185 | { |
nothing calls this directly
no test coverage detected