2024-01-16 03:09:34 +00:00
|
|
|
pub enum Error{
|
2024-01-18 23:33:22 +00:00
|
|
|
InvalidSegment,
|
2024-01-16 03:09:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* block types
|
|
|
|
|
|
|
|
BLOCK_BOT_HEADER:
|
|
|
|
u128 map_resource_uuid //which map is this bot running
|
|
|
|
//don't include style info in bot header because it's in the simulation state
|
|
|
|
//blocks are laid out in chronological order, but indices may jump around.
|
|
|
|
u64 num_segments
|
|
|
|
for _ in 0..num_segments{
|
|
|
|
i64 time //simulation_state timestamp
|
|
|
|
u64 block_id
|
|
|
|
}
|
|
|
|
|
|
|
|
BLOCK_BOT_SEGMENT:
|
|
|
|
//format version indicates what version of these structures to use
|
|
|
|
SimulationState simulation_state //SimulationState is just under ClientState which includes Play/Pause events that the simulation doesn't know about.
|
|
|
|
//to read, greedily decode instructions until eof
|
|
|
|
loop{
|
|
|
|
//delta encode as much as possible (time,mousepos)
|
|
|
|
//strafe ticks are implied
|
|
|
|
//physics can be implied in an input-only bot file
|
|
|
|
TimedInstruction<SimulationInstruction> instruction
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2024-01-17 04:07:11 +00:00
|
|
|
//xdd
|
|
|
|
mod simulation{
|
|
|
|
pub struct State{}
|
|
|
|
pub struct Instruction{}
|
|
|
|
}
|
|
|
|
mod instruction{
|
|
|
|
pub struct TimedInstruction<Instruction>{instruction:Instruction}
|
|
|
|
}
|
|
|
|
mod timeline{
|
|
|
|
pub struct Timeline<Instruction>{timeline:Vec<super::instruction::TimedInstruction<Instruction>>}
|
|
|
|
}
|
|
|
|
|
|
|
|
//serious code
|
|
|
|
|
2024-01-18 23:33:22 +00:00
|
|
|
struct SegmentId(u64);
|
|
|
|
|
|
|
|
pub struct Segment{
|
|
|
|
state:simulation::State,
|
|
|
|
instructions:Vec<instruction::TimedInstruction<simulation::Instruction>>
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct StreamableBot{
|
|
|
|
file:crate::file::File,
|
|
|
|
timeline:timeline::Timeline<SegmentId>,
|
|
|
|
}
|
|
|
|
impl StreamableBot{
|
|
|
|
pub fn load_segment(&mut self,segment_id:u64)->Result<Segment,Error>{
|
|
|
|
//load region from disk
|
|
|
|
//parse the models and determine what resources need to be loaded
|
|
|
|
//load resources into self.resources
|
|
|
|
//return Region
|
|
|
|
Err(Error::InvalidSegment)
|
|
|
|
}
|
2024-01-16 03:09:34 +00:00
|
|
|
}
|