Module Ent

module Ent: sig .. end
Entity/Component Oriented Game Framework


type ('component_type, 'component) entity 
('component_type, 'component) entity
val new_entity : unit -> ('a, 'b) entity
generic game element
val get_id : ('a, 'b) entity -> int
raises an exception if the entity has not been added to the world
val get_id_opt : ('a, 'b) entity -> int option
same than get_id but returns None instead of raising an exception


val add_component : ('component_type, 'component) entity ->
'component_type * 'component -> ('component_type, 'component) entity
add_component e (component_type, component_data)
val replace_component : ('component_type, 'component) entity ->
'component_type -> 'component -> ('component_type, 'component) entity
replace_component e component_type component_data
val has_component : ('component_type, 'component) entity -> 'component_type -> bool
val get_component : ('component_type, 'component) entity -> 'component_type -> 'component
raises Not_found if none found
val get_component_opt : ('component_type, 'component) entity ->
'component_type -> 'component option


type ('a, 'b) world 
type delta = float 
val new_world : unit -> ('a, 'b) world
val add_entity : ('a, 'b) world -> ('a, 'b) entity -> ('a, 'b) world
val add_entities : ('a, 'b) world -> ('a, 'b) entity list -> ('a, 'b) world
val add_entity_id : ('a, 'b) world -> ('a, 'b) entity -> ('a, 'b) world * int
same than add_entity but also return the id that was given to this entity
val world_step : ('a, 'b) world -> delta -> ('a, 'b) world
delta is the amount of time spent since last call to world_step
val iter_entities : (('a, 'b) entity -> unit) -> ('a, 'b) world -> unit
val fold_entities : (('a, 'b) entity -> 'c -> 'c) -> ('a, 'b) world -> 'c -> 'c
val num_entities : ('a, 'b) world -> int
val get_entity : ('a, 'b) world -> int -> ('a, 'b) entity
val get_entity_opt : ('a, 'b) world -> int -> ('a, 'b) entity option
get an entity by its id


a system may update or remove entities, or create new ones, each time world_step is called
type 'a update = 
| Updated of 'a
| Unchanged
| Removed
type ('a, 'b) system = ('a, 'b) entity ->
('a, 'b) world ->
delta -> ('a, 'b) entity update * ('a, 'b) entity list
the first returned value should be the input entity with eventual changes and the second returned value is eventual new entities that should be added to the world
val add_system : ('a, 'b) world -> ('a, 'b) system -> ('a, 'b) world