Skip to content

Bar

namespace Griff.Scenes;
public sealed class Bar : Component, IDrawable

A bar that fills up to show Value out of Max: health, a boss’s health, charge, a timer. Name an entity in Track and it shows that entity’s Health with no code, or any of its outputs with Output (a board’s score towards its target, a turn’s time left). When it goes down, the part just lost lingers in the Trail color for a moment before draining away. Its parts can be pictures too: a FillImage revealed as it fills, over a BackgroundImage.

This is a component: its saved properties are on its component page.

public Color Background { get; set; }

The empty part of the bar, or what tints its BackgroundImage (white shows the picture as it is).

public string? BackgroundImage { get; set; }

A picture for the bar behind the fill, shown whole, instead of a plain color.

public float BackgroundSlice { get; set; }

For a background that stretches (nine-slice), like Slice: how much of the BackgroundImage, from 0 to 0.5 of its width and height, is border at each edge. Its corners then keep their shape however long the bar is. 0 stretches the whole picture.

public float BackgroundSliceSize { get; set; }

With BackgroundSlice: how big the border is drawn, in world units (never more than half the bar).

public BarDirection Direction { get; set; }

Which way it fills.

public Color Fill { get; set; }

The color of the full part, or what tints its FillImage (white shows the picture as it is).

public string? FillImage { get; set; }

A picture for the full part instead of a plain color, e.g. “Sprites/gauge.png”: laid over the whole bar and shown only as far as it’s full in its Direction, cut off there rather than squeezed, so it stays crisp. The trail shows the same picture, tinted by Trail.

public float Fraction { get; }

How full the bar is, from 0 to 1.

public float Max { get; set; }

The value at which it’s full.

public int Order { get; set; }

Higher draws on top, like Order.

public string? Output { get; set; }

Show an output instead of health: what it gives now (see component_describe’s Outputs), out of what it says it’s out of, or Max if it doesn’t, e.g. a board’s “Score” (out of its Target Score), a turn order’s “Time Left”, a faction’s “Amount:Gold”. Without a Track, it’s this entity’s, or the nearest one it’s inside.

public Vector2 Size { get; set; }

World units before the transform’s scale, centered on the entity.

public string? Track { get; set; }

The name of an entity whose Health the bar shows, e.g. “Player” or “Boss”: its Current out of its Max, every frame (or its Output). Once that entity is gone the bar shows empty.

public Color Trail { get; set; }

The part just lost, shown for a moment before it drains away. Transparent for none.

public float TrailFraction { get; }

How far the Trail reaches, from 0 to 1: at least Fraction.

public float Value { get; set; }

How full it is, out of Max.

public override string? LinkLabel(string property)