import type { Mesh } from "./Mesh"

/** Definition of an **Entity** actor kind: something that lives in the world with
 *  its own behavior and a live transform (mobs, and later the npc / powerups) -- as
 *  opposed to a baked, static `Prop`. `State` is the per-instance runtime record the
 *  behavior mutates; `World` is whatever that behavior reads (e.g. `Terrain`).
 *
 *  Every field is plain data or a module function, so a definition is **imported
 *  into each context** (main thread + each render worker) rather than structured-
 *  cloned across the wire -- the per-kind polymorphism is code, not serialized
 *  state. That's what lets a registry of these stay compatible with the worker
 *  renderer (only plain instance data ever crosses; behavior is loaded per side). */
export type Entity<State, World> = {
  /** Stable tag for the kind (also the texture key today). The registry's order,
   *  not this string, is what becomes the id packed into the mob SAB. */
  name: string
  /** Build the canonical local-space mesh once; every instance shares it, differing
   *  only by its per-frame model matrix. */
  build: (mesh: Mesh) => void
  /** Advance one instance by `dt` seconds. */
  update: (state: State, dt: number, world: World) => void
  /** Local bounding radius (pre-scale) for the per-frame cull AABB. */
  boundingRadius: number
  /** Local body height (pre-scale) for the top of the stand-on collider. */
  bodyHeight: number
}
