Init.cs 980 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. using Model;
  3. namespace Hotfix
  4. {
  5. public static class Init
  6. {
  7. private static void Start()
  8. {
  9. try
  10. {
  11. Hotfix.Scene.ModelScene = Game.Scene;
  12. Hotfix.Scene.ModelScene.AddComponent<OpcodeTypeComponent>();
  13. Hotfix.Scene.ModelScene.AddComponent<Model.MessageDispatherComponent>();
  14. Hotfix.Scene.ModelScene.AddComponent<NetOuterComponent>();
  15. Hotfix.Scene.ModelScene.AddComponent<ResourcesComponent>();
  16. Hotfix.Scene.ModelScene.AddComponent<BehaviorTreeComponent>();
  17. Hotfix.Scene.AddComponent<UIComponent>();
  18. Hotfix.Scene.AddComponent<UnitComponent>();
  19. Hotfix.Scene.GetComponent<EventComponent>().Run(EventIdType.InitSceneStart);
  20. }
  21. catch (Exception e)
  22. {
  23. Log.Error(e.ToString());
  24. }
  25. }
  26. private static void Update()
  27. {
  28. try
  29. {
  30. ObjectEvents.Instance.Update();
  31. }
  32. catch (Exception e)
  33. {
  34. Log.Error(e.ToString());
  35. }
  36. }
  37. private static void OnApplicationQuit()
  38. {
  39. Hotfix.Close();
  40. }
  41. }
  42. }