You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
143 lines
4.7 KiB
143 lines
4.7 KiB
3 years ago
|
using System.Collections.Generic;
|
||
|
using System.ComponentModel;
|
||
|
using System.Net;
|
||
|
|
||
|
namespace ET
|
||
|
{
|
||
|
public partial class StartSceneConfigCategory
|
||
|
{
|
||
|
public MultiMap<int, StartSceneConfig> Gates = new MultiMap<int, StartSceneConfig>();
|
||
|
|
||
|
public Dictionary<int, StartSceneConfig> Realms = new Dictionary<int, StartSceneConfig>();
|
||
|
|
||
|
public MultiMap<int, StartSceneConfig> ProcessScenes = new MultiMap<int, StartSceneConfig>();
|
||
|
|
||
|
public Dictionary<long, Dictionary<string, StartSceneConfig>> ZoneScenesByName = new Dictionary<long, Dictionary<string, StartSceneConfig>>();
|
||
|
|
||
|
public StartSceneConfig LocationConfig;
|
||
|
|
||
|
public StartSceneConfig LoginCenterConfig;
|
||
|
|
||
|
public List<StartSceneConfig> Robots = new List<StartSceneConfig>();
|
||
|
|
||
|
public Dictionary<int, StartSceneConfig> UnitCaches = new Dictionary<int, StartSceneConfig>();
|
||
|
|
||
|
public List<StartSceneConfig> GetByProcess(int process)
|
||
|
{
|
||
|
return this.ProcessScenes[process];
|
||
|
}
|
||
|
|
||
|
public StartSceneConfig GetBySceneName(int zone, string name)
|
||
|
{
|
||
|
return this.ZoneScenesByName[zone][name];
|
||
|
}
|
||
|
|
||
|
public StartSceneConfig GetUnitCacheConfig(long unitId)
|
||
|
{
|
||
|
int zone = UnitIdStruct.GetUnitZone(unitId);
|
||
|
return this.UnitCaches[zone];
|
||
|
}
|
||
|
|
||
|
public override void AfterEndInit()
|
||
|
{
|
||
|
foreach (StartSceneConfig startSceneConfig in this.GetAll().Values)
|
||
|
{
|
||
|
this.ProcessScenes.Add(startSceneConfig.Process, startSceneConfig);
|
||
|
|
||
|
if (!this.ZoneScenesByName.ContainsKey(startSceneConfig.Zone))
|
||
|
{
|
||
|
this.ZoneScenesByName.Add(startSceneConfig.Zone, new Dictionary<string, StartSceneConfig>());
|
||
|
}
|
||
|
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;
|
||
|
case SceneType.Robot:
|
||
|
this.Robots.Add(startSceneConfig);
|
||
|
break;
|
||
|
case SceneType.Realm:
|
||
|
this.Realms.Add(startSceneConfig.Zone, startSceneConfig);
|
||
|
break;
|
||
|
case SceneType.LoginCenter:
|
||
|
this.LoginCenterConfig = startSceneConfig;
|
||
|
break;
|
||
|
case SceneType.UnitCache:
|
||
|
this.UnitCaches.Add(startSceneConfig.Zone, startSceneConfig);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public partial class StartSceneConfig: ISupportInitialize
|
||
|
{
|
||
|
public long InstanceId;
|
||
|
|
||
|
public SceneType Type;
|
||
|
|
||
|
public StartProcessConfig StartProcessConfig
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return StartProcessConfigCategory.Instance.Get(this.Process);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public StartZoneConfig StartZoneConfig
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
return StartZoneConfigCategory.Instance.Get(this.Zone);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// 内网地址外网端口,通过防火墙映射端口过来
|
||
|
private IPEndPoint innerIPOutPort;
|
||
|
|
||
|
public IPEndPoint InnerIPOutPort
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (innerIPOutPort == null)
|
||
|
{
|
||
|
this.innerIPOutPort = NetworkHelper.ToIPEndPoint($"{this.StartProcessConfig.InnerIP}:{this.OuterPort}");
|
||
|
}
|
||
|
|
||
|
return this.innerIPOutPort;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private IPEndPoint outerIPPort;
|
||
|
|
||
|
// 外网地址外网端口
|
||
|
public IPEndPoint OuterIPPort
|
||
|
{
|
||
|
get
|
||
|
{
|
||
|
if (this.outerIPPort == null)
|
||
|
{
|
||
|
this.outerIPPort = NetworkHelper.ToIPEndPoint($"{this.StartProcessConfig.OuterIP}:{this.OuterPort}");
|
||
|
}
|
||
|
|
||
|
return this.outerIPPort;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public override void BeginInit()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
public override void EndInit()
|
||
|
{
|
||
|
this.Type = EnumHelper.FromString<SceneType>(this.SceneType);
|
||
|
InstanceIdStruct instanceIdStruct = new InstanceIdStruct(this.Process, (uint) this.Id);
|
||
|
this.InstanceId = instanceIdStruct.ToLong();
|
||
|
}
|
||
|
}
|
||
|
}
|