Skip to content

Commit

Permalink
feature: added scene cache for builds
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyjor committed Dec 29, 2024
1 parent f8f6ed4 commit 2e921c1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/JulGame.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 10 additions & 2 deletions src/engine/SceneManagement/SceneReader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down

0 comments on commit 2e921c1

Please sign in to comment.