Moar fixes and optimizations
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use bevy::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashSet;
|
||||
|
||||
use crate::{fighter::attack::AttackHitbox, math::int::FGi32};
|
||||
|
||||
@@ -17,3 +18,19 @@ pub struct FighterAttackScript {
|
||||
pub iasa_frame: u32,
|
||||
pub wont_autocancel_window: (u32, u32),
|
||||
}
|
||||
|
||||
impl FighterAttackScript {
|
||||
pub fn validate(&self) -> Result<(), String> {
|
||||
let mut ids = HashSet::with_capacity(self.hitboxes.len());
|
||||
for hitbox in &self.hitboxes {
|
||||
hitbox.validate()?;
|
||||
if !ids.insert(hitbox.id) {
|
||||
return Err(format!("duplicate hitbox id {}", hitbox.id));
|
||||
}
|
||||
}
|
||||
if self.wont_autocancel_window.0 > self.wont_autocancel_window.1 {
|
||||
return Err("autocancel window end precedes its start".into());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user