2024-02-11 22:23:13 +00:00
|
|
|
|
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;
|
2024-02-10 19:11:16 +00:00
|
|
|
|
using GameServer.Settings;
|
2024-02-10 16:04:03 +00:00
|
|
|
|
using GameServer.Systems.Entity;
|
|
|
|
|
using GameServer.Systems.Event;
|
2024-02-10 19:11:16 +00:00
|
|
|
|
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();
|
|
|
|
|
|
2024-02-10 22:28:35 +00:00
|
|
|
|
builder.SetupConfiguration();
|
2024-02-11 22:23:13 +00:00
|
|
|
|
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();
|
|
|
|
|
}
|
2024-02-10 22:28:35 +00:00
|
|
|
|
|
|
|
|
|
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-12 09:26:53 +00:00
|
|
|
|
builder.Services.Configure<GameplayFeatureSettings>(builder.Configuration.GetRequiredSection("Features"));
|
2024-02-10 22:28:35 +00:00
|
|
|
|
}
|
2024-02-07 21:41:39 +00:00
|
|
|
|
}
|