diff --git a/ProjectObsidian/ProtoFlux/Math/Factorial.cs b/ProjectObsidian/ProtoFlux/Math/Factorial.cs new file mode 100644 index 0000000..158cc8d --- /dev/null +++ b/ProjectObsidian/ProtoFlux/Math/Factorial.cs @@ -0,0 +1,24 @@ +using System; +using Elements.Core; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; +using FrooxEngine.ProtoFlux; + +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math +{ + [NodeCategory("Obsidian/Math")] + [NodeName("Factorial")] + public class FactorialNode : ValueFunctionNode + { + public ValueInput Input; + + protected override int Compute(FrooxEngineContext context) + { + var input = Input.Evaluate(context); + var fact = 1; + var loop = MathX.Clamp(input, 0, 16); + for (var i = 1; i <= loop; i++) fact *= i; + return fact; + } + } +}