summaryrefslogtreecommitdiffstats
path: root/Scripts/Fold/Editor/FoldGraph.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Scripts/Fold/Editor/FoldGraph.cs')
-rw-r--r--Scripts/Fold/Editor/FoldGraph.cs146
1 files changed, 0 insertions, 146 deletions
diff --git a/Scripts/Fold/Editor/FoldGraph.cs b/Scripts/Fold/Editor/FoldGraph.cs
deleted file mode 100644
index c0719d9..0000000
--- a/Scripts/Fold/Editor/FoldGraph.cs
+++ /dev/null
@@ -1,146 +0,0 @@
-using System;
-using System.Collections.Generic;
-using UnityEngine;
-
-[Serializable]
-public class FoldEdge
-{
- public string outputNodeGuid, outputPortName, inputNodeGuid, inputPortName;
-}
-
-[Serializable]
-public readonly struct FoldOperationDefinition
-{
- public readonly string title;
- public readonly int opcode;
- public readonly (string name, Type type)[] inputs;
-
- public FoldOperationDefinition(string title, int opcode, params (string name, Type type)[] inputs)
- {
- this.title = title;
- this.opcode = opcode;
- this.inputs = inputs;
- }
-
- public FoldNodeSerialized Serialize(FoldGraphView graphView, string guid)
- {
- var serialized = new FoldNodeSerialized { opcode = opcode };
- int floatIndex = 0, vectorIndex = 0;
-
- foreach (var (name, type) in inputs)
- {
- if (type == typeof(float))
- SetFloat(ref serialized, floatIndex++, graphView.GetInputValue(guid, name, 0f));
- else if (type == typeof(Vector4))
- SetVector(ref serialized, vectorIndex++, graphView.GetInputValue(guid, name, Vector4.zero));
- }
-
- return serialized;
- }
-
- static void SetFloat(ref FoldNodeSerialized node, int index, float value)
- {
- switch (index)
- {
- case 0: node.float0 = value; break;
- case 1: node.float1 = value; break;
- case 2: node.float2 = value; break;
- case 3: node.float3 = value; break;
- }
- }
-
- static void SetVector(ref FoldNodeSerialized node, int index, Vector4 value)
- {
- switch (index)
- {
- case 0: node.vec0 = value; break;
- case 1: node.vec1 = value; break;
- case 2: node.vec2 = value; break;
- case 3: node.vec3 = value; break;
- }
- }
-}
-
-[Serializable]
-public abstract class FoldNodeData
-{
- public string guid = Guid.NewGuid().ToString();
- public Vector2 position;
- public virtual string Title => GetType().Name;
-}
-
-[Serializable]
-public abstract class FoldOperationData : FoldNodeData
-{
- protected abstract FoldOperationDefinition Definition { get; }
- public override string Title => Definition.title;
- public virtual IEnumerable<(string name, Type type)> GetInputPorts() => Definition.inputs;
- public virtual FoldNodeSerialized Serialize(FoldGraphView graphView) => Definition.Serialize(graphView, guid);
-}
-
-[Serializable] public class FloatValueNodeData : FoldNodeData { public float value; public override string Title => "Float"; }
-[Serializable] public class VectorValueNodeData : FoldNodeData { public Vector4 value; public override string Title => "Vector"; }
-[Serializable] public class GameObjectNodeData : FoldNodeData { public GameObject output; public override string Title => "GameObject"; }
-[Serializable] public class KeyframeNodeData : FoldNodeData { public override string Title => "Keyframe"; }
-
-[Serializable]
-public class AxisAlignNodeData : FoldOperationData
-{
- static readonly FoldOperationDefinition DefinitionInfo = new(
- "Axis Align",
- 4,
- ("po", typeof(Vector4)),
- ("pp", typeof(Vector4)),
- ("r", typeof(Vector4)),
- ("t", typeof(float)));
-
- protected override FoldOperationDefinition Definition => DefinitionInfo;
-}
-
-[Serializable]
-public class PlaneToTubeNodeData : FoldOperationData
-{
- static readonly FoldOperationDefinition DefinitionInfo = new(
- "Plane to Tube",
- 2,
- ("p", typeof(Vector4)),
- ("r", typeof(Vector4)),
- ("s", typeof(Vector4)),
- ("t", typeof(float)));
-
- protected override FoldOperationDefinition Definition => DefinitionInfo;
-}
-
-[Serializable]
-public class PointAlignNodeData : FoldOperationData
-{
- static readonly FoldOperationDefinition DefinitionInfo = new(
- "Point Align",
- 3,
- ("po", typeof(Vector4)),
- ("pp", typeof(Vector4)),
- ("r", typeof(Vector4)),
- ("t", typeof(float)));
-
- protected override FoldOperationDefinition Definition => DefinitionInfo;
-}
-
-[Serializable]
-public class TubeToPlaneNodeData : FoldOperationData
-{
- static readonly FoldOperationDefinition DefinitionInfo = new(
- "Tube to Plane",
- 1,
- ("p", typeof(Vector4)),
- ("r", typeof(Vector4)),
- ("s", typeof(Vector4)),
- ("t", typeof(float)));
-
- protected override FoldOperationDefinition Definition => DefinitionInfo;
-}
-
-public class FoldGraph : ScriptableObject
-{
- [SerializeReference] public List<FoldNodeData> nodes = new();
- public List<FoldEdge> edges = new();
-}