logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Struct HudValueTransform

    Reshapes a bound value before it reaches a representation: SCALE_AND_OFFSET applies a linear value * multiplier + offset, and REMAP_RANGE maps one range onto another.

    Implements
    IEquatable<HudValueTransform>
    Inherited Members
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetType()
    Namespace: Serenity.GameUi.Domain.ValueObjects
    Assembly: Serenity.GameUi.Domain.dll
    Syntax
    public readonly struct HudValueTransform : IEquatable<HudValueTransform>
    Remarks

    Carried per binding, not per element: a gauge's value and capacity bindings each need their own transform, because a value/capacity ratio breaks the moment the two sides are reshaped differently — an element-level transform would apply the same reshaping to both and could not express "remap only the value".

    Every consumer of a binding's read value sees the transformed result, including the icon-set representation's text-based matching — there is exactly one place the transform is applied, in CompiledHudBinding.TryRead.

    Constructors

    HudValueTransform(HudValueTransformKind, double, double, double, double, double, double, bool)

    Creates a value transform.

    Declaration
    public HudValueTransform(HudValueTransformKind kind, double multiplier, double offset, double sourceMinimum, double sourceMaximum, double displayMinimum, double displayMaximum, bool clampsToDisplayRange)
    Parameters
    Type Name Description
    HudValueTransformKind kind

    Which reshaping to apply.

    double multiplier

    The scale factor, for SCALE_AND_OFFSET.

    double offset

    The additive offset, for SCALE_AND_OFFSET.

    double sourceMinimum

    The source range's low end, for REMAP_RANGE.

    double sourceMaximum

    The source range's high end, for REMAP_RANGE.

    double displayMinimum

    The display range's low end, for REMAP_RANGE.

    double displayMaximum

    The display range's high end, for REMAP_RANGE.

    bool clampsToDisplayRange

    Whether the mapped output is clamped to the display range.

    Fields

    ClampsToDisplayRange

    Whether a REMAP_RANGE clamps its output to the display range, rather than letting a source value outside SourceMinimum–SourceMaximum extrapolate past it.

    Declaration
    public readonly bool ClampsToDisplayRange
    Field Value
    Type Description
    bool

    DisplayMaximum

    The high end of the range a REMAP_RANGE maps onto.

    Declaration
    public readonly double DisplayMaximum
    Field Value
    Type Description
    double

    DisplayMinimum

    The low end of the range a REMAP_RANGE maps onto.

    Declaration
    public readonly double DisplayMinimum
    Field Value
    Type Description
    double

    Kind

    Which reshaping, if any, this transform applies.

    Declaration
    public readonly HudValueTransformKind Kind
    Field Value
    Type Description
    HudValueTransformKind

    Multiplier

    The factor a SCALE_AND_OFFSET multiplies the value by.

    Declaration
    public readonly double Multiplier
    Field Value
    Type Description
    double

    Offset

    The amount a SCALE_AND_OFFSET adds after multiplying.

    Declaration
    public readonly double Offset
    Field Value
    Type Description
    double

    SourceMaximum

    The high end of the range a REMAP_RANGE reads from.

    Declaration
    public readonly double SourceMaximum
    Field Value
    Type Description
    double

    SourceMinimum

    The low end of the range a REMAP_RANGE reads from.

    Declaration
    public readonly double SourceMinimum
    Field Value
    Type Description
    double

    Properties

    Identity

    No reshaping; a value passes through unchanged.

    Declaration
    public static HudValueTransform Identity { get; }
    Property Value
    Type Description
    HudValueTransform

    IsActive

    Whether this transform reshapes anything at all.

    Declaration
    public bool IsActive { get; }
    Property Value
    Type Description
    bool

    Methods

    Apply(double)

    Applies this transform to a value already converted to a number.

    Declaration
    public double Apply(double value)
    Parameters
    Type Name Description
    double value

    The value read from the binding, as a number.

    Returns
    Type Description
    double

    The reshaped value, or value unchanged for NONE.

    Equals(HudValueTransform)

    Declaration
    public bool Equals(HudValueTransform other)
    Parameters
    Type Name Description
    HudValueTransform other
    Returns
    Type Description
    bool

    Equals(object)

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    object obj
    Returns
    Type Description
    bool
    Overrides
    ValueType.Equals(object)

    GetHashCode()

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    int
    Overrides
    ValueType.GetHashCode()

    IsWellFormed(out string)

    Whether this transform is configured well enough to ever do anything sensible.

    Declaration
    public bool IsWellFormed(out string reason)
    Parameters
    Type Name Description
    string reason

    Why the transform is malformed, or empty when it is well formed.

    Returns
    Type Description
    bool

    False when the transform cannot possibly reshape a value as authored.

    Remarks

    Only REMAP_RANGE can be malformed: a degenerate source range (SourceMinimum equal to SourceMaximum) has no ratio to map by, so Apply(double) already treats it as the identity to avoid a divide by zero — this method is what lets a validator flag that as a defect instead of silently accepting a transform that never applies.

    ToString()

    Declaration
    public override string ToString()
    Returns
    Type Description
    string
    Overrides
    ValueType.ToString()

    Operators

    operator ==(HudValueTransform, HudValueTransform)

    Declaration
    public static bool operator ==(HudValueTransform left, HudValueTransform right)
    Parameters
    Type Name Description
    HudValueTransform left
    HudValueTransform right
    Returns
    Type Description
    bool

    operator !=(HudValueTransform, HudValueTransform)

    Declaration
    public static bool operator !=(HudValueTransform left, HudValueTransform right)
    Parameters
    Type Name Description
    HudValueTransform left
    HudValueTransform right
    Returns
    Type Description
    bool

    Implements

    IEquatable<T>
    In this article
    © 2026 Serenity. All Rights Reserved