static void HandleConstants(GraphBuilder builder, out INode node, out PortMapper portToOffsetMapping, IConstantNodeModel constantNodeModel) { portToOffsetMapping = new PortMapper(); var outputPortId = constantNodeModel.OutputPort?.UniqueId ?? ""; switch (constantNodeModel) { case StringConstantModel stringConstantModel: { var index = builder.StoreStringConstant(stringConstantModel.value ?? string.Empty); var cf = new ConstantString { Value = new StringReference(index, StringReference.Storage.Managed) }; node = MapPort(portToOffsetMapping, outputPortId, Direction.Output, ref cf.ValuePort.Port, cf); return; } case BooleanConstantNodeModel booleanConstantNodeModel: { var cf = new ConstantBool { Value = booleanConstantNodeModel.value }; node = MapPort(portToOffsetMapping, outputPortId, Direction.Output, ref cf.ValuePort.Port, cf); return; } case IntConstantModel intConstantModel: { var cf = new ConstantInt { Value = intConstantModel.value }; node = MapPort(portToOffsetMapping, outputPortId, Direction.Output, ref cf.ValuePort.Port, cf); return; } case FloatConstantModel floatConstantModel: { var cf = new ConstantFloat { Value = floatConstantModel.value }; node = MapPort(portToOffsetMapping, outputPortId, Direction.Output, ref cf.ValuePort.Port, cf); return; } case Vector2ConstantModel vector2ConstantModel: { var cf = new ConstantFloat2 { Value = vector2ConstantModel.value }; node = MapPort(portToOffsetMapping, outputPortId, Direction.Output, ref cf.ValuePort.Port, cf); return; } case Vector3ConstantModel vector3ConstantModel: { var cf = new ConstantFloat3 { Value = vector3ConstantModel.value }; node = MapPort(portToOffsetMapping, outputPortId, Direction.Output, ref cf.ValuePort.Port, cf); return; } case Vector4ConstantModel vector4ConstantModel: { var cf = new ConstantFloat4 { Value = vector4ConstantModel.value }; node = MapPort(portToOffsetMapping, outputPortId, Direction.Output, ref cf.ValuePort.Port, cf); return; } case QuaternionConstantModel quaternionConstantModel: { var cf = new ConstantQuaternion { Value = quaternionConstantModel.value }; node = MapPort(portToOffsetMapping, outputPortId, Direction.Output, ref cf.ValuePort.Port, cf); return; } case ObjectConstantModel _: { throw new NotImplementedException( "Conversion and all - either a prefab (might live in a graph) or a scene object (must be injected during runtime bootstrap)"); // portToOffsetMapping = new Dictionary<IPortModel, uint>(); // var cf = new ConstantEntity {Value = objectConstantModel.value}; // MapPort(portToOffsetMapping, objectConstantModel.OutputPort, ref cf.ValuePort.Port, nodeId); // node = cf; // return; } default: throw new NotImplementedException(); } }
public void DocumentNode(SearcherItem searcherItem, INodeModel nodeModel) { INode node; switch (nodeModel) { case IDotsNodeModel baseDotsNodeModel: node = baseDotsNodeModel.Node; break; case StringConstantModel _: node = new ConstantString(); break; case BooleanConstantNodeModel _: node = new ConstantBool(); break; case IntConstantModel _: node = new ConstantInt(); break; case FloatConstantModel _: node = new ConstantFloat(); break; case Vector2ConstantModel _: node = new ConstantFloat2(); break; case Vector3ConstantModel _: node = new ConstantFloat3(); break; case Vector4ConstantModel _: node = new ConstantFloat4(); break; case QuaternionConstantModel _: node = new ConstantQuaternion(); break; default: return; } var nodeType = node.GetType(); var executionType = GetNodeExecutionType(nodeType, node); var title = Attribute.IsDefined(node.GetType(), typeof(WorkInProgressAttribute)) ? $"{searcherItem.Name} [WIP]" : searcherItem.Name; SectionTitle(title, 1); var nodeDescription = GetNodeDescription(nodeType, executionType, out string exampleText, out string dataSetup); if (!String.IsNullOrEmpty(nodeDescription)) { Paragraph(nodeDescription); } GetPortsDescription(executionType, node); if (exampleText != null) { SectionTitle("Examples", 2); Paragraph(exampleText); } if (dataSetup != null) { SectionTitle("Data Setup", 2); Paragraph(dataSetup); } }