Relaxed enum value

This commit is contained in:
barsdeveloper
2023-04-26 22:56:46 +02:00
parent 53c28e7049
commit d97f1f39d7
8 changed files with 91 additions and 25 deletions

View File

@@ -0,0 +1,5 @@
import EnumEntity from "./EnumEntity.js"
export default class EnumDisplayValueEntity extends EnumEntity {
}

View File

@@ -0,0 +1,37 @@
import IEntity from "./IEntity.js"
/** @typedef {import("./IEntity.js").EntityConstructor} EntityConstructor */
export default class MirroredEntity extends IEntity {
static attributes = {
...super.attributes,
type: {
ignored: true,
},
key: {
ignored: true,
},
object: {
ignored: true,
},
}
constructor(values = {}) {
super({})
/** @type {EntityConstructor} */ this.type
/** @type {String} */ this.key
/** @type {IEntity} */ this.object
}
get() {
return this.object?.[this.key]
}
set(value) {
if (this.object[this.key]) {
this.object[this.key] = value
}
}
}

View File

@@ -530,7 +530,7 @@ export default class ObjectEntity extends IEntity {
}
isMaterial() {
return this.getClass() === Configuration.paths.materialGraphNode || this.MaterialExpression !== undefined
return this.getClass() === Configuration.paths.materialGraphNode
}
/** @return {ObjectEntity} */
@@ -620,7 +620,7 @@ export default class ObjectEntity extends IEntity {
if (this.getClass() === Configuration.paths.macro) {
return Utility.formatStringName(this.MacroGraphReference?.getMacroName())
}
if (this.isMaterial()) {
if (this.isMaterial() && this.MaterialExpression) {
const materialObject = /** @type {ObjectEntity} */(
this[Configuration.subObjectAttributeNameFromReference(this.MaterialExpression, true)]
)

View File

@@ -20,6 +20,7 @@ import UnionType from "./UnionType.js"
import Utility from "../Utility.js"
import Vector2DEntity from "./Vector2DEntity.js"
import VectorEntity from "./VectorEntity.js"
import EnumDisplayValueEntity from "./EnumDisplayValueEntity.js"
/**
* @typedef {import("./IEntity.js").AnyValue} AnyValue
@@ -46,9 +47,10 @@ export default class PinEntity extends IEntity {
"string": String,
}
static #alternativeTypeEntityMap = {
[Configuration.paths.vector2D]: SimpleSerializationVector2DEntity,
[Configuration.paths.vector]: SimpleSerializationVectorEntity,
"enum": EnumDisplayValueEntity,
[Configuration.paths.rotator]: SimpleSerializationRotatorEntity,
[Configuration.paths.vector]: SimpleSerializationVectorEntity,
[Configuration.paths.vector2D]: SimpleSerializationVector2DEntity,
}
static lookbehind = "Pin"
static attributes = {