module CEnt:sig
..end
typeid =
Ent.id
typeentity =
Comp.entity
entity / component
conceptval new_entity : unit -> entity
val get_id : entity -> id
val get_id_opt : entity -> id option
get_id
but returns None instead of raising an exception
An entity may have as many components as needed, but only
one component of each type.
val has_component : entity -> Comp.component_type -> bool
val has_components : entity -> Comp.component_type list -> bool
(this function does not tell if the entity contains other components
or not)
val has_any_component : entity -> Comp.component_type list -> bool
val iter_components : entity -> (Comp.component_type -> Comp.component -> unit) -> unit
val get_components : entity -> Comp.component_type list
val cmp_components : entity -> Comp.component_type list -> int
val components_match : entity -> Comp.component_type list -> bool
Comp
,
which have been generated (from the type definition of component
)
with the gen_comp
command line tool.type('delta, 'fld)
world =('delta, 'fld) Comp.world
'delta
type parameter see the doc of the function world_step
and see world_step_fold
about the 'fld
type
val new_world : unit -> ('a, 'b) world
val add_entity : ('a, 'b) world -> entity -> ('a, 'b) world
val add_entities : ('a, 'b) world -> entity list -> ('a, 'b) world
val add_entity_id : ('a, 'b) world -> entity -> ('a, 'b) world * id
add_entity
but also return the id that was given to this entityval add_entities_id : ('a, 'b) world -> entity list -> ('a, 'b) world * id list
val add_entities_init : w:('a, 'b) world ->
n:int -> f:(int -> entity) -> ('a, 'b) world
val has_entity : ('a, 'b) world -> id -> bool
id
val replace_entity : ('a, 'b) world -> id -> entity -> ('a, 'b) world
val remove_entity : ('a, 'b) world -> entity -> ('a, 'b) world
val remove_entity_id : ('a, 'b) world -> id -> ('a, 'b) world
val get_entity : ('a, 'b) world -> id -> entity
val get_entity_opt : ('a, 'b) world -> id -> entity option
val get_entities : ('a, 'b) world -> id list -> entity list
val do_get_entities : ('a, 'b) world -> id list -> entity list
Not_found
if an id is not foundval get_entities_with_components : ('a, 'b) world -> Comp.component_type list -> entity list
typesystem_label =
Ent.system_label
val world_step : ('delta, unit) world ->
?labels:system_label list -> 'delta -> ('delta, unit) world
'delta
is the input parameter that is given to the systems
Only the systems with one of the given system_label
will be applied,
except if no labels
are given, then all systems are applied.
val world_step_fold : ('delta, 'fld) world ->
?labels:system_label list ->
'delta -> 'fld -> ('delta, 'fld) world * 'fld
world_step
but with an additional folded parameter,
see foldable_system
sval iter_entities : (entity -> unit) -> ('a, 'b) world -> unit
val fold_entities : (entity -> 'p -> 'p) -> ('a, 'b) world -> 'p -> 'p
val num_entities : ('a, 'b) world -> int
val num_entities_with_components : ('a, 'b) world -> Comp.component_type list -> int
typemapper =
Comp.component_type Ent.mapper
val make_mapper : Comp.component_type list -> mapper
system
may update or remove entities, or create new ones, each time
world_step
is called.type'a
update ='a Ent.update
type('a, 'b)
system =(Comp.component_type, Comp.component, 'a, 'b) Ent.system
val add_system : ('delta, 'a) world ->
mapper ->
?label:system_label ->
('delta, 'a) system -> ('delta, 'a) world
val add_systems : ('delta, 'a) world ->
(mapper * system_label option * ('delta, 'a) system) list ->
('delta, 'a) world
type('delta, 'fld)
foldable_system =(Comp.component_type, Comp.component, 'delta, 'fld) Ent.foldable_system
system
but a foldable_system
has an additional folded
parameter that can be given with world_step_fold
val add_foldable_system : ('delta, 'fld) world ->
mapper ->
?label:system_label ->
('delta, 'fld) foldable_system -> ('delta, 'fld) world
val add_foldable_systems : ('delta, 'fld) world ->
(mapper * system_label option * ('delta, 'fld) foldable_system)
list -> ('delta, 'fld) world