State :: struct { id: Mode; camera: Camera2D; } state_init :: (current_mode: Mode, st: ..State) { for st array_add(*states, it); current = state_find(current_mode); } state_switch :: (state_id: Mode) { idx := state_find(state_id); new_state := *states[idx]; old_state := *states[current]; old_state.camera = camera; camera = new_state.camera; current = idx; } #scope_file states: [..]State; current: int; state_find :: (id: Mode) -> idx: int { ok, idx := array_find(states, { id, {} }, find_by_id); assert(ok, "Should not happen @ state_find"); return idx; } find_by_id :: (a: State, b: State) -> bool { return a.id == b.id; }