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.
74 lines
3.2 KiB
74 lines
3.2 KiB
3 years ago
|
using System;
|
||
|
using System.Net;
|
||
|
|
||
|
namespace ET
|
||
|
{
|
||
|
public class AppStart_Init: AEvent<EventType.AppStart>
|
||
|
{
|
||
|
protected override void Run(EventType.AppStart args)
|
||
|
{
|
||
|
RunAsync(args).Coroutine();
|
||
|
}
|
||
|
|
||
|
private async ETTask RunAsync(EventType.AppStart args)
|
||
|
{
|
||
|
Game.Scene.AddComponent<ConfigComponent>();
|
||
|
await ConfigComponent.Instance.LoadAsync();
|
||
|
|
||
|
StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(Game.Options.Process);
|
||
|
|
||
|
Game.Scene.AddComponent<TimerComponent>();
|
||
|
Game.Scene.AddComponent<OpcodeTypeComponent>();
|
||
|
Game.Scene.AddComponent<MessageDispatcherComponent>();
|
||
|
Game.Scene.AddComponent<SessionStreamDispatcher>();
|
||
|
Game.Scene.AddComponent<CoroutineLockComponent>();
|
||
|
// 发送普通actor消息
|
||
|
Game.Scene.AddComponent<ActorMessageSenderComponent>();
|
||
|
// 发送location actor消息
|
||
|
Game.Scene.AddComponent<ActorLocationSenderComponent>();
|
||
|
// 访问location server的组件
|
||
|
Game.Scene.AddComponent<LocationProxyComponent>();
|
||
|
Game.Scene.AddComponent<ActorMessageDispatcherComponent>();
|
||
|
// 数值订阅组件
|
||
|
Game.Scene.AddComponent<NumericWatcherComponent>();
|
||
|
|
||
|
Game.Scene.AddComponent<NetThreadComponent>();
|
||
|
|
||
|
Game.Scene.AddComponent<NavmeshComponent, Func<string, byte[]>>(RecastFileReader.Read);
|
||
|
Game.Scene.AddComponent<DBManagerComponent>();
|
||
|
//Game.Scene.AddComponent<HttpComponent,string>("http://127.0.0.1:10086/");
|
||
|
|
||
|
switch (Game.Options.AppType)
|
||
|
{
|
||
|
case AppType.Server:
|
||
|
{
|
||
|
Game.Scene.AddComponent<NetInnerComponent, IPEndPoint, int>(processConfig.InnerIPPort, SessionStreamDispatcherType.SessionStreamDispatcherServerInner);
|
||
|
|
||
|
var processScenes = StartSceneConfigCategory.Instance.GetByProcess(Game.Options.Process);
|
||
|
foreach (StartSceneConfig startConfig in processScenes)
|
||
|
{
|
||
|
await SceneFactory.Create(Game.Scene, startConfig.Id, startConfig.InstanceId, startConfig.Zone, startConfig.Name,
|
||
|
startConfig.Type, startConfig);
|
||
|
}
|
||
|
|
||
|
break;
|
||
|
}
|
||
|
case AppType.Watcher:
|
||
|
{
|
||
|
StartMachineConfig startMachineConfig = WatcherHelper.GetThisMachineConfig();
|
||
|
WatcherComponent watcherComponent = Game.Scene.AddComponent<WatcherComponent>();
|
||
|
watcherComponent.Start(Game.Options.CreateScenes);
|
||
|
Game.Scene.AddComponent<NetInnerComponent, IPEndPoint, int>(NetworkHelper.ToIPEndPoint($"{startMachineConfig.InnerIP}:{startMachineConfig.WatcherPort}"), SessionStreamDispatcherType.SessionStreamDispatcherServerInner);
|
||
|
break;
|
||
|
}
|
||
|
case AppType.GameTool:
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
if (Game.Options.Console == 1)
|
||
|
{
|
||
|
Game.Scene.AddComponent<ConsoleComponent>();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|