mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-04 08:08:18 +08:00
37 lines
773 B
JavaScript
37 lines
773 B
JavaScript
import AttributeInfo from "./AttributeInfo.js"
|
|
|
|
/** @template {Attribute} T */
|
|
export default class MirroredEntity {
|
|
|
|
static attributes = {
|
|
type: new AttributeInfo({
|
|
ignored: true,
|
|
}),
|
|
getter: new AttributeInfo({
|
|
ignored: true,
|
|
}),
|
|
}
|
|
|
|
/**
|
|
* @param {ConstructorType<T>} type
|
|
* @param {() => T} getter
|
|
*/
|
|
constructor(type, getter = null) {
|
|
this.type = type
|
|
this.getter = getter
|
|
}
|
|
|
|
get() {
|
|
return this.getter()
|
|
}
|
|
|
|
/** @returns {AttributeConstructor<Attribute>} */
|
|
getTargetType() {
|
|
const result = this.type
|
|
if (result instanceof MirroredEntity) {
|
|
return result.getTargetType()
|
|
}
|
|
return result
|
|
}
|
|
}
|