From b9ead7812f3a43c1d6565e139880f9821824748f Mon Sep 17 00:00:00 2001 From: frozenreflex Date: Wed, 17 Apr 2024 14:27:55 -0500 Subject: [PATCH 01/13] Fix node prefixes --- ProjectObsidian/ProtoFlux/Devices/ViveTrackerBattery.cs | 2 +- .../ProtoFlux/Math/Physics/CentripetalForceCalculationNode.cs | 1 + ProjectObsidian/ProtoFlux/Strings/CountSubstring.cs | 2 +- ProjectObsidian/ProtoFlux/Strings/DecodeBase64Node.cs | 2 +- ProjectObsidian/ProtoFlux/Strings/DecodeMorseNode.cs | 2 +- ProjectObsidian/ProtoFlux/Strings/EncodeBase64Node.cs | 2 +- ProjectObsidian/ProtoFlux/Strings/EncodeMD5.cs | 2 +- ProjectObsidian/ProtoFlux/Strings/EncodeMorse.cs | 2 +- ProjectObsidian/ProtoFlux/Strings/EncodeSHA256.cs | 2 +- ProjectObsidian/ProtoFlux/Strings/HMAC.cs | 2 +- ProjectObsidian/ProtoFlux/Strings/HammingDistanceNode.cs | 2 +- .../ProtoFlux/Strings/HammingDistanceNonNullableNode.cs | 2 +- ProjectObsidian/ProtoFlux/Users/IsUserInNoclipNode.cs | 2 +- ProjectObsidian/ProtoFlux/Users/Status/IsUserInSeatedMode.cs | 2 +- 14 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ProjectObsidian/ProtoFlux/Devices/ViveTrackerBattery.cs b/ProjectObsidian/ProtoFlux/Devices/ViveTrackerBattery.cs index 53d624c..868b8df 100644 --- a/ProjectObsidian/ProtoFlux/Devices/ViveTrackerBattery.cs +++ b/ProjectObsidian/ProtoFlux/Devices/ViveTrackerBattery.cs @@ -11,7 +11,7 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.FrooxEngine.Input; -[NodeCategory("Devices")] +[NodeCategory("Obsidian/Devices")] public class ViveTrackerBattery : VoidNode { public ObjectArgument User; diff --git a/ProjectObsidian/ProtoFlux/Math/Physics/CentripetalForceCalculationNode.cs b/ProjectObsidian/ProtoFlux/Math/Physics/CentripetalForceCalculationNode.cs index ca10a98..b3ddaef 100644 --- a/ProjectObsidian/ProtoFlux/Math/Physics/CentripetalForceCalculationNode.cs +++ b/ProjectObsidian/ProtoFlux/Math/Physics/CentripetalForceCalculationNode.cs @@ -7,6 +7,7 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Physics { + [NodeCategory("Obsidian/Math/Physics")] public class CentripetalForceCalculationNode : ValueFunctionNode { public ValueInput Mass; diff --git a/ProjectObsidian/ProtoFlux/Strings/CountSubstring.cs b/ProjectObsidian/ProtoFlux/Strings/CountSubstring.cs index 5a5834a..cb77e90 100644 --- a/ProjectObsidian/ProtoFlux/Strings/CountSubstring.cs +++ b/ProjectObsidian/ProtoFlux/Strings/CountSubstring.cs @@ -5,7 +5,7 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Strings { - [NodeCategory("ProtoFlux/Obsidian/String")] + [NodeCategory("Obsidian/String")] public class CountSubstringNode : ValueFunctionNode { public readonly ObjectInput String; diff --git a/ProjectObsidian/ProtoFlux/Strings/DecodeBase64Node.cs b/ProjectObsidian/ProtoFlux/Strings/DecodeBase64Node.cs index 7a410d5..2fc125f 100644 --- a/ProjectObsidian/ProtoFlux/Strings/DecodeBase64Node.cs +++ b/ProjectObsidian/ProtoFlux/Strings/DecodeBase64Node.cs @@ -6,7 +6,7 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Strings { - [NodeCategory("ProtoFlux/Obsidian/String")] + [NodeCategory("Obsidian/String")] public class DecodeBase64Node : ObjectFunctionNode { public readonly ObjectInput Input; diff --git a/ProjectObsidian/ProtoFlux/Strings/DecodeMorseNode.cs b/ProjectObsidian/ProtoFlux/Strings/DecodeMorseNode.cs index e22153f..2163d1a 100644 --- a/ProjectObsidian/ProtoFlux/Strings/DecodeMorseNode.cs +++ b/ProjectObsidian/ProtoFlux/Strings/DecodeMorseNode.cs @@ -7,7 +7,7 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Strings { - [NodeCategory("ProtoFlux/Obsidian/String")] + [NodeCategory("Obsidian/String")] public class DecodeMorseNode : ObjectFunctionNode { public readonly ObjectInput Input; diff --git a/ProjectObsidian/ProtoFlux/Strings/EncodeBase64Node.cs b/ProjectObsidian/ProtoFlux/Strings/EncodeBase64Node.cs index 488b454..f9bac39 100644 --- a/ProjectObsidian/ProtoFlux/Strings/EncodeBase64Node.cs +++ b/ProjectObsidian/ProtoFlux/Strings/EncodeBase64Node.cs @@ -6,7 +6,7 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Strings { - [NodeCategory("ProtoFlux/Obsidian/String")] + [NodeCategory("Obsidian/String")] public class EncodeBase64Node : ObjectFunctionNode { public readonly ObjectInput Input; diff --git a/ProjectObsidian/ProtoFlux/Strings/EncodeMD5.cs b/ProjectObsidian/ProtoFlux/Strings/EncodeMD5.cs index 1ce2c72..f651c29 100644 --- a/ProjectObsidian/ProtoFlux/Strings/EncodeMD5.cs +++ b/ProjectObsidian/ProtoFlux/Strings/EncodeMD5.cs @@ -7,7 +7,7 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Strings { - [NodeCategory("ProtoFlux/Obsidian/String")] + [NodeCategory("Obsidian/String")] public class EncodeMD5Node : ObjectFunctionNode { private static readonly MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider(); diff --git a/ProjectObsidian/ProtoFlux/Strings/EncodeMorse.cs b/ProjectObsidian/ProtoFlux/Strings/EncodeMorse.cs index 7f715db..811d627 100644 --- a/ProjectObsidian/ProtoFlux/Strings/EncodeMorse.cs +++ b/ProjectObsidian/ProtoFlux/Strings/EncodeMorse.cs @@ -7,7 +7,7 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Strings { - [NodeCategory("ProtoFlux/Obsidian/String")] + [NodeCategory("Obsidian/String")] public class EncodeMorseNode : ObjectFunctionNode { public readonly ObjectInput Input; diff --git a/ProjectObsidian/ProtoFlux/Strings/EncodeSHA256.cs b/ProjectObsidian/ProtoFlux/Strings/EncodeSHA256.cs index e28332e..77ef680 100644 --- a/ProjectObsidian/ProtoFlux/Strings/EncodeSHA256.cs +++ b/ProjectObsidian/ProtoFlux/Strings/EncodeSHA256.cs @@ -7,7 +7,7 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Strings { - [NodeCategory("ProtoFlux/Obsidian/String")] + [NodeCategory("Obsidian/String")] public class EncodeSha256Node : ObjectFunctionNode { private static readonly SHA256 SHA = SHA256.Create(); diff --git a/ProjectObsidian/ProtoFlux/Strings/HMAC.cs b/ProjectObsidian/ProtoFlux/Strings/HMAC.cs index edf0633..00e4770 100644 --- a/ProjectObsidian/ProtoFlux/Strings/HMAC.cs +++ b/ProjectObsidian/ProtoFlux/Strings/HMAC.cs @@ -16,7 +16,7 @@ public enum HashFunction SHA512 } - [NodeCategory("ProtoFlux/Obsidian/String")] + [NodeCategory("Obsidian/String")] public class HMACNode : ObjectFunctionNode { public readonly ObjectInput Message; diff --git a/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNode.cs b/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNode.cs index b9c5a38..edcee5c 100644 --- a/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNode.cs +++ b/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNode.cs @@ -6,7 +6,7 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Strings { - [NodeCategory("ProtoFlux/Obsidian/String")] + [NodeCategory("Obsidian/String")] public class HammingDistanceNode : ObjectFunctionNode { public readonly ObjectInput String1; diff --git a/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNonNullableNode.cs b/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNonNullableNode.cs index c06702b..1c0f840 100644 --- a/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNonNullableNode.cs +++ b/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNonNullableNode.cs @@ -5,7 +5,7 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Strings { - [NodeCategory("ProtoFlux/Obsidian/String")] + [NodeCategory("Obsidian/String")] public class HammingDistanceNonNullableNode : ValueFunctionNode { public readonly ObjectInput String1; diff --git a/ProjectObsidian/ProtoFlux/Users/IsUserInNoclipNode.cs b/ProjectObsidian/ProtoFlux/Users/IsUserInNoclipNode.cs index 99e4879..e80c8dd 100644 --- a/ProjectObsidian/ProtoFlux/Users/IsUserInNoclipNode.cs +++ b/ProjectObsidian/ProtoFlux/Users/IsUserInNoclipNode.cs @@ -5,7 +5,7 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.FrooxEngine.Locomotion { [ContinuouslyChanging] - [NodeCategory("ProtoFlux/Obsidian/Locomotion")] + [NodeCategory("Obsidian/Locomotion")] public class IsUserInNoClipNode : ValueFunctionNode { public readonly ObjectInput User; diff --git a/ProjectObsidian/ProtoFlux/Users/Status/IsUserInSeatedMode.cs b/ProjectObsidian/ProtoFlux/Users/Status/IsUserInSeatedMode.cs index 9fc5ef2..1cf9c1f 100644 --- a/ProjectObsidian/ProtoFlux/Users/Status/IsUserInSeatedMode.cs +++ b/ProjectObsidian/ProtoFlux/Users/Status/IsUserInSeatedMode.cs @@ -5,7 +5,7 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.FrooxEngine.Locomotion { [ContinuouslyChanging] - [NodeCategory("ProtoFlux/Obsidian/Locomotion")] + [NodeCategory("Obsidian/Locomotion")] public class IsUserInSeatedModeNode : ValueFunctionNode { public readonly ObjectInput User; From a49f410dbea4e25987e2b0e8e2d39874b6568378 Mon Sep 17 00:00:00 2001 From: frozenreflex Date: Wed, 17 Apr 2024 14:30:57 -0500 Subject: [PATCH 02/13] Fix random nodes --- ProjectObsidian/ProtoFlux/Math/Random/RandomBool2.cs | 8 +++++--- ProjectObsidian/ProtoFlux/Math/Random/RandomBool3.cs | 4 +++- ProjectObsidian/ProtoFlux/Math/Random/RandomBool4.cs | 4 +++- ProjectObsidian/ProtoFlux/Math/Random/RandomCharacter.cs | 4 +++- ProjectObsidian/ProtoFlux/Math/Random/RandomDouble.cs | 4 +++- .../ProtoFlux/Math/Random/RandomEulerAngles.cs | 4 +++- ProjectObsidian/ProtoFlux/Math/Random/RandomInt2.cs | 4 +++- 7 files changed, 23 insertions(+), 9 deletions(-) diff --git a/ProjectObsidian/ProtoFlux/Math/Random/RandomBool2.cs b/ProjectObsidian/ProtoFlux/Math/Random/RandomBool2.cs index ce512b9..5217155 100644 --- a/ProjectObsidian/ProtoFlux/Math/Random/RandomBool2.cs +++ b/ProjectObsidian/ProtoFlux/Math/Random/RandomBool2.cs @@ -4,7 +4,9 @@ using ProtoFlux.Runtimes.Execution; using ProtoFlux.Runtimes.Execution.Nodes.Actions; -[NodeCategory("ProtoFlux/Obsidian/Math/Random")] +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Random; + +[NodeCategory("Obsidian/Math/Random")] [ContinuouslyChanging] public class RandomBool2 : ObjectFunctionNode @@ -13,8 +15,8 @@ public class RandomBool2 : ObjectFunctionNode protected override bool2 Compute(ExecutionContext context) { - float2 chance = Chance.Evaluate(context); - bool2 result = new bool2( + var chance = Chance.Evaluate(context); + var result = new bool2( RandomX.Chance(chance.x), RandomX.Chance(chance.y) ); diff --git a/ProjectObsidian/ProtoFlux/Math/Random/RandomBool3.cs b/ProjectObsidian/ProtoFlux/Math/Random/RandomBool3.cs index f9ec0a5..1ff6089 100644 --- a/ProjectObsidian/ProtoFlux/Math/Random/RandomBool3.cs +++ b/ProjectObsidian/ProtoFlux/Math/Random/RandomBool3.cs @@ -4,7 +4,9 @@ using ProtoFlux.Runtimes.Execution.Nodes.Actions; using FrooxEngine; -[NodeCategory("ProtoFlux/Obsidian/Math/Random")] +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Random; + +[NodeCategory("Obsidian/Math/Random")] [NodeName("Random Bool3")] [ContinuouslyChanging] public class RandomBool3 : ValueFunctionNode diff --git a/ProjectObsidian/ProtoFlux/Math/Random/RandomBool4.cs b/ProjectObsidian/ProtoFlux/Math/Random/RandomBool4.cs index 0926934..c5faabd 100644 --- a/ProjectObsidian/ProtoFlux/Math/Random/RandomBool4.cs +++ b/ProjectObsidian/ProtoFlux/Math/Random/RandomBool4.cs @@ -4,7 +4,9 @@ using ProtoFlux.Runtimes.Execution.Nodes.Actions; using FrooxEngine; -[NodeCategory("ProtoFlux/Obsidian/Math/Random")] +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Random; + +[NodeCategory("Obsidian/Math/Random")] [NodeName("Random Bool4")] [ContinuouslyChanging] public class RandomBool4 : ValueFunctionNode diff --git a/ProjectObsidian/ProtoFlux/Math/Random/RandomCharacter.cs b/ProjectObsidian/ProtoFlux/Math/Random/RandomCharacter.cs index e6bd71c..6c5bfeb 100644 --- a/ProjectObsidian/ProtoFlux/Math/Random/RandomCharacter.cs +++ b/ProjectObsidian/ProtoFlux/Math/Random/RandomCharacter.cs @@ -3,7 +3,9 @@ using ProtoFlux.Runtimes.Execution; using ProtoFlux.Runtimes.Execution.Nodes.Actions; -[NodeCategory("ProtoFlux/Obsidian/Math/Random")] +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Random; + +[NodeCategory("Obsidian/Math/Random")] [NodeName("Random Character")] [ContinuouslyChanging] public class RandomCharacter : ValueFunctionNode diff --git a/ProjectObsidian/ProtoFlux/Math/Random/RandomDouble.cs b/ProjectObsidian/ProtoFlux/Math/Random/RandomDouble.cs index b5f498f..fd832ec 100644 --- a/ProjectObsidian/ProtoFlux/Math/Random/RandomDouble.cs +++ b/ProjectObsidian/ProtoFlux/Math/Random/RandomDouble.cs @@ -3,7 +3,9 @@ using ProtoFlux.Runtimes.Execution; using ProtoFlux.Runtimes.Execution.Nodes.Actions; -[NodeCategory("ProtoFlux/Obsidian/Math/Random")] +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Random; + +[NodeCategory("Obsidian/Math/Random")] [NodeName("Random Double")] [ContinuouslyChanging] public class RandomDouble : ValueFunctionNode diff --git a/ProjectObsidian/ProtoFlux/Math/Random/RandomEulerAngles.cs b/ProjectObsidian/ProtoFlux/Math/Random/RandomEulerAngles.cs index 27ebf79..80e67a6 100644 --- a/ProjectObsidian/ProtoFlux/Math/Random/RandomEulerAngles.cs +++ b/ProjectObsidian/ProtoFlux/Math/Random/RandomEulerAngles.cs @@ -3,7 +3,9 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; -[NodeCategory("ProtoFlux/Obsidian/Math/Random")] +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Random; + +[NodeCategory("Obsidian/Math/Random")] [NodeName("Random Euler Angles")] [ContinuouslyChanging] diff --git a/ProjectObsidian/ProtoFlux/Math/Random/RandomInt2.cs b/ProjectObsidian/ProtoFlux/Math/Random/RandomInt2.cs index dbd9a77..bd1bd29 100644 --- a/ProjectObsidian/ProtoFlux/Math/Random/RandomInt2.cs +++ b/ProjectObsidian/ProtoFlux/Math/Random/RandomInt2.cs @@ -2,7 +2,9 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; -[NodeCategory("ProtoFlux/Obsidian/Math/Random")] +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Random; + +[NodeCategory("Obsidian/Math/Random")] [NodeName("Random Int2")] public class RandomInt2 : ValueFunctionNode { From 2ce4f6b8be683b9895207ad96c6de5fd0bdffc64 Mon Sep 17 00:00:00 2001 From: frozenreflex Date: Wed, 17 Apr 2024 14:31:49 -0500 Subject: [PATCH 03/13] Fix constants --- ProjectObsidian/ProtoFlux/Math/Constants/EpsilonDouble.cs | 4 +++- ProjectObsidian/ProtoFlux/Math/Constants/EpsilonFloat.cs | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ProjectObsidian/ProtoFlux/Math/Constants/EpsilonDouble.cs b/ProjectObsidian/ProtoFlux/Math/Constants/EpsilonDouble.cs index 073de3f..44fe20b 100644 --- a/ProjectObsidian/ProtoFlux/Math/Constants/EpsilonDouble.cs +++ b/ProjectObsidian/ProtoFlux/Math/Constants/EpsilonDouble.cs @@ -2,7 +2,9 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; -[NodeCategory("LogiX/NeosPlus/Math/Constants")] +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Constants; + +[NodeCategory("Obsidian/Math/Constants")] [NodeName("Epsilon Double")] public class EpsilonDouble : ValueFunctionNode { diff --git a/ProjectObsidian/ProtoFlux/Math/Constants/EpsilonFloat.cs b/ProjectObsidian/ProtoFlux/Math/Constants/EpsilonFloat.cs index 9524bc8..07db4f4 100644 --- a/ProjectObsidian/ProtoFlux/Math/Constants/EpsilonFloat.cs +++ b/ProjectObsidian/ProtoFlux/Math/Constants/EpsilonFloat.cs @@ -2,7 +2,9 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; -[NodeCategory("Protoflux/Obsidian/Math/Constants")] +namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Constants; + +[NodeCategory("Obsidian/Math/Constants")] [NodeName("Epsilon Float")] public class EpsilonFloat : ValueFunctionNode { From e27114e85ca472a50a7551ec88063cee90e32e86 Mon Sep 17 00:00:00 2001 From: frozenreflex Date: Wed, 17 Apr 2024 14:52:23 -0500 Subject: [PATCH 04/13] Add arguments to bindings, define binding variables in order of original file --- .../BindingGenerator.cs | 67 ++++++++++--------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/ProjectObsidian.SourceGenerators/BindingGenerator.cs b/ProjectObsidian.SourceGenerators/BindingGenerator.cs index be79f15..f7020fc 100644 --- a/ProjectObsidian.SourceGenerators/BindingGenerator.cs +++ b/ProjectObsidian.SourceGenerators/BindingGenerator.cs @@ -53,27 +53,6 @@ public class BindingGeneratorSyntaxWalker : CSharpSyntaxWalker _usingDeclarations .Where(u => !string.IsNullOrWhiteSpace(u)) .Aggregate("", (current, u) => current + $"using {u};\n"); - - private string ObjectInputDeclaration => _objectInputs.Aggregate("", - (current, pair) => - current + $" new public readonly SyncRef> {pair.Key};\n"); - - private string ObjectOutputDeclaration => _objectOutputs.Aggregate("", - (current, pair) => - current + $" new public readonly NodeObjectOutput<{pair.Value}> {pair.Key};\n"); - - private string ValueInputDeclaration => _valueInputs.Aggregate("", - (current, pair) => - current + $" new public readonly SyncRef> {pair.Key};\n"); - - private string ValueOutputDeclaration => _valueOutputs.Aggregate("", - (current, pair) => - current + $" new public readonly NodeValueOutput<{pair.Value}> {pair.Key};\n"); - - private string ImpulseDeclaration => _impulseOrder.Aggregate("", - (current, name) => - current + $" new public readonly SyncRef {name};\n"); - private string InputCountOverride => _inputOrder.Count == 0 ? "" : $" public override int NodeInputCount => base.NodeInputCount + {_inputOrder.Count};"; @@ -181,6 +160,9 @@ protected override INodeOutput GetOutputInternal(ref int index) } } + private List _declarations = []; + private string Declarations => string.Concat(_declarations); + public string Result { get @@ -196,11 +178,7 @@ namespace {BindingPrefix}{_currentNameSpace}; [Category(new string[] {{""ProtoFlux/Runtimes/Execution/Nodes/{_category}""}})] public partial class {_fullName} : {_baseType} {{ -{ObjectInputDeclaration} -{ObjectOutputDeclaration} -{ValueInputDeclaration} -{ValueOutputDeclaration} -{ImpulseDeclaration} +{Declarations} public override System.Type NodeType => typeof ({_currentNameSpace}.{_fullName}); public {_currentNameSpace}.{_fullName} TypedNodeInstance {{ get; private set; }} public override INode NodeInstance => (INode)this.TypedNodeInstance; @@ -252,31 +230,60 @@ public override void VisitFieldDeclaration(FieldDeclarationSyntax node) { var type = node.Declaration.Type.ToString(); var name = node.Declaration.Variables.First().ToString(); + + //object in/out if (type.Contains("ObjectInput<")) { - _objectInputs.Add(name, type.TrimEnds("ObjectInput<".Length, 1)); + var t = type.TrimEnds("ObjectInput<".Length, 1); + _objectInputs.Add(name, t); _inputOrder.Add(name); + _declarations.Add($" new public readonly SyncRef> {name};\n"); } if (type.Contains("ObjectOutput<")) { - _objectOutputs.Add(name, type.TrimEnds("ObjectOutput<".Length, 1)); + var t = type.TrimEnds("ObjectOutput<".Length, 1); + _objectOutputs.Add(name, t); _outputOrder.Add(name); + _declarations.Add($" new public readonly NodeObjectOutput<{t}> {name};\n"); } + //value in/out if (type.Contains("ValueInput<")) { - _valueInputs.Add(name, type.TrimEnds("ValueInput<".Length, 1)); + var t = type.TrimEnds("ValueInput<".Length, 1); + _valueInputs.Add(name, t); _inputOrder.Add(name); + _declarations.Add($" new public readonly SyncRef> {name};\n"); } if (type.Contains("ValueOutput<")) { - _valueOutputs.Add(name, type.TrimEnds("ValueOutput<".Length, 1)); + var t = type.TrimEnds("ValueOutput<".Length, 1); + _valueOutputs.Add(name, t); _outputOrder.Add(name); + _declarations.Add($" new public readonly NodeValueOutput<{t}> {name};\n"); } + //impulses if (type.EndsWith("Continuation")) { _impulseOrder.Add(name); + _declarations.Add($" new public readonly SyncRef {name};\n"); + } + + //arguments + if (type.Contains("ObjectArgument<")) + { + var t = type.TrimEnds("ObjectArgument<".Length, 1); + _objectArguments.Add(name, t); + _inputOrder.Add(name); + _declarations.Add($" new public readonly SyncRef> {name};\n"); + } + if (type.Contains("ValueArgument<")) + { + var t = type.TrimEnds("ValueArgument<".Length, 1); + _valueArguments.Add(name, t); + _inputOrder.Add(name); + _declarations.Add($" new public readonly SyncRef> {name};\n"); } base.VisitFieldDeclaration(node); } From 64d5b5667f654a06ee467ff65460c6b032b7a211 Mon Sep 17 00:00:00 2001 From: frozenreflex Date: Wed, 17 Apr 2024 16:13:52 -0500 Subject: [PATCH 05/13] Fix crashes --- .../BindingGenerator.cs | 19 +++++++++++-------- .../ProtoFlux/JSON/JsonAppendToArray.cs | 5 +++-- .../JSON/JsonCountArrayChildrenNode.cs | 7 ++++--- .../JSON/JsonCountObjectChildrenNode.cs | 7 ++++--- ProjectObsidian/ProtoFlux/JSON/JsonEmpty.cs | 15 ++++++++------- .../ProtoFlux/JSON/JsonGetFromArrayNode.cs | 5 +++-- .../ProtoFlux/JSON/JsonGetFromObject.cs | 5 +++-- .../ProtoFlux/JSON/JsonInsertToArrayNode.cs | 7 ++++--- .../ProtoFlux/JSON/JsonParseStringArray.cs | 5 +++-- .../ProtoFlux/JSON/JsonParseStringNode.cs | 5 +++-- .../ProtoFlux/JSON/JsonQuickGetObject.cs | 5 +++-- .../ProtoFlux/JSON/JsonRemoveFromArrayNode.cs | 5 +++-- .../JSON/JsonRemoveFromObjectNode.cs | 5 +++-- .../ProtoFlux/JSON/JsonToStringNode.cs | 5 +++-- .../ProtoFlux/Math/Constants/EpsilonDouble.cs | 5 +++-- .../ProtoFlux/Math/Constants/EpsilonFloat.cs | 5 +++-- .../CentripetalForceCalculationNode.cs | 5 +++-- .../Math/Physics/DragCalculationNode.cs | 5 +++-- .../Math/Physics/KinecticFrictionNode.cs | 5 +++-- .../Math/Physics/RefractCalculationNode.cs | 5 +++-- .../ProtoFlux/Math/Random/RandomBool2.cs | 5 +++-- .../ProtoFlux/Math/Random/RandomBool3.cs | 5 +++-- .../ProtoFlux/Math/Random/RandomBool4.cs | 5 +++-- .../ProtoFlux/Math/Random/RandomCharacter.cs | 5 +++-- .../ProtoFlux/Math/Random/RandomDouble.cs | 5 +++-- .../Math/Random/RandomEulerAngles.cs | 5 +++-- .../ProtoFlux/Math/Random/RandomInt2.cs | 5 +++-- .../ProtoFlux/Strings/CountSubstring.cs | 5 +++-- .../ProtoFlux/Strings/DecodeBase64Node.cs | 5 +++-- .../ProtoFlux/Strings/DecodeMorseNode.cs | 5 +++-- .../ProtoFlux/Strings/EncodeBase64Node.cs | 5 +++-- .../ProtoFlux/Strings/EncodeMD5.cs | 5 +++-- .../ProtoFlux/Strings/EncodeMorse.cs | 5 +++-- .../ProtoFlux/Strings/EncodeSHA256.cs | 5 +++-- ProjectObsidian/ProtoFlux/Strings/HMAC.cs | 5 +++-- .../Strings/HammingDistanceNonNullableNode.cs | 5 +++-- .../ProtoFlux/Users/IsUserInNoclipNode.cs | 19 ++++++------------- .../Users/Status/IsUserInSeatedMode.cs | 9 +++++---- 38 files changed, 135 insertions(+), 103 deletions(-) diff --git a/ProjectObsidian.SourceGenerators/BindingGenerator.cs b/ProjectObsidian.SourceGenerators/BindingGenerator.cs index f7020fc..2341414 100644 --- a/ProjectObsidian.SourceGenerators/BindingGenerator.cs +++ b/ProjectObsidian.SourceGenerators/BindingGenerator.cs @@ -179,8 +179,8 @@ namespace {BindingPrefix}{_currentNameSpace}; public partial class {_fullName} : {_baseType} {{ {Declarations} - public override System.Type NodeType => typeof ({_currentNameSpace}.{_fullName}); - public {_currentNameSpace}.{_fullName} TypedNodeInstance {{ get; private set; }} + public override System.Type NodeType => typeof (global::{_currentNameSpace}.{_fullName}); + public global::{_currentNameSpace}.{_fullName} TypedNodeInstance {{ get; private set; }} public override INode NodeInstance => (INode)this.TypedNodeInstance; public override void ClearInstance() => this.TypedNodeInstance = null; {InputCountOverride} @@ -189,11 +189,11 @@ public partial class {_fullName} : {_baseType} public override N Instantiate() {{ if (this.TypedNodeInstance != null) throw new System.InvalidOperationException(""Node has already been instantiated""); - var localVar = new {_currentNameSpace}.{_fullName}(); + var localVar = new global::{_currentNameSpace}.{_fullName}(); this.TypedNodeInstance = localVar; return localVar as N; }} - protected override void AssociateInstanceInternal(INode node) => this.TypedNodeInstance = node is {_currentNameSpace}.{_fullName} localVar ? localVar : throw new System.ArgumentException(""Node instance is not of type "" + typeof ({_currentNameSpace}.{_fullName})?.ToString()); + protected override void AssociateInstanceInternal(INode node) => this.TypedNodeInstance = node is global::{_currentNameSpace}.{_fullName} localVar ? localVar : throw new System.ArgumentException(""Node instance is not of type "" + typeof (global::{_currentNameSpace}.{_fullName})?.ToString()); {GetInputInternalOverride} {GetOutputInternalOverride} {GetImpulseInternalOverride} @@ -206,6 +206,7 @@ public override N Instantiate() private bool _valid; private string _currentNameSpace; private string _fullName; + private string _additionalName = ""; public string BaseName; private string _baseType; private string _fullBaseType; @@ -318,11 +319,13 @@ public override void VisitClassDeclaration(ClassDeclarationSyntax node) if (node.TypeParameterList is not null) { - fullName += "<"; - fullName = node.TypeParameterList.Parameters.Aggregate(fullName, + _additionalName += "<"; + _additionalName = node.TypeParameterList.Parameters.Aggregate(_additionalName, (current, p) => current + $"{p.Identifier.Text},"); - fullName = fullName.Substring(0, fullName.Length - 1); //remove last , - fullName += ">"; + _additionalName = _additionalName.Substring(0, _additionalName.Length - 1); //remove last , + _additionalName += ">"; + + fullName += _additionalName; } BaseName = baseName; diff --git a/ProjectObsidian/ProtoFlux/JSON/JsonAppendToArray.cs b/ProjectObsidian/ProtoFlux/JSON/JsonAppendToArray.cs index 8843b1f..37c5037 100644 --- a/ProjectObsidian/ProtoFlux/JSON/JsonAppendToArray.cs +++ b/ProjectObsidian/ProtoFlux/JSON/JsonAppendToArray.cs @@ -4,6 +4,7 @@ using ProtoFlux.Runtimes.Execution; using FrooxEngine; using Elements.Core; +using FrooxEngine.ProtoFlux; namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json { @@ -11,11 +12,11 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json [GenericTypes(typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(string), typeof(Uri), typeof(JToken), typeof(JObject), typeof(JArray))] - public class JsonAppendToArrayNode : ObjectFunctionNode + public class JsonAppendToArrayNode : ObjectFunctionNode { public readonly ObjectInput Array; public readonly ObjectInput Object; - protected override JArray Compute(ExecutionContext context) + protected override JArray Compute(FrooxEngineContext context) { var array = Array.Evaluate(context); var obj = Object.Evaluate(context); diff --git a/ProjectObsidian/ProtoFlux/JSON/JsonCountArrayChildrenNode.cs b/ProjectObsidian/ProtoFlux/JSON/JsonCountArrayChildrenNode.cs index 5a5a8ee..3517dd2 100644 --- a/ProjectObsidian/ProtoFlux/JSON/JsonCountArrayChildrenNode.cs +++ b/ProjectObsidian/ProtoFlux/JSON/JsonCountArrayChildrenNode.cs @@ -1,15 +1,16 @@ -using Newtonsoft.Json.Linq; +using FrooxEngine.ProtoFlux; +using Newtonsoft.Json.Linq; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json { [NodeCategory("Obsidian/Json")] - public class JsonCountArrayChildrenNode : ValueFunctionNode + public class JsonCountArrayChildrenNode : ValueFunctionNode { public readonly ObjectInput Input; - protected override int Compute(ExecutionContext context) + protected override int Compute(FrooxEngineContext context) { var input = Input.Evaluate(context); return input?.Count ?? -1; diff --git a/ProjectObsidian/ProtoFlux/JSON/JsonCountObjectChildrenNode.cs b/ProjectObsidian/ProtoFlux/JSON/JsonCountObjectChildrenNode.cs index 7011d53..a4086da 100644 --- a/ProjectObsidian/ProtoFlux/JSON/JsonCountObjectChildrenNode.cs +++ b/ProjectObsidian/ProtoFlux/JSON/JsonCountObjectChildrenNode.cs @@ -1,15 +1,16 @@ -using Newtonsoft.Json.Linq; +using FrooxEngine.ProtoFlux; +using Newtonsoft.Json.Linq; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json { [NodeCategory("Obsidian/Json")] - public class JsonCountObjectChildrenNode : ValueFunctionNode + public class JsonCountObjectChildrenNode : ValueFunctionNode { public readonly ObjectInput Input; - protected override int Compute(ExecutionContext context) + protected override int Compute(FrooxEngineContext context) { var input = Input.Evaluate(context); return input?.Count ?? -1; diff --git a/ProjectObsidian/ProtoFlux/JSON/JsonEmpty.cs b/ProjectObsidian/ProtoFlux/JSON/JsonEmpty.cs index 0744d19..fc712e5 100644 --- a/ProjectObsidian/ProtoFlux/JSON/JsonEmpty.cs +++ b/ProjectObsidian/ProtoFlux/JSON/JsonEmpty.cs @@ -1,30 +1,31 @@ -using Newtonsoft.Json.Linq; +using FrooxEngine.ProtoFlux; +using Newtonsoft.Json.Linq; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json { [NodeCategory("Obsidian/Json")] - public class JsonEmptyObjectNode : ObjectFunctionNode + public class JsonEmptyObjectNode : ObjectFunctionNode { - protected override JObject Compute(ExecutionContext context) + protected override JObject Compute(FrooxEngineContext context) { return new JObject(); } } [NodeCategory("Obsidian/Json")] - public class JsonEmptyArrayNode : ObjectFunctionNode + public class JsonEmptyArrayNode : ObjectFunctionNode { - protected override JArray Compute(ExecutionContext context) + protected override JArray Compute(FrooxEngineContext context) { return new JArray(); } } [NodeCategory("Obsidian/Json")] - public class JsonNullValueNode : ObjectFunctionNode + public class JsonNullValueNode : ObjectFunctionNode { - protected override JToken Compute(ExecutionContext context) + protected override JToken Compute(FrooxEngineContext context) { return JValue.CreateNull(); } diff --git a/ProjectObsidian/ProtoFlux/JSON/JsonGetFromArrayNode.cs b/ProjectObsidian/ProtoFlux/JSON/JsonGetFromArrayNode.cs index bab1afe..2524b5a 100644 --- a/ProjectObsidian/ProtoFlux/JSON/JsonGetFromArrayNode.cs +++ b/ProjectObsidian/ProtoFlux/JSON/JsonGetFromArrayNode.cs @@ -4,6 +4,7 @@ using ProtoFlux.Runtimes.Execution; using Elements.Core; using FrooxEngine; +using FrooxEngine.ProtoFlux; namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json { @@ -11,13 +12,13 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json [GenericTypes(typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(string), typeof(Uri), typeof(JToken), typeof(JObject), typeof(JArray))] - public class JsonGetFromArrayNode : ObjectFunctionNode + public class JsonGetFromArrayNode : ObjectFunctionNode { public readonly ObjectInput Input; public readonly ObjectInput Index; - protected override T Compute(ExecutionContext context) + protected override T Compute(FrooxEngineContext context) { var input = Input.Evaluate(context); var index = Index.Evaluate(context); diff --git a/ProjectObsidian/ProtoFlux/JSON/JsonGetFromObject.cs b/ProjectObsidian/ProtoFlux/JSON/JsonGetFromObject.cs index 7f18dd1..64f8da4 100644 --- a/ProjectObsidian/ProtoFlux/JSON/JsonGetFromObject.cs +++ b/ProjectObsidian/ProtoFlux/JSON/JsonGetFromObject.cs @@ -4,6 +4,7 @@ using ProtoFlux.Runtimes.Execution; using Elements.Core; using FrooxEngine; +using FrooxEngine.ProtoFlux; namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json { @@ -11,12 +12,12 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json [GenericTypes(typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(string), typeof(Uri), typeof(JToken), typeof(JObject), typeof(JArray))] - public class JsonGetFromObjectNode : ObjectFunctionNode + public class JsonGetFromObjectNode : ObjectFunctionNode { public readonly ObjectInput Input; public readonly ObjectInput Tag; - protected override T Compute(ExecutionContext context) + protected override T Compute(FrooxEngineContext context) { var input = Input.Evaluate(context); var tag = Tag.Evaluate(context); diff --git a/ProjectObsidian/ProtoFlux/JSON/JsonInsertToArrayNode.cs b/ProjectObsidian/ProtoFlux/JSON/JsonInsertToArrayNode.cs index 3e1c315..044c924 100644 --- a/ProjectObsidian/ProtoFlux/JSON/JsonInsertToArrayNode.cs +++ b/ProjectObsidian/ProtoFlux/JSON/JsonInsertToArrayNode.cs @@ -4,6 +4,7 @@ using ProtoFlux.Runtimes.Execution; using Elements.Core; using FrooxEngine; +using FrooxEngine.ProtoFlux; namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json { @@ -11,13 +12,13 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json [GenericTypes(typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(string), typeof(Uri), typeof(JToken), typeof(JObject), typeof(JArray))] - public class JsonInsertToArrayNode : ObjectFunctionNode + public class JsonInsertToArrayNode : ObjectFunctionNode { public readonly ObjectInput Array; public readonly ObjectInput Object; public readonly ObjectInput Index; - protected override JArray Compute(ExecutionContext context) + protected override JArray Compute(FrooxEngineContext context) { var array = Array.Evaluate(context); var obj = Object.Evaluate(context); @@ -28,7 +29,7 @@ protected override JArray Compute(ExecutionContext context) try { var output = (JArray)array.DeepClone(); - JToken token = obj is JToken jToken ? jToken : new JValue(obj); + var token = obj is JToken jToken ? jToken : new JValue(obj); output.Insert(index, token); return output; } diff --git a/ProjectObsidian/ProtoFlux/JSON/JsonParseStringArray.cs b/ProjectObsidian/ProtoFlux/JSON/JsonParseStringArray.cs index 0cd6694..7d18d4d 100644 --- a/ProjectObsidian/ProtoFlux/JSON/JsonParseStringArray.cs +++ b/ProjectObsidian/ProtoFlux/JSON/JsonParseStringArray.cs @@ -1,4 +1,5 @@ using System; +using FrooxEngine.ProtoFlux; using Newtonsoft.Json.Linq; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; @@ -6,11 +7,11 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json { [NodeCategory("Obsidian/Json")] - public class JsonParseStringArrayNode : ObjectFunctionNode + public class JsonParseStringArrayNode : ObjectFunctionNode { public readonly ObjectInput Input; - protected override JArray Compute(ExecutionContext context) + protected override JArray Compute(FrooxEngineContext context) { var input = Input.Evaluate(context); if (string.IsNullOrEmpty(input)) diff --git a/ProjectObsidian/ProtoFlux/JSON/JsonParseStringNode.cs b/ProjectObsidian/ProtoFlux/JSON/JsonParseStringNode.cs index d841b4c..1624cd1 100644 --- a/ProjectObsidian/ProtoFlux/JSON/JsonParseStringNode.cs +++ b/ProjectObsidian/ProtoFlux/JSON/JsonParseStringNode.cs @@ -1,4 +1,5 @@ using System; +using FrooxEngine.ProtoFlux; using Newtonsoft.Json.Linq; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; @@ -6,12 +7,12 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json { [NodeCategory("Obsidian/Json")] - public class JsonParseStringNode : ObjectFunctionNode + public class JsonParseStringNode : ObjectFunctionNode { public readonly ObjectInput Input; - protected override JObject Compute(ExecutionContext context) + protected override JObject Compute(FrooxEngineContext context) { var input = Input.Evaluate(context); if (string.IsNullOrEmpty(input)) diff --git a/ProjectObsidian/ProtoFlux/JSON/JsonQuickGetObject.cs b/ProjectObsidian/ProtoFlux/JSON/JsonQuickGetObject.cs index d71289c..b5e491d 100644 --- a/ProjectObsidian/ProtoFlux/JSON/JsonQuickGetObject.cs +++ b/ProjectObsidian/ProtoFlux/JSON/JsonQuickGetObject.cs @@ -4,6 +4,7 @@ using ProtoFlux.Runtimes.Execution; using Elements.Core; using FrooxEngine; +using FrooxEngine.ProtoFlux; namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json { @@ -11,11 +12,11 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json [GenericTypes(typeof(byte), typeof(sbyte), typeof(short), typeof(ushort), typeof(int), typeof(uint), typeof(long), typeof(ulong), typeof(float), typeof(double), typeof(string), typeof(Uri), typeof(JToken), typeof(JObject), typeof(JArray))] - public class JsonQuickGetFromObjectNode : ObjectFunctionNode + public class JsonQuickGetFromObjectNode : ObjectFunctionNode { public readonly ObjectInput Input; public readonly ObjectInput Tag; - protected override T Compute(ExecutionContext context) + protected override T Compute(FrooxEngineContext context) { var input = Input.Evaluate(context); var tag = Tag.Evaluate(context); diff --git a/ProjectObsidian/ProtoFlux/JSON/JsonRemoveFromArrayNode.cs b/ProjectObsidian/ProtoFlux/JSON/JsonRemoveFromArrayNode.cs index 87526f6..25ea200 100644 --- a/ProjectObsidian/ProtoFlux/JSON/JsonRemoveFromArrayNode.cs +++ b/ProjectObsidian/ProtoFlux/JSON/JsonRemoveFromArrayNode.cs @@ -1,4 +1,5 @@ using System; +using FrooxEngine.ProtoFlux; using Newtonsoft.Json.Linq; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; @@ -6,13 +7,13 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json { [NodeCategory("Obsidian/Json")] - public class JsonRemoveFromArrayNode : ObjectFunctionNode + public class JsonRemoveFromArrayNode : ObjectFunctionNode { public readonly ObjectInput Array; public readonly ObjectInput Index; - protected override JArray Compute(ExecutionContext context) + protected override JArray Compute(FrooxEngineContext context) { var array = Array.Evaluate(context); var index = Index.Evaluate(context); diff --git a/ProjectObsidian/ProtoFlux/JSON/JsonRemoveFromObjectNode.cs b/ProjectObsidian/ProtoFlux/JSON/JsonRemoveFromObjectNode.cs index 0272e80..7fa503b 100644 --- a/ProjectObsidian/ProtoFlux/JSON/JsonRemoveFromObjectNode.cs +++ b/ProjectObsidian/ProtoFlux/JSON/JsonRemoveFromObjectNode.cs @@ -1,4 +1,5 @@ using System; +using FrooxEngine.ProtoFlux; using Newtonsoft.Json.Linq; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; @@ -6,13 +7,13 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json { [NodeCategory("Obsidian/Json")] - public class JsonRemoveFromObjectNode : ObjectFunctionNode + public class JsonRemoveFromObjectNode : ObjectFunctionNode { public readonly ObjectInput Input; public readonly ObjectInput Tag; - protected override JObject Compute(ExecutionContext context) + protected override JObject Compute(FrooxEngineContext context) { var input = Input.Evaluate(context); if (input == null) return null; diff --git a/ProjectObsidian/ProtoFlux/JSON/JsonToStringNode.cs b/ProjectObsidian/ProtoFlux/JSON/JsonToStringNode.cs index 6fdcf62..6d2ddd5 100644 --- a/ProjectObsidian/ProtoFlux/JSON/JsonToStringNode.cs +++ b/ProjectObsidian/ProtoFlux/JSON/JsonToStringNode.cs @@ -1,5 +1,6 @@ using System; using FrooxEngine; +using FrooxEngine.ProtoFlux; using Newtonsoft.Json.Linq; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; @@ -8,11 +9,11 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Json; [NodeCategory("Obsidian/Json")] [GenericTypes(typeof(JToken), typeof(JObject), typeof(JArray))] -public class JsonToStringNode : ObjectFunctionNode where T : JToken +public class JsonToStringNode : ObjectFunctionNode { public readonly ObjectInput Input; - protected override string Compute(ExecutionContext context) + protected override string Compute(FrooxEngineContext context) { var input = Input.Evaluate(context); return input?.ToString(); diff --git a/ProjectObsidian/ProtoFlux/Math/Constants/EpsilonDouble.cs b/ProjectObsidian/ProtoFlux/Math/Constants/EpsilonDouble.cs index 44fe20b..1bcb2c6 100644 --- a/ProjectObsidian/ProtoFlux/Math/Constants/EpsilonDouble.cs +++ b/ProjectObsidian/ProtoFlux/Math/Constants/EpsilonDouble.cs @@ -1,4 +1,5 @@ using Elements.Core; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; @@ -6,9 +7,9 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Constants; [NodeCategory("Obsidian/Math/Constants")] [NodeName("Epsilon Double")] -public class EpsilonDouble : ValueFunctionNode +public class EpsilonDouble : ValueFunctionNode { - protected override double Compute(ExecutionContext context) + protected override double Compute(FrooxEngineContext context) { return MathX.DOUBLE_EPSILON; } diff --git a/ProjectObsidian/ProtoFlux/Math/Constants/EpsilonFloat.cs b/ProjectObsidian/ProtoFlux/Math/Constants/EpsilonFloat.cs index 07db4f4..2626b29 100644 --- a/ProjectObsidian/ProtoFlux/Math/Constants/EpsilonFloat.cs +++ b/ProjectObsidian/ProtoFlux/Math/Constants/EpsilonFloat.cs @@ -1,4 +1,5 @@ using Elements.Core; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; @@ -6,9 +7,9 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Constants; [NodeCategory("Obsidian/Math/Constants")] [NodeName("Epsilon Float")] -public class EpsilonFloat : ValueFunctionNode +public class EpsilonFloat : ValueFunctionNode { - protected override float Compute(ExecutionContext context) + protected override float Compute(FrooxEngineContext context) { return MathX.FLOAT_EPSILON; } diff --git a/ProjectObsidian/ProtoFlux/Math/Physics/CentripetalForceCalculationNode.cs b/ProjectObsidian/ProtoFlux/Math/Physics/CentripetalForceCalculationNode.cs index b3ddaef..4bb176f 100644 --- a/ProjectObsidian/ProtoFlux/Math/Physics/CentripetalForceCalculationNode.cs +++ b/ProjectObsidian/ProtoFlux/Math/Physics/CentripetalForceCalculationNode.cs @@ -4,17 +4,18 @@ using ProtoFlux.Runtimes.Execution; using ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Physics; using System; +using FrooxEngine.ProtoFlux; namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Physics { [NodeCategory("Obsidian/Math/Physics")] - public class CentripetalForceCalculationNode : ValueFunctionNode + public class CentripetalForceCalculationNode : ValueFunctionNode { public ValueInput Mass; public ValueInput Velocity; public ValueInput Radius; - protected override float Compute(ExecutionContext context) + protected override float Compute(FrooxEngineContext context) { try { diff --git a/ProjectObsidian/ProtoFlux/Math/Physics/DragCalculationNode.cs b/ProjectObsidian/ProtoFlux/Math/Physics/DragCalculationNode.cs index 79b9616..33c326e 100644 --- a/ProjectObsidian/ProtoFlux/Math/Physics/DragCalculationNode.cs +++ b/ProjectObsidian/ProtoFlux/Math/Physics/DragCalculationNode.cs @@ -3,18 +3,19 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; using System; +using FrooxEngine.ProtoFlux; namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Physics { [NodeCategory("Obsidian/Math/Physics")] - public class DragCalculationNode : ValueFunctionNode + public class DragCalculationNode : ValueFunctionNode { public ValueInput FluidDensity; // rho public ValueInput ObjectVelocity; // v public ValueInput DragCoefficient; // Cd public ValueInput CrossSectionalArea; // A - protected override float3 Compute(ExecutionContext context) + protected override float3 Compute(FrooxEngineContext context) { float rho = FluidDensity.Evaluate(context); float3 v = ObjectVelocity.Evaluate(context); diff --git a/ProjectObsidian/ProtoFlux/Math/Physics/KinecticFrictionNode.cs b/ProjectObsidian/ProtoFlux/Math/Physics/KinecticFrictionNode.cs index 091a480..15b67db 100644 --- a/ProjectObsidian/ProtoFlux/Math/Physics/KinecticFrictionNode.cs +++ b/ProjectObsidian/ProtoFlux/Math/Physics/KinecticFrictionNode.cs @@ -3,16 +3,17 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; using System; +using FrooxEngine.ProtoFlux; namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Physics { [NodeCategory("Obsidian/Math/Physics")] - public class KineticFrictionNode : ValueFunctionNode + public class KineticFrictionNode : ValueFunctionNode { public ValueInput NormalForce; public ValueInput KineticFrictionCoefficient; - protected override float3 Compute(ExecutionContext context) + protected override float3 Compute(FrooxEngineContext context) { float3 normal = NormalForce.Evaluate(context); float coefficient = KineticFrictionCoefficient.Evaluate(context); diff --git a/ProjectObsidian/ProtoFlux/Math/Physics/RefractCalculationNode.cs b/ProjectObsidian/ProtoFlux/Math/Physics/RefractCalculationNode.cs index d317375..bd0b67b 100644 --- a/ProjectObsidian/ProtoFlux/Math/Physics/RefractCalculationNode.cs +++ b/ProjectObsidian/ProtoFlux/Math/Physics/RefractCalculationNode.cs @@ -3,17 +3,18 @@ using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; using System; +using FrooxEngine.ProtoFlux; namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Physics { [NodeCategory("Obsidian/Math/Physics")] - public class RefractionNode : ValueFunctionNode + public class RefractionNode : ValueFunctionNode { public ValueInput RefractiveIndex1; public ValueInput RefractiveIndex2; public ValueInput AngleOfIncidence; - protected override float Compute(ExecutionContext context) + protected override float Compute(FrooxEngineContext context) { float n1 = RefractiveIndex1.Evaluate(context); float n2 = RefractiveIndex2.Evaluate(context); diff --git a/ProjectObsidian/ProtoFlux/Math/Random/RandomBool2.cs b/ProjectObsidian/ProtoFlux/Math/Random/RandomBool2.cs index 5217155..5ce02eb 100644 --- a/ProjectObsidian/ProtoFlux/Math/Random/RandomBool2.cs +++ b/ProjectObsidian/ProtoFlux/Math/Random/RandomBool2.cs @@ -1,5 +1,6 @@ using System; using Elements.Core; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; using ProtoFlux.Runtimes.Execution.Nodes.Actions; @@ -9,11 +10,11 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Random; [NodeCategory("Obsidian/Math/Random")] [ContinuouslyChanging] -public class RandomBool2 : ObjectFunctionNode +public class RandomBool2 : ObjectFunctionNode { public ValueInput Chance; - protected override bool2 Compute(ExecutionContext context) + protected override bool2 Compute(FrooxEngineContext context) { var chance = Chance.Evaluate(context); var result = new bool2( diff --git a/ProjectObsidian/ProtoFlux/Math/Random/RandomBool3.cs b/ProjectObsidian/ProtoFlux/Math/Random/RandomBool3.cs index 1ff6089..8e12411 100644 --- a/ProjectObsidian/ProtoFlux/Math/Random/RandomBool3.cs +++ b/ProjectObsidian/ProtoFlux/Math/Random/RandomBool3.cs @@ -3,17 +3,18 @@ using ProtoFlux.Runtimes.Execution; using ProtoFlux.Runtimes.Execution.Nodes.Actions; using FrooxEngine; +using FrooxEngine.ProtoFlux; namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Random; [NodeCategory("Obsidian/Math/Random")] [NodeName("Random Bool3")] [ContinuouslyChanging] -public class RandomBool3 : ValueFunctionNode +public class RandomBool3 : ValueFunctionNode { public ValueInput Chance; - protected override bool3 Compute(ExecutionContext context) + protected override bool3 Compute(FrooxEngineContext context) { var chance = Chance.Evaluate(context); return new bool3(RandomX.Chance(chance.x), RandomX.Chance(chance.y), RandomX.Chance(chance.z)); diff --git a/ProjectObsidian/ProtoFlux/Math/Random/RandomBool4.cs b/ProjectObsidian/ProtoFlux/Math/Random/RandomBool4.cs index c5faabd..da9c8f0 100644 --- a/ProjectObsidian/ProtoFlux/Math/Random/RandomBool4.cs +++ b/ProjectObsidian/ProtoFlux/Math/Random/RandomBool4.cs @@ -3,17 +3,18 @@ using ProtoFlux.Runtimes.Execution; using ProtoFlux.Runtimes.Execution.Nodes.Actions; using FrooxEngine; +using FrooxEngine.ProtoFlux; namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Random; [NodeCategory("Obsidian/Math/Random")] [NodeName("Random Bool4")] [ContinuouslyChanging] -public class RandomBool4 : ValueFunctionNode +public class RandomBool4 : ValueFunctionNode { public ValueInput Chance; - protected override bool4 Compute(ExecutionContext context) + protected override bool4 Compute(FrooxEngineContext context) { var chance = Chance.Evaluate(context); return new bool4( diff --git a/ProjectObsidian/ProtoFlux/Math/Random/RandomCharacter.cs b/ProjectObsidian/ProtoFlux/Math/Random/RandomCharacter.cs index 6c5bfeb..c64b917 100644 --- a/ProjectObsidian/ProtoFlux/Math/Random/RandomCharacter.cs +++ b/ProjectObsidian/ProtoFlux/Math/Random/RandomCharacter.cs @@ -1,4 +1,5 @@ using Elements.Core; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; using ProtoFlux.Runtimes.Execution.Nodes.Actions; @@ -8,13 +9,13 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Random; [NodeCategory("Obsidian/Math/Random")] [NodeName("Random Character")] [ContinuouslyChanging] -public class RandomCharacter : ValueFunctionNode +public class RandomCharacter : ValueFunctionNode { public ValueInput Start; public ValueInput End; public ObjectInput String; - protected override char Compute(ExecutionContext context) + protected override char Compute(FrooxEngineContext context) { var str = String.Evaluate(context); var start = MathX.Clamp(Start.Evaluate(context), 0, str.Length); diff --git a/ProjectObsidian/ProtoFlux/Math/Random/RandomDouble.cs b/ProjectObsidian/ProtoFlux/Math/Random/RandomDouble.cs index fd832ec..da0c26e 100644 --- a/ProjectObsidian/ProtoFlux/Math/Random/RandomDouble.cs +++ b/ProjectObsidian/ProtoFlux/Math/Random/RandomDouble.cs @@ -1,4 +1,5 @@ using Elements.Core; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; using ProtoFlux.Runtimes.Execution.Nodes.Actions; @@ -8,12 +9,12 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Random; [NodeCategory("Obsidian/Math/Random")] [NodeName("Random Double")] [ContinuouslyChanging] -public class RandomDouble : ValueFunctionNode +public class RandomDouble : ValueFunctionNode { public ValueInput Min; public ValueInput Max; - protected override double Compute(ExecutionContext context) + protected override double Compute(FrooxEngineContext context) { var min = Min.Evaluate(context); var max = Max.Evaluate(context); diff --git a/ProjectObsidian/ProtoFlux/Math/Random/RandomEulerAngles.cs b/ProjectObsidian/ProtoFlux/Math/Random/RandomEulerAngles.cs index 80e67a6..a774882 100644 --- a/ProjectObsidian/ProtoFlux/Math/Random/RandomEulerAngles.cs +++ b/ProjectObsidian/ProtoFlux/Math/Random/RandomEulerAngles.cs @@ -1,5 +1,6 @@ using Elements.Core; using FrooxEngine; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; @@ -9,7 +10,7 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Random; [NodeName("Random Euler Angles")] [ContinuouslyChanging] -public class RandomEulerAngles : ValueFunctionNode +public class RandomEulerAngles : ValueFunctionNode { public ValueInput minPitch; public ValueInput maxPitch; @@ -18,7 +19,7 @@ public class RandomEulerAngles : ValueFunctionNode public ValueInput minRoll; public ValueInput maxRoll; - protected override float3 Compute(ExecutionContext context) + protected override float3 Compute(FrooxEngineContext context) { float pitch = RandomX.Range(minPitch.Evaluate(context), maxPitch.Evaluate(context)); float yaw = RandomX.Range(minYaw.Evaluate(context), maxYaw.Evaluate(context)); diff --git a/ProjectObsidian/ProtoFlux/Math/Random/RandomInt2.cs b/ProjectObsidian/ProtoFlux/Math/Random/RandomInt2.cs index bd1bd29..40f500b 100644 --- a/ProjectObsidian/ProtoFlux/Math/Random/RandomInt2.cs +++ b/ProjectObsidian/ProtoFlux/Math/Random/RandomInt2.cs @@ -1,4 +1,5 @@ using Elements.Core; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; @@ -6,12 +7,12 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Obsidian.Math.Random; [NodeCategory("Obsidian/Math/Random")] [NodeName("Random Int2")] -public class RandomInt2 : ValueFunctionNode +public class RandomInt2 : ValueFunctionNode { public ValueInput Min; public ValueInput Max; - protected override int2 Compute(ExecutionContext context) + protected override int2 Compute(FrooxEngineContext context) { int2 min = Min.Evaluate(context,int2.Zero); int2 max = Max.Evaluate(context,int2.One); diff --git a/ProjectObsidian/ProtoFlux/Strings/CountSubstring.cs b/ProjectObsidian/ProtoFlux/Strings/CountSubstring.cs index cb77e90..b6181f0 100644 --- a/ProjectObsidian/ProtoFlux/Strings/CountSubstring.cs +++ b/ProjectObsidian/ProtoFlux/Strings/CountSubstring.cs @@ -1,17 +1,18 @@ using System; using FrooxEngine; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; namespace ProtoFlux.Runtimes.Execution.Nodes.Strings { [NodeCategory("Obsidian/String")] - public class CountSubstringNode : ValueFunctionNode + public class CountSubstringNode : ValueFunctionNode { public readonly ObjectInput String; public readonly ObjectInput Pattern; - protected override int Compute(ExecutionContext context) + protected override int Compute(FrooxEngineContext context) { var str = String.Evaluate(context); var pattern = Pattern.Evaluate(context); diff --git a/ProjectObsidian/ProtoFlux/Strings/DecodeBase64Node.cs b/ProjectObsidian/ProtoFlux/Strings/DecodeBase64Node.cs index 2fc125f..f27806f 100644 --- a/ProjectObsidian/ProtoFlux/Strings/DecodeBase64Node.cs +++ b/ProjectObsidian/ProtoFlux/Strings/DecodeBase64Node.cs @@ -1,17 +1,18 @@ using System; using System.Text; using FrooxEngine; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; namespace ProtoFlux.Runtimes.Execution.Nodes.Strings { [NodeCategory("Obsidian/String")] - public class DecodeBase64Node : ObjectFunctionNode + public class DecodeBase64Node : ObjectFunctionNode { public readonly ObjectInput Input; - protected override string Compute(ExecutionContext context) + protected override string Compute(FrooxEngineContext context) { var input = Input.Evaluate(context); if (string.IsNullOrEmpty(input)) return null; diff --git a/ProjectObsidian/ProtoFlux/Strings/DecodeMorseNode.cs b/ProjectObsidian/ProtoFlux/Strings/DecodeMorseNode.cs index 2163d1a..37350ec 100644 --- a/ProjectObsidian/ProtoFlux/Strings/DecodeMorseNode.cs +++ b/ProjectObsidian/ProtoFlux/Strings/DecodeMorseNode.cs @@ -1,6 +1,7 @@ using System; using System.Text; using FrooxEngine; +using FrooxEngine.ProtoFlux; using Obsidian; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; @@ -8,11 +9,11 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Strings { [NodeCategory("Obsidian/String")] - public class DecodeMorseNode : ObjectFunctionNode + public class DecodeMorseNode : ObjectFunctionNode { public readonly ObjectInput Input; - protected override string Compute(ExecutionContext context) + protected override string Compute(FrooxEngineContext context) { var input = Input.Evaluate(context); if (string.IsNullOrWhiteSpace(input)) diff --git a/ProjectObsidian/ProtoFlux/Strings/EncodeBase64Node.cs b/ProjectObsidian/ProtoFlux/Strings/EncodeBase64Node.cs index f9bac39..cf147ef 100644 --- a/ProjectObsidian/ProtoFlux/Strings/EncodeBase64Node.cs +++ b/ProjectObsidian/ProtoFlux/Strings/EncodeBase64Node.cs @@ -1,17 +1,18 @@ using System; using System.Text; using FrooxEngine; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; namespace ProtoFlux.Runtimes.Execution.Nodes.Strings { [NodeCategory("Obsidian/String")] - public class EncodeBase64Node : ObjectFunctionNode + public class EncodeBase64Node : ObjectFunctionNode { public readonly ObjectInput Input; - protected override string Compute(ExecutionContext context) + protected override string Compute(FrooxEngineContext context) { var input = Input.Evaluate(context); return string.IsNullOrEmpty(input) ? null : Convert.ToBase64String(Encoding.UTF8.GetBytes(input)); diff --git a/ProjectObsidian/ProtoFlux/Strings/EncodeMD5.cs b/ProjectObsidian/ProtoFlux/Strings/EncodeMD5.cs index f651c29..48de7be 100644 --- a/ProjectObsidian/ProtoFlux/Strings/EncodeMD5.cs +++ b/ProjectObsidian/ProtoFlux/Strings/EncodeMD5.cs @@ -2,18 +2,19 @@ using System.Security.Cryptography; using System.Text; using FrooxEngine; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; namespace ProtoFlux.Runtimes.Execution.Nodes.Strings { [NodeCategory("Obsidian/String")] - public class EncodeMD5Node : ObjectFunctionNode + public class EncodeMD5Node : ObjectFunctionNode { private static readonly MD5CryptoServiceProvider MD5 = new MD5CryptoServiceProvider(); public readonly ObjectInput Input; - protected override string Compute(ExecutionContext context) + protected override string Compute(FrooxEngineContext context) { var input = Input.Evaluate(context); if (string.IsNullOrEmpty(input)) diff --git a/ProjectObsidian/ProtoFlux/Strings/EncodeMorse.cs b/ProjectObsidian/ProtoFlux/Strings/EncodeMorse.cs index 811d627..cbe50aa 100644 --- a/ProjectObsidian/ProtoFlux/Strings/EncodeMorse.cs +++ b/ProjectObsidian/ProtoFlux/Strings/EncodeMorse.cs @@ -1,6 +1,7 @@ using System; using System.Text; using FrooxEngine; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; using Obsidian; @@ -8,11 +9,11 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.Strings { [NodeCategory("Obsidian/String")] - public class EncodeMorseNode : ObjectFunctionNode + public class EncodeMorseNode : ObjectFunctionNode { public readonly ObjectInput Input; - protected override string Compute(ExecutionContext context) + protected override string Compute(FrooxEngineContext context) { var input = Input.Evaluate(context); if (string.IsNullOrWhiteSpace(input)) diff --git a/ProjectObsidian/ProtoFlux/Strings/EncodeSHA256.cs b/ProjectObsidian/ProtoFlux/Strings/EncodeSHA256.cs index 77ef680..bf5065e 100644 --- a/ProjectObsidian/ProtoFlux/Strings/EncodeSHA256.cs +++ b/ProjectObsidian/ProtoFlux/Strings/EncodeSHA256.cs @@ -2,20 +2,21 @@ using System.Security.Cryptography; using System.Text; using FrooxEngine; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; namespace ProtoFlux.Runtimes.Execution.Nodes.Strings { [NodeCategory("Obsidian/String")] - public class EncodeSha256Node : ObjectFunctionNode + public class EncodeSha256Node : ObjectFunctionNode { private static readonly SHA256 SHA = SHA256.Create(); public readonly ObjectInput Input; - protected override string Compute(ExecutionContext context) + protected override string Compute(FrooxEngineContext context) { var input = Input.Evaluate(context); if (string.IsNullOrEmpty(input)) diff --git a/ProjectObsidian/ProtoFlux/Strings/HMAC.cs b/ProjectObsidian/ProtoFlux/Strings/HMAC.cs index 00e4770..b758901 100644 --- a/ProjectObsidian/ProtoFlux/Strings/HMAC.cs +++ b/ProjectObsidian/ProtoFlux/Strings/HMAC.cs @@ -2,6 +2,7 @@ using System.Security.Cryptography; using System.Text; using FrooxEngine; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; @@ -17,13 +18,13 @@ public enum HashFunction } [NodeCategory("Obsidian/String")] - public class HMACNode : ObjectFunctionNode + public class HMACNode : ObjectFunctionNode { public readonly ObjectInput Message; public readonly ObjectInput Key; public readonly ObjectInput HashAlgorithm; - protected override string Compute(ExecutionContext context) + protected override string Compute(FrooxEngineContext context) { string message = Message.Evaluate(context); string key = Key.Evaluate(context); diff --git a/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNonNullableNode.cs b/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNonNullableNode.cs index 1c0f840..e0dd806 100644 --- a/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNonNullableNode.cs +++ b/ProjectObsidian/ProtoFlux/Strings/HammingDistanceNonNullableNode.cs @@ -1,19 +1,20 @@ using System; using FrooxEngine; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; namespace ProtoFlux.Runtimes.Execution.Nodes.Strings { [NodeCategory("Obsidian/String")] - public class HammingDistanceNonNullableNode : ValueFunctionNode + public class HammingDistanceNonNullableNode : ValueFunctionNode { public readonly ObjectInput String1; public readonly ObjectInput String2; - protected override int Compute(ExecutionContext context) + protected override int Compute(FrooxEngineContext context) { var string1 = String1.Evaluate(context); var string2 = String2.Evaluate(context); diff --git a/ProjectObsidian/ProtoFlux/Users/IsUserInNoclipNode.cs b/ProjectObsidian/ProtoFlux/Users/IsUserInNoclipNode.cs index e80c8dd..9529250 100644 --- a/ProjectObsidian/ProtoFlux/Users/IsUserInNoclipNode.cs +++ b/ProjectObsidian/ProtoFlux/Users/IsUserInNoclipNode.cs @@ -1,4 +1,5 @@ using FrooxEngine; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; @@ -6,24 +7,16 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.FrooxEngine.Locomotion { [ContinuouslyChanging] [NodeCategory("Obsidian/Locomotion")] - public class IsUserInNoClipNode : ValueFunctionNode + public class IsUserInNoClipNode : ValueFunctionNode { public readonly ObjectInput User; - protected override bool Compute(ExecutionContext context) + protected override bool Compute(FrooxEngineContext context) { - User user = User.Evaluate(context); - if (user == null) - { - return false; - } - - LocomotionController locomotionController = user.Root?.GetRegisteredComponent(); - if (locomotionController == null) - { - return false; - } + var user = User.Evaluate(context); + var locomotionController = user?.Root?.GetRegisteredComponent(); + if (locomotionController == null) return false; return locomotionController.ActiveModule.GetType() == typeof(NoclipLocomotion); } } diff --git a/ProjectObsidian/ProtoFlux/Users/Status/IsUserInSeatedMode.cs b/ProjectObsidian/ProtoFlux/Users/Status/IsUserInSeatedMode.cs index 1cf9c1f..0b4862b 100644 --- a/ProjectObsidian/ProtoFlux/Users/Status/IsUserInSeatedMode.cs +++ b/ProjectObsidian/ProtoFlux/Users/Status/IsUserInSeatedMode.cs @@ -1,4 +1,5 @@ using FrooxEngine; +using FrooxEngine.ProtoFlux; using ProtoFlux.Core; using ProtoFlux.Runtimes.Execution; @@ -6,14 +7,14 @@ namespace ProtoFlux.Runtimes.Execution.Nodes.FrooxEngine.Locomotion { [ContinuouslyChanging] [NodeCategory("Obsidian/Locomotion")] - public class IsUserInSeatedModeNode : ValueFunctionNode + public class IsUserInSeatedModeNode : ValueFunctionNode { public readonly ObjectInput User; - protected override bool Compute(ExecutionContext context) + protected override bool Compute(FrooxEngineContext context) { - User user = User.Evaluate(context); - return user == null ? false : user.InputInterface.SeatedMode; + var user = User.Evaluate(context); + return user != null && user.InputInterface.SeatedMode; } } } \ No newline at end of file From 21670699f0a8f5fabe213cac8f218764393768f5 Mon Sep 17 00:00:00 2001 From: frozenreflex Date: Wed, 17 Apr 2024 16:19:42 -0500 Subject: [PATCH 06/13] Add more node types, add async calls --- ProjectObsidian.SourceGenerators/BindingGenerator.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ProjectObsidian.SourceGenerators/BindingGenerator.cs b/ProjectObsidian.SourceGenerators/BindingGenerator.cs index 2341414..ed2e52f 100644 --- a/ProjectObsidian.SourceGenerators/BindingGenerator.cs +++ b/ProjectObsidian.SourceGenerators/BindingGenerator.cs @@ -47,7 +47,7 @@ public class BindingGeneratorSyntaxWalker : CSharpSyntaxWalker public const string FluxPrefix = "ProtoFlux.Runtimes.Execution."; //TODO: add more, this is not all of the valid node types - public static readonly string[] ValidNodeTypes = { "VoidNode", "ObjectFunctionNode", "ValueFunctionNode" }; + public static readonly string[] ValidNodeTypes = { "VoidNode", "ObjectFunctionNode", "ValueFunctionNode", "AsyncActionNode", "ActionNode" }; private string UsingEnumerate => _usingDeclarations @@ -270,6 +270,11 @@ public override void VisitFieldDeclaration(FieldDeclarationSyntax node) _impulseOrder.Add(name); _declarations.Add($" new public readonly SyncRef {name};\n"); } + if (type.EndsWith("AsyncCall")) + { + _impulseOrder.Add(name); + _declarations.Add($" new public readonly SyncRef {name};\n"); + } //arguments if (type.Contains("ObjectArgument<")) From 6ca8e743b94e86cc2c0b4c5bb3754f5659ce7e96 Mon Sep 17 00:00:00 2001 From: frozenreflex Date: Wed, 17 Apr 2024 17:03:45 -0500 Subject: [PATCH 07/13] Add name override, add impulse lists cleanup --- .../BindingGenerator.cs | 231 +++++++----------- 1 file changed, 89 insertions(+), 142 deletions(-) diff --git a/ProjectObsidian.SourceGenerators/BindingGenerator.cs b/ProjectObsidian.SourceGenerators/BindingGenerator.cs index ed2e52f..6822646 100644 --- a/ProjectObsidian.SourceGenerators/BindingGenerator.cs +++ b/ProjectObsidian.SourceGenerators/BindingGenerator.cs @@ -43,6 +43,55 @@ public void Execute(GeneratorExecutionContext context) public class BindingGeneratorSyntaxWalker : CSharpSyntaxWalker { + private class OrderedCount + { + private readonly string CountVariableName; + private readonly string MethodName; + private readonly string MethodReturnType; + public string CountOverride => VariableNames.Count == 0 + ? "" + : $" public override int {CountVariableName} => base.{CountVariableName} + {VariableNames.Count};"; + + public void Add(string value) => VariableNames.Add(value); + + public string GetOverride + { + get + { + if (VariableNames.Count == 0) return ""; + var str = $@" + protected override {MethodReturnType} {MethodName}(ref int index) + {{ + var item = base.{MethodName}(ref index); + if (item != null) return item; + switch (index) + {{ +"; + for (var index = 0; index < VariableNames.Count; index++) + { + var order = VariableNames[index]; + str += $" case {index}:\n return this.{order};\n"; + } + str += $@" + default: + index -= {VariableNames.Count}; + return null; + }} + }}"; + return str; + } + } + + public readonly List VariableNames = new(); + + public OrderedCount(string countVariableName, string methodName, string methodReturnType) + { + CountVariableName = countVariableName; + MethodName = methodName; + MethodReturnType = methodReturnType; + } + } + public const string BindingPrefix = "FrooxEngine."; public const string FluxPrefix = "ProtoFlux.Runtimes.Execution."; @@ -53,113 +102,12 @@ public class BindingGeneratorSyntaxWalker : CSharpSyntaxWalker _usingDeclarations .Where(u => !string.IsNullOrWhiteSpace(u)) .Aggregate("", (current, u) => current + $"using {u};\n"); - private string InputCountOverride => _inputOrder.Count == 0 - ? "" - : $" public override int NodeInputCount => base.NodeInputCount + {_inputOrder.Count};"; - private string OutputCountOverride => _outputOrder.Count == 0 - ? "" - : $" public override int NodeOutputCount => base.NodeOutputCount + {_outputOrder.Count};"; + private readonly OrderedCount _inputCount = new("NodeInputCount", "GetInputInternal", "ISyncRef"); + private readonly OrderedCount _outputCount = new("NodeOutputCount", "GetOutputInternal", "INodeOutput"); + private readonly OrderedCount _impulseCount = new("NodeImpulseCount", "GetImpulseInternal", "ISyncRef"); + private readonly OrderedCount _impulseListCount = new("NodeImpulseListCount", "GetImpulseListInternal", "ISyncList"); - private string ImpulseCountOverride => _impulseOrder.Count == 0 - ? "" - : $" public override int NodeImpulseCount => base.NodeImpulseCount + {_impulseOrder.Count};"; - - private string GetInputInternalOverride - { - get - { - if (_inputOrder.Count == 0) return ""; - var str = $$""" - - protected override ISyncRef GetInputInternal(ref int index) - { - var inputInternal = base.GetInputInternal(ref index); - if (inputInternal != null) return inputInternal; - switch (index) - { - - """; - for (var index = 0; index < _inputOrder.Count; index++) - { - var order = _inputOrder[index]; - str += $" case {index}:\n return this.{order};\n"; - } - str += $$""" - - default: - index -= {{_inputOrder.Count}}; - return null; - } - } - """; - return str; - } - } - - private string GetImpulseInternalOverride - { - get - { - if (_impulseOrder.Count == 0) return ""; - var str = $$""" - - protected override ISyncRef GetImpulseInternal(ref int index) - { - var impulseInternal = base.GetImpulseInternal(ref index); - if (impulseInternal != null) return impulseInternal; - switch (index) - { - - """; - for (var index = 0; index < _impulseOrder.Count; index++) - { - var order = _impulseOrder[index]; - str += $" case {index}:\n return this.{order};\n"; - } - str += $$""" - - default: - index -= {{_impulseOrder.Count}}; - return null; - } - } - """; - return str; - } - } - private string GetOutputInternalOverride - { - get - { - if (_outputOrder.Count == 0) return ""; - var str = $$""" - - protected override INodeOutput GetOutputInternal(ref int index) - { - var outputInternal = base.GetOutputInternal(ref index); - if (outputInternal != null) return outputInternal; - switch (index) - { - - """; - for (var index = 0; index < _outputOrder.Count; index++) - { - var order = _outputOrder[index]; - str += $" case {index}:\n return this.{order};\n"; - } - str += $$""" - - default: - index -= {{_outputOrder.Count}}; - return null; - } - } - """; - return str; - } - } - private List _declarations = []; private string Declarations => string.Concat(_declarations); @@ -179,13 +127,15 @@ namespace {BindingPrefix}{_currentNameSpace}; public partial class {_fullName} : {_baseType} {{ {Declarations} +{_nodeNameOverride} public override System.Type NodeType => typeof (global::{_currentNameSpace}.{_fullName}); public global::{_currentNameSpace}.{_fullName} TypedNodeInstance {{ get; private set; }} public override INode NodeInstance => (INode)this.TypedNodeInstance; public override void ClearInstance() => this.TypedNodeInstance = null; -{InputCountOverride} -{OutputCountOverride} -{ImpulseCountOverride} +{_inputCount.CountOverride} +{_outputCount.CountOverride} +{_impulseCount.CountOverride} +{_impulseListCount.CountOverride} public override N Instantiate() {{ if (this.TypedNodeInstance != null) throw new System.InvalidOperationException(""Node has already been instantiated""); @@ -194,9 +144,10 @@ public override N Instantiate() return localVar as N; }} protected override void AssociateInstanceInternal(INode node) => this.TypedNodeInstance = node is global::{_currentNameSpace}.{_fullName} localVar ? localVar : throw new System.ArgumentException(""Node instance is not of type "" + typeof (global::{_currentNameSpace}.{_fullName})?.ToString()); -{GetInputInternalOverride} -{GetOutputInternalOverride} -{GetImpulseInternalOverride} +{_inputCount.GetOverride} +{_outputCount.GetOverride} +{_impulseCount.GetOverride} +{_impulseListCount.GetOverride} }}"; return str; } @@ -212,20 +163,7 @@ public override N Instantiate() private string _fullBaseType; private string _match; private string _category; - - private readonly Dictionary _objectInputs = new(); - private readonly Dictionary _valueInputs = new(); - - private readonly Dictionary _objectArguments = new(); - private readonly Dictionary _valueArguments = new(); - - private readonly Dictionary _objectOutputs = new(); - private readonly Dictionary _valueOutputs = new(); - - private readonly List _inputOrder = new(); - private readonly List _outputOrder = new(); - - private readonly List _impulseOrder = new(); + private string _nodeNameOverride = ""; public override void VisitFieldDeclaration(FieldDeclarationSyntax node) { @@ -236,15 +174,13 @@ public override void VisitFieldDeclaration(FieldDeclarationSyntax node) if (type.Contains("ObjectInput<")) { var t = type.TrimEnds("ObjectInput<".Length, 1); - _objectInputs.Add(name, t); - _inputOrder.Add(name); + _inputCount.Add(name); _declarations.Add($" new public readonly SyncRef> {name};\n"); } if (type.Contains("ObjectOutput<")) { var t = type.TrimEnds("ObjectOutput<".Length, 1); - _objectOutputs.Add(name, t); - _outputOrder.Add(name); + _outputCount.Add(name); _declarations.Add($" new public readonly NodeObjectOutput<{t}> {name};\n"); } @@ -252,43 +188,46 @@ public override void VisitFieldDeclaration(FieldDeclarationSyntax node) if (type.Contains("ValueInput<")) { var t = type.TrimEnds("ValueInput<".Length, 1); - _valueInputs.Add(name, t); - _inputOrder.Add(name); + _inputCount.Add(name); _declarations.Add($" new public readonly SyncRef> {name};\n"); } if (type.Contains("ValueOutput<")) { var t = type.TrimEnds("ValueOutput<".Length, 1); - _valueOutputs.Add(name, t); - _outputOrder.Add(name); + _outputCount.Add(name); _declarations.Add($" new public readonly NodeValueOutput<{t}> {name};\n"); } //impulses if (type.EndsWith("Continuation")) { - _impulseOrder.Add(name); + _impulseCount.Add(name); _declarations.Add($" new public readonly SyncRef {name};\n"); } if (type.EndsWith("AsyncCall")) { - _impulseOrder.Add(name); + _impulseCount.Add(name); _declarations.Add($" new public readonly SyncRef {name};\n"); } + //impulse lists + if (type.EndsWith("ContinuationList")) + { + _impulseListCount.Add(name); + _declarations.Add($" new public readonly SyncRefList {name};\n"); + } + //arguments if (type.Contains("ObjectArgument<")) { var t = type.TrimEnds("ObjectArgument<".Length, 1); - _objectArguments.Add(name, t); - _inputOrder.Add(name); + _inputCount.Add(name); _declarations.Add($" new public readonly SyncRef> {name};\n"); } if (type.Contains("ValueArgument<")) { var t = type.TrimEnds("ValueArgument<".Length, 1); - _valueArguments.Add(name, t); - _inputOrder.Add(name); + _inputCount.Add(name); _declarations.Add($" new public readonly SyncRef> {name};\n"); } base.VisitFieldDeclaration(node); @@ -350,14 +289,22 @@ public override void VisitClassDeclaration(ClassDeclarationSyntax node) var find = node.AttributeLists.SelectMany(i => i.Attributes) .FirstOrDefault(i => i.Name.ToString() == "NodeCategory"); - if (find is null || find.ArgumentList is null) + if (find?.ArgumentList is null) { base.VisitClassDeclaration(node); return; } + + _category = find.ArgumentList.Arguments.First().ToString().TrimEnds(1,1); + + var findName = node.AttributeLists.SelectMany(i => i.Attributes) + .FirstOrDefault(i => i.Name.ToString() == "NodeName"); - _category = find.ArgumentList.Arguments.First().ToString(); - _category = _category.Substring(1, _category.Length - 2); + + if (findName?.ArgumentList != null) + { + _nodeNameOverride = $" public override string NodeName => {findName.ArgumentList.Arguments.First().ToString().TrimEnds(1,1)};"; + } foreach (var u in _usingDeclarations) { From 45cce381b0c69f679edeb847d4500a78d83deee7 Mon Sep 17 00:00:00 2001 From: frozenreflex Date: Wed, 17 Apr 2024 17:17:40 -0500 Subject: [PATCH 08/13] Cleanup --- .../BindingGenerator.cs | 94 ++++++++----------- 1 file changed, 38 insertions(+), 56 deletions(-) diff --git a/ProjectObsidian.SourceGenerators/BindingGenerator.cs b/ProjectObsidian.SourceGenerators/BindingGenerator.cs index 6822646..936a0ba 100644 --- a/ProjectObsidian.SourceGenerators/BindingGenerator.cs +++ b/ProjectObsidian.SourceGenerators/BindingGenerator.cs @@ -165,71 +165,54 @@ public override N Instantiate() private string _category; private string _nodeNameOverride = ""; + private void TypedFieldDetection(string type, string name, string targetTypeName, string declarationFormat, OrderedCount counter) + { + if (type.Contains(targetTypeName + "<")) + { + var t = type.TrimEnds((targetTypeName + "<").Length, 1); + counter.Add(name); + _declarations.Add(string.Format(declarationFormat, t, name)); + } + } + private void UntypedFieldDetection(string type, string name, string targetTypeName, string declarationFormat, OrderedCount counter) + { + if (type.Contains(targetTypeName + "<")) + { + counter.Add(name); + _declarations.Add(string.Format(declarationFormat, name)); + } + } public override void VisitFieldDeclaration(FieldDeclarationSyntax node) { var type = node.Declaration.Type.ToString(); var name = node.Declaration.Variables.First().ToString(); //object in/out - if (type.Contains("ObjectInput<")) - { - var t = type.TrimEnds("ObjectInput<".Length, 1); - _inputCount.Add(name); - _declarations.Add($" new public readonly SyncRef> {name};\n"); - } - if (type.Contains("ObjectOutput<")) - { - var t = type.TrimEnds("ObjectOutput<".Length, 1); - _outputCount.Add(name); - _declarations.Add($" new public readonly NodeObjectOutput<{t}> {name};\n"); - } + TypedFieldDetection(type, name, "ObjectInput", + " new public readonly SyncRef> {1};\n", _inputCount); + TypedFieldDetection(type, name, "ObjectOutput", + " new public readonly NodeObjectOutput<{0}> {1};\n", _outputCount); + TypedFieldDetection(type, name, "ObjectArgument", + " new public readonly SyncRef> {1};\n", _inputCount); //value in/out - if (type.Contains("ValueInput<")) - { - var t = type.TrimEnds("ValueInput<".Length, 1); - _inputCount.Add(name); - _declarations.Add($" new public readonly SyncRef> {name};\n"); - } - if (type.Contains("ValueOutput<")) - { - var t = type.TrimEnds("ValueOutput<".Length, 1); - _outputCount.Add(name); - _declarations.Add($" new public readonly NodeValueOutput<{t}> {name};\n"); - } - + TypedFieldDetection(type, name, "ValueInput", + " new public readonly SyncRef> {1};\n", _inputCount); + TypedFieldDetection(type, name, "ValueOutput", + " new public readonly NodeValueOutput<{0}> {1};\n", _outputCount); + TypedFieldDetection(type, name, "ValueArgument", + " new public readonly SyncRef> {1};\n", _inputCount); + //impulses - if (type.EndsWith("Continuation")) - { - _impulseCount.Add(name); - _declarations.Add($" new public readonly SyncRef {name};\n"); - } - if (type.EndsWith("AsyncCall")) - { - _impulseCount.Add(name); - _declarations.Add($" new public readonly SyncRef {name};\n"); - } + UntypedFieldDetection(type, name, "Continuation", + " new public readonly SyncRef {0};\n", _impulseCount); + UntypedFieldDetection(type, name, "AsyncCall", + " new public readonly SyncRef {0};\n", _impulseCount); //impulse lists - if (type.EndsWith("ContinuationList")) - { - _impulseListCount.Add(name); - _declarations.Add($" new public readonly SyncRefList {name};\n"); - } + UntypedFieldDetection(type, name, "ContinuationList", + " new public readonly SyncRefList {0};\n", _impulseListCount); - //arguments - if (type.Contains("ObjectArgument<")) - { - var t = type.TrimEnds("ObjectArgument<".Length, 1); - _inputCount.Add(name); - _declarations.Add($" new public readonly SyncRef> {name};\n"); - } - if (type.Contains("ValueArgument<")) - { - var t = type.TrimEnds("ValueArgument<".Length, 1); - _inputCount.Add(name); - _declarations.Add($" new public readonly SyncRef> {name};\n"); - } base.VisitFieldDeclaration(node); } @@ -302,9 +285,8 @@ public override void VisitClassDeclaration(ClassDeclarationSyntax node) if (findName?.ArgumentList != null) - { - _nodeNameOverride = $" public override string NodeName => {findName.ArgumentList.Arguments.First().ToString().TrimEnds(1,1)};"; - } + _nodeNameOverride = + $" public override string NodeName => {findName.ArgumentList.Arguments.First().ToString()};"; foreach (var u in _usingDeclarations) { From b97b443c15d98c49e7d20ae7cc3778358854c7e7 Mon Sep 17 00:00:00 2001 From: frozenreflex Date: Wed, 17 Apr 2024 17:26:13 -0500 Subject: [PATCH 09/13] Cleanup --- .../BindingGenerator.cs | 45 +++++++------------ 1 file changed, 16 insertions(+), 29 deletions(-) diff --git a/ProjectObsidian.SourceGenerators/BindingGenerator.cs b/ProjectObsidian.SourceGenerators/BindingGenerator.cs index 936a0ba..cefd86a 100644 --- a/ProjectObsidian.SourceGenerators/BindingGenerator.cs +++ b/ProjectObsidian.SourceGenerators/BindingGenerator.cs @@ -167,20 +167,16 @@ public override N Instantiate() private void TypedFieldDetection(string type, string name, string targetTypeName, string declarationFormat, OrderedCount counter) { - if (type.Contains(targetTypeName + "<")) - { - var t = type.TrimEnds((targetTypeName + "<").Length, 1); - counter.Add(name); - _declarations.Add(string.Format(declarationFormat, t, name)); - } + if (!type.Contains(targetTypeName + "<")) return; + var t = type.TrimEnds((targetTypeName + "<").Length, 1); + counter.Add(name); + _declarations.Add(string.Format(" new public readonly " + declarationFormat + "{0};\n", name, t)); } private void UntypedFieldDetection(string type, string name, string targetTypeName, string declarationFormat, OrderedCount counter) { - if (type.Contains(targetTypeName + "<")) - { - counter.Add(name); - _declarations.Add(string.Format(declarationFormat, name)); - } + if (!type.Contains(targetTypeName + "<")) return; + counter.Add(name); + _declarations.Add(string.Format(declarationFormat, name)); } public override void VisitFieldDeclaration(FieldDeclarationSyntax node) { @@ -188,30 +184,21 @@ public override void VisitFieldDeclaration(FieldDeclarationSyntax node) var name = node.Declaration.Variables.First().ToString(); //object in/out - TypedFieldDetection(type, name, "ObjectInput", - " new public readonly SyncRef> {1};\n", _inputCount); - TypedFieldDetection(type, name, "ObjectOutput", - " new public readonly NodeObjectOutput<{0}> {1};\n", _outputCount); - TypedFieldDetection(type, name, "ObjectArgument", - " new public readonly SyncRef> {1};\n", _inputCount); + TypedFieldDetection(type, name, "ObjectInput", "SyncRef>", _inputCount); + TypedFieldDetection(type, name, "ObjectOutput", "NodeObjectOutput<{1}>", _outputCount); + TypedFieldDetection(type, name, "ObjectArgument", "SyncRef>", _inputCount); //value in/out - TypedFieldDetection(type, name, "ValueInput", - " new public readonly SyncRef> {1};\n", _inputCount); - TypedFieldDetection(type, name, "ValueOutput", - " new public readonly NodeValueOutput<{0}> {1};\n", _outputCount); - TypedFieldDetection(type, name, "ValueArgument", - " new public readonly SyncRef> {1};\n", _inputCount); + TypedFieldDetection(type, name, "ValueInput", "SyncRef>", _inputCount); + TypedFieldDetection(type, name, "ValueOutput", "NodeValueOutput<{0}>", _outputCount); + TypedFieldDetection(type, name, "ValueArgument", "SyncRef>", _inputCount); //impulses - UntypedFieldDetection(type, name, "Continuation", - " new public readonly SyncRef {0};\n", _impulseCount); - UntypedFieldDetection(type, name, "AsyncCall", - " new public readonly SyncRef {0};\n", _impulseCount); + UntypedFieldDetection(type, name, "Continuation", "SyncRef", _impulseCount); + UntypedFieldDetection(type, name, "AsyncCall", "SyncRef", _impulseCount); //impulse lists - UntypedFieldDetection(type, name, "ContinuationList", - " new public readonly SyncRefList {0};\n", _impulseListCount); + UntypedFieldDetection(type, name, "ContinuationList", "SyncRefList", _impulseListCount); base.VisitFieldDeclaration(node); } From fc165043c41ace50f7e892d4d3030c500398bcbd Mon Sep 17 00:00:00 2001 From: frozenreflex Date: Wed, 17 Apr 2024 17:26:46 -0500 Subject: [PATCH 10/13] Cleanup --- ProjectObsidian.SourceGenerators/BindingGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProjectObsidian.SourceGenerators/BindingGenerator.cs b/ProjectObsidian.SourceGenerators/BindingGenerator.cs index cefd86a..2e44f00 100644 --- a/ProjectObsidian.SourceGenerators/BindingGenerator.cs +++ b/ProjectObsidian.SourceGenerators/BindingGenerator.cs @@ -170,7 +170,7 @@ private void TypedFieldDetection(string type, string name, string targetTypeName if (!type.Contains(targetTypeName + "<")) return; var t = type.TrimEnds((targetTypeName + "<").Length, 1); counter.Add(name); - _declarations.Add(string.Format(" new public readonly " + declarationFormat + "{0};\n", name, t)); + _declarations.Add(string.Format(" new public readonly " + declarationFormat + " {0};\n", name, t)); } private void UntypedFieldDetection(string type, string name, string targetTypeName, string declarationFormat, OrderedCount counter) { From 6bb25a22c5d284047ffdb513c647a8871506b3c7 Mon Sep 17 00:00:00 2001 From: frozenreflex Date: Wed, 17 Apr 2024 18:30:33 -0500 Subject: [PATCH 11/13] Support every single node type and input/output I can think of/could find --- .../BindingGenerator.cs | 75 +++++++++++++------ 1 file changed, 54 insertions(+), 21 deletions(-) diff --git a/ProjectObsidian.SourceGenerators/BindingGenerator.cs b/ProjectObsidian.SourceGenerators/BindingGenerator.cs index 2e44f00..177ca94 100644 --- a/ProjectObsidian.SourceGenerators/BindingGenerator.cs +++ b/ProjectObsidian.SourceGenerators/BindingGenerator.cs @@ -21,7 +21,6 @@ public void Initialize(GeneratorInitializationContext context) public void Execute(GeneratorExecutionContext context) { - var index = 0; foreach (var tree in context.Compilation.SyntaxTrees) { var result = new StringBuilder(); @@ -33,10 +32,7 @@ public void Execute(GeneratorExecutionContext context) var res = result.ToString(); if (!string.IsNullOrWhiteSpace(res)) - { context.AddSource($"{walker.BaseName}Bindings.g.cs", result.ToString()); - index++; - } } } } @@ -96,7 +92,22 @@ public OrderedCount(string countVariableName, string methodName, string methodRe public const string FluxPrefix = "ProtoFlux.Runtimes.Execution."; //TODO: add more, this is not all of the valid node types - public static readonly string[] ValidNodeTypes = { "VoidNode", "ObjectFunctionNode", "ValueFunctionNode", "AsyncActionNode", "ActionNode" }; + public static readonly string[] ValidNodeTypes = + { + "NestedNode", + "VoidNode", + + "ObjectFunctionNode", + "ValueFunctionNode", + + "ActionNode", + "ActionFlowNode", + "ActionBreakableFlowNode", + + "AsyncActionNode", + "AsyncActionFlowNode", + "AsyncActionBreakableFlowNode", + }; private string UsingEnumerate => _usingDeclarations @@ -106,7 +117,19 @@ public OrderedCount(string countVariableName, string methodName, string methodRe private readonly OrderedCount _inputCount = new("NodeInputCount", "GetInputInternal", "ISyncRef"); private readonly OrderedCount _outputCount = new("NodeOutputCount", "GetOutputInternal", "INodeOutput"); private readonly OrderedCount _impulseCount = new("NodeImpulseCount", "GetImpulseInternal", "ISyncRef"); + private readonly OrderedCount _operationCount = new("NodeImpulseCount", "GetImpulseInternal", "INodeOperation"); + + private readonly OrderedCount _inputListCount = new("NodeInputListCount", "GetInputListInternal", "ISyncList"); + private readonly OrderedCount _outputListCount = new("NodeOutputListCount", "GetOutputListInternal", "ISyncList"); private readonly OrderedCount _impulseListCount = new("NodeImpulseListCount", "GetImpulseListInternal", "ISyncList"); + private readonly OrderedCount _operationListCount = new("NodeOperationListCount", "GetOperationListInternal", "ISyncList"); + + private IEnumerable _counts => new[] + { _inputCount, _outputCount, _impulseCount, _operationCount, + _inputListCount, _outputListCount, _impulseListCount, _operationListCount }; + + private string CountOverride => string.Concat(_counts.Select(i => i.CountOverride)); + private string GetOverride => string.Concat(_counts.Select(i => i.GetOverride)); private List _declarations = []; private string Declarations => string.Concat(_declarations); @@ -132,10 +155,7 @@ public partial class {_fullName} : {_baseType} public global::{_currentNameSpace}.{_fullName} TypedNodeInstance {{ get; private set; }} public override INode NodeInstance => (INode)this.TypedNodeInstance; public override void ClearInstance() => this.TypedNodeInstance = null; -{_inputCount.CountOverride} -{_outputCount.CountOverride} -{_impulseCount.CountOverride} -{_impulseListCount.CountOverride} +{CountOverride} public override N Instantiate() {{ if (this.TypedNodeInstance != null) throw new System.InvalidOperationException(""Node has already been instantiated""); @@ -144,10 +164,7 @@ public override N Instantiate() return localVar as N; }} protected override void AssociateInstanceInternal(INode node) => this.TypedNodeInstance = node is global::{_currentNameSpace}.{_fullName} localVar ? localVar : throw new System.ArgumentException(""Node instance is not of type "" + typeof (global::{_currentNameSpace}.{_fullName})?.ToString()); -{_inputCount.GetOverride} -{_outputCount.GetOverride} -{_impulseCount.GetOverride} -{_impulseListCount.GetOverride} +{GetOverride} }}"; return str; } @@ -167,14 +184,14 @@ public override N Instantiate() private void TypedFieldDetection(string type, string name, string targetTypeName, string declarationFormat, OrderedCount counter) { - if (!type.Contains(targetTypeName + "<")) return; + if (!type.Contains(targetTypeName)) return; var t = type.TrimEnds((targetTypeName + "<").Length, 1); counter.Add(name); _declarations.Add(string.Format(" new public readonly " + declarationFormat + " {0};\n", name, t)); } private void UntypedFieldDetection(string type, string name, string targetTypeName, string declarationFormat, OrderedCount counter) { - if (!type.Contains(targetTypeName + "<")) return; + if (!type.Contains(targetTypeName)) return; counter.Add(name); _declarations.Add(string.Format(declarationFormat, name)); } @@ -183,23 +200,39 @@ public override void VisitFieldDeclaration(FieldDeclarationSyntax node) var type = node.Declaration.Type.ToString(); var name = node.Declaration.Variables.First().ToString(); - //object in/out + //inputs TypedFieldDetection(type, name, "ObjectInput", "SyncRef>", _inputCount); - TypedFieldDetection(type, name, "ObjectOutput", "NodeObjectOutput<{1}>", _outputCount); TypedFieldDetection(type, name, "ObjectArgument", "SyncRef>", _inputCount); + TypedFieldDetection(type, name, "ValueInput", "SyncRef>", _inputCount); + TypedFieldDetection(type, name, "ValueArgument", "SyncRef>", _inputCount); - //value in/out - TypedFieldDetection(type, name, "ValueInput", "SyncRef>", _inputCount); - TypedFieldDetection(type, name, "ValueOutput", "NodeValueOutput<{0}>", _outputCount); - TypedFieldDetection(type, name, "ValueArgument", "SyncRef>", _inputCount); + //outputs + TypedFieldDetection(type, name, "ObjectOutput", "NodeObjectOutput<{1}>", _outputCount); + TypedFieldDetection(type, name, "ValueOutput", "NodeValueOutput<{1}>", _outputCount); //impulses + UntypedFieldDetection(type, name, "Call", "SyncRef", _impulseCount); UntypedFieldDetection(type, name, "Continuation", "SyncRef", _impulseCount); UntypedFieldDetection(type, name, "AsyncCall", "SyncRef", _impulseCount); + UntypedFieldDetection(type, name, "AsyncResumption", "SyncRef", _impulseCount); + + //operations + UntypedFieldDetection(type, name, "Operation", "SyncNodeOperation", _operationCount); + + //lists + + //input lists + TypedFieldDetection(type, name, "ValueInputList", "SyncRefList>", _inputListCount); + + //output lists + TypedFieldDetection(type, name, "ObjectInputList", "SyncRefList>", _outputListCount); //impulse lists UntypedFieldDetection(type, name, "ContinuationList", "SyncRefList", _impulseListCount); + //operation lists + UntypedFieldDetection(type, name, "SyncOperationList", "SyncList", _operationListCount); + base.VisitFieldDeclaration(node); } From 7a6deebab7a5d8883c8a2c847f79b9f150f9de15 Mon Sep 17 00:00:00 2001 From: frozenreflex Date: Thu, 18 Apr 2024 17:59:10 -0500 Subject: [PATCH 12/13] Fix field generation --- .../BindingGenerator.cs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ProjectObsidian.SourceGenerators/BindingGenerator.cs b/ProjectObsidian.SourceGenerators/BindingGenerator.cs index 177ca94..a167464 100644 --- a/ProjectObsidian.SourceGenerators/BindingGenerator.cs +++ b/ProjectObsidian.SourceGenerators/BindingGenerator.cs @@ -182,18 +182,20 @@ public override N Instantiate() private string _category; private string _nodeNameOverride = ""; - private void TypedFieldDetection(string type, string name, string targetTypeName, string declarationFormat, OrderedCount counter) + private bool TypedFieldDetection(string type, string name, string targetTypeName, string declarationFormat, OrderedCount counter) { - if (!type.Contains(targetTypeName)) return; + if (!type.Contains(targetTypeName)) return false; var t = type.TrimEnds((targetTypeName + "<").Length, 1); counter.Add(name); _declarations.Add(string.Format(" new public readonly " + declarationFormat + " {0};\n", name, t)); + return true; } - private void UntypedFieldDetection(string type, string name, string targetTypeName, string declarationFormat, OrderedCount counter) + private bool UntypedFieldDetection(string type, string name, string targetTypeName, string declarationFormat, OrderedCount counter) { - if (!type.Contains(targetTypeName)) return; + if (!type.Contains(targetTypeName)) return false; counter.Add(name); - _declarations.Add(string.Format(declarationFormat, name)); + _declarations.Add(string.Format(" new public readonly " + declarationFormat + " {0};\n", name)); + return true; } public override void VisitFieldDeclaration(FieldDeclarationSyntax node) { @@ -211,9 +213,11 @@ public override void VisitFieldDeclaration(FieldDeclarationSyntax node) TypedFieldDetection(type, name, "ValueOutput", "NodeValueOutput<{1}>", _outputCount); //impulses - UntypedFieldDetection(type, name, "Call", "SyncRef", _impulseCount); + if (!UntypedFieldDetection(type, name, "Call", "SyncRef", _impulseCount)) + { + UntypedFieldDetection(type, name, "AsyncCall", "SyncRef", _impulseCount); + } UntypedFieldDetection(type, name, "Continuation", "SyncRef", _impulseCount); - UntypedFieldDetection(type, name, "AsyncCall", "SyncRef", _impulseCount); UntypedFieldDetection(type, name, "AsyncResumption", "SyncRef", _impulseCount); //operations From b3b636bc5a5251d51d962aa765e34051ee90e59c Mon Sep 17 00:00:00 2001 From: frozenreflex Date: Thu, 18 Apr 2024 18:00:10 -0500 Subject: [PATCH 13/13] Fix order --- ProjectObsidian.SourceGenerators/BindingGenerator.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ProjectObsidian.SourceGenerators/BindingGenerator.cs b/ProjectObsidian.SourceGenerators/BindingGenerator.cs index a167464..fe1b860 100644 --- a/ProjectObsidian.SourceGenerators/BindingGenerator.cs +++ b/ProjectObsidian.SourceGenerators/BindingGenerator.cs @@ -213,10 +213,8 @@ public override void VisitFieldDeclaration(FieldDeclarationSyntax node) TypedFieldDetection(type, name, "ValueOutput", "NodeValueOutput<{1}>", _outputCount); //impulses - if (!UntypedFieldDetection(type, name, "Call", "SyncRef", _impulseCount)) - { - UntypedFieldDetection(type, name, "AsyncCall", "SyncRef", _impulseCount); - } + if (!UntypedFieldDetection(type, name, "AsyncCall", "SyncRef", _impulseCount)) + UntypedFieldDetection(type, name, "Call", "SyncRef", _impulseCount); UntypedFieldDetection(type, name, "Continuation", "SyncRef", _impulseCount); UntypedFieldDetection(type, name, "AsyncResumption", "SyncRef", _impulseCount);