mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-03-04 14:27:29 +08:00
Entities cleanup, Primitive concept introduced
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
import Entity from "./Entity";
|
||||
|
||||
export default class GuidEntity extends Entity {
|
||||
|
||||
static attributes = {
|
||||
value: String
|
||||
}
|
||||
|
||||
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) {
|
||||
if (guid?.constructor === String) {
|
||||
guid = {
|
||||
value: guid
|
||||
}
|
||||
} else if (guid?.constructor === Boolean) {
|
||||
guid = {
|
||||
value: GuidEntity.generateGuid(guid == true)
|
||||
}
|
||||
}
|
||||
super(guid)
|
||||
}
|
||||
|
||||
getAttributes() {
|
||||
return GuidEntity.attributes
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user