mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-13 16:44:49 +08:00
Decoding code fixes
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
import Configuration from "../Configuration.js"
|
||||
import ArrayEntity from "../entity/ArrayEntity.js"
|
||||
import GuidEntity from "../entity/GuidEntity.js"
|
||||
import NaturalNumberEntity from "../entity/NaturalNumberEntity.js"
|
||||
import PinEntity from "../entity/PinEntity.js"
|
||||
import StringEntity from "../entity/StringEntity.js"
|
||||
|
||||
/** @param {PinEntity} pinEntity */
|
||||
const indexFromUpperCaseLetterName = pinEntity =>
|
||||
pinEntity.PinName.match(/^\s*([A-Z])\s*$/)?.[1]?.charCodeAt(0) - "A".charCodeAt(0)
|
||||
pinEntity.PinName?.valueOf().match(/^\s*([A-Z])\s*$/)?.[1]?.charCodeAt(0) - "A".charCodeAt(0)
|
||||
|
||||
/** @param {ObjectEntity} entity */
|
||||
export default function nodeVariadic(entity) {
|
||||
@@ -19,7 +22,7 @@ export default function nodeVariadic(entity) {
|
||||
switch (type) {
|
||||
case Configuration.paths.commutativeAssociativeBinaryOperator:
|
||||
case Configuration.paths.promotableOperator:
|
||||
name = entity.FunctionReference?.MemberName
|
||||
name = entity.FunctionReference?.MemberName?.valueOf()
|
||||
switch (name) {
|
||||
default:
|
||||
if (
|
||||
@@ -50,7 +53,7 @@ export default function nodeVariadic(entity) {
|
||||
pinIndexFromEntity ??= indexFromUpperCaseLetterName
|
||||
pinNameFromIndex ??= (index, min = -1, max = -1) => {
|
||||
const result = String.fromCharCode(index >= 0 ? index : max + "A".charCodeAt(0) + 1)
|
||||
entity.NumAdditionalInputs = pinEntities().length - 1
|
||||
entity.NumAdditionalInputs = new NaturalNumberEntity(pinEntities().length - 1)
|
||||
return result
|
||||
}
|
||||
break
|
||||
@@ -58,7 +61,7 @@ export default function nodeVariadic(entity) {
|
||||
break
|
||||
case Configuration.paths.multiGate:
|
||||
pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isOutput())
|
||||
pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName.match(/^\s*Out[_\s]+(\d+)\s*$/i)?.[1])
|
||||
pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName?.valueOf().match(/^\s*Out[_\s]+(\d+)\s*$/i)?.[1])
|
||||
pinNameFromIndex ??= (index, min = -1, max = -1, newPin) =>
|
||||
`Out ${index >= 0 ? index : min > 0 ? "Out 0" : max + 1}`
|
||||
break
|
||||
@@ -74,26 +77,26 @@ export default function nodeVariadic(entity) {
|
||||
// break
|
||||
case Configuration.paths.switchInteger:
|
||||
pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isOutput())
|
||||
pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName.match(/^\s*(\d+)\s*$/)?.[1])
|
||||
pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName?.valueOf().match(/^\s*(\d+)\s*$/)?.[1])
|
||||
pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => (index < 0 ? max + 1 : index).toString()
|
||||
break
|
||||
case Configuration.paths.switchGameplayTag:
|
||||
pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => {
|
||||
const result = `Case_${index >= 0 ? index : min > 0 ? "0" : max + 1}`
|
||||
entity.PinNames ??= []
|
||||
entity.PinNames.push(result)
|
||||
delete entity.PinTags[entity.PinTags.length - 1]
|
||||
entity.PinTags[entity.PinTags.length] = null
|
||||
entity.PinNames ??= new ArrayEntity()
|
||||
entity.PinNames.values.push(new StringEntity(result))
|
||||
delete entity.PinTags.values[entity.PinTags.length - 1]
|
||||
entity.PinTags.values[entity.PinTags.length] = null
|
||||
return result
|
||||
}
|
||||
case Configuration.paths.switchName:
|
||||
case Configuration.paths.switchString:
|
||||
pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isOutput())
|
||||
pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName.match(/^\s*Case[_\s]+(\d+)\s*$/i)?.[1])
|
||||
pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName.valueOf().match(/^\s*Case[_\s]+(\d+)\s*$/i)?.[1])
|
||||
pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => {
|
||||
const result = `Case_${index >= 0 ? index : min > 0 ? "0" : max + 1}`
|
||||
entity.PinNames ??= []
|
||||
entity.PinNames.push(result)
|
||||
entity.PinNames ??= new ArrayEntity()
|
||||
entity.PinNames.values.push(new StringEntity(result))
|
||||
return result
|
||||
}
|
||||
break
|
||||
@@ -138,8 +141,8 @@ export default function nodeVariadic(entity) {
|
||||
}
|
||||
)
|
||||
const newPin = new PinEntity(modelPin)
|
||||
newPin.PinId = GuidEntity.generateGuid()
|
||||
newPin.PinName = pinNameFromIndex(index, min, max, newPin)
|
||||
newPin.PinId = new GuidEntity()
|
||||
newPin.PinName = new StringEntity(pinNameFromIndex(index, min, max, newPin))
|
||||
newPin.PinToolTip = undefined
|
||||
entity.getCustomproperties(true).push(newPin)
|
||||
return newPin
|
||||
|
||||
Reference in New Issue
Block a user