Skip to content

Commit

Permalink
fix: "persistentBetweenScenes" added for entity scene reading/writing
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyjor committed Dec 30, 2024
1 parent 7a7ea55 commit 2c2b841
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ function initialize_scripts_and_components()
end
end

MAIN.scene.rigidbodies = []
MAIN.scene.colliders = []
MAIN.scene.rigidbodies = []
MAIN.scene.colliders = []
for entity in MAIN.scene.entities
@debug "adding rigidbodies to global list"
if entity.rigidbody != C_NULL
Expand Down
3 changes: 2 additions & 1 deletion src/engine/SceneManagement/SceneReader.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ module SceneReaderModule
newEntity = Entity(get(entity, "name", "New entity"), string(entity.id))
newEntity.isActive = get(entity, "isActive", true)
newEntity.scripts = get(entity, "scripts", [])
newEntity.persistentBetweenScenes = get(entity, "persistentBetweenScenes", false)

for component in components
if typeof(component) == Animator
Expand Down Expand Up @@ -126,7 +127,7 @@ module SceneReaderModule
else
newUIElement = ScreenButton(uiElement.name, uiElement.buttonUpSpritePath, uiElement.buttonDownSpritePath, Vector2(uiElement.size.x, uiElement.size.y), Vector2(uiElement.position.x, uiElement.position.y), uiElement.fontPath, uiElement.text, Vector2(uiElement.textOffset.x, uiElement.textOffset.y))
end

newUIElement.persistentBetweenScenes = get(uiElement, "persistentBetweenScenes", false)
push!(res, newUIElement)
catch e
@error string(e)
Expand Down
9 changes: 8 additions & 1 deletion src/engine/SceneManagement/SceneWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ module SceneWriterModule

count = 1
for entity in entities
push!(entitiesDict, Dict("id" => string(entity.id), "parent" => entity.parent != C_NULL ? entity.parent.id : C_NULL, "isActive" => entity.isActive, "name" => entity.name, "components" => serialize_entity_components([entity.animator, entity.collider, entity.circleCollider, entity.rigidbody, entity.shape, entity.soundSource, entity.sprite, entity.transform]), "scripts" => serialize_entity_scripts(entity.scripts)))
push!(entitiesDict, Dict(
"id" => string(entity.id),
"parent" => entity.parent != C_NULL ? entity.parent.id : C_NULL,
"isActive" => entity.isActive,
"name" => entity.name,
"persistentBetweenScenes" => entity.persistentBetweenScenes,
"components" => serialize_entity_components([entity.animator, entity.collider, entity.circleCollider, entity.rigidbody, entity.shape, entity.soundSource, entity.sprite, entity.transform]),
"scripts" => serialize_entity_scripts(entity.scripts)))
count += 1
end

Expand Down

0 comments on commit 2c2b841

Please sign in to comment.