70 lines
3.1 KiB
Odin
70 lines
3.1 KiB
Odin
package ecs
|
|
|
|
Coordinator :: struct {
|
|
component_manager: ComponentManager,
|
|
entity_manager: EntityManager,
|
|
system_manager: SystemManager,
|
|
}
|
|
|
|
coordinator_init:: proc(coordinator: ^Coordinator) {
|
|
component_manager_init(&coordinator.component_manager)
|
|
entity_manager_init(&coordinator.entity_manager)
|
|
system_manager_init(&coordinator.system_manager)
|
|
}
|
|
|
|
coordinator_create_entity :: proc(coordinator: ^Coordinator) -> EntityID {
|
|
return entity_manager_create_entity(&coordinator.entity_manager)
|
|
}
|
|
|
|
coordinator_destroy_entity :: proc(coordinator: ^Coordinator, entity_id: EntityID) {
|
|
component_manager_destroy_entity(&coordinator.component_manager, entity_id)
|
|
entity_manager_destroy_entity(&coordinator.entity_manager, entity_id)
|
|
system_manager_destroy_entity(&coordinator.system_manager, entity_id)
|
|
}
|
|
|
|
coordinator_register_component :: proc(coordinator: ^Coordinator, $Component: typeid) {
|
|
component_manager_register_component(Component, &coordinator.component_manager)
|
|
}
|
|
|
|
coordinator_add_component :: proc(coordinator: ^Coordinator, component: $Component, entity_id: EntityID) {
|
|
component_manager_add_component(&coordinator.component_manager, component, entity_id)
|
|
|
|
signature := entity_manager_get_signature(&coordinator.entity_manager, entity_id)
|
|
signature_set(&signature, component_manager_get_component_id(&coordinator.component_manager, Component))
|
|
entity_manager_set_signature(&coordinator.entity_manager, entity_id, signature)
|
|
|
|
system_manager_change_entity_signature(&coordinator.system_manager, entity_id, signature)
|
|
}
|
|
|
|
coordinator_remove_component :: proc(coordinator: ^Coordinator, $Component: typeid, entity_id: EntityID) {
|
|
component_manager_remove_component(&coordinator.component_manager, Component, entity_id)
|
|
|
|
signature := entity_manager_get_signature(&coordinator.entity_manager, entity_id)
|
|
signature_unset(&signature, component_manager_get_component_id(&coordinator.component_manager, Component))
|
|
entity_manager_set_signature(&coordinator.entity_manager, entity_id, signature)
|
|
|
|
system_manager_change_entity_signature(&coordinator.system_manager, entity_id, signature)
|
|
}
|
|
|
|
coordinator_get_component :: proc(coordinator: ^Coordinator, $Component: typeid, entity_id: EntityID) -> ^Component {
|
|
return component_manager_get_component(&coordinator.component_manager, Component, entity_id)
|
|
}
|
|
|
|
coordinator_get_component_id :: proc(coordinator: ^Coordinator, $Component: typeid) -> ComponentID {
|
|
return component_manager_get_component_id(&coordinator.component_manager, Component)
|
|
}
|
|
|
|
coordinator_register_system :: proc(coordinator: ^Coordinator, $System: typeid) -> ^System {
|
|
return system_manager_register_system(&coordinator.system_manager, System)
|
|
}
|
|
|
|
coordinator_set_system_signature :: proc(coordinator: ^Coordinator, $System: typeid, signature: Signature) {
|
|
system_manager_set_signature(&coordinator.system_manager, System, signature)
|
|
}
|
|
|
|
coordinator_delete :: proc(coordinator: ^Coordinator) {
|
|
component_manager_delete(&coordinator.component_manager)
|
|
entity_manager_delete(&coordinator.entity_manager)
|
|
system_manager_delete(&coordinator.system_manager)
|
|
}
|
|
|