diff --git a/capi/src/web_event_sink.rs b/capi/src/web_event_sink.rs index 94adf56d..84c39ed3 100644 --- a/capi/src/web_event_sink.rs +++ b/capi/src/web_event_sink.rs @@ -38,6 +38,7 @@ pub struct WebEventSink { resume_game_time: Option, set_custom_variable: Option, current_phase: Function, + current_split_index: Option, } #[wasm_bindgen] @@ -64,6 +65,7 @@ impl WebEventSink { resume_game_time: get_func(&obj, "resumeGameTime"), set_custom_variable: get_func(&obj, "setCustomVariable"), current_phase: get_func(&obj, "currentPhase").unwrap(), + current_split_index: get_func(&obj, "currentSplitIndex"), obj, } } @@ -216,4 +218,17 @@ impl TimerQuery for WebEventSink { _ => panic!("Unknown TimerPhase"), } } + fn current_split_index(&self) -> Option { + let i = self + .current_split_index + .as_ref()? + .call0(&self.obj) + .ok()? + .as_f64()?; + if i >= 0.0 { + Some(i as usize) + } else { + None + } + } }