logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class AchievementConditionTree

    The structural view of a condition tree: what a node's children are, and whether the graph hanging off a node is actually a tree at all.

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

    [SerializeReference] stores a graph, not a tree. A corrupted asset — or a hand-edited YAML file — can make a node its own descendant, and every recursive walk in this namespace would then recurse until the stack ends, which no catch can recover from.

    The guard is a single iterative walk with an identity-based visited set, run at the three places a tree arrives from outside: Validate(), AchievementAuthoringRules, and AchievementConditionSummary.Describe. The evaluator refuses a malformed tree at construction, so the per-evaluation walks — which run every frame and cannot afford a check — only ever see a tree that passed one.

    Fields

    MalformedTreeMessage

    What a malformed tree reports, wherever it is reported.

    Declaration
    public static readonly string MalformedTreeMessage
    Field Value
    Type Description
    string

    MaxDepth

    How deep an authored tree may nest. Far past anything an author would build by hand, and shallow enough that a walk of a malformed graph ends long before the stack does.

    Declaration
    public const int MaxDepth = 32
    Field Value
    Type Description
    int

    Methods

    ChildrenOf(AchievementCondition)

    The children of a node, whatever shape of node it is.

    Declaration
    public static IReadOnlyList<AchievementCondition> ChildrenOf(AchievementCondition node)
    Parameters
    Type Name Description
    AchievementCondition node

    The node to read. Null yields no children.

    Returns
    Type Description
    IReadOnlyList<AchievementCondition>
    Remarks

    Reads Children rather than testing for concrete types, so a leaf added later — even outside this namespace — is walked correctly by every caller the moment it overrides that property. Tree walking and validation in this namespace are type-agnostic for that reason; the Unity-side editor GUI, node writer and recipe importer still switch on the concrete condition types, which is that side's own concern to close in a later PR.

    IsWellFormed(AchievementCondition)

    Whether the graph hanging off a node is a tree that can be walked: no node appears twice, and nothing nests deeper than MaxDepth.

    Declaration
    public static bool IsWellFormed(AchievementCondition root)
    Parameters
    Type Name Description
    AchievementCondition root

    The tree's root. Null is well formed: there is nothing to walk.

    Returns
    Type Description
    bool
    Remarks

    A node appearing twice is treated as malformed even when the second appearance is a diamond rather than a cycle, because a shared instance cannot hold two different tallies — its captured state would be written once and restored into both places.

    In this article
    © 2026 Serenity. All Rights Reserved