mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-05-12 22:47:30 +08:00
Refactoring, various fixes
This commit is contained in:
@@ -9,19 +9,27 @@ export default class IElement extends HTMLElement {
|
||||
|
||||
static tagName = ""
|
||||
|
||||
/** @type {Blueprint} */
|
||||
blueprint
|
||||
|
||||
/** @type {IEntity} */
|
||||
entity
|
||||
|
||||
/** @type {ITemplate} */
|
||||
template
|
||||
|
||||
/** @type {IContext[]} */
|
||||
inputObjects = []
|
||||
|
||||
/**
|
||||
* @param {IEntity} entity The entity containing blueprint related data for this graph element
|
||||
* @param {ITemplate} template The template to render this node
|
||||
*/
|
||||
constructor(entity, template) {
|
||||
super()
|
||||
/** @type {Blueprint} */
|
||||
this.blueprint = null
|
||||
/** @type {IEntity} */
|
||||
this.entity = entity
|
||||
/** @type {ITemplate} */
|
||||
this.template = template
|
||||
/** @type {IContext[]} */
|
||||
this.inputObjects = []
|
||||
}
|
||||
|
||||
@@ -39,14 +47,22 @@ export default class IElement extends HTMLElement {
|
||||
this.inputObjects.forEach(v => v.unlistenDOMElement())
|
||||
}
|
||||
|
||||
createInputObjects() {
|
||||
return []
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {IElement} element
|
||||
*/
|
||||
/** @param {IElement} element */
|
||||
isSameGraph(element) {
|
||||
return this.blueprint && this.blueprint == element?.blueprint
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {} T
|
||||
* @param {new () => T} type
|
||||
* @returns {T}
|
||||
*/
|
||||
getInputObject(type) {
|
||||
return this.inputObjects.find(object => object.constructor == type)
|
||||
}
|
||||
|
||||
// Subclasses will want to override
|
||||
createInputObjects() {
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user