Calculated serialization type

This commit is contained in:
barsdeveloper
2022-09-11 13:55:01 +02:00
parent 57ef15c943
commit 9f789b3e09
18 changed files with 510 additions and 412 deletions

View File

@@ -1,3 +1,4 @@
import CalculatedType from "./CalculatedType"
import GuidEntity from "./GuidEntity"
import IEntity from "./IEntity"
import LinearColorEntity from "./LinearColorEntity"
@@ -6,9 +7,22 @@ import ObjectReferenceEntity from "./ObjectReferenceEntity"
import PinReferenceEntity from "./PinReferenceEntity"
import SerializedType from "./SerializedType"
import TypeInitialization from "./TypeInitialization"
import VectorEntity from "./VectorEntity"
export default class PinEntity extends IEntity {
static #typeEntityMap = {
"/Script/CoreUObject.LinearColor": LinearColorEntity,
"/Script/CoreUObject.Vector": VectorEntity,
"bool": Boolean,
"exec": String,
"name": String,
"real": Number,
"string": String,
}
static get typeEntityMap() {
return PinEntity.#typeEntityMap
}
static lookbehind = "Pin"
static attributes = {
PinId: GuidEntity,
@@ -30,12 +44,16 @@ export default class PinEntity extends IEntity {
bSerializeAsSinglePrecisionFloat: false,
},
LinkedTo: new TypeInitialization([PinReferenceEntity], false),
DefaultValue: new TypeInitialization(
new SerializedType([
LinearColorEntity,
]),
false
),
DefaultValue:
new CalculatedType(
/** @param {PinEntity} pinEntity */
pinEntity => new TypeInitialization(
PinEntity.typeEntityMap[pinEntity.getType()] ?? String,
false,
undefined,
true
)
),
AutogeneratedDefaultValue: new TypeInitialization(String, false),
DefaultObject: new TypeInitialization(ObjectReferenceEntity, false, null),
PersistentGuid: GuidEntity,
@@ -47,6 +65,13 @@ export default class PinEntity extends IEntity {
bOrphanedPin: false,
}
getType() {
if (this.PinType.PinCategory == "struct") {
return this.PinType.PinSubCategoryObject.path
}
return this.PinType.PinCategory
}
getDefaultValue() {
return this.DefaultValue ?? ""
}
@@ -108,13 +133,6 @@ export default class PinEntity extends IEntity {
return false
}
getType() {
if (this.PinType.PinCategory == "struct") {
return this.PinType.PinSubCategoryObject.path
}
return this.PinType.PinCategory
}
getSubCategory() {
return this.PinType.PinSubCategoryObject.path
}