Files
ueblueprint/js/entity/ComputedTypeEntity.js
barsdeveloper 1c2778fbf8 Still WIP
2024-05-28 16:44:39 +02:00

23 lines
584 B
JavaScript

import IEntity from "./IEntity.js"
export default class ComputedTypeEntity extends IEntity {
/** @type {(entity: IEntity) => typeof IEntity} */
static f
/**
* @template {typeof ComputedTypeEntity.f} T
* @param {T} producer
*/
static from(producer) {
const result = /** @type {(typeof ComputedTypeEntity) & { f: T }} */(this.asUniqueClass())
result.f = producer
return result
}
/** @param {IEntity} entity */
compute(entity) {
return /** @type {typeof ComputedTypeEntity} */(this.Self()).f(entity)
}
}