コード例 #1
0
        public static void Main(string[] args)
        {
            DllMap.Initialise();
            var serviceProvider = CreateServiceProvider();

            using var clientGame = serviceProvider.GetService <ClientGame>();
            clientGame !.Run();
        }
コード例 #2
0
        public static void Main(string[] args)
        {
            _configuration = new ConfigurationBuilder()
                             .AddJsonFile("appsettings.json", false, true)
                             .Build();

            ClientStartParameters clientStartParameters = new ClientStartParameters
            {
                ProjectId = 1,
            };

#if RELEASE
            if (args.Length == 0)
            {
                Console.WriteLine("Unable to start client. Use the launcher.");
                return;
            }

            if (args.Length > 0)
            {
                var clientStartParametersEncoded = args[0];
                var clientStartParametersJson    = Convert.FromBase64String(clientStartParametersEncoded);
                var clientStartParameters        = JsonSerializer.Deserialize <ClientStartParameters>(clientStartParametersJson);
                if (clientStartParameters == null)
                {
                    Console.WriteLine("Illegal StartParameters, unable to start client. Use the launcher.");
                    Console.ReadLine();
                    return;
                }

                var connectionTicketEncoded = UrlEncodeBase64(clientStartParameters.ConnectionTicket);

                using var httpClient   = new HttpClient();
                httpClient.BaseAddress = new Uri(_configuration["Api:ApiEndpoint"]);
                httpClient.DefaultRequestHeaders.Clear();
                var validateTicketResponse = httpClient.GetAsync($"api/auth/validateTicket/{connectionTicketEncoded}").GetAwaiter().GetResult();
                if (!validateTicketResponse.IsSuccessStatusCode)
                {
                    Console.WriteLine("Unable to start client. Use the launcher.");
                    Console.ReadLine();
                    return;
                }
            }
#endif

            DllMap.Initialise();
            using var serviceProvider = CreateServiceProvider(clientStartParameters);

            var graphicsSettings = serviceProvider.GetRequiredService <IOptions <GraphicsSettings> >();
            Environment.SetEnvironmentVariable("FNA3D_FORCE_DRIVER", graphicsSettings.Value.Backend.ToString());

            using var mainGame = serviceProvider.GetRequiredService <MainGame>();
            mainGame.Run();
        }