Map refactoring to prep for loading
This commit is contained in:
@@ -89,6 +89,8 @@ void sceneMapEntityGetPosition(const entity_t *entity, vec3 outPosition) {
|
||||
}
|
||||
|
||||
void sceneMapRender(scenedata_t *data) {
|
||||
if(!mapIsLoaded()) return;
|
||||
|
||||
// Look at target.
|
||||
vec3 cameraTarget;
|
||||
switch(RPG_CAMERA.mode) {
|
||||
@@ -166,6 +168,8 @@ void sceneMapRenderEntity(entity_t *entity) {
|
||||
}
|
||||
|
||||
void sceneMapRenderMap() {
|
||||
assertTrue(mapIsLoaded(), "No map loaded to render");
|
||||
|
||||
// For each chunk.
|
||||
for(uint32_t i = 0; i < MAP_CHUNK_COUNT; i++) {
|
||||
chunk_t *chunk = MAP.chunkOrder[i];
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "assert/assert.h"
|
||||
#include "display/framebuffer.h"
|
||||
#include "util/string.h"
|
||||
#include "asset/asset.h"
|
||||
#include "script/scriptmanager.h"
|
||||
|
||||
scenemanager_t SCENE_MANAGER;
|
||||
|
||||
@@ -60,9 +62,20 @@ errorret_t sceneManagerSetScene(scene_t *scene) {
|
||||
|
||||
SCENE_MANAGER.current = scene;
|
||||
|
||||
if(scene && scene->init) {
|
||||
if(scene && (scene->flags & SCENE_FLAG_INITIALIZED) == 0) {
|
||||
scene->flags |= SCENE_FLAG_INITIALIZED;
|
||||
errorChain(scene->init(&SCENE_MANAGER.sceneData));
|
||||
|
||||
if(scene->init) errorChain(scene->init(&SCENE_MANAGER.sceneData));
|
||||
|
||||
// Execute scene script if it exists
|
||||
char_t buffer[256];
|
||||
snprintf(buffer, sizeof(buffer), "scene/%s.dsf", scene->name);
|
||||
if(assetFileExists(buffer)) {
|
||||
scriptcontext_t ctx;
|
||||
scriptContextInit(&ctx);
|
||||
errorChain(scriptContextExecFile(&ctx, buffer));
|
||||
scriptContextDispose(&ctx);
|
||||
}
|
||||
}
|
||||
|
||||
errorOk();
|
||||
|
||||
Reference in New Issue
Block a user