Program.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using AtomicEngine;
  3. // net genproject C:\Dev\atomic\AtomicGameEngine\Script\AtomicNET\AtomicNETProject.json WINDOWS
  4. // net parse C:\Dev\atomic\AtomicGameEngine\Artifacts\AtomicNET\Build\AtomicNETService\bin\Debug\AtomicNETService.exe
  5. // net compile C:\Dev\atomic\AtomicGameEngine\Artifacts\AtomicNET\Build\AtomicNET.sln
  6. namespace AtomicTools
  7. {
  8. public class Program
  9. {
  10. public static void Main(string[] args)
  11. {
  12. // create the service
  13. var app = NETServiceApplication.Create();
  14. // Subscribe to IPC NET commands
  15. app.SubscribeToEvent("IPCCmd", (eventType, eventData) =>
  16. {
  17. // get the command
  18. string command = eventData["command"];
  19. switch (command)
  20. {
  21. // parse assembly for component information
  22. case "parse":
  23. // Get the assembly to parse
  24. string assemblyPath = eventData["assemblyPath"];
  25. // Inspect the assembly for components
  26. var assemblyJSON = AtomicTools.InspectAssembly(assemblyPath);
  27. // Return result
  28. var vmap = new ScriptVariantMap();
  29. // FIXME: update index operator to a generic
  30. vmap.SetUInt("id", eventData.GetUInt("id"));
  31. vmap["command"] = command;
  32. vmap["result"] = assemblyJSON;
  33. AtomicNET.GetSubsystem<IPC>().SendEventToBroker("IPCCmdResult", vmap);
  34. break;
  35. // exit service
  36. case "exit":
  37. app.SendEvent("ExitRequested");
  38. break;
  39. }
  40. });
  41. // Managed code in charge of main loop
  42. while (app.RunFrame())
  43. {
  44. }
  45. // Shut 'er down
  46. app.Shutdown();
  47. }
  48. }
  49. }