Files
ueblueprint/js/entity/ObjectReferenceEntity.js
barsdeveloper 6f674b284d PCG nodes and other fixes (#14)
* Various fixes

* Fix name from SettingsInterface

* Allow path lookbehind for unknown keys entity

* Subraph object name

* Several fixes

* Various fixes

* Fix colors

* Various pin types
2023-09-14 23:07:09 +02:00

58 lines
1.5 KiB
JavaScript
Executable File

import Configuration from "../Configuration.js"
import Utility from "../Utility.js"
import IEntity from "./IEntity.js"
export default class ObjectReferenceEntity extends IEntity {
static attributes = {
...super.attributes,
type: {
default: "",
},
path: {
default: "",
},
}
static {
this.cleanupAttributes(this.attributes)
}
constructor(values = {}) {
if (values.constructor === String) {
values = {
path: values
}
}
super(values)
/** @type {String} */ this.type
/** @type {String} */ this.path
}
static createNoneInstance() {
return new ObjectReferenceEntity({ type: "None", path: "" })
}
sanitize() {
if (this.type && !this.type.startsWith("/")) {
let deprecatedType = this.type + "_Deprecated"
let path = Object.keys(Configuration.paths)
.find(type => {
const name = Utility.getNameFromPath(Configuration.paths[type])
return name === this.type || name === deprecatedType
})
if (path) {
this.type = Configuration.paths[path]
}
}
}
getName() {
return Utility.getNameFromPath(this.path.replace(/_C$/, ""))
}
toString() {
return `${this.type}'"${this.path}"'`
}
}