Only update overworld entities while the overworld scene is active
Entities (and the player's pause-to-open-game-menu handling with them) previously kept updating every frame regardless of the active scene, matching an existing TODO in rpgUpdate(). Gating the entity loop itself means the game menu (and any other entity-driven input) naturally can't trigger mid-battle or before the initial scene hands off to the overworld, without needing a scene check at each individual call site. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
+12
-6
@@ -19,6 +19,7 @@
|
||||
#include "assert/assert.h"
|
||||
#include "save/save.h"
|
||||
#include "error/error.h"
|
||||
#include "scene/scene.h"
|
||||
|
||||
#include "ui/rpg/uiemoji.h"
|
||||
#include "rpg/story/storyflag.h"
|
||||
@@ -80,12 +81,17 @@ errorret_t rpgUpdate(void) {
|
||||
// TODO: Do not update if the scene is not the map scene?
|
||||
errorChain(mapUpdate());
|
||||
|
||||
// Update overworld ents.
|
||||
entity_t *ent = &ENTITIES[0];
|
||||
do {
|
||||
if(ent->type == ENTITY_TYPE_NULL) continue;
|
||||
entityUpdate(ent);
|
||||
} while(++ent < &ENTITIES[ENTITY_COUNT]);
|
||||
// Update overworld ents - only while actually in the overworld. Entities
|
||||
// (the player among them) keep existing across scene changes, but their
|
||||
// input/movement/animation logic doesn't make sense to run mid-battle or
|
||||
// before the initial scene has handed off to the overworld.
|
||||
if(SCENE.current == SCENE_TYPE_OVERWORLD) {
|
||||
entity_t *ent = &ENTITIES[0];
|
||||
do {
|
||||
if(ent->type == ENTITY_TYPE_NULL) continue;
|
||||
entityUpdate(ent);
|
||||
} while(++ent < &ENTITIES[ENTITY_COUNT]);
|
||||
}
|
||||
|
||||
cutsceneSystemUpdate();
|
||||
errorChain(rpgCameraUpdate());
|
||||
|
||||
Reference in New Issue
Block a user