Remove obsolete project files for MrGameEng.AI, MrGameEng.Assets, MrGameEng.Atlases, and MrGameEng.Collisions modules. Introduce new AssetManager and related classes for asset loading and management, including support for texture atlases and mod definitions. Enhance mod loading capabilities with DefDatabase and LanguageManager for JSON-based definitions and localization. Implement a shelf packing algorithm for efficient texture atlas creation.
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
using MrGameEng.Core;
|
||||
using MrGameEng.Graphics;
|
||||
|
||||
namespace MrGameEng.Tilemaps;
|
||||
|
||||
/// <summary>Wires the tilemaps module into a <see cref="Scene"/>.</summary>
|
||||
public static class SceneTilemapExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Adds <see cref="TilemapRenderSystem"/> to the scene's draw phase, right before the
|
||||
/// renderer flush. Call from <c>OnLoad</c> after <c>UseRenderer2D()</c>.
|
||||
/// </summary>
|
||||
public static void UseTilemaps(this Scene scene)
|
||||
{
|
||||
var renderer =
|
||||
scene.Context.Services.GetOrDefault<Renderer2D>()
|
||||
?? throw new InvalidOperationException(
|
||||
"UseTilemaps requires UseRenderer2D to be called first."
|
||||
);
|
||||
|
||||
var systems = scene.DrawSystems.ChildSystems;
|
||||
for (var i = 0; i < systems.Count; i++)
|
||||
{
|
||||
if (systems[i] is RenderFlushSystem)
|
||||
{
|
||||
scene.DrawSystems.Insert(i, new TilemapRenderSystem(renderer));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw new InvalidOperationException(
|
||||
"RenderFlushSystem not found (is UseRenderer2D wired on this scene?)."
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user