Editor/Embedded/ValveResourceFormat/ResourceTypes/ModelFlex/FlexOps/FlexOpMax.cs

A Flex operation type used in the model flex rule system, implementing a Max operator. It pops two float values from a provided execution stack and pushes the larger value back onto the stack.

Reflection
#nullable enable
using System;
using System.Collections.Generic;
using System.Linq;
using HumanoidRetargeter.EditorTools.Embedded.ValveResourceFormat.Utils;
namespace HumanoidRetargeter.EditorTools.Embedded.ValveResourceFormat.ResourceTypes.ModelFlex.FlexOps;

    /// <summary>
    /// Flex operation that computes the maximum of two values.
    /// </summary>
    public class FlexOpMax : FlexOp
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="FlexOpMax"/> class.
        /// </summary>
        public FlexOpMax(float data) : base(data) { }

        /// <inheritdoc/>
        /// <remarks>
        /// Pops two values from the stack and pushes the maximum value.
        /// </remarks>
        public override void Run(in FlexRuleContext context)
        {
            var v1 = context.Stack.Pop();
            var v2 = context.Stack.Pop();

            context.Stack.Push(Math.Max(v1, v2));
        }
    }