diff --git a/src/JulGame.jl b/src/JulGame.jl index 3dad02a9..35a8888b 100644 --- a/src/JulGame.jl +++ b/src/JulGame.jl @@ -6,6 +6,8 @@ module JulGame IS_EDITOR = false IS_PACKAGE_COMPILED::Bool = false DELTA_TIME = 0.0 + # TODO: Create a globals file + SCENE_CACHE::Dict = Dict{String, Any}() include("ModuleExtensions/SDL2Extension.jl") const SDL2E = SDL2Extension diff --git a/src/engine/SceneManagement/SceneReader.jl b/src/engine/SceneManagement/SceneReader.jl index d4837c58..ac3a72eb 100644 --- a/src/engine/SceneManagement/SceneReader.jl +++ b/src/engine/SceneManagement/SceneReader.jl @@ -24,8 +24,16 @@ module SceneReaderModule export deserialize_scene function deserialize_scene(filePath) try - entitiesJson = read(filePath, String) - json = JSON3.read(entitiesJson) + json = nothing + if haskey(JulGame.SCENE_CACHE, basename(filePath)) + json = JulGame.SCENE_CACHE[basename(filePath)] + @debug("using cached scene") + else + entitiesJson = read(filePath, String) + json = JSON3.read(entitiesJson) + @debug("using scene from scene file") + end + entities = [] uiElements = [] res = []