WutheringWaves/GameServer/Program.cs

50 lines
1.9 KiB
C#
Raw Normal View History

using Core.Config;
using Core.Extensions;
using GameServer.Controllers.Factory;
2024-02-09 22:15:05 +00:00
using GameServer.Controllers.Manager;
using GameServer.Extensions;
2024-02-09 09:20:14 +00:00
using GameServer.Models;
2024-02-07 21:41:39 +00:00
using GameServer.Network;
2024-02-09 09:44:42 +00:00
using GameServer.Network.Kcp;
2024-02-09 22:15:05 +00:00
using GameServer.Network.Messages;
2024-02-07 21:41:39 +00:00
using GameServer.Network.Rpc;
using GameServer.Settings;
2024-02-10 16:04:03 +00:00
using GameServer.Systems.Entity;
using GameServer.Systems.Event;
using Microsoft.Extensions.Configuration;
2024-02-07 21:41:39 +00:00
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace GameServer;
internal static class Program
{
private static async Task Main(string[] args)
{
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
builder.Logging.AddConsole();
builder.SetupConfiguration();
builder.Services.UseLocalResources()
.AddControllers()
.AddSingleton<ConfigManager>()
2024-02-09 09:44:42 +00:00
.AddSingleton<KcpGateway>().AddScoped<PlayerSession>()
2024-02-09 22:15:05 +00:00
.AddScoped<MessageManager>().AddSingleton<EventHandlerFactory>()
2024-02-07 21:41:39 +00:00
.AddScoped<RpcManager>().AddScoped<IRpcEndPoint, RpcSessionEndPoint>()
.AddSingleton<SessionManager>()
2024-02-10 16:04:03 +00:00
.AddScoped<EventSystem>().AddScoped<EntitySystem>().AddScoped<EntityFactory>()
.AddScoped<ModelManager>().AddScoped<ControllerManager>()
2024-02-07 21:41:39 +00:00
.AddHostedService<WWGameServer>();
await builder.Build().RunAsync();
}
private static void SetupConfiguration(this HostApplicationBuilder builder)
{
builder.Configuration.AddJsonFile("gameplay.json");
builder.Services.Configure<GatewaySettings>(builder.Configuration.GetRequiredSection("Gateway"));
builder.Services.Configure<PlayerStartingValues>(builder.Configuration.GetRequiredSection("StartingValues"));
}
2024-02-07 21:41:39 +00:00
}