com.xmobitea.changx.gn-unity 2.0.2 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (170) hide show
  1. package/Editor/GNServerSettingsEditor.cs +27 -23
  2. package/Runtime/Common/GNArray.cs +302 -302
  3. package/Runtime/Common/GNArray.cs.meta +11 -11
  4. package/Runtime/Common/GNData.cs +48 -48
  5. package/Runtime/Common/GNData.cs.meta +11 -11
  6. package/Runtime/Common/GNHashtable.cs +241 -241
  7. package/Runtime/Common/GNHashtable.cs.meta +11 -11
  8. package/Runtime/Common/IGNData.cs +11 -11
  9. package/Runtime/Common/IGNData.cs.meta +11 -11
  10. package/Runtime/Common.meta +8 -8
  11. package/Runtime/Config/GNServerSettings.cs.meta +11 -11
  12. package/Runtime/Config.meta +8 -8
  13. package/Runtime/Constant/Commands.cs.meta +11 -11
  14. package/Runtime/Constant/EnumType/FriendStatus.cs +12 -12
  15. package/Runtime/Constant/EnumType/FriendStatus.cs.meta +11 -11
  16. package/Runtime/Constant/EnumType/GoogleLoginType.cs.meta +11 -11
  17. package/Runtime/Constant/EnumType/GroupStatus.cs.meta +11 -11
  18. package/Runtime/Constant/EnumType/InvalidMemberType.cs +23 -23
  19. package/Runtime/Constant/EnumType/InvalidMemberType.cs.meta +11 -11
  20. package/Runtime/Constant/EnumType/ItemType.cs.meta +11 -11
  21. package/Runtime/Constant/EnumType/MatchmakingMemberStatus.cs.meta +11 -11
  22. package/Runtime/Constant/EnumType/MatchmakingTicketStatus.cs.meta +11 -11
  23. package/Runtime/Constant/EnumType/OwnerType.cs.meta +11 -11
  24. package/Runtime/Constant/EnumType/PermissionDataItem.cs +10 -10
  25. package/Runtime/Constant/EnumType/PermissionDataItem.cs.meta +11 -11
  26. package/Runtime/Constant/EnumType/RequestRole.cs +11 -11
  27. package/Runtime/Constant/EnumType/RequestRole.cs.meta +7 -7
  28. package/Runtime/Constant/EnumType/RequestType.cs +19 -19
  29. package/Runtime/Constant/EnumType/RequestType.cs.meta +11 -11
  30. package/Runtime/Constant/EnumType.meta +8 -8
  31. package/Runtime/Constant/ErrorCode/GNErrorCode.cs.meta +7 -7
  32. package/Runtime/Constant/ErrorCode.meta +8 -8
  33. package/Runtime/Constant/EventCode.cs +16 -16
  34. package/Runtime/Constant/EventCode.cs.meta +11 -11
  35. package/Runtime/Constant/OperationCode.cs.meta +11 -11
  36. package/Runtime/Constant/ParameterCode/GNParameterCode.cs.meta +11 -11
  37. package/Runtime/Constant/ParameterCode/ParameterCode.cs +12 -12
  38. package/Runtime/Constant/ParameterCode/ParameterCode.cs.meta +11 -11
  39. package/Runtime/Constant/ParameterCode.meta +8 -8
  40. package/Runtime/Constant/ReturnCode.cs +25 -25
  41. package/Runtime/Constant/ReturnCode.cs.meta +11 -11
  42. package/Runtime/Constant.meta +8 -8
  43. package/Runtime/Entity/DataMember.cs +124 -124
  44. package/Runtime/Entity/DataMember.cs.meta +11 -11
  45. package/Runtime/Entity/GNMetadata.cs +27 -27
  46. package/Runtime/Entity/GNMetadata.cs.meta +11 -11
  47. package/Runtime/Entity/InvalidMember.cs +33 -33
  48. package/Runtime/Entity/InvalidMember.cs.meta +11 -11
  49. package/Runtime/Entity/Models/AuthenticateModels.cs.meta +11 -11
  50. package/Runtime/Entity/Models/AuthenticateRequestModels.cs.meta +11 -11
  51. package/Runtime/Entity/Models/AuthenticateResponseModels.cs.meta +11 -11
  52. package/Runtime/Entity/Models/CharacterPlayerModels.cs.meta +11 -11
  53. package/Runtime/Entity/Models/CharacterPlayerRequestModels.cs.meta +11 -11
  54. package/Runtime/Entity/Models/CharacterPlayerResponseModels.cs.meta +11 -11
  55. package/Runtime/Entity/Models/ContentModels.cs.meta +11 -11
  56. package/Runtime/Entity/Models/ContentRequestModels.cs.meta +11 -11
  57. package/Runtime/Entity/Models/ContentResponseModels.cs.meta +11 -11
  58. package/Runtime/Entity/Models/DashboardModels.cs.meta +11 -11
  59. package/Runtime/Entity/Models/DashboardRequestModels.cs.meta +11 -11
  60. package/Runtime/Entity/Models/DashboardResponseModels.cs.meta +11 -11
  61. package/Runtime/Entity/Models/GamePlayerModels.cs.meta +11 -11
  62. package/Runtime/Entity/Models/GamePlayerRequestModels.cs.meta +11 -11
  63. package/Runtime/Entity/Models/GamePlayerResponseModels.cs.meta +11 -11
  64. package/Runtime/Entity/Models/GenericModels.cs.meta +11 -11
  65. package/Runtime/Entity/Models/GroupModels.cs.meta +11 -11
  66. package/Runtime/Entity/Models/GroupRequestModels.cs.meta +11 -11
  67. package/Runtime/Entity/Models/GroupResponseModels.cs.meta +11 -11
  68. package/Runtime/Entity/Models/InventoryModels.cs.meta +11 -11
  69. package/Runtime/Entity/Models/InventoryRequestModels.cs.meta +11 -11
  70. package/Runtime/Entity/Models/InventoryResponseModels.cs.meta +11 -11
  71. package/Runtime/Entity/Models/MasterPlayerModels.cs.meta +11 -11
  72. package/Runtime/Entity/Models/MasterPlayerRequestModels.cs.meta +11 -11
  73. package/Runtime/Entity/Models/MasterPlayerResponseModels.cs.meta +11 -11
  74. package/Runtime/Entity/Models/MultiplayerModels.cs.meta +11 -11
  75. package/Runtime/Entity/Models/MultiplayerRequestModels.cs.meta +11 -11
  76. package/Runtime/Entity/Models/MultiplayerResponseModels.cs +49 -49
  77. package/Runtime/Entity/Models/MultiplayerResponseModels.cs.meta +11 -11
  78. package/Runtime/Entity/Models/StoreInventoryModels.cs.meta +11 -11
  79. package/Runtime/Entity/Models/StoreInventoryRequestModels.cs.meta +11 -11
  80. package/Runtime/Entity/Models/StoreInventoryResponseModels.cs.meta +11 -11
  81. package/Runtime/Entity/Models.meta +8 -8
  82. package/Runtime/Entity/OperationEvent.cs +75 -75
  83. package/Runtime/Entity/OperationEvent.cs.meta +11 -11
  84. package/Runtime/Entity/OperationHelper.cs +35 -35
  85. package/Runtime/Entity/OperationHelper.cs.meta +11 -11
  86. package/Runtime/Entity/OperationRequest.cs +99 -99
  87. package/Runtime/Entity/OperationRequest.cs.meta +11 -11
  88. package/Runtime/Entity/OperationResponse.cs.meta +11 -11
  89. package/Runtime/Entity/Request/CustomOperationRequest.cs +61 -61
  90. package/Runtime/Entity/Request/CustomOperationRequest.cs.meta +11 -11
  91. package/Runtime/Entity/Request.meta +8 -8
  92. package/Runtime/Entity/Response/CustomOperationResponse.cs +63 -63
  93. package/Runtime/Entity/Response/CustomOperationResponse.cs.meta +11 -11
  94. package/Runtime/Entity/Response.meta +8 -8
  95. package/Runtime/Entity.meta +8 -8
  96. package/Runtime/GNNetwork.cs +182 -184
  97. package/Runtime/GNNetwork.cs.meta +11 -11
  98. package/Runtime/GNNetworkApi.cs +19 -26
  99. package/Runtime/GNNetworkApi.cs.meta +11 -11
  100. package/Runtime/GNNetworkAuthenticateApi.cs.meta +11 -11
  101. package/Runtime/GNNetworkCharacterPlayerApi.cs.meta +11 -11
  102. package/Runtime/GNNetworkContentApi.cs.meta +11 -11
  103. package/Runtime/GNNetworkDashboardApi.cs.meta +11 -11
  104. package/Runtime/GNNetworkGamePlayerApi.cs.meta +11 -11
  105. package/Runtime/GNNetworkGroupApi.cs.meta +11 -11
  106. package/Runtime/GNNetworkInventoryApi.cs.meta +11 -11
  107. package/Runtime/GNNetworkMasterPlayerApi.cs.meta +11 -11
  108. package/Runtime/GNNetworkMultiplayerApi.cs.meta +11 -11
  109. package/Runtime/GNNetworkStoreInventoryApi.cs.meta +11 -11
  110. package/Runtime/Helper/CodeHelper.cs +97 -97
  111. package/Runtime/Helper/CodeHelper.cs.meta +11 -11
  112. package/Runtime/Helper/ConverterService.cs +12 -41
  113. package/Runtime/Helper/ConverterService.cs.meta +11 -11
  114. package/Runtime/Helper/ParseGNHelper.cs +451 -451
  115. package/Runtime/Helper/ParseGNHelper.cs.meta +11 -11
  116. package/Runtime/Helper.meta +8 -8
  117. package/Runtime/Logger/GNDebug.cs +49 -49
  118. package/Runtime/Logger/GNDebug.cs.meta +11 -11
  119. package/Runtime/Logger.meta +8 -8
  120. package/Runtime/Networking/AuthenticateStatus.cs +35 -35
  121. package/Runtime/Networking/AuthenticateStatus.cs.meta +11 -11
  122. package/Runtime/Networking/Handler/IServerEventHandler.cs +25 -25
  123. package/Runtime/Networking/Handler/IServerEventHandler.cs.meta +11 -11
  124. package/Runtime/Networking/Handler/OnCharacterPlayerFriendUpdateEventHandler.cs +32 -32
  125. package/Runtime/Networking/Handler/OnCharacterPlayerFriendUpdateEventHandler.cs.meta +11 -11
  126. package/Runtime/Networking/Handler/OnCharacterPlayerGroupUpdateEventHandler.cs +33 -33
  127. package/Runtime/Networking/Handler/OnCharacterPlayerGroupUpdateEventHandler.cs.meta +11 -11
  128. package/Runtime/Networking/Handler/OnGamePlayerFriendUpdateEventHandler.cs +32 -32
  129. package/Runtime/Networking/Handler/OnGamePlayerFriendUpdateEventHandler.cs.meta +11 -11
  130. package/Runtime/Networking/Handler/OnGamePlayerGroupUpdateEventHandler.cs +32 -32
  131. package/Runtime/Networking/Handler/OnGamePlayerGroupUpdateEventHandler.cs.meta +11 -11
  132. package/Runtime/Networking/Handler/OnGroupMemberUpdateEventHandler.cs +29 -29
  133. package/Runtime/Networking/Handler/OnGroupMemberUpdateEventHandler.cs.meta +11 -11
  134. package/Runtime/Networking/Handler/OnGroupMessageUpdateEventHandler.cs +29 -29
  135. package/Runtime/Networking/Handler/OnGroupMessageUpdateEventHandler.cs.meta +11 -11
  136. package/Runtime/Networking/Handler.meta +8 -8
  137. package/Runtime/Networking/Http/HttpPeer.cs.meta +11 -11
  138. package/Runtime/Networking/Http/NetworkingHttpPeerBase.cs +25 -25
  139. package/Runtime/Networking/Http/NetworkingHttpPeerBase.cs.meta +11 -11
  140. package/Runtime/Networking/Http/NetworkingPeerHttpClientRequest.cs +486 -490
  141. package/Runtime/Networking/Http/NetworkingPeerHttpClientRequest.cs.meta +11 -11
  142. package/Runtime/Networking/Http/NetworkingPeerHttpRequest.cs +142 -142
  143. package/Runtime/Networking/Http/NetworkingPeerHttpRequest.cs.meta +11 -11
  144. package/Runtime/Networking/Http/NetworkingPeerUnityWebRequest.cs +188 -192
  145. package/Runtime/Networking/Http/NetworkingPeerUnityWebRequest.cs.meta +11 -11
  146. package/Runtime/Networking/Http.meta +8 -8
  147. package/Runtime/Networking/IPeer.cs +19 -19
  148. package/Runtime/Networking/IPeer.cs.meta +11 -11
  149. package/Runtime/Networking/NetworkingPeer.cs +144 -144
  150. package/Runtime/Networking/NetworkingPeer.cs.meta +11 -11
  151. package/Runtime/Networking/NetworkingPeerAPI.cs.meta +11 -11
  152. package/Runtime/Networking/OperationPending.cs +95 -95
  153. package/Runtime/Networking/OperationPending.cs.meta +11 -11
  154. package/Runtime/Networking/PeerBase.cs +242 -242
  155. package/Runtime/Networking/PeerBase.cs.meta +11 -11
  156. package/Runtime/Networking/Socket/NetworkingPeerSocketV2.cs +185 -183
  157. package/Runtime/Networking/Socket/NetworkingPeerSocketV2.cs.meta +11 -11
  158. package/Runtime/Networking/Socket/NetworkingPeerSocketV3.cs +177 -175
  159. package/Runtime/Networking/Socket/NetworkingPeerSocketV3.cs.meta +11 -11
  160. package/Runtime/Networking/Socket/NetworkingSocketPeerBase.cs.meta +11 -11
  161. package/Runtime/Networking/Socket/SocketPeer.cs +197 -191
  162. package/Runtime/Networking/Socket/SocketPeer.cs.meta +11 -11
  163. package/Runtime/Networking/Socket.meta +8 -8
  164. package/Runtime/Networking.meta +8 -8
  165. package/Runtime/Unity/ServiceUpdate.cs +20 -20
  166. package/Runtime/Unity/ServiceUpdate.cs.meta +11 -11
  167. package/Runtime/Unity.meta +8 -8
  168. package/Runtime/XmobiTea.GN.runtime.asmdef +16 -16
  169. package/Runtime/XmobiTea.GN.runtime.asmdef.meta +7 -7
  170. package/package.json +1 -1
@@ -1,302 +1,302 @@
1
- namespace XmobiTea.GN.Common
2
- {
3
- using System;
4
- using System.Collections.Generic;
5
- using System.Text;
6
-
7
- /// <summary>
8
- /// The GNData array, it store Array can be use to request or response
9
- /// </summary>
10
- public class GNArray : GNData
11
- {
12
- /// <summary>
13
- /// Builder for GNArray
14
- /// </summary>
15
- public class Builder
16
- {
17
- /// <summary>
18
- /// The origin array
19
- /// </summary>
20
- private List<object> array;
21
-
22
- /// <summary>
23
- /// Add a value to origin array
24
- /// </summary>
25
- /// <param name="value">The value type must is string, bool, number, Map or Array</param>
26
- /// <returns></returns>
27
- public Builder add(object value)
28
- {
29
- this.array.Add(value);
30
-
31
- return this;
32
- }
33
-
34
- /// <summary>
35
- /// Add some values to origin array
36
- /// </summary>
37
- /// <param name="list">The element value type must is type string, bool, number, Map or Array</param>
38
- /// <returns></returns>
39
- public Builder addAll(System.Collections.IList list)
40
- {
41
- foreach (var o in list)
42
- {
43
- this.add(o);
44
- }
45
-
46
- return this;
47
- }
48
-
49
- /// <summary>
50
- /// Build GNArray
51
- /// </summary>
52
- /// <returns></returns>
53
- public GNArray build()
54
- {
55
- var awnser = new GNArray();
56
-
57
- foreach (var o in this.array)
58
- {
59
- awnser.add(o);
60
- }
61
-
62
- return awnser;
63
- }
64
-
65
- /// <summary>
66
- /// Constructor for GNArray builder
67
- /// </summary>
68
- public Builder()
69
- {
70
- this.array = new List<object>();
71
- }
72
- }
73
-
74
- /// <summary>
75
- /// The GN array
76
- /// </summary>
77
- private List<object> array;
78
-
79
- /// <summary>
80
- /// The constructor for GNArray
81
- /// </summary>
82
- public GNArray()
83
- {
84
- this.array = new List<object>();
85
- }
86
-
87
- /// <summary>
88
- /// Add a value
89
- /// </summary>
90
- /// <param name="value">The </param>
91
- public void add(object value)
92
- {
93
- this.array.Add(GNData.createUseDataFromOriginData(value));
94
- }
95
-
96
- public ICollection<object> values()
97
- {
98
- return this.array;
99
- }
100
-
101
- public void clear()
102
- {
103
- this.array.Clear();
104
- }
105
-
106
- public bool remove(int index)
107
- {
108
- this.array.RemoveAt(index);
109
-
110
- return true;
111
- }
112
-
113
- public int count()
114
- {
115
- return this.array.Count;
116
- }
117
-
118
- protected object get<T>(int k, T defaultValue = default(T))
119
- {
120
- if (k < 0 || k > this.array.Count - 1) return defaultValue;
121
-
122
- var value = this.array[k];
123
-
124
- if (value == null) return defaultValue;
125
-
126
- if (value is T t)
127
- {
128
- return t;
129
- }
130
-
131
- return value;
132
- }
133
-
134
- public T[] toArray<T>()
135
- {
136
- var answer = new T[this.array.Count];
137
-
138
- for (var i = 0; i < this.array.Count; i++)
139
- {
140
- answer[i] = (T)this.customGet(i);
141
- }
142
-
143
- return answer;
144
- }
145
-
146
- public IList<T> toList<T>()
147
- {
148
- var answer = new List<T>();
149
-
150
- for (var i = 0; i < this.array.Count; i++)
151
- {
152
- answer.Add((T)this.customGet(i));
153
- }
154
-
155
- return answer;
156
- }
157
-
158
- private object customGet(int k)
159
- {
160
- var obj = this.get<object>(k);
161
- if (obj == null) return null;
162
-
163
- var objType = obj.GetType();
164
- if (objType == typeof(byte)) return this.getByte(k);
165
- else if (objType == typeof(sbyte)) return this.getSByte(k);
166
- else if (objType == typeof(short)) return this.getShort(k);
167
- else if (objType == typeof(int)) return this.getInt(k);
168
- else if (objType == typeof(float)) return this.getFloat(k);
169
- else if (objType == typeof(long)) return this.getLong(k);
170
- else if (objType == typeof(double)) return this.getDouble(k);
171
- else if (objType == typeof(bool)) return this.getBool(k);
172
- else if (objType == typeof(string)) return this.getString(k);
173
- else if (objType == typeof(GNArray) || objType == typeof(System.Collections.IList)) return this.getGNArray(k);
174
- else if (objType == typeof(GNHashtable) || objType == typeof(System.Collections.IDictionary)) return this.getGNHashtable(k);
175
-
176
- return obj;
177
- }
178
-
179
- public byte getByte(int k, byte defaultValue = 0)
180
- {
181
- return Convert.ToByte(this.get(k, defaultValue));
182
- }
183
-
184
- public sbyte getSByte(int k, sbyte defaultValue = 0)
185
- {
186
- return Convert.ToSByte(this.get(k, defaultValue));
187
- }
188
-
189
- public short getShort(int k, short defaultValue = 0)
190
- {
191
- return Convert.ToInt16(this.get(k, defaultValue));
192
- }
193
-
194
- public int getInt(int k, int defaultValue = 0)
195
- {
196
- return Convert.ToInt32(this.get(k, defaultValue));
197
- }
198
-
199
- public float getFloat(int k, float defaultValue = 0)
200
- {
201
- return Convert.ToSingle(this.get(k, defaultValue));
202
- }
203
-
204
- public long getLong(int k, long defaultValue = 0)
205
- {
206
- return Convert.ToInt64(this.get(k, defaultValue));
207
- }
208
-
209
- public double getDouble(int k, double defaultValue = 0)
210
- {
211
- return Convert.ToDouble(this.get(k, defaultValue));
212
- }
213
-
214
- public bool getBool(int k, bool defaultValue = false)
215
- {
216
- return Convert.ToBoolean(this.get(k, defaultValue));
217
- }
218
-
219
- public string getString(int k, string defaultValue = null)
220
- {
221
- return Convert.ToString(this.get(k, defaultValue));
222
- }
223
-
224
- public object getObject(int k, object defaultValue = null)
225
- {
226
- return this.get(k, defaultValue);
227
- }
228
-
229
- public T[] getArray<T>(int k, T[] defaultValue = null)
230
- {
231
- var value0 = this.getGNArray(k);
232
- if (value0 != null)
233
- {
234
- return value0.toArray<T>();
235
- }
236
-
237
- return defaultValue;
238
- }
239
-
240
- public IList<T> getList<T>(int k, IList<T> defaultValue = null)
241
- {
242
- var value0 = this.getGNArray(k);
243
- if (value0 != null)
244
- {
245
- return value0.toList<T>();
246
- }
247
-
248
- return defaultValue;
249
- }
250
-
251
- public GNArray getGNArray(int k, GNArray defaultValue = null)
252
- {
253
- return (GNArray)this.get(k, defaultValue);
254
- }
255
-
256
- public GNHashtable getGNHashtable(int k, GNHashtable defaultValue = null)
257
- {
258
- return (GNHashtable)this.get(k, defaultValue);
259
- }
260
-
261
- public override object toData()
262
- {
263
- var answer = new List<object>();
264
-
265
- foreach (var c in this.array)
266
- {
267
- answer.Add(GNData.createDataFromUseData(c));
268
- }
269
-
270
- return answer;
271
- }
272
-
273
- public override string toString()
274
- {
275
- var stringBuilder = new StringBuilder();
276
- stringBuilder.Append("[");
277
-
278
- for (var i = 0; i < this.array.Count; i++)
279
- {
280
- if (i != 0) stringBuilder.Append(",");
281
-
282
- var value = this.array[i];
283
-
284
- if (value == null) stringBuilder.Append("null");
285
- else if (value is GNData gnData) stringBuilder.Append(gnData.ToString());
286
- else if (value is string valueStr) stringBuilder.Append("\"" + valueStr + "\"");
287
- else if (value is bool boolValue) stringBuilder.Append(boolValue.ToString().ToLower());
288
- else stringBuilder.Append(value);
289
- }
290
-
291
- stringBuilder.Append("]");
292
- return stringBuilder.ToString();
293
- }
294
-
295
- public override string ToString()
296
- {
297
- return this.toString();
298
- }
299
-
300
- }
301
-
302
- }
1
+ namespace XmobiTea.GN.Common
2
+ {
3
+ using System;
4
+ using System.Collections.Generic;
5
+ using System.Text;
6
+
7
+ /// <summary>
8
+ /// The GNData array, it store Array can be use to request or response
9
+ /// </summary>
10
+ public class GNArray : GNData
11
+ {
12
+ /// <summary>
13
+ /// Builder for GNArray
14
+ /// </summary>
15
+ public class Builder
16
+ {
17
+ /// <summary>
18
+ /// The origin array
19
+ /// </summary>
20
+ private List<object> array;
21
+
22
+ /// <summary>
23
+ /// Add a value to origin array
24
+ /// </summary>
25
+ /// <param name="value">The value type must is string, bool, number, Map or Array</param>
26
+ /// <returns></returns>
27
+ public Builder add(object value)
28
+ {
29
+ this.array.Add(value);
30
+
31
+ return this;
32
+ }
33
+
34
+ /// <summary>
35
+ /// Add some values to origin array
36
+ /// </summary>
37
+ /// <param name="list">The element value type must is type string, bool, number, Map or Array</param>
38
+ /// <returns></returns>
39
+ public Builder addAll(System.Collections.IList list)
40
+ {
41
+ foreach (var o in list)
42
+ {
43
+ this.add(o);
44
+ }
45
+
46
+ return this;
47
+ }
48
+
49
+ /// <summary>
50
+ /// Build GNArray
51
+ /// </summary>
52
+ /// <returns></returns>
53
+ public GNArray build()
54
+ {
55
+ var awnser = new GNArray();
56
+
57
+ foreach (var o in this.array)
58
+ {
59
+ awnser.add(o);
60
+ }
61
+
62
+ return awnser;
63
+ }
64
+
65
+ /// <summary>
66
+ /// Constructor for GNArray builder
67
+ /// </summary>
68
+ public Builder()
69
+ {
70
+ this.array = new List<object>();
71
+ }
72
+ }
73
+
74
+ /// <summary>
75
+ /// The GN array
76
+ /// </summary>
77
+ private List<object> array;
78
+
79
+ /// <summary>
80
+ /// The constructor for GNArray
81
+ /// </summary>
82
+ public GNArray()
83
+ {
84
+ this.array = new List<object>();
85
+ }
86
+
87
+ /// <summary>
88
+ /// Add a value
89
+ /// </summary>
90
+ /// <param name="value">The </param>
91
+ public void add(object value)
92
+ {
93
+ this.array.Add(GNData.createUseDataFromOriginData(value));
94
+ }
95
+
96
+ public ICollection<object> values()
97
+ {
98
+ return this.array;
99
+ }
100
+
101
+ public void clear()
102
+ {
103
+ this.array.Clear();
104
+ }
105
+
106
+ public bool remove(int index)
107
+ {
108
+ this.array.RemoveAt(index);
109
+
110
+ return true;
111
+ }
112
+
113
+ public int count()
114
+ {
115
+ return this.array.Count;
116
+ }
117
+
118
+ protected object get<T>(int k, T defaultValue = default(T))
119
+ {
120
+ if (k < 0 || k > this.array.Count - 1) return defaultValue;
121
+
122
+ var value = this.array[k];
123
+
124
+ if (value == null) return defaultValue;
125
+
126
+ if (value is T t)
127
+ {
128
+ return t;
129
+ }
130
+
131
+ return value;
132
+ }
133
+
134
+ public T[] toArray<T>()
135
+ {
136
+ var answer = new T[this.array.Count];
137
+
138
+ for (var i = 0; i < this.array.Count; i++)
139
+ {
140
+ answer[i] = (T)this.customGet(i);
141
+ }
142
+
143
+ return answer;
144
+ }
145
+
146
+ public IList<T> toList<T>()
147
+ {
148
+ var answer = new List<T>();
149
+
150
+ for (var i = 0; i < this.array.Count; i++)
151
+ {
152
+ answer.Add((T)this.customGet(i));
153
+ }
154
+
155
+ return answer;
156
+ }
157
+
158
+ private object customGet(int k)
159
+ {
160
+ var obj = this.get<object>(k);
161
+ if (obj == null) return null;
162
+
163
+ var objType = obj.GetType();
164
+ if (objType == typeof(byte)) return this.getByte(k);
165
+ else if (objType == typeof(sbyte)) return this.getSByte(k);
166
+ else if (objType == typeof(short)) return this.getShort(k);
167
+ else if (objType == typeof(int)) return this.getInt(k);
168
+ else if (objType == typeof(float)) return this.getFloat(k);
169
+ else if (objType == typeof(long)) return this.getLong(k);
170
+ else if (objType == typeof(double)) return this.getDouble(k);
171
+ else if (objType == typeof(bool)) return this.getBool(k);
172
+ else if (objType == typeof(string)) return this.getString(k);
173
+ else if (objType == typeof(GNArray) || objType == typeof(System.Collections.IList)) return this.getGNArray(k);
174
+ else if (objType == typeof(GNHashtable) || objType == typeof(System.Collections.IDictionary)) return this.getGNHashtable(k);
175
+
176
+ return obj;
177
+ }
178
+
179
+ public byte getByte(int k, byte defaultValue = 0)
180
+ {
181
+ return Convert.ToByte(this.get(k, defaultValue));
182
+ }
183
+
184
+ public sbyte getSByte(int k, sbyte defaultValue = 0)
185
+ {
186
+ return Convert.ToSByte(this.get(k, defaultValue));
187
+ }
188
+
189
+ public short getShort(int k, short defaultValue = 0)
190
+ {
191
+ return Convert.ToInt16(this.get(k, defaultValue));
192
+ }
193
+
194
+ public int getInt(int k, int defaultValue = 0)
195
+ {
196
+ return Convert.ToInt32(this.get(k, defaultValue));
197
+ }
198
+
199
+ public float getFloat(int k, float defaultValue = 0)
200
+ {
201
+ return Convert.ToSingle(this.get(k, defaultValue));
202
+ }
203
+
204
+ public long getLong(int k, long defaultValue = 0)
205
+ {
206
+ return Convert.ToInt64(this.get(k, defaultValue));
207
+ }
208
+
209
+ public double getDouble(int k, double defaultValue = 0)
210
+ {
211
+ return Convert.ToDouble(this.get(k, defaultValue));
212
+ }
213
+
214
+ public bool getBool(int k, bool defaultValue = false)
215
+ {
216
+ return Convert.ToBoolean(this.get(k, defaultValue));
217
+ }
218
+
219
+ public string getString(int k, string defaultValue = null)
220
+ {
221
+ return Convert.ToString(this.get(k, defaultValue));
222
+ }
223
+
224
+ public object getObject(int k, object defaultValue = null)
225
+ {
226
+ return this.get(k, defaultValue);
227
+ }
228
+
229
+ public T[] getArray<T>(int k, T[] defaultValue = null)
230
+ {
231
+ var value0 = this.getGNArray(k);
232
+ if (value0 != null)
233
+ {
234
+ return value0.toArray<T>();
235
+ }
236
+
237
+ return defaultValue;
238
+ }
239
+
240
+ public IList<T> getList<T>(int k, IList<T> defaultValue = null)
241
+ {
242
+ var value0 = this.getGNArray(k);
243
+ if (value0 != null)
244
+ {
245
+ return value0.toList<T>();
246
+ }
247
+
248
+ return defaultValue;
249
+ }
250
+
251
+ public GNArray getGNArray(int k, GNArray defaultValue = null)
252
+ {
253
+ return (GNArray)this.get(k, defaultValue);
254
+ }
255
+
256
+ public GNHashtable getGNHashtable(int k, GNHashtable defaultValue = null)
257
+ {
258
+ return (GNHashtable)this.get(k, defaultValue);
259
+ }
260
+
261
+ public override object toData()
262
+ {
263
+ var answer = new List<object>();
264
+
265
+ foreach (var c in this.array)
266
+ {
267
+ answer.Add(GNData.createDataFromUseData(c));
268
+ }
269
+
270
+ return answer;
271
+ }
272
+
273
+ public override string toString()
274
+ {
275
+ var stringBuilder = new StringBuilder();
276
+ stringBuilder.Append("[");
277
+
278
+ for (var i = 0; i < this.array.Count; i++)
279
+ {
280
+ if (i != 0) stringBuilder.Append(",");
281
+
282
+ var value = this.array[i];
283
+
284
+ if (value == null) stringBuilder.Append("null");
285
+ else if (value is GNData gnData) stringBuilder.Append(gnData.ToString());
286
+ else if (value is string valueStr) stringBuilder.Append("\"" + valueStr + "\"");
287
+ else if (value is bool boolValue) stringBuilder.Append(boolValue.ToString().ToLower());
288
+ else stringBuilder.Append(value);
289
+ }
290
+
291
+ stringBuilder.Append("]");
292
+ return stringBuilder.ToString();
293
+ }
294
+
295
+ public override string ToString()
296
+ {
297
+ return this.toString();
298
+ }
299
+
300
+ }
301
+
302
+ }
@@ -1,11 +1,11 @@
1
- fileFormatVersion: 2
2
- guid: 27cc30db333c3d445b91909cb283a935
3
- MonoImporter:
4
- externalObjects: {}
5
- serializedVersion: 2
6
- defaultReferences: []
7
- executionOrder: 0
8
- icon: {instanceID: 0}
9
- userData:
10
- assetBundleName:
11
- assetBundleVariant:
1
+ fileFormatVersion: 2
2
+ guid: 27cc30db333c3d445b91909cb283a935
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant: