mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-27 10:44:43 +08:00
Still WIP
This commit is contained in:
22
js/entity/ComputedTypeEntity.js
Normal file
22
js/entity/ComputedTypeEntity.js
Normal file
@@ -0,0 +1,22 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user