Skip to content

Commit

Permalink
fix persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyjor committed Dec 30, 2024
1 parent 2c2b841 commit 967884f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,15 @@ function JulGame.change_scene(sceneFileName::String)
this.close = true
this.shouldChangeScene = true
#destroy current scene
@debug "Entities before destroying: $(length(this.scene.entities))"
@debug "Entity count before destroying: $(length(this.scene.entities))"
count = 0
skipcount = 0
persistentEntities = []
entitiesToDestroy = []

for entity in this.scene.entities
if entity.persistentBetweenScenes && (!JulGame.IS_EDITOR || this.isGameModeRunningInEditor)
#println("Persistent entity: ", entity.name, " with id: ", entity.id)
@debug("Persistent entity: ", entity.name, " with id: ", entity.id)
push!(persistentEntities, entity)
skipcount += 1
continue
Expand All @@ -344,9 +346,13 @@ function JulGame.change_scene(sceneFileName::String)
end
end

JulGame.destroy_entity(this, entity)
push!(entitiesToDestroy, entity)
count += 1
end

for entity in entitiesToDestroy
JulGame.destroy_entity(this, entity)
end
@debug "Destroyed $count entities while changing scenes"
@debug "Skipped $skipcount entities while changing scenes"

Expand Down

0 comments on commit 967884f

Please sign in to comment.