mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-23 15:24:45 +08:00
Fix pasted nodes links
This commit is contained in:
@@ -279,12 +279,14 @@ export default class Blueprint extends IElement {
|
||||
|
||||
/** @param {PinReferenceEntity} pinReference */
|
||||
getPin(pinReference) {
|
||||
let result = this.template.getPin(this, pinReference)
|
||||
if (result) {
|
||||
let result = this.template.getPin(pinReference)
|
||||
if (result
|
||||
// Make sure it wasn't renamed in the meantime
|
||||
&& result.nodeElement.getNodeName() == pinReference.objectName) {
|
||||
return result
|
||||
}
|
||||
// Slower fallback
|
||||
return [... this.nodes
|
||||
//.filter(n => !n.parentNode)
|
||||
.find(n => pinReference.objectName.toString() == n.getNodeName())
|
||||
?.getPinElements() ?? []]
|
||||
.find(p => pinReference.pinGuid.toString() == p.GetPinIdValue())
|
||||
@@ -357,7 +359,7 @@ export default class Blueprint extends IElement {
|
||||
}
|
||||
}
|
||||
graphElements.filter(element => element instanceof NodeElement).forEach(
|
||||
node => /** @type {NodeElement} */(node).sanitizeLinks()
|
||||
node => /** @type {NodeElement} */(node).sanitizeLinks(graphElements)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import PinReferenceEntity from "../entity/PinReferenceEntity"
|
||||
import SerializerFactory from "../serialization/SerializerFactory"
|
||||
import Utility from "../Utility"
|
||||
|
||||
/** @typedef {import("./IElement").default} IElement */
|
||||
|
||||
/** @extends {ISelectableDraggableElement<ObjectEntity, NodeTemplate>} */
|
||||
export default class NodeElement extends ISelectableDraggableElement {
|
||||
|
||||
@@ -102,8 +104,9 @@ export default class NodeElement extends ISelectableDraggableElement {
|
||||
return this.entity.getDisplayName()
|
||||
}
|
||||
|
||||
sanitizeLinks() {
|
||||
this.getPinElements().forEach(pin => pin.sanitizeLinks())
|
||||
/** @param {IElement[]} nodesWhitelist */
|
||||
sanitizeLinks(nodesWhitelist = []) {
|
||||
this.getPinElements().forEach(pin => pin.sanitizeLinks(nodesWhitelist))
|
||||
}
|
||||
|
||||
/** @param {String} name */
|
||||
|
||||
@@ -192,10 +192,14 @@ export default class PinElement extends IElement {
|
||||
this.entity.DefaultValue = value
|
||||
}
|
||||
|
||||
sanitizeLinks() {
|
||||
/** @param {IElement[]} nodesWhitelist */
|
||||
sanitizeLinks(nodesWhitelist = []) {
|
||||
this.entity.LinkedTo = this.getLinks().filter(pinReference => {
|
||||
let pin = this.blueprint.getPin(pinReference)
|
||||
if (pin) {
|
||||
if (nodesWhitelist.length && !nodesWhitelist.includes(pin.nodeElement)) {
|
||||
return false
|
||||
}
|
||||
let link = this.blueprint.getLink(this, pin, true)
|
||||
if (!link) {
|
||||
this.blueprint.addGraphElement(new LinkElement(this, pin))
|
||||
|
||||
Reference in New Issue
Block a user