World.cs 878 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.IO;
  3. using Component;
  4. using Helper;
  5. using Log;
  6. using Logic;
  7. namespace World
  8. {
  9. public class World
  10. {
  11. private static readonly World instance = new World();
  12. private readonly LogicEntry logicEntry = LogicEntry.Instance;
  13. private readonly Config config = Config.Instance;
  14. public static World Instance
  15. {
  16. get
  17. {
  18. return instance;
  19. }
  20. }
  21. public void ReloadLogic()
  22. {
  23. this.logicEntry.Reload();
  24. }
  25. public void ReloadConfig()
  26. {
  27. this.config.Reload();
  28. }
  29. public void Enter(short opcode, byte[] content)
  30. {
  31. try
  32. {
  33. var messageEnv = new MessageEnv();
  34. messageEnv.Set(this);
  35. this.logicEntry.Enter(messageEnv, opcode, content);
  36. }
  37. catch (Exception e)
  38. {
  39. Logger.Trace("message handle error: {0}", e.Message);
  40. }
  41. }
  42. public Config Config
  43. {
  44. get
  45. {
  46. return this.config;
  47. }
  48. }
  49. }
  50. }