From a5c335bf8fe5946d20cb0e59b6ed61269f7a218f Mon Sep 17 00:00:00 2001 From: xLinka Date: Tue, 25 Jun 2024 13:33:25 +0100 Subject: [PATCH] Create Factorial Node Reference #1688 https://github.com/Yellow-Dog-Man/Resonite-Issues/issues/1688 Adding factorial node as a basis for ticket 1688 on main github --- ProjectObsidian/ProtoFlux/Math/Factorial.cs | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 ProjectObsidian/ProtoFlux/Math/Factorial.cs 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; + } + } +}