logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class HudRepresentationRules

    Canonical, engine-agnostic rules for pairing a bound HUD value with a representation: which representations can render a given value kind, and which of them need a capacity binding to mean anything.

    Inheritance
    object
    HudRepresentationRules
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Serenity.GameUi.Application.Validation
    Assembly: Serenity.GameUi.Application.dll
    Syntax
    public static class HudRepresentationRules
    Remarks

    Defined once here so the builder tool's dropdown, the runtime safety net and the HUD validator all agree. Mirrors UiOptionRules.GetAllowedInteractionTypes, which plays the same role for menu options after that rule had been independently re-implemented in three places.

    Methods

    GetAllowedRepresentations(HudValueKind)

    Returns the representations that can render the given value kind, in preference order (the first is the sensible default).

    Declaration
    public static IReadOnlyList<HudRepresentationKind> GetAllowedRepresentations(HudValueKind valueKind)
    Parameters
    Type Name Description
    HudValueKind valueKind

    The classification of the bound value.

    Returns
    Type Description
    IReadOnlyList<HudRepresentationKind>

    The allowed representations.

    GetDefaultRepresentation(HudValueKind)

    Returns the default representation for a value kind.

    Declaration
    public static HudRepresentationKind GetDefaultRepresentation(HudValueKind valueKind)
    Parameters
    Type Name Description
    HudValueKind valueKind

    The classification of the bound value.

    Returns
    Type Description
    HudRepresentationKind

    The first allowed representation.

    IsRepresentationAllowed(HudValueKind, HudRepresentationKind)

    Determines whether a representation can render the given value kind.

    Declaration
    public static bool IsRepresentationAllowed(HudValueKind valueKind, HudRepresentationKind representation)
    Parameters
    Type Name Description
    HudValueKind valueKind

    The classification of the bound value.

    HudRepresentationKind representation

    The representation to check.

    Returns
    Type Description
    bool

    True when the pairing is valid.

    RequiresCapacityBinding(HudRepresentationKind)

    Determines whether a representation needs a capacity binding. Stack, segmented and gauge representations draw the empty part as well as the filled part, so without a maximum they cannot be laid out at all.

    Declaration
    public static bool RequiresCapacityBinding(HudRepresentationKind representation)
    Parameters
    Type Name Description
    HudRepresentationKind representation

    The representation to check.

    Returns
    Type Description
    bool

    True when a capacity binding is required.

    RequiresValueBinding(HudRepresentationKind)

    Determines whether a representation reads a value at all. A plain sprite or a standalone label is decoration — a frame, a heading — and demanding a binding for it would force every decorative element to invent data to ignore. A flexbox box is the same kind of decoration: it lays other elements out and reads no value of its own.

    Declaration
    public static bool RequiresValueBinding(HudRepresentationKind representation)
    Parameters
    Type Name Description
    HudRepresentationKind representation

    The representation to check.

    Returns
    Type Description
    bool

    True when the representation renders a bound value.

    Validate(HudValueKind, HudRepresentationKind, bool)

    Validates one element's value-kind / representation / capacity combination.

    Declaration
    public static List<string> Validate(HudValueKind valueKind, HudRepresentationKind representation, bool hasCapacityBinding)
    Parameters
    Type Name Description
    HudValueKind valueKind

    The classification of the bound value.

    HudRepresentationKind representation

    The chosen representation.

    bool hasCapacityBinding

    Whether a capacity binding is authored.

    Returns
    Type Description
    List<string>

    Human-readable issue descriptions; empty when the combination is valid.

    In this article
    © 2026 Serenity. All Rights Reserved