has<T extends EntityStruct> abstract method

T has<T extends EntityStruct>(
  1. T create()
)

Declares one prefab and returns it, for the field that keeps it.

Takes the constructor, not an instance: a struct's fields declare their own columns from their initialisers (final hp = Field.int32(100)), and those run during construction, so the descriptor they declare against has to be open before the object exists. descriptor.has(Mote()) builds it too early and no longer compiles; descriptor.has(Mote.new) is the spelling. A prefab whose constructor takes arguments passes a closure - descriptor.has(() => Bullet(speed: 5)).

Implementation

T has<T extends EntityStruct>(T Function() create);