33f50a2c69
Removes the per-platform save/savestream/autosave implementations, the settings UI frames, and the autosave overlay, replacing them with a savemanager.c/h + savefile.h/savedevice.h scaffold to build the new save system on top of. Also separates the concrete UI_ELEMENTS registration into uielementlist.h/.c so uielement.c only holds the generic per-element lifecycle logic. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
92 lines
2.5 KiB
C
92 lines
2.5 KiB
C
/**
|
|
* Copyright (c) 2025 Dominic Masters
|
|
*
|
|
* This software is released under the MIT License.
|
|
* https://opensource.org/licenses/MIT
|
|
*/
|
|
|
|
#include "rpg.h"
|
|
#include "entity/entity.h"
|
|
#include "rpg/overworld/map.h"
|
|
#include "rpg/overworld/maparea.h"
|
|
#include "rpg/cutscene/cutscenesystem.h"
|
|
#include "rpg/item/backpack.h"
|
|
#include "rpg/battle/party.h"
|
|
#include "ui/rpg/textbox/uitextboxminilist.h"
|
|
#include "time/time.h"
|
|
#include "rpgcamera.h"
|
|
#include "util/memory.h"
|
|
#include "assert/assert.h"
|
|
#include "error/error.h"
|
|
#include "scene/scene.h"
|
|
#include "ui/rpg/uiemoji.h"
|
|
#include "rpg/story/storyflag.h"
|
|
|
|
errorret_t rpgInit(void) {
|
|
memoryZero(ENTITIES, sizeof(ENTITIES));
|
|
memoryZero(MAP_AREAS, sizeof(MAP_AREAS));
|
|
|
|
backpackInit();
|
|
partyInit();
|
|
cutsceneSystemInit();
|
|
errorChain(mapInit());
|
|
rpgCameraInit();
|
|
|
|
|
|
// Init test world
|
|
errorChain(mapPositionSet((chunkpos_t){ 0, 0, 0 }));
|
|
|
|
// The player is the one entity that isn't sourced from map/chunk data -
|
|
// every other entity (NPCs, items) and map area comes from the loaded
|
|
// chunks' own spawn data (see rpg/overworld/map.c mapChunkLoaded).
|
|
uint8_t entIndex = entityGetAvailable();
|
|
assertTrue(entIndex != 0xFF, "No available entity slots!.");
|
|
entity_t *ent = &ENTITIES[entIndex];
|
|
entityInit(ent, ENTITY_TYPE_PLAYER);
|
|
entityPositionSet(ent, (worldpos_t){ 10, 2, 0 });// Also assigns the chunk.
|
|
RPG_CAMERA.mode = RPG_CAMERA_MODE_FOLLOW_ENTITY;
|
|
RPG_CAMERA.followEntity.followEntityId = ent->id;
|
|
|
|
// Starting inventory.
|
|
backpackAdd(ITEM_ID_POTION, 5);
|
|
backpackAdd(ITEM_ID_POTATO, 3);
|
|
backpackAdd(ITEM_ID_APPLE, 8);
|
|
|
|
|
|
// All Good!
|
|
errorOk();
|
|
}
|
|
|
|
errorret_t rpgUpdate(void) {
|
|
#ifdef DUSK_TIME_DYNAMIC
|
|
if(TIME.dynamicUpdate) {
|
|
errorOk();
|
|
}
|
|
#endif
|
|
|
|
// TODO: Do not update if the scene is not the map scene?
|
|
errorChain(mapUpdate());
|
|
|
|
// 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());
|
|
errorOk();
|
|
}
|
|
|
|
errorret_t rpgDispose(void) {
|
|
cutsceneSystemDispose();
|
|
errorChain(mapDispose());
|
|
|
|
errorOk();
|
|
} |