mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-13 00:24:48 +08:00
Refactoring entities (#23)
* 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
This commit is contained in:
@@ -1,345 +1,287 @@
|
||||
import Parsernostrum from "parsernostrum"
|
||||
import P from "parsernostrum"
|
||||
import Configuration from "../Configuration.js"
|
||||
import Utility from "../Utility.js"
|
||||
import nodeColor from "../decoding/nodeColor.js"
|
||||
import nodeIcon from "../decoding/nodeIcon.js"
|
||||
import nodeVariadic from "../decoding/nodeVariadic.js"
|
||||
import Grammar from "../serialization/Grammar.js"
|
||||
import AttributeInfo from "./AttributeInfo.js"
|
||||
import Utility from "../Utility.js"
|
||||
import AlternativesEntity from "./AlternativesEntity.js"
|
||||
import ArrayEntity from "./ArrayEntity.js"
|
||||
import BooleanEntity from "./BooleanEntity.js"
|
||||
import FunctionReferenceEntity from "./FunctionReferenceEntity.js"
|
||||
import GuidEntity from "./GuidEntity.js"
|
||||
import IEntity from "./IEntity.js"
|
||||
import IdentifierEntity from "./IdentifierEntity.js"
|
||||
import IntegerEntity from "./IntegerEntity.js"
|
||||
import LinearColorEntity from "./LinearColorEntity.js"
|
||||
import MacroGraphReferenceEntity from "./MacroGraphReferenceEntity.js"
|
||||
import MirroredEntity from "./MirroredEntity.js"
|
||||
import NaturalNumberEntity from "./NaturalNumberEntity.js"
|
||||
import NullEntity from "./NullEntity.js"
|
||||
import NumberEntity from "./NumberEntity.js"
|
||||
import ObjectReferenceEntity from "./ObjectReferenceEntity.js"
|
||||
import PinEntity from "./PinEntity.js"
|
||||
import ScriptVariableEntity from "./ScriptVariableEntity.js"
|
||||
import StringEntity from "./StringEntity.js"
|
||||
import SymbolEntity from "./SymbolEntity.js"
|
||||
import Union from "./Union.js"
|
||||
import UnknownPinEntity from "./UnknownPinEntity.js"
|
||||
import VariableReferenceEntity from "./VariableReferenceEntity.js"
|
||||
import nodeVariadic from "../decoding/nodeVariadic.js"
|
||||
|
||||
export default class ObjectEntity extends IEntity {
|
||||
|
||||
#exported = false
|
||||
get exported() {
|
||||
return this.#exported
|
||||
}
|
||||
set exported(value) {
|
||||
this.#exported = value
|
||||
}
|
||||
|
||||
static #nameRegex = /^(\w+?)(?:_(\d+))?$/
|
||||
/** @type {(k: String) => String} */
|
||||
static printKey = k => !k.startsWith(Configuration.subObjectAttributeNamePrefix) ? k : ""
|
||||
static attributeSeparator = "\n"
|
||||
static wrap = this.notWrapped
|
||||
static trailing = true
|
||||
static attributes = {
|
||||
...super.attributes,
|
||||
isExported: new AttributeInfo({
|
||||
type: Boolean,
|
||||
ignored: true,
|
||||
}),
|
||||
Class: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
Name: AttributeInfo.createType(String),
|
||||
Archetype: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
ExportPath: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
ObjectRef: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
BlueprintElementType: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
BlueprintElementInstance: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
PinTags: new AttributeInfo({
|
||||
type: [null],
|
||||
inlined: true,
|
||||
}),
|
||||
PinNames: new AttributeInfo({
|
||||
type: [String],
|
||||
inlined: true,
|
||||
}),
|
||||
AxisKey: AttributeInfo.createType(SymbolEntity),
|
||||
InputAxisKey: AttributeInfo.createType(SymbolEntity),
|
||||
InputName: AttributeInfo.createType(String),
|
||||
InputType: AttributeInfo.createType(SymbolEntity),
|
||||
NumAdditionalInputs: AttributeInfo.createType(Number),
|
||||
bIsPureFunc: AttributeInfo.createType(Boolean),
|
||||
bIsConstFunc: AttributeInfo.createType(Boolean),
|
||||
bIsCaseSensitive: AttributeInfo.createType(Boolean),
|
||||
VariableReference: AttributeInfo.createType(VariableReferenceEntity),
|
||||
SelfContextInfo: AttributeInfo.createType(SymbolEntity),
|
||||
DelegatePropertyName: AttributeInfo.createType(String),
|
||||
DelegateOwnerClass: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
ComponentPropertyName: AttributeInfo.createType(String),
|
||||
EventReference: AttributeInfo.createType(FunctionReferenceEntity),
|
||||
FunctionReference: AttributeInfo.createType(FunctionReferenceEntity),
|
||||
FunctionScript: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
CustomFunctionName: AttributeInfo.createType(String),
|
||||
TargetType: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
MacroGraphReference: AttributeInfo.createType(MacroGraphReferenceEntity),
|
||||
Enum: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
EnumEntries: new AttributeInfo({
|
||||
type: [String],
|
||||
inlined: true,
|
||||
}),
|
||||
InputKey: AttributeInfo.createType(SymbolEntity),
|
||||
OpName: AttributeInfo.createType(String),
|
||||
CachedChangeId: AttributeInfo.createType(GuidEntity),
|
||||
FunctionDisplayName: AttributeInfo.createType(String),
|
||||
AddedPins: new AttributeInfo({
|
||||
type: [UnknownPinEntity],
|
||||
default: () => [],
|
||||
inlined: true,
|
||||
silent: true,
|
||||
}),
|
||||
ChangeId: AttributeInfo.createType(GuidEntity),
|
||||
MaterialFunction: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
bOverrideFunction: AttributeInfo.createType(Boolean),
|
||||
bInternalEvent: AttributeInfo.createType(Boolean),
|
||||
bConsumeInput: AttributeInfo.createType(Boolean),
|
||||
bExecuteWhenPaused: AttributeInfo.createType(Boolean),
|
||||
bOverrideParentBinding: AttributeInfo.createType(Boolean),
|
||||
bControl: AttributeInfo.createType(Boolean),
|
||||
bAlt: AttributeInfo.createType(Boolean),
|
||||
bShift: AttributeInfo.createType(Boolean),
|
||||
bCommand: AttributeInfo.createType(Boolean),
|
||||
CommentColor: AttributeInfo.createType(LinearColorEntity),
|
||||
bCommentBubbleVisible_InDetailsPanel: AttributeInfo.createType(Boolean),
|
||||
bColorCommentBubble: AttributeInfo.createType(Boolean),
|
||||
ProxyFactoryFunctionName: AttributeInfo.createType(String),
|
||||
ProxyFactoryClass: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
ProxyClass: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
StructType: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
MaterialExpression: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
MaterialExpressionComment: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
MoveMode: AttributeInfo.createType(SymbolEntity),
|
||||
TimelineName: AttributeInfo.createType(String),
|
||||
TimelineGuid: AttributeInfo.createType(GuidEntity),
|
||||
SizeX: AttributeInfo.createType(new MirroredEntity(IntegerEntity)),
|
||||
SizeY: AttributeInfo.createType(new MirroredEntity(IntegerEntity)),
|
||||
Text: AttributeInfo.createType(new MirroredEntity(String)),
|
||||
MaterialExpressionEditorX: AttributeInfo.createType(new MirroredEntity(IntegerEntity)),
|
||||
MaterialExpressionEditorY: AttributeInfo.createType(new MirroredEntity(IntegerEntity)),
|
||||
NodeTitle: AttributeInfo.createType(String),
|
||||
NodeTitleColor: AttributeInfo.createType(LinearColorEntity),
|
||||
PositionX: AttributeInfo.createType(new MirroredEntity(IntegerEntity)),
|
||||
PositionY: AttributeInfo.createType(new MirroredEntity(IntegerEntity)),
|
||||
SettingsInterface: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
PCGNode: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
HiGenGridSize: AttributeInfo.createType(SymbolEntity),
|
||||
Operation: AttributeInfo.createType(SymbolEntity),
|
||||
NodePosX: AttributeInfo.createType(IntegerEntity),
|
||||
NodePosY: AttributeInfo.createType(IntegerEntity),
|
||||
NodeHeight: AttributeInfo.createType(IntegerEntity),
|
||||
NodeWidth: AttributeInfo.createType(IntegerEntity),
|
||||
Graph: AttributeInfo.createType(ObjectReferenceEntity),
|
||||
SubgraphInstance: AttributeInfo.createType(String),
|
||||
InputPins: new AttributeInfo({
|
||||
type: [ObjectReferenceEntity],
|
||||
inlined: true,
|
||||
}),
|
||||
OutputPins: new AttributeInfo({
|
||||
type: [ObjectReferenceEntity],
|
||||
inlined: true,
|
||||
}),
|
||||
bExposeToLibrary: AttributeInfo.createType(Boolean),
|
||||
bCanRenameNode: AttributeInfo.createType(Boolean),
|
||||
bCommentBubblePinned: AttributeInfo.createType(Boolean),
|
||||
bCommentBubbleVisible: AttributeInfo.createType(Boolean),
|
||||
NodeComment: AttributeInfo.createType(String),
|
||||
AdvancedPinDisplay: AttributeInfo.createType(IdentifierEntity),
|
||||
DelegateReference: AttributeInfo.createType(VariableReferenceEntity),
|
||||
EnabledState: AttributeInfo.createType(IdentifierEntity),
|
||||
NodeGuid: AttributeInfo.createType(GuidEntity),
|
||||
ErrorType: AttributeInfo.createType(IntegerEntity),
|
||||
ErrorMsg: AttributeInfo.createType(String),
|
||||
ScriptVariables: new AttributeInfo({
|
||||
type: [ScriptVariableEntity],
|
||||
inlined: true,
|
||||
}),
|
||||
Node: AttributeInfo.createType(new MirroredEntity(ObjectReferenceEntity)),
|
||||
ExportedNodes: AttributeInfo.createType(String),
|
||||
CustomProperties: AttributeInfo.createType([new Union(PinEntity, UnknownPinEntity)]),
|
||||
Class: ObjectReferenceEntity,
|
||||
Name: StringEntity,
|
||||
Archetype: ObjectReferenceEntity,
|
||||
ExportPath: ObjectReferenceEntity,
|
||||
ObjectRef: ObjectReferenceEntity,
|
||||
BlueprintElementType: ObjectReferenceEntity,
|
||||
BlueprintElementInstance: ObjectReferenceEntity,
|
||||
ConstA: MirroredEntity.of(NumberEntity),
|
||||
ConstB: MirroredEntity.of(NumberEntity),
|
||||
PinTags: ArrayEntity.of(NullEntity).flagInlined(),
|
||||
PinNames: ArrayEntity.of(StringEntity).flagInlined(),
|
||||
AxisKey: SymbolEntity,
|
||||
InputAxisKey: SymbolEntity,
|
||||
InputName: StringEntity,
|
||||
InputType: SymbolEntity,
|
||||
NumAdditionalInputs: NaturalNumberEntity,
|
||||
bIsPureFunc: BooleanEntity,
|
||||
bIsConstFunc: BooleanEntity,
|
||||
bIsCaseSensitive: BooleanEntity,
|
||||
VariableReference: VariableReferenceEntity,
|
||||
SelfContextInfo: SymbolEntity,
|
||||
DelegatePropertyName: StringEntity,
|
||||
DelegateOwnerClass: ObjectReferenceEntity,
|
||||
ComponentPropertyName: StringEntity,
|
||||
EventReference: FunctionReferenceEntity,
|
||||
FunctionReference: FunctionReferenceEntity,
|
||||
FunctionScript: ObjectReferenceEntity,
|
||||
CustomFunctionName: StringEntity,
|
||||
TargetType: ObjectReferenceEntity,
|
||||
MacroGraphReference: MacroGraphReferenceEntity,
|
||||
Enum: ObjectReferenceEntity,
|
||||
EnumEntries: ArrayEntity.of(StringEntity).flagInlined(),
|
||||
InputKey: SymbolEntity,
|
||||
OpName: StringEntity,
|
||||
CachedChangeId: GuidEntity,
|
||||
FunctionDisplayName: StringEntity,
|
||||
AddedPins: ArrayEntity.of(UnknownPinEntity).withDefault().flagInlined().flagSilent(),
|
||||
ChangeId: GuidEntity,
|
||||
MaterialFunction: ObjectReferenceEntity,
|
||||
bOverrideFunction: BooleanEntity,
|
||||
bInternalEvent: BooleanEntity,
|
||||
bConsumeInput: BooleanEntity,
|
||||
bExecuteWhenPaused: BooleanEntity,
|
||||
bOverrideParentBinding: BooleanEntity,
|
||||
bControl: BooleanEntity,
|
||||
bAlt: BooleanEntity,
|
||||
bShift: BooleanEntity,
|
||||
bCommand: BooleanEntity,
|
||||
CommentColor: LinearColorEntity,
|
||||
bCommentBubbleVisible_InDetailsPanel: BooleanEntity,
|
||||
bColorCommentBubble: BooleanEntity,
|
||||
ProxyFactoryFunctionName: StringEntity,
|
||||
ProxyFactoryClass: ObjectReferenceEntity,
|
||||
ProxyClass: ObjectReferenceEntity,
|
||||
StructType: ObjectReferenceEntity,
|
||||
MaterialExpression: ObjectReferenceEntity,
|
||||
MaterialExpressionComment: ObjectReferenceEntity,
|
||||
MoveMode: SymbolEntity,
|
||||
TimelineName: StringEntity,
|
||||
TimelineGuid: GuidEntity,
|
||||
SizeX: MirroredEntity.of(IntegerEntity),
|
||||
SizeY: MirroredEntity.of(IntegerEntity),
|
||||
Text: MirroredEntity.of(StringEntity),
|
||||
MaterialExpressionEditorX: MirroredEntity.of(IntegerEntity),
|
||||
MaterialExpressionEditorY: MirroredEntity.of(IntegerEntity),
|
||||
NodeTitle: StringEntity,
|
||||
NodeTitleColor: LinearColorEntity,
|
||||
PositionX: MirroredEntity.of(IntegerEntity),
|
||||
PositionY: MirroredEntity.of(IntegerEntity),
|
||||
SettingsInterface: ObjectReferenceEntity,
|
||||
PCGNode: ObjectReferenceEntity,
|
||||
HiGenGridSize: SymbolEntity,
|
||||
Operation: SymbolEntity,
|
||||
NodePosX: IntegerEntity,
|
||||
NodePosY: IntegerEntity,
|
||||
NodeHeight: IntegerEntity,
|
||||
NodeWidth: IntegerEntity,
|
||||
Graph: ObjectReferenceEntity,
|
||||
SubgraphInstance: StringEntity,
|
||||
InputPins: ArrayEntity.of(ObjectReferenceEntity).flagInlined(),
|
||||
OutputPins: ArrayEntity.of(ObjectReferenceEntity).flagInlined(),
|
||||
bExposeToLibrary: BooleanEntity,
|
||||
bCanRenameNode: BooleanEntity,
|
||||
bCommentBubblePinned: BooleanEntity,
|
||||
bCommentBubbleVisible: BooleanEntity,
|
||||
NodeComment: StringEntity,
|
||||
AdvancedPinDisplay: SymbolEntity,
|
||||
DelegateReference: VariableReferenceEntity,
|
||||
EnabledState: SymbolEntity,
|
||||
NodeGuid: GuidEntity,
|
||||
ErrorType: IntegerEntity,
|
||||
ErrorMsg: StringEntity,
|
||||
ScriptVariables: ArrayEntity.of(ScriptVariableEntity),
|
||||
Node: MirroredEntity.of(ObjectReferenceEntity),
|
||||
ExportedNodes: StringEntity,
|
||||
CustomProperties: ArrayEntity.of(AlternativesEntity.accepting(PinEntity, UnknownPinEntity)).withDefault().flagSilent(),
|
||||
}
|
||||
static nameRegex = /^(\w+?)(?:_(\d+))?$/
|
||||
static customPropertyGrammar = Parsernostrum.seq(
|
||||
Parsernostrum.reg(/CustomProperties\s+/),
|
||||
Grammar.grammarFor(
|
||||
undefined,
|
||||
this.attributes.CustomProperties.type[0]
|
||||
),
|
||||
static customPropertyGrammar = P.seq(
|
||||
P.reg(/CustomProperties\s+/),
|
||||
this.attributes.CustomProperties.type.grammar,
|
||||
).map(([_0, pin]) => values => {
|
||||
if (!values.CustomProperties) {
|
||||
values.CustomProperties = []
|
||||
}
|
||||
values.CustomProperties.push(pin)
|
||||
/** @type {InstanceType<typeof this.attributes.CustomProperties>} */(
|
||||
values.CustomProperties ??= new (this.attributes.CustomProperties)()
|
||||
).values.push(pin)
|
||||
})
|
||||
static inlinedArrayEntryGrammar = Parsernostrum.seq(
|
||||
Parsernostrum.alt(
|
||||
static inlinedArrayEntryGrammar = P.seq(
|
||||
P.alt(
|
||||
Grammar.symbolQuoted.map(v => [v, true]),
|
||||
Grammar.symbol.map(v => [v, false]),
|
||||
),
|
||||
Parsernostrum.reg(
|
||||
new RegExp(`\\s*\\(\\s*(\\d+)\\s*\\)\\s*\\=\\s*`),
|
||||
1
|
||||
).map(Number)
|
||||
P.reg(new RegExp(String.raw`\s*\(\s*(\d+)\s*\)\s*\=\s*`), 1).map(Number)
|
||||
)
|
||||
.chain(
|
||||
/** @param {[[String, Boolean], Number]} param */
|
||||
/** @param {[[keyof ObjectEntity.attributes, Boolean], Number]} param */
|
||||
([[symbol, quoted], index]) =>
|
||||
Grammar.grammarFor(this.attributes[symbol])
|
||||
.map(currentValue =>
|
||||
values => {
|
||||
(values[symbol] ??= [])[index] = currentValue
|
||||
Utility.objectSet(values, ["attributes", symbol, "quoted"], quoted)
|
||||
if (!this.attributes[symbol]?.inlined) {
|
||||
if (!values.attributes) {
|
||||
IEntity.defineAttributes(values, {})
|
||||
}
|
||||
Utility.objectSet(values, ["attributes", symbol, "type"], [currentValue.constructor])
|
||||
Utility.objectSet(values, ["attributes", symbol, "inlined"], true)
|
||||
(this.attributes[symbol]?.grammar ?? IEntity.unknownEntityGrammar).map(currentValue =>
|
||||
values => {
|
||||
if (values[symbol] === undefined) {
|
||||
let arrayEntity = ArrayEntity
|
||||
if (quoted != arrayEntity.quoted) {
|
||||
arrayEntity = arrayEntity.flagQuoted(quoted)
|
||||
}
|
||||
if (!arrayEntity.inlined) {
|
||||
arrayEntity = arrayEntity.flagInlined()
|
||||
}
|
||||
values[symbol] = new arrayEntity()
|
||||
}
|
||||
)
|
||||
/** @type {ArrayEntity} */
|
||||
const target = values[symbol]
|
||||
target.values[index] = currentValue
|
||||
}
|
||||
)
|
||||
)
|
||||
static grammar = this.createGrammar()
|
||||
|
||||
static createSubObjectGrammar() {
|
||||
return Parsernostrum.lazy(() => this.grammar)
|
||||
.map(object =>
|
||||
values => values[Configuration.subObjectAttributeNameFromEntity(object)] = object
|
||||
)
|
||||
}
|
||||
|
||||
static createGrammar() {
|
||||
return Parsernostrum.seq(
|
||||
Parsernostrum.reg(/Begin +Object/),
|
||||
Parsernostrum.seq(
|
||||
Parsernostrum.whitespace,
|
||||
Parsernostrum.alt(
|
||||
this.createSubObjectGrammar(),
|
||||
this.customPropertyGrammar,
|
||||
Grammar.createAttributeGrammar(this, Parsernostrum.reg(Grammar.Regex.MultipleWordsSymbols)),
|
||||
Grammar.createAttributeGrammar(this, Grammar.attributeNameQuoted, undefined, (obj, k, v) =>
|
||||
Utility.objectSet(obj, ["attributes", ...k, "quoted"], true)
|
||||
),
|
||||
this.inlinedArrayEntryGrammar,
|
||||
)
|
||||
)
|
||||
.map(([_0, entry]) => entry)
|
||||
.many(),
|
||||
Parsernostrum.reg(/\s+End +Object/),
|
||||
)
|
||||
.map(([_0, attributes, _2]) => {
|
||||
const values = {}
|
||||
attributes.forEach(attributeSetter => attributeSetter(values))
|
||||
return new this(values)
|
||||
})
|
||||
}
|
||||
|
||||
static getMultipleObjectsGrammar() {
|
||||
return Parsernostrum.seq(
|
||||
Parsernostrum.whitespaceOpt,
|
||||
static grammarMultipleObjects = P.seq(
|
||||
P.whitespaceOpt,
|
||||
this.grammar,
|
||||
P.seq(
|
||||
P.whitespace,
|
||||
this.grammar,
|
||||
Parsernostrum.seq(
|
||||
Parsernostrum.whitespace,
|
||||
this.grammar,
|
||||
)
|
||||
.map(([_0, object]) => object)
|
||||
.many(),
|
||||
Parsernostrum.whitespaceOpt
|
||||
)
|
||||
.map(([_0, first, remaining, _4]) => [first, ...remaining])
|
||||
}
|
||||
.map(([_0, object]) => object)
|
||||
.many(),
|
||||
P.whitespaceOpt
|
||||
).map(([_0, first, remaining, _4]) => [first, ...remaining])
|
||||
|
||||
/** @type {String} */
|
||||
#class
|
||||
|
||||
constructor(values = {}, suppressWarns = false) {
|
||||
if ("NodePosX" in values !== "NodePosY" in values) {
|
||||
constructor(values = {}) {
|
||||
if (("NodePosX" in values) !== ("NodePosY" in values)) {
|
||||
const entries = Object.entries(values)
|
||||
const [key, position] = "NodePosX" in values
|
||||
? ["NodePosY", Object.keys(values).indexOf("NodePosX") + 1]
|
||||
: ["NodePosX", Object.keys(values).indexOf("NodePosY")]
|
||||
const entry = [key, new (AttributeInfo.getAttribute(values, key, "type", ObjectEntity))()]
|
||||
entries.splice(position, 0, entry)
|
||||
entries.splice(position, 0, [key, new IntegerEntity(0)])
|
||||
values = Object.fromEntries(entries)
|
||||
}
|
||||
super(values, suppressWarns)
|
||||
|
||||
// Attributes not assigned a strong type in attributes because the names are too generic
|
||||
/** @type {Number | MirroredEntity<Boolean>} */ this.R
|
||||
/** @type {Number | MirroredEntity<Boolean>} */ this.G
|
||||
/** @type {Number | MirroredEntity<Boolean>} */ this.B
|
||||
/** @type {Number | MirroredEntity<Boolean>} */ this.A
|
||||
super(values)
|
||||
|
||||
// Attributes
|
||||
/** @type {(PinEntity | UnknownPinEntity)[]} */ this.CustomProperties
|
||||
/** @type {Boolean} */ this.bIsPureFunc
|
||||
/** @type {Boolean} */ this.isExported
|
||||
/** @type {FunctionReferenceEntity} */ this.ComponentPropertyName
|
||||
/** @type {FunctionReferenceEntity} */ this.EventReference
|
||||
/** @type {FunctionReferenceEntity} */ this.FunctionReference
|
||||
/** @type {IdentifierEntity} */ this.AdvancedPinDisplay
|
||||
/** @type {IdentifierEntity} */ this.EnabledState
|
||||
/** @type {IntegerEntity} */ this.NodeHeight
|
||||
/** @type {IntegerEntity} */ this.NodePosX
|
||||
/** @type {IntegerEntity} */ this.NodePosY
|
||||
/** @type {IntegerEntity} */ this.NodeWidth
|
||||
/** @type {LinearColorEntity} */ this.CommentColor
|
||||
/** @type {LinearColorEntity} */ this.NodeTitleColor
|
||||
/** @type {MacroGraphReferenceEntity} */ this.MacroGraphReference
|
||||
/** @type {MirroredEntity} */ this.MaterialExpressionEditorX
|
||||
/** @type {MirroredEntity} */ this.MaterialExpressionEditorY
|
||||
/** @type {MirroredEntity} */ this.SizeX
|
||||
/** @type {MirroredEntity} */ this.SizeY
|
||||
/** @type {MirroredEntity} */ this.Text
|
||||
/** @type {MirroredEntity<IntegerEntity>} */ this.PositionX
|
||||
/** @type {MirroredEntity<IntegerEntity>} */ this.PositionY
|
||||
/** @type {MirroredEntity<ObjectReferenceEntity>} */ this.Node
|
||||
/** @type {null[]} */ this.PinTags
|
||||
/** @type {Number} */ this.NumAdditionalInputs
|
||||
/** @type {ObjectReferenceEntity[]} */ this.InputPins
|
||||
/** @type {ObjectReferenceEntity[]} */ this.OutputPins
|
||||
/** @type {ObjectReferenceEntity} */ this.Archetype
|
||||
/** @type {ObjectReferenceEntity} */ this.BlueprintElementInstance
|
||||
/** @type {ObjectReferenceEntity} */ this.BlueprintElementType
|
||||
/** @type {ObjectReferenceEntity} */ this.Class
|
||||
/** @type {ObjectReferenceEntity} */ this.Enum
|
||||
/** @type {ObjectReferenceEntity} */ this.ExportPath
|
||||
/** @type {ObjectReferenceEntity} */ this.FunctionScript
|
||||
/** @type {ObjectReferenceEntity} */ this.Graph
|
||||
/** @type {ObjectReferenceEntity} */ this.MaterialExpression
|
||||
/** @type {ObjectReferenceEntity} */ this.MaterialExpressionComment
|
||||
/** @type {ObjectReferenceEntity} */ this.MaterialFunction
|
||||
/** @type {ObjectReferenceEntity} */ this.ObjectRef
|
||||
/** @type {ObjectReferenceEntity} */ this.PCGNode
|
||||
/** @type {ObjectReferenceEntity} */ this.SettingsInterface
|
||||
/** @type {ObjectReferenceEntity} */ this.StructType
|
||||
/** @type {ObjectReferenceEntity} */ this.TargetType
|
||||
/** @type {ScriptVariableEntity[]} */ this.ScriptVariables
|
||||
/** @type {String[]} */ this.EnumEntries
|
||||
/** @type {String[]} */ this.PinNames
|
||||
/** @type {String} */ this.CustomFunctionName
|
||||
/** @type {String} */ this.DelegatePropertyName
|
||||
/** @type {String} */ this.ExportedNodes
|
||||
/** @type {String} */ this.FunctionDisplayName
|
||||
/** @type {String} */ this.InputName
|
||||
/** @type {String} */ this.Name
|
||||
/** @type {String} */ this.NodeComment
|
||||
/** @type {String} */ this.NodeTitle
|
||||
/** @type {String} */ this.Operation
|
||||
/** @type {String} */ this.OpName
|
||||
/** @type {String} */ this.ProxyFactoryFunctionName
|
||||
/** @type {String} */ this.SubgraphInstance
|
||||
/** @type {String} */ this.Text
|
||||
/** @type {SymbolEntity} */ this.AxisKey
|
||||
/** @type {SymbolEntity} */ this.HiGenGridSize
|
||||
/** @type {SymbolEntity} */ this.InputAxisKey
|
||||
/** @type {SymbolEntity} */ this.InputKey
|
||||
/** @type {SymbolEntity} */ this.InputType
|
||||
/** @type {UnknownPinEntity[]} */ this.AddedPins
|
||||
/** @type {VariableReferenceEntity} */ this.DelegateReference
|
||||
/** @type {VariableReferenceEntity} */ this.VariableReference
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.AddedPins>} */ this.AddedPins
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.AdvancedPinDisplay>} */ this.AdvancedPinDisplay
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.Archetype>} */ this.Archetype
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.AxisKey>} */ this.AxisKey
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.bIsPureFunc>} */ this.bIsPureFunc
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.BlueprintElementInstance>} */ this.BlueprintElementInstance
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.ConstA>} */ this.ConstA
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.ConstB>} */ this.ConstB
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.BlueprintElementType>} */ this.BlueprintElementType
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.Class>} */ this.Class
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.CommentColor>} */ this.CommentColor
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.ComponentPropertyName>} */ this.ComponentPropertyName
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.CustomFunctionName>} */ this.CustomFunctionName
|
||||
/** @type {ArrayEntity<typeof PinEntity | typeof UnknownPinEntity>} */ this.CustomProperties
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.DelegatePropertyName>} */ this.DelegatePropertyName
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.DelegateReference>} */ this.DelegateReference
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.EnabledState>} */ this.EnabledState
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.Enum>} */ this.Enum
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.EnumEntries>} */ this.EnumEntries
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.EventReference>} */ this.EventReference
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.ExportedNodes>} */ this.ExportedNodes
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.ExportPath>} */ this.ExportPath
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.FunctionDisplayName>} */ this.FunctionDisplayName
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.FunctionReference>} */ this.FunctionReference
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.FunctionScript>} */ this.FunctionScript
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.Graph>} */ this.Graph
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.HiGenGridSize>} */ this.HiGenGridSize
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.InputAxisKey>} */ this.InputAxisKey
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.InputKey>} */ this.InputKey
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.InputName>} */ this.InputName
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.InputPins>} */ this.InputPins
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.InputType>} */ this.InputType
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.MacroGraphReference>} */ this.MacroGraphReference
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.MaterialExpression>} */ this.MaterialExpression
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.MaterialExpressionComment>} */ this.MaterialExpressionComment
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.MaterialExpressionEditorX>} */ this.MaterialExpressionEditorX
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.MaterialExpressionEditorY>} */ this.MaterialExpressionEditorY
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.MaterialFunction>} */ this.MaterialFunction
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.Name>} */ this.Name
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.Node>} */ this.Node
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.NodeComment>} */ this.NodeComment
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.NodeHeight>} */ this.NodeHeight
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.NodePosX>} */ this.NodePosX
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.NodePosY>} */ this.NodePosY
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.NodeTitle>} */ this.NodeTitle
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.NodeTitleColor>} */ this.NodeTitleColor
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.NodeWidth>} */ this.NodeWidth
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.NumAdditionalInputs>} */ this.NumAdditionalInputs
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.ObjectRef>} */ this.ObjectRef
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.Operation>} */ this.Operation
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.OpName>} */ this.OpName
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.OutputPins>} */ this.OutputPins
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.PCGNode>} */ this.PCGNode
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.PinTags>} */ this.PinTags
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.PinNames>} */ this.PinNames
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.PositionX>} */ this.PositionX
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.PositionY>} */ this.PositionY
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.ProxyFactoryFunctionName>} */ this.ProxyFactoryFunctionName
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.ScriptVariables>} */ this.ScriptVariables
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.SettingsInterface>} */ this.SettingsInterface
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.SizeX>} */ this.SizeX
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.SizeY>} */ this.SizeY
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.StructType>} */ this.StructType
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.SubgraphInstance>} */ this.SubgraphInstance
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.TargetType>} */ this.TargetType
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.Text>} */ this.Text
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.Text>} */ this.Text
|
||||
/** @type {InstanceType<typeof ObjectEntity.attributes.VariableReference>} */ this.VariableReference
|
||||
|
||||
// Legacy nodes pins
|
||||
if (this["Pins"] instanceof Array) {
|
||||
this["Pins"].forEach(
|
||||
if (this["Pins"] instanceof ArrayEntity) {
|
||||
this["Pins"].valueOf().forEach(
|
||||
/** @param {ObjectReferenceEntity} objectReference */
|
||||
objectReference => {
|
||||
const pinObject = this[Configuration.subObjectAttributeNameFromReference(objectReference, true)]
|
||||
if (pinObject) {
|
||||
const pinEntity = PinEntity.fromLegacyObject(pinObject)
|
||||
pinEntity.LinkedTo = []
|
||||
pinEntity.LinkedTo = new (PinEntity.attributes.LinkedTo)()
|
||||
this.getCustomproperties(true).push(pinEntity)
|
||||
Utility.objectSet(this, ["attributes", "CustomProperties", "ignored"], true)
|
||||
this.CustomProperties.ignored = true
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -354,24 +296,37 @@ export default class ObjectEntity extends IEntity {
|
||||
obj.MaterialExpressionEditorX && (obj.MaterialExpressionEditorX.getter = () => this.NodePosX)
|
||||
obj.MaterialExpressionEditorY && (obj.MaterialExpressionEditorY.getter = () => this.NodePosY)
|
||||
if (this.getType() === Configuration.paths.materialExpressionComponentMask) {
|
||||
// The following attributes are too generic therefore not assigned a MirroredEntity
|
||||
const rgbaPins = Configuration.rgba.map(pinName =>
|
||||
this.getPinEntities().find(pin => pin.PinName === pinName && (pin.recomputesNodeTitleOnChange = true))
|
||||
)
|
||||
const attribute = {}
|
||||
obj.R = new MirroredEntity(Boolean, () => rgbaPins[0].DefaultValue)
|
||||
obj.G = new MirroredEntity(Boolean, () => rgbaPins[1].DefaultValue)
|
||||
obj.B = new MirroredEntity(Boolean, () => rgbaPins[2].DefaultValue)
|
||||
obj.A = new MirroredEntity(Boolean, () => rgbaPins[3].DefaultValue)
|
||||
Utility.objectSet(obj, ["attributes", "R", "default"], false)
|
||||
Utility.objectSet(obj, ["attributes", "R", "silent"], true)
|
||||
Utility.objectSet(obj, ["attributes", "G", "default"], false)
|
||||
Utility.objectSet(obj, ["attributes", "G", "silent"], true)
|
||||
Utility.objectSet(obj, ["attributes", "B", "default"], false)
|
||||
Utility.objectSet(obj, ["attributes", "B", "silent"], true)
|
||||
Utility.objectSet(obj, ["attributes", "A", "default"], false)
|
||||
Utility.objectSet(obj, ["attributes", "A", "silent"], true)
|
||||
obj._keys = [...Configuration.rgba, ...Object.keys(obj).filter(k => !Configuration.rgba.includes(k))]
|
||||
const rgbaPins = Configuration.rgba.map(pinName => {
|
||||
const result = this.getPinEntities().find(pin => pin.PinName.toString() === pinName)
|
||||
result.recomputesNodeTitleOnChange = true
|
||||
return result
|
||||
})
|
||||
// Reorder keys so that the added ones stay first
|
||||
obj.keys = [...Configuration.rgba, ...obj.keys]
|
||||
const silentBool = MirroredEntity.of(BooleanEntity).withDefault().flagSilent()
|
||||
obj["R"] = new silentBool(() => rgbaPins[0].DefaultValue)
|
||||
obj["G"] = new silentBool(() => rgbaPins[1].DefaultValue)
|
||||
obj["B"] = new silentBool(() => rgbaPins[2].DefaultValue)
|
||||
obj["A"] = new silentBool(() => rgbaPins[3].DefaultValue)
|
||||
} else if (this.getType() === Configuration.paths.materialExpressionSubtract) {
|
||||
const silentNumber = MirroredEntity
|
||||
.of(NumberEntity.withPrecision(6))
|
||||
.withDefault(() => new MirroredEntity(() => new NumberEntity(1)))
|
||||
.flagSilent()
|
||||
const pinA = this.getCustomproperties().find(pin => pin.PinName?.toString() === "A")
|
||||
const pinB = this.getCustomproperties().find(pin => pin.PinName?.toString() === "B")
|
||||
if (pinA || pinB) {
|
||||
// Reorder keys so that the added ones stay first
|
||||
obj.keys = ["ConstA", "ConstB", ...obj.keys]
|
||||
if (pinA) {
|
||||
pinA.recomputesNodeTitleOnChange = true
|
||||
obj.ConstA = new silentNumber(() => pinA.DefaultValue)
|
||||
}
|
||||
if (pinB) {
|
||||
pinB.recomputesNodeTitleOnChange = true
|
||||
obj.ConstB = new silentNumber(() => pinB.DefaultValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/** @type {ObjectEntity} */
|
||||
@@ -383,15 +338,15 @@ export default class ObjectEntity extends IEntity {
|
||||
/** @param {ObjectEntity} obj */
|
||||
obj => {
|
||||
if (obj.Node !== undefined) {
|
||||
const nodeRef = obj.Node.get()
|
||||
const nodeRef = obj.Node.getter()
|
||||
if (
|
||||
nodeRef.type === this.PCGNode.type
|
||||
&& nodeRef.path === `${this.Name}.${this.PCGNode.path}`
|
||||
) {
|
||||
obj.Node.getter = () => new ObjectReferenceEntity({
|
||||
type: this.PCGNode.type,
|
||||
path: `${this.Name}.${this.PCGNode.path}`,
|
||||
})
|
||||
obj.Node.getter = () => new ObjectReferenceEntity(
|
||||
this.PCGNode.type,
|
||||
`${this.Name}.${this.PCGNode.path}`,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -400,7 +355,7 @@ export default class ObjectEntity extends IEntity {
|
||||
}
|
||||
let inputIndex = 0
|
||||
let outputIndex = 0
|
||||
this.CustomProperties?.forEach((pinEntity, i) => {
|
||||
this.getCustomproperties().forEach((pinEntity, i) => {
|
||||
pinEntity.objectEntity = this
|
||||
pinEntity.pinIndex = pinEntity.isInput()
|
||||
? inputIndex++
|
||||
@@ -410,10 +365,55 @@ export default class ObjectEntity extends IEntity {
|
||||
})
|
||||
}
|
||||
|
||||
/** @returns {P<ObjectEntity>} */
|
||||
static createGrammar() {
|
||||
return P.seq(
|
||||
P.reg(/Begin +Object/),
|
||||
P.seq(
|
||||
P.whitespace,
|
||||
P.alt(
|
||||
this.createSubObjectGrammar(),
|
||||
this.customPropertyGrammar,
|
||||
Grammar.createAttributeGrammar(this, P.reg(Grammar.Regex.MultipleWordsSymbols)),
|
||||
Grammar.createAttributeGrammar(
|
||||
this,
|
||||
Grammar.attributeNameQuoted,
|
||||
undefined,
|
||||
(values, attributeKey, attributeValue) => {
|
||||
Utility.objectSet(values, [...attributeKey, "quoted"], true)
|
||||
},
|
||||
),
|
||||
this.inlinedArrayEntryGrammar,
|
||||
)
|
||||
)
|
||||
.map(([_0, entry]) => entry)
|
||||
.many(),
|
||||
P.reg(/\s+End +Object/),
|
||||
)
|
||||
.map(([_0, attributes, _2]) => {
|
||||
const values = {}
|
||||
attributes.forEach(attributeSetter => attributeSetter(values))
|
||||
return new this(values)
|
||||
})
|
||||
.label("ObjectEntity")
|
||||
}
|
||||
|
||||
static createSubObjectGrammar() {
|
||||
return P.lazy(() => this.grammar)
|
||||
.map(object =>
|
||||
values => {
|
||||
object.trailing = false
|
||||
values[Configuration.subObjectAttributeNameFromEntity(object)] = object
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
/** @type {String} */
|
||||
#class
|
||||
getClass() {
|
||||
if (!this.#class) {
|
||||
this.#class = (this.Class?.path ? this.Class.path : this.Class?.type)
|
||||
?? (this.ExportPath?.path ? this.ExportPath.path : this.ExportPath?.type)
|
||||
?? this.ExportPath.type
|
||||
?? ""
|
||||
if (this.#class && !this.#class.startsWith("/")) {
|
||||
// Old path names did not start with /Script or /Engine, check tests/resources/LegacyNodes.js
|
||||
@@ -441,12 +441,12 @@ export default class ObjectEntity extends IEntity {
|
||||
if (dropCounter) {
|
||||
return this.getNameAndCounter()[0]
|
||||
}
|
||||
return this.Name
|
||||
return this.Name.toString()
|
||||
}
|
||||
|
||||
/** @returns {[String, Number]} */
|
||||
getNameAndCounter() {
|
||||
const result = this.getObjectName().match(ObjectEntity.nameRegex)
|
||||
const result = this.getObjectName().match(ObjectEntity.#nameRegex)
|
||||
let name = ""
|
||||
let counter = null
|
||||
return result
|
||||
@@ -509,10 +509,7 @@ export default class ObjectEntity extends IEntity {
|
||||
}
|
||||
|
||||
getCustomproperties(canCreate = false) {
|
||||
if (canCreate && !this.CustomProperties) {
|
||||
this.CustomProperties = []
|
||||
}
|
||||
return this.CustomProperties ?? []
|
||||
return this.CustomProperties.values
|
||||
}
|
||||
|
||||
/** @returns {PinEntity[]} */
|
||||
@@ -587,7 +584,7 @@ export default class ObjectEntity extends IEntity {
|
||||
|
||||
isPcg() {
|
||||
return this.getClass() === Configuration.paths.pcgEditorGraphNode
|
||||
|| this.getPcgSubobject()
|
||||
|| this.getPcgSubobject() != null
|
||||
}
|
||||
|
||||
isNiagara() {
|
||||
@@ -629,7 +626,7 @@ export default class ObjectEntity extends IEntity {
|
||||
}
|
||||
|
||||
getDelegatePin() {
|
||||
return this.getCustomproperties().find(pin => pin.PinType.PinCategory === "delegate")
|
||||
return this.getCustomproperties().find(pin => pin.PinType.PinCategory.toString() === "delegate")
|
||||
}
|
||||
|
||||
nodeColor() {
|
||||
@@ -643,4 +640,70 @@ export default class ObjectEntity extends IEntity {
|
||||
additionalPinInserter() {
|
||||
return nodeVariadic(this)
|
||||
}
|
||||
|
||||
/** @param {String} key */
|
||||
showProperty(key) {
|
||||
switch (key) {
|
||||
case "Class":
|
||||
case "Name":
|
||||
case "Archetype":
|
||||
case "ExportPath":
|
||||
case "CustomProperties":
|
||||
// Serielized separately, check doWrite()
|
||||
return false
|
||||
}
|
||||
return super.showProperty(key)
|
||||
}
|
||||
|
||||
/** @param {typeof ObjectEntity} Self */
|
||||
doSerialize(
|
||||
insideString = false,
|
||||
indentation = "",
|
||||
Self = /** @type {typeof ObjectEntity} */(this.constructor),
|
||||
printKey = Self.printKey,
|
||||
keySeparator = Self.keySeparator,
|
||||
attributeSeparator = Self.attributeSeparator,
|
||||
wrap = Self.wrap,
|
||||
) {
|
||||
const deeperIndentation = indentation + Configuration.indentation
|
||||
const content = super.doSerialize(insideString, deeperIndentation, Self, printKey, keySeparator, attributeSeparator, wrap)
|
||||
let result = indentation + "Begin Object"
|
||||
+ ((this.Class?.type || this.Class?.path)
|
||||
// && Self.attributes.Class.ignored !== true
|
||||
// && this.Class.ignored !== true
|
||||
? ` Class${keySeparator}${this.Class.serialize(insideString)}`
|
||||
: ""
|
||||
)
|
||||
+ (this.Name
|
||||
// && Self.attributes.Name.ignored !== true
|
||||
// && this.Name.ignored !== true
|
||||
? ` Name${keySeparator}${this.Name.serialize(insideString)}`
|
||||
: ""
|
||||
)
|
||||
+ (this.Archetype
|
||||
// && Self.attributes.Archetype.ignored !== true
|
||||
// && this.Archetype.ignored !== true
|
||||
? ` Archetype${keySeparator}${this.Archetype.serialize(insideString)}`
|
||||
: ""
|
||||
)
|
||||
+ ((this.ExportPath?.type || this.ExportPath?.path)
|
||||
// && Self.attributes.ExportPath.ignored !== true
|
||||
// && this.ExportPath.ignored !== true
|
||||
? ` ExportPath${keySeparator}${this.ExportPath.serialize(insideString)}`
|
||||
: ""
|
||||
)
|
||||
+ (content ? attributeSeparator + content : "")
|
||||
+ (Self.attributes.CustomProperties.ignored !== true && this.CustomProperties.ignored !== true
|
||||
? this.getCustomproperties().map(pin =>
|
||||
deeperIndentation
|
||||
+ printKey("CustomProperties ")
|
||||
+ pin.serialize(insideString)
|
||||
).join(Self.attributeSeparator)
|
||||
: ""
|
||||
)
|
||||
+ attributeSeparator
|
||||
+ indentation + "End Object"
|
||||
+ (this.trailing ? attributeSeparator : "")
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user