Files
chaussette.sale/game_state.gd
2025-04-14 09:13:22 +02:00

55 lines
1.6 KiB
GDScript

extends Node
var _game : GameControler
var isUsingTouch = false
var hasChosenNotToMakeChoices = false
var hasChosenToMakeChoices = false
var hasCompletedBobDialogue = false
var hasMetBob = false
var hasVisitedBakery = false
var isPlayerDeaf = false
var float_thomas_music_position = 0
var current_scene = "outside"
var position_outside = Vector2(-134.3333, -164.0905)
var position_bakery = Vector2(461, 710)
func update_position(p: Vector2):
match current_scene:
"outside":
position_outside = p
"bakery":
position_bakery = p
func save():
var ret = {}
var thisScript: GDScript = get_script()
for propertyInfo in thisScript.get_script_property_list():
var propertyName: String = propertyInfo.name
var propertyValue = get(propertyName)
ret[propertyName] = JSON.stringify(propertyValue)
# don't save protected fields
if propertyName.begins_with("_") :
continue
return ret
func load_save(data:Dictionary):
var thisScript: GDScript = get_script()
for propertyInfo in thisScript.get_script_property_list():
var propertyName: String = propertyInfo.name
# don't load protected fields
if propertyName.begins_with("_") :
continue
if data.get(propertyName) == null:
continue
if propertyName.begins_with("is") or propertyName.begins_with("has"):
set(propertyName, data.get(propertyName) == "true")
elif propertyName.begins_with("position_"):
var strplps = (data.get(propertyName) as String).replace("\"(", "").replace(")\"", "")
var parts = strplps.split(", ")
set(propertyName, Vector2(float(parts[0]), float(parts[1])))
else:
set(propertyName, data.get(propertyName).lstrip("\"").rstrip("\""))