mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:50:33 +08:00
Guid => GuidEntity
This commit is contained in:
28
js/entity/GuidEntity.js
Executable file
28
js/entity/GuidEntity.js
Executable file
@@ -0,0 +1,28 @@
|
||||
import Entity from "./Entity"
|
||||
|
||||
export default class GuidEntity extends Entity {
|
||||
|
||||
static attributes = {
|
||||
value: String
|
||||
}
|
||||
|
||||
static generateGuid(random = true) {
|
||||
let values = new Uint32Array(4)
|
||||
if (random === true) {
|
||||
crypto.getRandomValues(values)
|
||||
}
|
||||
let guid = ""
|
||||
values.forEach(n => {
|
||||
guid += ('00000000' + n.toString(16).toUpperCase()).slice(-8)
|
||||
})
|
||||
return new GuidEntity({ valud: guid })
|
||||
}
|
||||
|
||||
getAttributes() {
|
||||
return GuidEntity.attributes
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.value
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import Entity from "./Entity"
|
||||
import FunctionReferenceEntity from "./FunctionReferenceEntity"
|
||||
import Guid from "./primitive/Guid"
|
||||
import GuidEntity from "./GuidEntity"
|
||||
import ObjectReferenceEntity from "./ObjectReferenceEntity"
|
||||
import PinEntity from "./PinEntity"
|
||||
import TypeInitialization from "./TypeInitialization"
|
||||
@@ -17,7 +17,7 @@ export default class ObjectEntity extends Entity {
|
||||
TargetType: new TypeInitialization(ObjectReferenceEntity, false, null),
|
||||
NodePosX: 0,
|
||||
NodePosY: 0,
|
||||
NodeGuid: Guid,
|
||||
NodeGuid: GuidEntity,
|
||||
CustomProperties: [PinEntity]
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import Entity from "./Entity"
|
||||
import Guid from "./primitive/Guid"
|
||||
import GuidEntity from "./GuidEntity"
|
||||
import LocalizedTextEntity from "./LocalizedTextEntity"
|
||||
import ObjectReferenceEntity from "./ObjectReferenceEntity"
|
||||
import PinReferenceEntity from "./PinReferenceEntity"
|
||||
@@ -8,7 +8,7 @@ import TypeInitialization from "./TypeInitialization"
|
||||
export default class PinEntity extends Entity {
|
||||
|
||||
static attributes = {
|
||||
PinId: Guid,
|
||||
PinId: GuidEntity,
|
||||
PinName: "",
|
||||
PinFriendlyName: new TypeInitialization(LocalizedTextEntity, false, null),
|
||||
PinToolTip: "",
|
||||
@@ -28,7 +28,7 @@ export default class PinEntity extends Entity {
|
||||
LinkedTo: [PinReferenceEntity],
|
||||
DefaultValue: "",
|
||||
AutogeneratedDefaultValue: "",
|
||||
PersistentGuid: Guid,
|
||||
PersistentGuid: GuidEntity,
|
||||
bHidden: false,
|
||||
bNotConnectable: false,
|
||||
bDefaultValueIsReadOnly: false,
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import Entity from "./Entity"
|
||||
import Guid from "./primitive/Guid"
|
||||
import GuidEntity from "./GuidEntity"
|
||||
import PathSymbol from "./PathSymbolEntity"
|
||||
|
||||
export default class PinReferenceEntity extends Entity {
|
||||
|
||||
static attributes = {
|
||||
objectName: PathSymbol,
|
||||
pinGuid: Guid
|
||||
pinGuid: GuidEntity
|
||||
}
|
||||
|
||||
getAttributes() {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import Entity from "./Entity"
|
||||
import Guid from "./primitive/Guid"
|
||||
import GuidEntity from "./GuidEntity"
|
||||
|
||||
export default class VariableReferenceEntity extends Entity {
|
||||
|
||||
static attributes = {
|
||||
MemberName: String,
|
||||
MemberGuid: Guid,
|
||||
MemberGuid: GuidEntity,
|
||||
bSelfContext: false
|
||||
}
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
import Primitive from "./Primitive"
|
||||
|
||||
export default class Guid extends Primitive {
|
||||
|
||||
static generateGuid(random) {
|
||||
let values = new Uint32Array(4)
|
||||
if (random === true) {
|
||||
crypto.getRandomValues(values)
|
||||
}
|
||||
let result = ""
|
||||
values.forEach(n => {
|
||||
result += ('00000000' + n.toString(16).toUpperCase()).slice(-8)
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
constructor(guid) {
|
||||
super()
|
||||
// Using constructor equality and not instanceof in order to consider both primitives and objects
|
||||
if (guid?.constructor === Boolean) {
|
||||
guid = Guid.generateGuid(guid == true)
|
||||
}
|
||||
if (guid instanceof Guid) {
|
||||
guid = guid.value
|
||||
}
|
||||
this.value = guid
|
||||
}
|
||||
|
||||
toString() {
|
||||
return this.value.toString()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user