From ea2756201e8c8fec899f619a8c3b8e86708f33e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lex=20Rom=C3=A1n=20N=C3=BA=C3=B1ez?= Date: Tue, 13 Oct 2026 12:24:44 +0200 Subject: [PATCH] Rename semantics, fix save states and fix regrab count not being reset on respawn. --- src/debug_tools/save_state.rs | 5 ++++- src/fighter/state/ledge_wait.rs | 2 +- src/fighter/state/mod.rs | 5 +++++ src/game_settings.rs | 4 ++-- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/debug_tools/save_state.rs b/src/debug_tools/save_state.rs index 4845211..874f461 100644 --- a/src/debug_tools/save_state.rs +++ b/src/debug_tools/save_state.rs @@ -2,7 +2,7 @@ use bevy::prelude::*; use crate::{ camera::MatchCamera, fighter::{ - FighterECB, FighterFacingDirection, FighterHitboxes, FighterHitstop, FighterHitstopShake, FighterInvulnerabilityState, FighterPendingRespawn, FighterPreviousFacingDirection, FighterPreviousTranslation, FighterSurfaceState, FighterTranslation, FighterVelocity, animation::FighterAnimationFrame, attack::{ + FighterECB, FighterFacingDirection, FighterHitboxes, FighterHitstop, FighterHitstopShake, FighterInvulnerabilityState, FighterLedgeInformation, FighterPendingRespawn, FighterPreviousFacingDirection, FighterPreviousTranslation, FighterSurfaceState, FighterTranslation, FighterVelocity, animation::FighterAnimationFrame, attack::{ FighterDamage, FighterKnockbackVelocity, FighterPendingHitReaction, FighterPendingHits, FighterSolvedHurtboxes, FighterStaleMoveQueue, }, baked_animation::FighterBoneMatrices, state::FighterState, @@ -48,6 +48,7 @@ struct FighterCheckpoint { surface: FighterSurfaceState, pending_respawn: FighterPendingRespawn, invulnerability_state: FighterInvulnerabilityState, + ledge_information: FighterLedgeInformation, } pub(super) fn save_or_restore(world: &mut World) { @@ -151,6 +152,7 @@ pub(super) fn save_or_restore(world: &mut World) { entity.insert(saved.surface.clone()); entity.insert(saved.pending_respawn.clone()); entity.insert(saved.invulnerability_state.clone()); + entity.insert(saved.ledge_information.clone()); } world.insert_resource(checkpoint.pending_hits.clone()); world.insert_resource(checkpoint.stage_collision); @@ -188,6 +190,7 @@ fn capture_fighter(world: &World, entity: Entity) -> Option { surface: fighter.get::()?.clone(), pending_respawn: fighter.get::()?.clone(), invulnerability_state: fighter.get::()?.clone(), + ledge_information: fighter.get::()?.clone(), }) } diff --git a/src/fighter/state/ledge_wait.rs b/src/fighter/state/ledge_wait.rs index 109abfb..9fe5524 100644 --- a/src/fighter/state/ledge_wait.rs +++ b/src/fighter/state/ledge_wait.rs @@ -66,7 +66,7 @@ impl FighterStateImpl for LedgeWaitState { state_context.velocity.0 = FGVec2::ZERO; state_context.knockback_velocity.0 = FGVec2::ZERO; - if state_context.ledge_info.grab_count < state_context.game_settings.fighter_common.max_ledge_regrab_count { + if state_context.ledge_info.grab_count < state_context.game_settings.fighter_common.max_ledge_grab_count { *state_context.vulnerability = FighterInvulnerabilityState::Intangible { frames_remaining: Some( state_context diff --git a/src/fighter/state/mod.rs b/src/fighter/state/mod.rs index 7ebf716..c15532c 100644 --- a/src/fighter/state/mod.rs +++ b/src/fighter/state/mod.rs @@ -500,6 +500,7 @@ pub struct StatefulFighterQuery { pub player: &'static Player, pub pending_hit_reaction: &'static mut FighterPendingHitReaction, pub hitstop: &'static mut FighterHitstop, + pub ledge_info: &'static mut FighterLedgeInformation, pub hitstop_shake: &'static mut FighterHitstopShake, pub pending_respawn: &'static mut FighterPendingRespawn, pub damage: &'static mut FighterDamage, @@ -709,6 +710,7 @@ pub fn state_collision_interrupt_system( mut pending_respawn, player, mut damage, + mut ledge_info, .. } = fighter; @@ -757,6 +759,9 @@ pub fn state_collision_interrupt_system( // reset percentage *damage = FighterDamage::default(); + // reset ledge + + *ledge_info = FighterLedgeInformation::default(); transition_state( &mut state, diff --git a/src/game_settings.rs b/src/game_settings.rs index 956ed0c..bcf4169 100644 --- a/src/game_settings.rs +++ b/src/game_settings.rs @@ -55,8 +55,8 @@ pub struct FighterSettingsCommon { pub ledge_drop_regrab_lockout_duration_frames: u32, /// How many frames (+ the ledge animation duration) the fighter will be invulnerable after grabbing the ledge pub ledge_grab_invulnerability_duration: u32, - /// How many times the fighter can regrab the ledge and still get invulnerability - pub max_ledge_regrab_count: u32, + /// How many times the fighter can grab the ledge without landing and still get invulnerability + pub max_ledge_grab_count: u32, /// When hit while the receiver is in the air, use this angle pub sakurai_angle_aerial_angle: FGi32,