52 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using Microsoft.Xna.Framework;
 | 
						|
using Microsoft.Xna.Framework.Graphics;
 | 
						|
 | 
						|
using Engine.Core;
 | 
						|
 | 
						|
namespace Engine.Integration.MonoGame;
 | 
						|
 | 
						|
public class MonoGameWindow : Game
 | 
						|
{
 | 
						|
    public GraphicsDeviceManager Graphics { get; protected set; } = null!;
 | 
						|
    public IUniverse Universe { get; protected set; } = null!;
 | 
						|
    public ColorRGB BackgroundColor { get; set; } = new ColorRGB(35, 20, 35);
 | 
						|
 | 
						|
    public MonoGameWindow(IUniverse? universe = null)
 | 
						|
    {
 | 
						|
        Preserver.Preserve();
 | 
						|
        Graphics = new GraphicsDeviceManager(this);
 | 
						|
        Content.RootDirectory = "Content";
 | 
						|
        IsMouseVisible = true;
 | 
						|
        Universe = universe ?? new Universe();
 | 
						|
 | 
						|
        Universe.InstantiateUniverseObject().SetUniverseObject("Window Container")
 | 
						|
            .BehaviourController.AddBehaviour<MonoGameWindowContainer>(this);
 | 
						|
 | 
						|
        Universe.InstantiateUniverseObject().SetUniverseObject("Content Loader")
 | 
						|
            .BehaviourController.AddBehaviour<LoadContentManager>();
 | 
						|
    }
 | 
						|
 | 
						|
    protected override void Initialize()
 | 
						|
    {
 | 
						|
        Universe.Initialize();
 | 
						|
 | 
						|
        base.Initialize();
 | 
						|
    }
 | 
						|
 | 
						|
    protected override void Update(GameTime gameTime)
 | 
						|
    {
 | 
						|
        Universe.Update(gameTime.ToEngineTime());
 | 
						|
 | 
						|
        base.Update(gameTime);
 | 
						|
    }
 | 
						|
 | 
						|
    protected override void Draw(GameTime gameTime)
 | 
						|
    {
 | 
						|
        GraphicsDevice.Clear(((ColorRGBA)BackgroundColor).ToColor());
 | 
						|
 | 
						|
        Universe.Draw();
 | 
						|
 | 
						|
        base.Draw(gameTime);
 | 
						|
    }
 | 
						|
}
 |