using Friflo.Engine.ECS;
using Microsoft.Xna.Framework;
using MrGameEng.Graphics;
namespace MrGameEng.Tilemaps;
///
/// Tilemap component: a of ids drawn with a .
/// Cell (0,0) sits at , cells are world units square.
/// Only the cells visible through the camera are submitted each frame, so grids can be large.
/// Create via the constructor — the struct default has no grid and draws nothing.
///
public struct Tilemap : IComponent
{
/// Tile definitions; ids in the grid index into it.
public TileSet? TileSet;
/// The cells. Mutating ids takes effect next frame.
public TileGrid? Grid;
/// World position of the top-left corner of cell (0,0).
public Vector2 Origin;
/// Cell size in world units.
public float TileSize;
/// Render layer of the whole map.
public LayerId Layer;
/// Draw order within the layer (smaller = drawn first / behind).
public float Depth;
/// Tint multiplied into every tile on top of its .
public Color Color;
/// Creates a tilemap at world origin.
public Tilemap(TileGrid grid, TileSet tileSet, float tileSize, LayerId layer = default)
{
Grid = grid;
TileSet = tileSet;
TileSize = tileSize;
Layer = layer;
Origin = Vector2.Zero;
Depth = 0f;
Color = Color.White;
}
}