Skip to content

Commit

Permalink
Fix round reset happening at the wrong time
Browse files Browse the repository at this point in the history
  • Loading branch information
haihala committed Dec 26, 2024
1 parent 8dfd3cb commit f3af208
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 14 deletions.
9 changes: 6 additions & 3 deletions client/characters/src/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub struct Gauges(pub Vec<(GaugeType, Gauge)>);

impl Gauges {
pub fn from_stats(stats: &Stats, additional_properties: Vec<(GaugeType, Gauge)>) -> Self {
Gauges(
let mut out = Gauges(
vec![
(
GaugeType::Health,
Expand All @@ -36,7 +36,6 @@ impl Gauges {
(
GaugeType::Meter,
Gauge {
// TODO: Add more stats attributes here and in reset
max: Some(100),
render_instructions: RenderInstructions::Bar(
ResourceBarVisual::default_meter(),
Expand All @@ -48,7 +47,11 @@ impl Gauges {
.into_iter()
.chain(additional_properties)
.collect(),
)
);

out.reset(stats);

out
}

pub fn reset(&mut self, stats: &Stats) {
Expand Down
2 changes: 0 additions & 2 deletions client/foundation/src/time/game_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,13 @@ impl ComputedStates for InMatch {
#[derive(Debug, Resource, Default, Clone)]
pub struct RoundLog {
log: Vec<RoundResult>,
pub reset_done: bool,
}
impl RoundLog {
pub fn clear(&mut self) {
*self = Self::default();
}
pub fn add(&mut self, result: RoundResult) {
self.log.push(result);
self.reset_done = false;
}
pub fn last(&self) -> Option<RoundResult> {
self.log.last().cloned()
Expand Down
2 changes: 1 addition & 1 deletion client/lib/src/player_state_management/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use foundation::{MatchState, RollbackSchedule, SystemStep};
use bevy::prelude::*;

pub use move_activation::MoveBuffer;
pub use player_setup::reset_combat;

pub struct PlayerStateManagementPlugin;

Expand All @@ -24,7 +25,6 @@ impl Plugin for PlayerStateManagementPlugin {
player_setup::setup_players
.run_if(in_state(MatchState::Loading))
.in_set(SystemStep::SpawnPlayers),
player_setup::reset_combat.in_set(SystemStep::RoundReset),
side_switcher::sideswitcher.in_set(SystemStep::SideSwitch),
(
condition_management::expire_conditions,
Expand Down
8 changes: 1 addition & 7 deletions client/lib/src/player_state_management/player_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use bevy_ggrs::AddRollbackCommandExtension;
use characters::{Character, Gauges, Hurtboxes, Inventory};
use foundation::{
AnimationType, CharacterClock, CharacterFacing, Characters, Clock, Combo, Facing, InMatch,
Player, Players, RoundLog, Stats, WagArgs,
Player, Players, Stats, WagArgs,
};
use input_parsing::{InputParser, PadBundle};
use player_state::PlayerState;
Expand Down Expand Up @@ -166,13 +166,7 @@ pub fn reset_combat(
&mut Combo,
)>,
mut clock: ResMut<Clock>,
mut round_result: ResMut<RoundLog>,
) {
if round_result.reset_done {
return;
}
round_result.reset_done = true;

info!("Round start reset");
clock.reset();

Expand Down
3 changes: 2 additions & 1 deletion client/lib/src/ui/shop/shop_rendering.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use foundation::{

use crate::{
assets::{Announcer, Music},
camera,
camera, player_state_management,
state_transitions::TransitionTimer,
};

Expand Down Expand Up @@ -244,6 +244,7 @@ fn end_shopping(
});

music.pop();
commands.run_system_cached(player_state_management::reset_combat);

for shop in [&mut shops.player_one, &mut shops.player_two] {
shop.closed = false;
Expand Down

0 comments on commit f3af208

Please sign in to comment.