using System; using System.IO; using Microsoft.Xna.Framework.Graphics; using Syntriax.Engine.Core; using Syntriax.Engine.Core.Debug; using Syntriax.Engine.Core.Serialization; using Syntriax.Engine.Integration.MonoGame; using Syntriax.Engine.Serializers.Yaml; Universe universe = new(); ISerializer serializer = new YamlSerializer(); ILogger logger = new FileLogger($"logs/{DateTime.UtcNow:yyyy-MM-dd_HH-mm-ss}.log"); #if DEBUG logger = new LoggerWrapper(logger, new ConsoleLogger()); #endif universe.InstantiateUniverseObject().SetUniverseObject("Logger").BehaviourController.AddBehaviour().Logger = logger; string settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "settings.yaml"); ClientConfiguration clientConfiguration; try { clientConfiguration = serializer.Deserialize(File.ReadAllText(settingsPath)); logger.Log(clientConfiguration, $"{settingsPath} read"); } catch (Exception exception) { clientConfiguration = new(); logger.LogError(serializer, $"Error loading {settingsPath}. Creating new settings file"); logger.LogException(serializer, exception); File.WriteAllText(settingsPath, serializer.Serialize(clientConfiguration)); } if (clientConfiguration.Host) Pong.PongUniverse.ApplyPongServer(universe, clientConfiguration.HostPort); Pong.PongUniverse.ApplyPongClient(universe, clientConfiguration.ServerAddress, clientConfiguration.ServerPort); Pong.PongUniverse.ApplyPongUniverse(universe); universe.InstantiateUniverseObject().SetUniverseObject("Desktop HO") .BehaviourController.AddBehaviour(); using MonoGameWindow monoGameWindow = new(universe); monoGameWindow.Graphics.PreferredBackBufferWidth = clientConfiguration.windowWidth; monoGameWindow.Graphics.PreferredBackBufferHeight = clientConfiguration.windowHeight; monoGameWindow.Graphics.GraphicsProfile = GraphicsProfile.HiDef; monoGameWindow.Run();