@@ -58,13 +58,14 @@ class FirebaseTypeConverter extends RefCounted:
58
58
"nullValue" : _to_null ,
59
59
"booleanValue" : _to_bool ,
60
60
"integerValue" : _to_int ,
61
- "doubleValue" : _to_float
61
+ "doubleValue" : _to_float ,
62
+ "vector2Value" : _to_vector2 ,
63
+ "vector2iValue" : _to_vector2i
62
64
}
63
65
64
66
func convert_value (type , value ):
65
67
if converters .has (type ):
66
68
return converters [type ].call (value )
67
-
68
69
return value
69
70
70
71
func _to_null (value ):
@@ -78,6 +79,12 @@ class FirebaseTypeConverter extends RefCounted:
78
79
79
80
func _to_float (value ):
80
81
return float (value )
82
+
83
+ func _to_vector2 (value ):
84
+ return type_convert (value , TYPE_VECTOR2 )
85
+
86
+ func _to_vector2i (value ):
87
+ return type_convert (value , TYPE_VECTOR2I )
81
88
82
89
static func from_firebase_type (value ):
83
90
if value == null :
@@ -91,7 +98,13 @@ static func from_firebase_type(value):
91
98
value = Time .get_datetime_dict_from_datetime_string (value .values ()[0 ], false )
92
99
else :
93
100
var converter = FirebaseTypeConverter .new ()
94
- value = converter .convert_value (value .keys ()[0 ], value .values ()[0 ])
101
+ var type : String = value .keys ()[0 ]
102
+ value = value .values ()[0 ]
103
+ if type == "stringValue" :
104
+ var split_type : String = value .split ("(" )[0 ]
105
+ if split_type in [ "Vector2" , "Vector2i" ]:
106
+ type = "{0} Value" .format ([split_type .to_lower ()])
107
+ value = converter .convert_value (type , value )
95
108
96
109
return value
97
110
@@ -115,7 +128,10 @@ static func to_firebase_type(value : Variant) -> Dictionary:
115
128
TYPE_ARRAY :
116
129
var_type = "arrayValue"
117
130
value = {"values" : array2fields (value )}
118
-
131
+ TYPE_VECTOR2 , TYPE_VECTOR2I :
132
+ var_type = "stringValue"
133
+ value = var_to_str (value )
134
+
119
135
return { var_type : value }
120
136
121
137
# Pass the .fields inside a Firestore Document to print out the Dictionary { 'key' : 'value' }
@@ -343,4 +359,4 @@ class AwaitDetachable extends Node2D:
343
359
func _init (freeable_node , await_signal : Signal ) -> void :
344
360
awaiter = await_signal
345
361
add_child (freeable_node )
346
- awaiter .connect (queue_free )
362
+ awaiter .connect (queue_free )
0 commit comments