using UnityEngine;
namespace Unity.VisualScripting
{
///
/// Returns the power of a base and exponent.
///
[UnitCategory("Math/Scalar")]
[UnitTitle("Exponentiate")]
[UnitOrder(105)]
public sealed class ScalarExponentiate : Unit
{
///
/// The base.
///
[DoNotSerialize]
[PortLabel("x")]
public ValueInput @base { get; private set; }
///
/// The exponent.
///
[DoNotSerialize]
[PortLabel("n")]
public ValueInput exponent { get; private set; }
///
/// The power of base elevated to exponent.
///
[DoNotSerialize]
[PortLabel("x\u207f")]
public ValueOutput power { get; private set; }
protected override void Definition()
{
@base = ValueInput(nameof(@base), 1);
exponent = ValueInput(nameof(exponent), 2);
power = ValueOutput(nameof(power), Exponentiate);
Requirement(@base, power);
Requirement(exponent, power);
}
public float Exponentiate(Flow flow)
{
return Mathf.Pow(flow.GetValue(@base), flow.GetValue(exponent));
}
}
}