// // DllMain.cs // // Copyright (c) František Boháček. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. using System.Runtime.InteropServices; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Logging; using NosSmooth.ChatCommands; using NosSmooth.Core.Extensions; using NosSmooth.Data.NOSFiles.Extensions; using NosSmooth.Extensions.Combat.Extensions; using NosSmooth.Extensions.Pathfinding.Extensions; using NosSmooth.Extensions.SharedBinding.Extensions; using NosSmooth.Game.Extensions; using NosSmooth.LocalClient.Extensions; using Remora.Commands.Extensions; using SimplePiiBot.Commands; using SimplePiiBot.Responders; namespace SimplePiiBot; /// /// The entrypoint class. /// public class DllMain { /// /// Allocate console. /// /// Whether the operation was successful. [DllImport("kernel32")] public static extern bool AllocConsole(); /// /// Represents the dll entrypoint method. /// [UnmanagedCallersOnly(EntryPoint = "Main")] public static void Main() { AllocConsole(); new Thread ( () => { try { MainEntry().GetAwaiter().GetResult(); } catch (Exception e) { Console.WriteLine(e.ToString()); } } ).Start(); } /// /// The entrypoint method. /// /// A representing the asynchronous operation. private static async Task MainEntry() { var host = Host.CreateDefaultBuilder() .UseConsoleLifetime() .ConfigureLogging ( b => { b .ClearProviders() .AddConsole(); } ) .ConfigureServices ( s => { s.AddNostaleCore() .AddNostaleGame() .AddLocalClient() .AddNostaleDataFiles() .ShareNosSmooth() .AddNostaleCombat() .AddNostalePathfinding() .AddSingleton() .AddNostaleChatCommands() .AddGameResponder() .AddCommandTree() .WithCommandGroup() .WithCommandGroup(); s.AddHostedService(); } ).Build(); await host.RunAsync(); } }