2024-02-11 22:23:13 +00:00
|
|
|
|
using Core.Config;
|
|
|
|
|
using Core.Extensions;
|
2024-02-14 21:22:21 +00:00
|
|
|
|
using GameServer.Controllers.ChatCommands;
|
2024-02-17 13:49:28 +00:00
|
|
|
|
using GameServer.Controllers.Combat;
|
2024-02-11 22:23:13 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
2024-02-14 21:22:21 +00:00
|
|
|
|
Console.Title = "Wuthering Waves | Game Server";
|
2024-02-20 19:39:08 +00:00
|
|
|
|
Console.WriteLine(" __ __ __ .__ .__ __ __ \r\n/ \\ / \\__ ___/ |_| |__ ___________|__| ____ ____ / \\ / \\_____ ___ __ ____ ______\r\n\\ \\/\\/ / | \\ __\\ | \\_/ __ \\_ __ \\ |/ \\ / ___\\ \\ \\/\\/ /\\__ \\\\ \\/ // __ \\ / ___/\r\n \\ /| | /| | | Y \\ ___/| | \\/ | | \\/ /_/ > \\ / / __ \\\\ /\\ ___/ \\___ \\ \r\n \\__/\\ / |____/ |__| |___| /\\___ >__| |__|___| /\\___ / \\__/\\ / (____ /\\_/ \\___ >____ >\r\n \\/ \\/ \\/ \\//_____/ \\/ \\/ \\/ \\/ \r\n\r\n\t\t\t\t\t\t\t\t\t\t\t\tGame Server\n");
|
|
|
|
|
|
2024-02-07 21:41:39 +00:00
|
|
|
|
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()
|
2024-02-14 21:22:21 +00:00
|
|
|
|
.AddCommands()
|
2024-02-11 22:23:13 +00:00
|
|
|
|
.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>()
|
2024-02-17 13:49:28 +00:00
|
|
|
|
.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
|
|
|
|
}
|
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
|
|
|
|
}
|