mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:50:33 +08:00
* Still WIP * WIP * ArrayEntity parsing fixed * Fix format text entity * Tests for various entity classes and update entity class implementations * More tests and fixed * More entities fixed * Simple entities serialization fixed * Entities tests fixed * Remove serialization bits * Fix Function reference * CustomProperties creating fixed * WIP * Better typing for grammars * Decoding code fixes * Fixing still * Several fixes * rename toString to serialize * Several fixes * More fixes * Moving more stuff out of Utility * Several fixes * Fixing Linear color entity print * Serialization fixes * Fix serialization * Method to compute grammar * Renaming fix * Fix array grammar and equality check * Fix inlined keys * Fix type * Several serialization fixes * Fix undefined dereference * Several fixes * More fixes and cleanup * Fix keys quoting mechanism * Fix natural number assignment * Fix Int64 toString() * Fix quoted keys for inlined arrays * Fix PG pins * Fix several test cases * Types fixes * New pin default value empty * Fix non existing DefaultValue for variadic nodes * Smaller fixes for crashes * Fix link color when attached to knot * Linking test and more reliability operations for adding pins * Improve issue 18 test * More tests and fixes * Fix enum pin entity * Remove failing test
126 lines
4.9 KiB
JavaScript
126 lines
4.9 KiB
JavaScript
import Configuration from "../Configuration.js"
|
|
import CommentNodeTemplate from "../template/node/CommentNodeTemplate.js"
|
|
import EventNodeTemplate from "../template/node/EventNodeTemplate.js"
|
|
import KnotNodeTemplate from "../template/node/KnotNodeTemplate.js"
|
|
import MetasoundNodeTemplate from "../template/node/MetasoundNodeTemplate.js"
|
|
import MetasoundOperationTemplate from "../template/node/MetasoundOperationTemplate.js"
|
|
import NodeTemplate from "../template/node/NodeTemplate.js"
|
|
import VariableAccessNodeTemplate from "../template/node/VariableAccessNodeTemplate.js"
|
|
import VariableConversionNodeTemplate from "../template/node/VariableConversionNodeTemplate.js"
|
|
import VariableOperationNodeTemplate from "../template/node/VariableOperationNodeTemplate.js"
|
|
|
|
/**
|
|
* @param {ObjectEntity} nodeEntity
|
|
* @return {new () => NodeTemplate}
|
|
*/
|
|
export default function nodeTemplateClass(nodeEntity) {
|
|
if (
|
|
nodeEntity.getClass() === Configuration.paths.callFunction
|
|
|| nodeEntity.getClass() === Configuration.paths.commutativeAssociativeBinaryOperator
|
|
|| nodeEntity.getClass() === Configuration.paths.callArrayFunction
|
|
) {
|
|
const memberParent = nodeEntity.FunctionReference?.MemberParent?.path ?? ""
|
|
const memberName = nodeEntity.FunctionReference?.MemberName?.toString()
|
|
if (
|
|
memberName && (
|
|
memberParent === Configuration.paths.kismetMathLibrary
|
|
|| memberParent === Configuration.paths.kismetArrayLibrary
|
|
)) {
|
|
if (memberName.startsWith("Conv_")) {
|
|
return VariableConversionNodeTemplate
|
|
}
|
|
if (
|
|
memberName.startsWith("Add_")
|
|
|| memberName.startsWith("And_")
|
|
|| memberName.startsWith("Boolean") // Boolean logic operations
|
|
|| memberName.startsWith("Cross_")
|
|
|| memberName.startsWith("Dot_")
|
|
|| memberName.startsWith("Not_")
|
|
|| memberName.startsWith("Or_")
|
|
|| memberName.startsWith("Percent_")
|
|
|| memberName.startsWith("Xor_")
|
|
) {
|
|
return VariableOperationNodeTemplate
|
|
}
|
|
switch (memberName) {
|
|
case "Abs":
|
|
case "Array_Add":
|
|
case "Array_AddUnique":
|
|
case "Array_Identical":
|
|
case "BMax":
|
|
case "BMin":
|
|
case "CrossProduct2D":
|
|
case "DotProduct2D":
|
|
case "Exp":
|
|
case "FMax":
|
|
case "FMin":
|
|
case "GetPI":
|
|
case "Max":
|
|
case "MaxInt64":
|
|
case "Min":
|
|
case "MinInt64":
|
|
case "Sqrt":
|
|
case "Square":
|
|
case "Vector4_CrossProduct3":
|
|
case "Vector4_DotProduct":
|
|
case "Vector4_DotProduct3":
|
|
// Trigonometry
|
|
case "Acos":
|
|
case "Asin":
|
|
case "Cos":
|
|
case "DegAcos":
|
|
case "DegCos":
|
|
case "DegSin":
|
|
case "DegTan":
|
|
case "Sin":
|
|
case "Tan":
|
|
return VariableOperationNodeTemplate
|
|
}
|
|
}
|
|
if (memberParent === Configuration.paths.blueprintSetLibrary) {
|
|
return VariableOperationNodeTemplate
|
|
}
|
|
if (memberParent === Configuration.paths.blueprintMapLibrary) {
|
|
return VariableOperationNodeTemplate
|
|
}
|
|
}
|
|
switch (nodeEntity.getClass()) {
|
|
case Configuration.paths.comment:
|
|
case Configuration.paths.materialGraphNodeComment:
|
|
return CommentNodeTemplate
|
|
case Configuration.paths.createDelegate:
|
|
return NodeTemplate
|
|
case Configuration.paths.metasoundEditorGraphExternalNode:
|
|
if (nodeEntity["ClassName"]?.["Name"] == "Add") {
|
|
return MetasoundOperationTemplate
|
|
}
|
|
return MetasoundNodeTemplate
|
|
case Configuration.paths.niagaraNodeOp:
|
|
if (
|
|
[
|
|
"Boolean::LogicEq",
|
|
"Boolean::LogicNEq",
|
|
"Numeric::Abs",
|
|
"Numeric::Add",
|
|
"Numeric::Mul",
|
|
].includes(nodeEntity.OpName?.toString())
|
|
) {
|
|
return VariableOperationNodeTemplate
|
|
}
|
|
break
|
|
case Configuration.paths.promotableOperator:
|
|
return VariableOperationNodeTemplate
|
|
case Configuration.paths.knot:
|
|
return KnotNodeTemplate
|
|
case Configuration.paths.literal:
|
|
case Configuration.paths.self:
|
|
case Configuration.paths.variableGet:
|
|
case Configuration.paths.variableSet:
|
|
return VariableAccessNodeTemplate
|
|
}
|
|
if (nodeEntity.isEvent()) {
|
|
return EventNodeTemplate
|
|
}
|
|
return NodeTemplate
|
|
}
|