mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-06 23:57:30 +08:00
Fix Export paths name adjustments
This commit is contained in:
@@ -160,6 +160,7 @@ export default class BlueprintEntity extends ObjectEntity {
|
||||
["ScriptVariables", new (blueprintEntity.attributes.ScriptVariables)(scriptVariables.reverse())]
|
||||
)
|
||||
const result = new BlueprintEntity(Object.fromEntries(entries))
|
||||
result.mirrorNameInExportPaths(entity.Name?.toString())
|
||||
result.#objectEntitiesNameCounter = this.#objectEntitiesNameCounter
|
||||
result.#objectEntities = this.#objectEntities
|
||||
return result
|
||||
|
||||
@@ -370,45 +370,7 @@ export default class ObjectEntity extends IEntity {
|
||||
? outputIndex++
|
||||
: i
|
||||
})
|
||||
|
||||
// Mirror name part of the object in ExportPath
|
||||
const originalName = this.Name?.toString()
|
||||
const exportPath = this.ExportPath?.valueOf()
|
||||
if (originalName && exportPath?.path.endsWith(originalName)) {
|
||||
const mirroredEntity = /** @type {typeof ObjectEntity} */(this.constructor).attributes.ExportPath
|
||||
this.ExportPath = new mirroredEntity(
|
||||
() => new (mirroredEntity.type)(
|
||||
exportPath.type,
|
||||
exportPath.path.replace(originalName, (this.Name ?? "")?.toString()),
|
||||
exportPath.full
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
// Mirror name part of the nested object in ExportPath
|
||||
if (originalName) {
|
||||
const values = Object.values(this)
|
||||
for (let i = 0; i < values.length; ++i) {
|
||||
const value = values[i]
|
||||
if (value instanceof ObjectEntity) {
|
||||
values.push(...Object.values(value))
|
||||
if (!value.ExportPath?.valueOf(this).path.includes(originalName)) {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
const mirroredEntity = /** @type {typeof ObjectEntity} */(value.constructor).attributes.ExportPath
|
||||
const exportPath = value.ExportPath?.valueOf()
|
||||
value.ExportPath = new mirroredEntity(
|
||||
(self = this) => new (mirroredEntity.type)(
|
||||
exportPath.type,
|
||||
exportPath.path.replace(originalName, (this.Name ?? "")?.toString()),
|
||||
exportPath.full
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
this.mirrorNameInExportPaths()
|
||||
}
|
||||
|
||||
/** @returns {P<ObjectEntity>} */
|
||||
@@ -454,6 +416,40 @@ export default class ObjectEntity extends IEntity {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* @protected
|
||||
* Mirror then name part of the objects contained in this one in ExportPath
|
||||
*/
|
||||
mirrorNameInExportPaths(originalName = this.Name?.toString()) {
|
||||
if (!originalName) {
|
||||
return
|
||||
}
|
||||
const values = [this]
|
||||
for (let i = 0; i < values.length; ++i) {
|
||||
const value = values[i]
|
||||
if (value instanceof ObjectEntity) {
|
||||
values.push(...Object.values(value))
|
||||
if (!value.ExportPath?.valueOf().path.includes(originalName)) {
|
||||
continue
|
||||
}
|
||||
} else {
|
||||
continue
|
||||
}
|
||||
const mirroredEntity = /** @type {typeof ObjectEntity} */(value.constructor).attributes.ExportPath
|
||||
let originalExportPath = value.ExportPath
|
||||
value.ExportPath = new mirroredEntity(
|
||||
() => {
|
||||
const exportPath = originalExportPath.valueOf()
|
||||
return new (mirroredEntity.type)(
|
||||
exportPath.type,
|
||||
exportPath.path.replace(originalName, this.Name?.toString() ?? ""),
|
||||
exportPath.full
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** @type {String} */
|
||||
#class
|
||||
getClass() {
|
||||
|
||||
@@ -277,7 +277,7 @@ export default class PinEntity extends IEntity {
|
||||
}
|
||||
|
||||
isLinked() {
|
||||
return this.LinkedTo?.length > 0 ?? false
|
||||
return this.LinkedTo?.length > 0
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user