StartSceneConfig.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using System.Collections.Generic;
  2. using System.ComponentModel;
  3. namespace ET
  4. {
  5. public partial class StartSceneConfigCategory
  6. {
  7. public MultiMap<int, StartSceneConfig> Gates = new MultiMap<int, StartSceneConfig>();
  8. public MultiMap<int, StartSceneConfig> ProcessScenes = new MultiMap<int, StartSceneConfig>();
  9. public Dictionary<long, Dictionary<string, StartSceneConfig>> ZoneScenesByName = new Dictionary<long, Dictionary<string, StartSceneConfig>>();
  10. public StartSceneConfig LocationConfig;
  11. public List<StartSceneConfig> GetByProcess(int process)
  12. {
  13. return this.ProcessScenes[process];
  14. }
  15. public StartSceneConfig GetBySceneName(int zone, string name)
  16. {
  17. return this.ZoneScenesByName[zone][name];
  18. }
  19. public override void EndInit()
  20. {
  21. foreach (StartSceneConfig startSceneConfig in this.GetAll().Values)
  22. {
  23. this.ProcessScenes.Add(startSceneConfig.Process, startSceneConfig);
  24. if (!this.ZoneScenesByName.ContainsKey(startSceneConfig.Zone))
  25. {
  26. this.ZoneScenesByName.Add(startSceneConfig.Zone, new Dictionary<string, StartSceneConfig>());
  27. }
  28. this.ZoneScenesByName[startSceneConfig.Zone].Add(startSceneConfig.Name, startSceneConfig);
  29. switch (startSceneConfig.Type)
  30. {
  31. case SceneType.Gate:
  32. this.Gates.Add(startSceneConfig.Zone, startSceneConfig);
  33. break;
  34. case SceneType.Location:
  35. this.LocationConfig = startSceneConfig;
  36. break;
  37. }
  38. }
  39. }
  40. }
  41. public partial class StartSceneConfig: ISupportInitialize
  42. {
  43. public long SceneId;
  44. public SceneType Type;
  45. public StartProcessConfig StartProcessConfig
  46. {
  47. get
  48. {
  49. return StartProcessConfigCategory.Instance.Get(this.Process);
  50. }
  51. }
  52. public StartZoneConfig StartZoneConfig
  53. {
  54. get
  55. {
  56. return StartZoneConfigCategory.Instance.Get(this.Process);
  57. }
  58. }
  59. private string outerAddress;
  60. public string OuterAddress
  61. {
  62. get
  63. {
  64. if (this.outerAddress == null)
  65. {
  66. this.outerAddress = $"{this.StartProcessConfig.OuterIP}:{this.OuterPort}";
  67. }
  68. return this.outerAddress;
  69. }
  70. }
  71. private string innerOuterAddress;
  72. public string InnerOuterAddress
  73. {
  74. get
  75. {
  76. if (this.innerOuterAddress == null)
  77. {
  78. this.innerOuterAddress = $"{this.StartProcessConfig.InnerAddress}:{this.OuterPort}";
  79. }
  80. return this.innerOuterAddress;
  81. }
  82. }
  83. public void BeginInit()
  84. {
  85. }
  86. public void EndInit()
  87. {
  88. this.Type = EnumHelper.FromString<SceneType>(this.SceneType);
  89. InstanceIdStruct instanceIdStruct = new InstanceIdStruct(this.Process, (uint) this.Id);
  90. this.SceneId = instanceIdStruct.ToLong();
  91. }
  92. }
  93. }