|
3 | 3 | using System.IO; |
4 | 4 | using System.Diagnostics; |
5 | 5 | using System.Collections.Generic; |
| 6 | +using System.Linq; |
6 | 7 | using Ecsact.Editor; |
7 | 8 |
|
| 9 | +#nullable enable |
| 10 | + |
8 | 11 | [System.Serializable] |
9 | 12 | struct MessageBase { |
10 | 13 | public string type; |
@@ -44,12 +47,13 @@ struct SuccessMessage { |
44 | 47 | struct ModuleMethodsMessage { |
45 | 48 | [System.Serializable] |
46 | 49 | public struct MethodInfo { |
| 50 | + public string method_name; |
47 | 51 | public bool available; |
48 | 52 | } |
49 | 53 |
|
50 | 54 | public const string type = "module_methods"; |
51 | 55 | public string module_name; |
52 | | - public Dictionary<string, MethodInfo> methods; |
| 56 | + public List<MethodInfo> methods; |
53 | 57 | } |
54 | 58 |
|
55 | 59 | [System.Serializable] |
@@ -284,12 +288,59 @@ private static void ReceiveMessage |
284 | 288 | UnityEngine.Debug.Log(message.content); |
285 | 289 | } |
286 | 290 |
|
| 291 | + private static void CheckMethods |
| 292 | + ( IEnumerable<string> methods |
| 293 | + , ModuleMethodsMessage message |
| 294 | + ) |
| 295 | + { |
| 296 | + var methodsList = methods.ToList(); |
| 297 | + |
| 298 | + foreach(var methodName in methods) { |
| 299 | + var methodInfoIndex = message.methods.FindIndex( |
| 300 | + v => v.method_name == methodName |
| 301 | + ); |
| 302 | + if(methodInfoIndex == -1) { |
| 303 | + UnityEngine.Debug.LogWarning( |
| 304 | + $"Old method '{methodName}' should be <color=red>removed</color> " + |
| 305 | + $"from module <b>{message.module_name}</b>. It no longer exists. " + |
| 306 | + "(reported by ecsact_rtb)" |
| 307 | + ); |
| 308 | + } |
| 309 | + } |
| 310 | + |
| 311 | + foreach(var methodInfo in message.methods) { |
| 312 | + var methodName = methodInfo.method_name; |
| 313 | + if(!methods.Contains(methodName)) { |
| 314 | + UnityEngine.Debug.LogWarning( |
| 315 | + $"New method '{methodName}' should be <color=green>added</color> " + |
| 316 | + $"to module <b>{message.module_name}</b>. (reported by ecsact_rtb)" |
| 317 | + ); |
| 318 | + } |
| 319 | + } |
| 320 | + } |
| 321 | + |
287 | 322 | private static void ReceiveMessage |
288 | 323 | ( int progressId |
289 | 324 | , ModuleMethodsMessage message |
290 | 325 | ) |
291 | 326 | { |
292 | | - |
| 327 | + switch(message.module_name) { |
| 328 | + case "core": |
| 329 | + CheckMethods(EcsactRuntime.Core.methods, message); |
| 330 | + break; |
| 331 | + case "dynamic": |
| 332 | + CheckMethods(EcsactRuntime.Dynamic.methods, message); |
| 333 | + break; |
| 334 | + case "meta": |
| 335 | + CheckMethods(EcsactRuntime.Meta.methods, message); |
| 336 | + break; |
| 337 | + case "static": |
| 338 | + CheckMethods(EcsactRuntime.Static.methods, message); |
| 339 | + break; |
| 340 | + case "serialize": |
| 341 | + CheckMethods(EcsactRuntime.Serialize.methods, message); |
| 342 | + break; |
| 343 | + } |
293 | 344 | } |
294 | 345 |
|
295 | 346 | private static void ReceiveMessage |
|
0 commit comments