WutheringWaves/GameServer/Program.cs

69 lines
3.4 KiB
C#
Raw Normal View History

using Core.Config;
using Core.Extensions;
2024-02-14 21:22:21 +00:00
using GameServer.Controllers.ChatCommands;
using GameServer.Controllers.Combat;
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)
{
2024-02-14 21:22:21 +00:00
Console.Title = "Wuthering Waves | Game Server";
Console.WriteLine(" __ __ __ .__ .__ __ __ \r\n/ \\ / \\__ ___/ |_| |__ ___________|__| ____ ____ / \\ / \\_____ ___ __ ____ ______\r\n\\ \\/\\/ / | \\ __\\ | \\_/ __ \\_ __ \\ |/ \\ / ___\\ \\ \\/\\/ /\\__ \\\\ \\/ // __ \\ / ___/\r\n \\ /| | /| | | Y \\ ___/| | \\/ | | \\/ /_/ > \\ / / __ \\\\ /\\ ___/ \\___ \\ \r\n \\__/\\ / |____/ |__| |___| /\\___ >__| |__|___| /\\___ / \\__/\\ / (____ /\\_/ \\___ >____ >\r\n \\/ \\/ \\/ \\//_____/ \\/ \\/ \\/ \\/ \n");
2024-02-07 21:41:39 +00:00
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
builder.Logging.AddConsole();
builder.SetupConfiguration();
builder.Services.UseLocalResources()
.AddControllers()
2024-02-14 21:22:21 +00:00
.AddCommands()
.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>()
.AddScoped<CombatManager>().AddScoped<ChatCommandManager>()
2024-02-07 21:41:39 +00:00
.AddHostedService<WWGameServer>();
2024-02-14 21:22:21 +00:00
IHost host = builder.Build();
ILogger logger = host.Services.GetRequiredService<ILoggerFactory>().CreateLogger("WutheringWaves");
logger.LogInformation("Support: discord.gg/reversedrooms or discord.xeondev.com");
logger.LogInformation("Preparing server...");
host.Services.GetRequiredService<IHostApplicationLifetime>().ApplicationStarted.Register(() =>
{
logger.LogInformation("Server started! Let's play Wuthering Waves!");
});
await host.RunAsync();
2024-02-07 21:41:39 +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-07 21:41:39 +00:00
}