Initial work on attack and hitbox interpolation
This commit is contained in:
@@ -13,5 +13,7 @@ pub enum MoveAngleKind {
|
||||
|
||||
#[derive(Asset, Reflect, Serialize, Deserialize)]
|
||||
pub struct FighterAttackScript {
|
||||
pub hitboxes: Vec<AttackHitbox>
|
||||
pub hitboxes: Vec<AttackHitbox>,
|
||||
pub iasa_frame: u32,
|
||||
pub wont_autocancel_window: (u32, u32),
|
||||
}
|
||||
@@ -10,6 +10,8 @@ use crate::{
|
||||
struct MoveCompiler {
|
||||
hitboxes: HashMap<u32, attack::AttackHitbox>,
|
||||
active_hitboxes: Vec<u32>,
|
||||
wont_autocancel_window: Option<(u32, u32)>,
|
||||
iasa_frame: Option<u32>,
|
||||
cursor: u32,
|
||||
}
|
||||
|
||||
@@ -59,11 +61,29 @@ impl MoveCompiler {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_wont_autocancel_window(&mut self, start: u32, end: u32) -> Result<(), Box<EvalAltResult>> {
|
||||
if end < start {
|
||||
return Err(format!("Couldn't set won't autocancel window, end frame {} is smaller than start frame {}", end, start).into());
|
||||
}
|
||||
|
||||
self.wont_autocancel_window = Some((start, end));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn set_iasa_frame(&mut self, iasa_frame: u32) {
|
||||
self.iasa_frame = Some(iasa_frame);
|
||||
}
|
||||
|
||||
fn into_attack_script(mut self) -> Result<FighterAttackScript, String> {
|
||||
self.remove_all_hitboxes().map_err(|err| err.to_string())?;
|
||||
let hitboxes = self.hitboxes.into_iter().map(|(_, hitbox)| hitbox).collect();
|
||||
let iasa_frame = self.iasa_frame.unwrap_or(100000);
|
||||
let wont_autocancel_window = self.wont_autocancel_window.unwrap_or((0, 100000));
|
||||
Ok(FighterAttackScript {
|
||||
hitboxes
|
||||
hitboxes,
|
||||
iasa_frame,
|
||||
wont_autocancel_window
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -133,6 +153,28 @@ pub fn compile_script(text: &str) -> Result<FighterAttackScript, String> {
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
let mc = mc.clone();
|
||||
engine.register_fn(
|
||||
"set_wont_autocancel_window",
|
||||
move |start: i64, end: i64| -> Result<(), Box<EvalAltResult>> {
|
||||
let mut b = mc.borrow_mut();
|
||||
b.set_wont_autocancel_window(start as u32, end as u32)
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
let mc = mc.clone();
|
||||
engine.register_fn(
|
||||
"set_iasa_frame",
|
||||
move |frame: i64| {
|
||||
let mut b = mc.borrow_mut();
|
||||
b.set_iasa_frame(frame as u32);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
let mc = mc.clone();
|
||||
engine.register_fn(
|
||||
|
||||
Reference in New Issue
Block a user