use std::fs::File;
use std::io;
use tcm::{
input::{
BugpointInput, Input, InputCommand, PlayerButton, RestartInput, RestartType, TpsInput,
VanillaInput,
},
meta::MetaV2,
replay::{Replay, ReplaySerializer},
};
fn main() -> io::Result<()> {
println!("TCM Input Types Example");
let meta = MetaV2::new(240.0, 0, Some(98765));
let inputs = vec![
InputCommand::new(
60,
Input::Vanilla(VanillaInput {
button: PlayerButton::Jump,
push: true,
player2: false,
}),
),
InputCommand::new(
65,
Input::Vanilla(VanillaInput {
button: PlayerButton::Jump,
push: false,
player2: false,
}),
),
InputCommand::new(250, Input::Bugpoint(BugpointInput)),
InputCommand::new(300, Input::Tps(TpsInput { tps: 120.0 })),
InputCommand::new(
450,
Input::Restart(RestartInput {
restart_type: RestartType::Restart,
new_seed: Some(54321),
}),
),
];
let replay = Replay::new(meta, inputs);
println!("Created replay with {} inputs", replay.inputs.len());
let temp_path = std::env::temp_dir().join("tcm_input_types_example.tcm");
let mut file = File::create(&temp_path)?;
replay.serialize(&mut file)?;
println!("Wrote to: {}", temp_path.display());
std::fs::remove_file(&temp_path)?;
Ok(())
}