Views
namespace Griff.Runtime;
public static class ViewsHow a scene is seen, which a running game asks as it plays and the renderer reads as it builds a frame (see Griff.Rendering’s SceneRenderer): the main camera and how much of the world it shows, the view’s projection, what’s pinned to the screen, the order things are drawn in (what’s on top), and the lights reaching into the view. The runtime asks it rather than the renderer, so a game runs without knowing how it’s drawn; it keeps nothing between calls.
Methods
Section titled “Methods”DrawOrder
Section titled “DrawOrder”public static IEnumerable<Entity> DrawOrder(Scene scene)Drawable entities back to front: Order, then Z (higher is closer), then hierarchy order. With the camera’s SortByY, things lower down draw in front of things above them, before hierarchy order. What’s in a SortGroup sorts as one, at its root’s, and by its own Order within the group. An entity drawn on top (a Draggable being held, and what’s inside it) draws over everything else.
DrawParts
Section titled “DrawParts”public static IReadOnlyList<ValueTuple<Entity, int?>> DrawParts(Scene scene)Like DrawOrder, but with each part of what sorts in parts (ISortsInParts, when the camera sorts by Y) in its own place among the rest, as the game draws them: the entity and the part (a tilemap’s row of tiles), or null for the whole entity. An entity drawn in parts comes first at its own place, for what else it draws, then each of its parts.
FindCamera
Section titled “FindCamera”public static Entity? FindCamera(Scene scene)The scene’s main camera, which fills the screen: the first active camera without a Viewport (a viewport’s camera draws into its own part of the screen), or with every camera in one, the first. While a minigame has the screen (see Shown), the first such camera in it.
LightDraws
Section titled “LightDraws”public static IEnumerable<LightDraw> LightDraws(Scene scene)Every light in the scene that gives off any light, as it is now (flicker included), with the shadows of those that cast them, and then the light other components give off (see ILightSource).
Lights
Section titled “Lights”public static IReadOnlyList<LightDraw> Lights(Scene scene, float aspect)The lights in a scene that reach into the camera’s view, with their flicker as it is now.
OrderAbove
Section titled “OrderAbove”public static int OrderAbove(Entity? inside, int order)A draw order for a control made inside inside: at least order, and above anything drawn by it or the entities it’s inside (a button made on a panel draws over the panel’s backdrop).
OrderOf
Section titled “OrderOf”public static int? OrderOf(Entity entity)The draw order of an entity: its sprite’s, or else that of its first drawable component (in DrawStep order) with one; null if it draws nothing in the world.
ViewProjection
Section titled “ViewProjection”public static Matrix4x4 ViewProjection(Entity? camera, float size, float aspect)Orthographic projection of the camera’s view. size is half the visible height; the camera’s position, rotation and shake apply, its scale doesn’t.
Fields
Section titled “Fields”DefaultBackground
Section titled “DefaultBackground”public static readonly Color DefaultBackgroundDefaultCameraSize
Section titled “DefaultCameraSize”public const float DefaultCameraSizeScreenEntity
Section titled “ScreenEntity”public static readonly Entity ScreenEntityStands in for the entity of draws that belong to the screen rather than the scene, like the scene-change fade.