Split the platform out of Core: new Host library + HeadlessHost
CI / build-test (push) Successful in 1m24s
CI / build-test (push) Successful in 1m24s
Core now depends only on Friflo.Engine.ECS — no MonoGame, no platform. The windowed MonoGame host moves to the new MrGameEng.Host library: GameHost, GameHostOptions, visual scene transitions (OverlayTransition, Transitions.Fade/Wipe, TransitionRenderer) and the Input feature (namespace MrGameEng.Input is unchanged). Transition timing stays in Core (SceneManager exposes ActiveTransition/TransitionCoverage/ TransitionPhase; the host draws the overlay). EngineContext loses its GraphicsDevice property: hosts publish the device as a service and graphics code reads it via context.GetGraphicsDevice() in Graphics. Core gains HeadlessHost: a fixed-timestep loop without a window or GPU (Tick/RunTicks, Run with wall-clock pacing and lag resync) for dedicated servers, batch simulation and tests. Graphics and Audio now carry their own MonoGame.Framework.DesktopGL reference instead of inheriting it from Core. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
79d406a9f4
commit
2ac074004a
@@ -0,0 +1,63 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace MrGameEng.Host;
|
||||
|
||||
/// <summary>
|
||||
/// Minimal overlay renderer handed to <see cref="OverlayTransition.Draw"/>: fills rectangles
|
||||
/// in normalized screen coordinates (0..1 on both axes) over the rendered scene.
|
||||
/// </summary>
|
||||
public sealed class TransitionRenderer : IDisposable
|
||||
{
|
||||
private readonly GraphicsDevice _device;
|
||||
private readonly BasicEffect _effect;
|
||||
private readonly VertexPositionColor[] _vertices = new VertexPositionColor[6];
|
||||
|
||||
/// <summary>Disposes the GPU effect. Called by <see cref="GameHost"/> on shutdown.</summary>
|
||||
public void Dispose() => _effect.Dispose();
|
||||
|
||||
internal TransitionRenderer(GraphicsDevice device)
|
||||
{
|
||||
_device = device;
|
||||
_effect = new BasicEffect(device)
|
||||
{
|
||||
VertexColorEnabled = true,
|
||||
TextureEnabled = false,
|
||||
World = Matrix.Identity,
|
||||
View = Matrix.Identity,
|
||||
Projection = Matrix.CreateOrthographicOffCenter(0f, 1f, 1f, 0f, 0f, 1f),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills a rectangle given in normalized screen coordinates with <paramref name="color"/>
|
||||
/// at the given <paramref name="opacity"/> (0 = invisible, 1 = solid).
|
||||
/// </summary>
|
||||
public void Fill(float x, float y, float width, float height, Color color, float opacity = 1f)
|
||||
{
|
||||
var alpha = (byte)(Math.Clamp(opacity, 0f, 1f) * color.A);
|
||||
var premultiplied = Color.FromNonPremultiplied(color.R, color.G, color.B, alpha);
|
||||
|
||||
var topLeft = new Vector3(x, y, 0f);
|
||||
var topRight = new Vector3(x + width, y, 0f);
|
||||
var bottomLeft = new Vector3(x, y + height, 0f);
|
||||
var bottomRight = new Vector3(x + width, y + height, 0f);
|
||||
|
||||
_vertices[0] = new VertexPositionColor(topLeft, premultiplied);
|
||||
_vertices[1] = new VertexPositionColor(topRight, premultiplied);
|
||||
_vertices[2] = new VertexPositionColor(bottomLeft, premultiplied);
|
||||
_vertices[3] = new VertexPositionColor(bottomLeft, premultiplied);
|
||||
_vertices[4] = new VertexPositionColor(topRight, premultiplied);
|
||||
_vertices[5] = new VertexPositionColor(bottomRight, premultiplied);
|
||||
|
||||
_device.BlendState = BlendState.AlphaBlend;
|
||||
_device.DepthStencilState = DepthStencilState.None;
|
||||
_device.RasterizerState = RasterizerState.CullNone;
|
||||
|
||||
foreach (var pass in _effect.CurrentTechnique.Passes)
|
||||
{
|
||||
pass.Apply();
|
||||
_device.DrawUserPrimitives(PrimitiveType.TriangleList, _vertices, 0, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user