khanat-client/ressources/scripts/datas/proxy_data.gd

52 lines
1.6 KiB
GDScript

class_name ProxyData
extends Data
#
#05. signals
#06. enums
#07. constants
#08. exported variables
#09. public variables
#10. private variables
#11. onready variables
#12. optional built-in virtual _init method
#13. built-in virtual _ready method
#14. remaining built-in virtual methods
#15. public methods
func _init( p_data_filename, p_data = null ):
.set_data( "item_filename", p_data_filename )
.set_data( "modified_values", {} )
var ref_data = Data.new()
ref_data.set_data( "name", .get_data( "item_filename" ) )
ref_data.load()
if ref_data and ref_data is Data:
self.data = ref_data
var modified_values = {}
for data_name in self.data.datas.keys():
if self.data and p_data and not self.data.get_data( data_name ) == p_data.get_data( data_name ):
modified_values[ data_name ] = p_data.get_data( data_name )
.set_data( "modified_values", modified_values )
func set_data( p_data_name, p_value ):
if not .get_data( "modified_values" ):
.set_data( "modified_values", {} )
var new_modified_value = .get_data( "modified_values" )
new_modified_value[ p_data_name ] = p_value
.set_data( "modified_values", new_modified_value )
func get_data( p_key, p_default_value = null ):
if .get_data( "modified_values" ) and p_key in .get_data( "modified_values" ):
return .get_data( "modified_values" )[ p_key ]
elif self.data:
return self.data.get_data( p_key, p_default_value )
return p_default_value
#func save( p_emplacement = "usr"):
# .save( p_emplacement )
#
#func load( p_path = null, p_emplacement = "usr" ):
# .load( p_path, p_emplacement )
#16. private methods