A game about forced loneliness, made by TACStudios
1using UnityEngine;
2
3namespace Unity.VisualScripting
4{
5 /// <summary>
6 /// Returns the power of a base and exponent.
7 /// </summary>
8 [UnitCategory("Math/Scalar")]
9 [UnitTitle("Exponentiate")]
10 [UnitOrder(105)]
11 public sealed class ScalarExponentiate : Unit
12 {
13 /// <summary>
14 /// The base.
15 /// </summary>
16 [DoNotSerialize]
17 [PortLabel("x")]
18 public ValueInput @base { get; private set; }
19
20 /// <summary>
21 /// The exponent.
22 /// </summary>
23 [DoNotSerialize]
24 [PortLabel("n")]
25 public ValueInput exponent { get; private set; }
26
27 /// <summary>
28 /// The power of base elevated to exponent.
29 /// </summary>
30 [DoNotSerialize]
31 [PortLabel("x\u207f")]
32 public ValueOutput power { get; private set; }
33
34 protected override void Definition()
35 {
36 @base = ValueInput<float>(nameof(@base), 1);
37 exponent = ValueInput<float>(nameof(exponent), 2);
38 power = ValueOutput(nameof(power), Exponentiate);
39
40 Requirement(@base, power);
41 Requirement(exponent, power);
42 }
43
44 public float Exponentiate(Flow flow)
45 {
46 return Mathf.Pow(flow.GetValue<float>(@base), flow.GetValue<float>(exponent));
47 }
48 }
49}