FrameDrawing
namespace Griff.Runtime;
public sealed class FrameDrawingA running game’s frame as it’s being drawn, handed to each GameSystem in turn once every entity has drawn itself: first to see the world their own way (a first-person view, in DrawView), then to add what the game knows of and no single entity draws (a strategy game’s fog and HUD, a tactics game’s reachable cells) or change what’s there (hide what’s in the fog), in Draw. There’s one for the main view and one for each Viewport showing (see Viewport). It’s used again for the next frame, so don’t keep it.
Properties
Section titled “Properties”Aspect
Section titled “Aspect”public float Aspect { get; }The view’s width divided by its height: the screen’s, or a viewport’s part of it.
public StepBlend Blend { get; }How far this frame is between the game’s last two steps, for what a system draws from the game’s own state (see StepBlend); BlendOf for what belongs to an entity.
Camera
Section titled “Camera”public Entity? Camera { get; }The camera’s entity: the main camera, or a Viewport’s; null if the scene has none (a default camera at the origin is used).
CameraSize
Section titled “CameraSize”public float CameraSize { get; }Half the height of the camera’s view, in world units.
public Game Game { get; }The game being drawn.
LineWidth
Section titled “LineWidth”public float LineWidth { get; }A thin line’s width in world units: about two pixels on a 720-pixel-high screen, whatever the zoom.
public bool Lit { get; set; }False when the world drawn isn’t lit by the scene’s darkness and lights, because a system lit it itself (a first-person view).
public Scene Scene { get; }Its scene.
SeenThrough
Section titled “SeenThrough”public Entity? SeenThrough { get; set; }The entity this view sees the world through, set by a system that draws it through someone’s eyes (a first-person view’s player), or null for a view from above: what draws over the world from above (a cell outline, a tool’s line) leaves such a view alone.
Sprites
Section titled “Sprites”public List<SpriteDraw> Sprites { get; set; }Everything drawn so far, back to front. Change it in place (hide, fade or insert draws among the world’s), or set a new list to draw the world another way. A list set here becomes the frame’s (and may be reused for a later one), so don’t keep it.
public Box View { get; set; }The part of the world in view (ignoring the camera’s rotation). A system that sees the world its own way sets it.
ViewProjection
Section titled “ViewProjection”public Matrix4x4 ViewProjection { get; set; }World to clip space (-1..1). A system that sees the world its own way sets it.
Viewport
Section titled “Viewport”public Viewport? Viewport { get; }The Viewport this frame is drawn for (see Camera, its camera), or null for the main view, the whole screen. Every system draws into each view; a HUD of the whole screen belongs in the main one.
Methods
Section titled “Methods”AddOverWorld
Section titled “AddOverWorld”public void AddOverWorld(IEnumerable<SpriteDraw> draws)Adds draws over the whole world and under what’s pinned to the screen (after whatever was added this way before). The first time, everything pinned to the screen is moved after the world, keeping its order.
BlendOf
Section titled “BlendOf”public StepBlend BlendOf(Entity entity)How far this frame is between the game’s last two steps for what entity draws: as it is if it jumped in the last step (see StepBlend).
Circle
Section titled “Circle”public static IEnumerable<SpriteDraw> Circle(Vector2 center, float radius, float thickness, Color color)A ring in the world, belonging to the screen.
DrawEntities
Section titled “DrawEntities”public List<SpriteDraw> DrawEntities(Func<Entity, bool> include)The draws of the scene’s entities that include takes (those on the screen, say), drawn again as they look in View: for a system that has drawn the world its own way.
IsOnScreen
Section titled “IsOnScreen”public bool IsOnScreen(Entity entity)True if entity’s draws are pinned to the screen (a HUD, a menu, something riding along inside the camera) rather than in the world. In a viewport’s view, only what rides inside its camera is.
public static SpriteDraw Label(string text, Vector2 at, float size, Color color, TextAlign align = TextAlign.Center)A line of text in the world, belonging to the screen rather than any entity.
public static SpriteDraw Line(Vector2 from, Vector2 to, float thickness, Color color)A line in the world, belonging to the screen rather than any entity.
Outline
Section titled “Outline”public static IEnumerable<SpriteDraw> Outline(Vector2 center, Vector2 size, float thickness, Color color)The edges of a rectangle in the world, belonging to the screen.
PinToView
Section titled “PinToView”public void PinToView(List<SpriteDraw> draws, Vector2 laidOutAt, float laidOutHalfHeight, int start = 0)Moves the draws of draws from start on, laid out in the world over a view centered at laidOutAt and laidOutHalfHeight high as the game stepped (a system’s HUD), onto the view this frame is drawn with: the camera moves, zooms and shakes between steps, so a HUD laid out over where it was keeps still on the screen.
public static SpriteDraw Quad(Vector2 center, Vector2 size, Color color)A solid rectangle in the world, belonging to the screen rather than any entity.
public bool Shows(Entity entity)True if this view draws entity at all: not another view’s own, nor behind the minigame that has the screen (see Minigame). A system drawing what belongs to an entity goes by this.
ShowsInWorld
Section titled “ShowsInWorld”public bool ShowsInWorld(Entity entity)True if this view draws entity in its world: neither pinned to its screen nor another view’s own (riding inside another viewport’s camera, or in a viewport’s view, the main view’s HUD).