56 lines
1.5 KiB
C#
56 lines
1.5 KiB
C#
using Microsoft.Xna.Framework;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
|
|
using Syntriax.Engine.Core;
|
|
|
|
namespace Syntriax.Engine.Integration.MonoGame;
|
|
|
|
public abstract 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()
|
|
{
|
|
Preserver.Preserve();
|
|
Graphics = new GraphicsDeviceManager(this);
|
|
Content.RootDirectory = "Content";
|
|
IsMouseVisible = true;
|
|
Universe = new Universe();
|
|
}
|
|
|
|
protected abstract void PopulateUniverse(IUniverse universe);
|
|
protected override void Initialize()
|
|
{
|
|
Universe.Initialize();
|
|
Universe.InstantiateUniverseObject().SetUniverseObject("Window Container")
|
|
.BehaviourController.AddBehaviour<MonoGameWindowContainer>(this);
|
|
|
|
PopulateUniverse(Universe);
|
|
|
|
base.Initialize();
|
|
}
|
|
|
|
protected override void LoadContent()
|
|
{
|
|
// TODO: use this.Content to load your game content here
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|