Skip to content

IDrawable

namespace Griff.Scenes;
public interface IDrawable

A component that draws something: Griff’s own (sprites, tilemaps, text, bars, particles, boards) and scripts’ alike. Each frame the renderer goes through the entities once, in hierarchy order (the Hierarchy panel’s, top to bottom), and asks each of an entity’s drawable components, in DrawStep order, to Draw itself; then it puts the entities’ draws back to front (see DrawOrder), each entity’s kept together in the order they were added. So Draw is called in the same order whatever layer things are on, and needn’t know what’s drawn under it (a GameSystem’s Draw sees the whole frame). A running game is drawn between its last two steps: transforms are placed there by themselves, and what a component draws from its own state gets there through Blend (keep what changes in a Smoothed).

public virtual int? DrawOrder { get; }

Where the entity draws among the others: higher draws on top (ties go by Z, then hierarchy order). An entity’s Sprite sets it if it has one, or else its first drawable component (by DrawStep) with an order. Null draws at the entity’s order without setting it, so it draws only alongside something that does.

public virtual int DrawStep { get; }

Where its draws go among the entity’s others, lower first: one of DrawSteps, or a number between.

public abstract void Draw(Drawing drawing)

Adds what it draws this frame to drawing, back to front.