using System.Collections.Generic; using System.ComponentModel; using System.Net; namespace ET { public partial class StartSceneConfigCategory { public MultiMap Gates = new MultiMap(); public MultiMap ProcessScenes = new MultiMap(); public Dictionary> ZoneScenesByName = new Dictionary>(); public StartSceneConfig LocationConfig; public List GetByProcess(int process) { return this.ProcessScenes[process]; } public StartSceneConfig GetBySceneName(int zone, string name) { return this.ZoneScenesByName[zone][name]; } public override void EndInit() { foreach (StartSceneConfig startSceneConfig in this.GetAll()) { this.ProcessScenes.Add(startSceneConfig.Process, startSceneConfig); if (!this.ZoneScenesByName.ContainsKey(startSceneConfig.Zone)) { this.ZoneScenesByName.Add(startSceneConfig.Zone, new Dictionary()); } this.ZoneScenesByName[startSceneConfig.Zone].Add(startSceneConfig.Name, startSceneConfig); switch (startSceneConfig.Type) { case SceneType.Gate: this.Gates.Add(startSceneConfig.Zone, startSceneConfig); break; case SceneType.Location: this.LocationConfig = startSceneConfig; break; } } } } public partial class StartSceneConfig : ISupportInitialize { public long SceneId; public SceneType Type; public StartProcessConfig StartProcessConfig { get { return StartProcessConfigCategory.Instance.Get(this.Process); } } public StartZoneConfig StartZoneConfig { get { return StartZoneConfigCategory.Instance.Get(this.Zone); } } private string outerAddress; public string OuterAddress { get { if (this.outerAddress == null) { this.outerAddress = $"{this.StartProcessConfig.OuterIP}:{this.OuterPort}"; } return this.outerAddress; } } private IPEndPoint innerOuterAddress; public IPEndPoint InnerOuterAddress { get { if (this.innerOuterAddress == null) { this.innerOuterAddress = NetworkHelper.ToIPEndPoint($"{this.StartProcessConfig.InnerIP}:{this.OuterPort}"); } return this.innerOuterAddress; } } public void BeginInit() { } public void EndInit() { this.Type = EnumHelper.FromString(this.SceneType); InstanceIdStruct instanceIdStruct = new InstanceIdStruct(this.Process, (uint)this.Id); this.SceneId = instanceIdStruct.ToLong(); } } }