30 lines
881 B
Odin
30 lines
881 B
Odin
package ecs
|
|
|
|
import sa "../sokol/app"
|
|
|
|
InputSystem :: struct {
|
|
using base: SystemBase,
|
|
}
|
|
|
|
input_system_update :: proc(input_system: ^InputSystem, coordinator: ^Coordinator, event: ^sa.Event) {
|
|
for entity in input_system.entities {
|
|
input := coordinator_get_component(InputComponent, coordinator, entity)
|
|
|
|
#partial switch event.type {
|
|
case .MOUSE_MOVE:
|
|
input.mouse_movement += {event.mouse_dx, event.mouse_dy}
|
|
case .KEY_DOWN:
|
|
input.key_down[event.key_code] = true
|
|
case .KEY_UP:
|
|
input.key_down[event.key_code] = false
|
|
}
|
|
}
|
|
}
|
|
|
|
input_system_mouse_reset :: proc(input_system: ^InputSystem, coordinator: ^Coordinator) {
|
|
for entity in input_system.entities {
|
|
input := coordinator_get_component(InputComponent, coordinator, entity)
|
|
|
|
input.mouse_movement = { 0, 0 }
|
|
}
|
|
}
|