Last active
January 9, 2022 18:13
-
-
Save CryZe/3da66284049f4d74d9f848a637c3ada6 to your computer and use it in GitHub Desktop.
Slight abstraction layer for the new Auto Splitting runtime.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Eversleep { | |
time_info: Watcher<TimeInfo>, | |
} | |
impl<'a> AutoSplitter<'a> for Eversleep { | |
type Data = &'a Pair<TimeInfo>; | |
fn unhooked(&mut self) { | |
self.time_info.update(None); | |
} | |
fn update(&'a mut self, process: &Process) -> Option<Self::Data> { | |
let time_info = self.time_info.update( | |
process | |
.get_module("UnityPlayer.dll") | |
.and_then(|unity| { | |
process.read_pointer_path(unity, &[0x01A0E220, 0x128, 0x80, 0x150]) | |
}) | |
.ok(), | |
)?; | |
let mut level_timer = ArrayString::<32>::new(); | |
time_info.level_timer_digits.format_into(&mut level_timer); | |
asl::set_variable("Level Time", &level_timer); | |
asl::set_variable("Character", time_info.character()); | |
Some(time_info) | |
} | |
fn should_start(time_info: &Self::Data) -> bool { | |
time_info.check(|t| t.run_active != 0) | |
} | |
fn should_split(time_info: &Self::Data) -> bool { | |
time_info.check(|t| t.timer_paused != 0) | |
} | |
fn should_reset(time_info: &Self::Data) -> bool { | |
time_info.check(|t| t.run_active == 0) | |
} | |
fn game_time(time_info: &Self::Data) -> Option<Duration> { | |
Some(Duration::seconds_f32(time_info.run_timer)) | |
} | |
fn game_time_is_paused(_time_info: &Self::Data) -> bool { | |
true | |
} | |
} | |
static STATE: Spinlock<BasicAutoSplitter<Eversleep>> = const_spinlock(BasicAutoSplitter::new( | |
"Eversleep Lunistice Gaiden.exe", | |
Eversleep { | |
time_info: Watcher::new(), | |
}, | |
)); | |
#[no_mangle] | |
pub extern "C" fn update() { | |
STATE.lock().update(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment