Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game Over screen Bug fix #158 #168

Merged
merged 1 commit into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion engine/src/gent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub struct GentPhysicsBundle {
pub linear_velocity: LinearVelocity,
}

#[derive(Component)]
#[derive(Component, Debug)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this derive needed or was it just used to debug the issue?

pub struct Gent {
pub e_gfx: Entity,
pub e_effects_gfx: Entity,
Expand Down
19 changes: 11 additions & 8 deletions game/src/game/enemy.rs
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the pub(crate) changes necessary here?

Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,11 @@ use theseeker_engine::script::ScriptPlayer;

use super::physics::Knockback;
use super::player::{Player, PlayerConfig, StatusModifier, Stealthing};
use crate::game::attack::arc_attack::Projectile;
use crate::game::attack::particles::ArcParticleEffectHandle;
use crate::game::attack::*;
use crate::game::gentstate::*;
use crate::game::{attack::arc_attack::Projectile, player::EnemiesNearby};
use crate::game::player::EnemiesNearby;
use crate::graphics::particles_util::BuildParticles;
use crate::prelude::*;

Expand Down Expand Up @@ -69,7 +70,7 @@ pub enum EnemyStateSet {

#[derive(Bundle, LdtkEntity, Default)]
pub struct EnemyBlueprintBundle {
marker: EnemyBlueprint,
pub(crate) marker: EnemyBlueprint,
}

#[derive(Bundle, LdtkEntity, Default)]
Expand Down Expand Up @@ -104,7 +105,7 @@ impl EnemySpawner {
#[component(storage = "SparseSet")]
pub struct EnemyBlueprint {
/// Hp added from spawner due to number of enemies killed.
bonus_hp: u32,
pub(crate) bonus_hp: u32,
}

#[derive(Bundle)]
Expand Down Expand Up @@ -572,7 +573,7 @@ fn check_player_range(
if let Ok((player_e, player_trans, player_stealth, mut enemies_nearby)) =
player_query.get_single_mut()
{
//reset every tick
// reset every tick
**enemies_nearby = 0;

for (
Expand All @@ -586,7 +587,7 @@ fn check_player_range(
is_defending,
) in query.iter_mut()
{
//TODO: still update enemies nearby in stealth?
// TODO: still update enemies nearby in stealth?
if player_stealth.is_some() {
*range = Range::Deaggro;
target.0 = None;
Expand Down Expand Up @@ -799,9 +800,11 @@ fn aggro(
transitions.push(Aggroed::new_transition(Patrolling));
} else if matches!(range, Range::Melee) {
match role {
Role::Melee => transitions.push(Waiting::new_transition(
MeleeAttack::default(),
)),
Role::Melee => {
transitions.push(Waiting::new_transition(
MeleeAttack::default(),
))
},
Role::Ranged => {
velocity.x = 0.;
transitions.push(Waiting::new_transition(
Expand Down
22 changes: 13 additions & 9 deletions game/src/game/player/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ use theseeker_engine::physics::{
};

use super::physics::Knockback;
use crate::game::attack::*;
use crate::game::gentstate::*;
use crate::game::{attack::*, xp_orbs::XpOrbPickup};
use crate::game::xp_orbs::XpOrbPickup;
use crate::prelude::*;

pub struct PlayerPlugin;
Expand Down Expand Up @@ -50,7 +51,10 @@ impl Plugin for PlayerPlugin {
app.add_systems(Startup, load_dash_asset);
app.add_systems(
GameTickUpdate,
((setup_player, despawn_dead_player)
((
setup_player,
despawn_dead_player.after(super::game_over::on_game_over),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be cleaner to use a SystemSet for ordering this but not really necessary.

)
.run_if(in_state(GameState::Playing)))
.before(PlayerStateSet::Transition)
.run_if(in_state(AppState::InGame)),
Expand Down Expand Up @@ -180,7 +184,7 @@ impl Passives {
}
}

//they could also be components...limit only by the pickup/gain function instead of sized hashmap
// they could also be components...limit only by the pickup/gain function instead of sized hashmap
#[derive(Debug, Eq, PartialEq, Hash, EnumIter)]
pub enum Passive {
/// Heal when killing an enemy
Expand Down Expand Up @@ -423,7 +427,7 @@ fn setup_player(
),
(
PlayerStats::init_from_config(&config),
//maybe consolidate with PlayerStats
// maybe consolidate with PlayerStats
PlayerStatMod::new(),
EnemiesNearby(0),
),
Expand Down Expand Up @@ -533,7 +537,7 @@ pub struct Attacking {
impl Attacking {
pub const MAX: u32 = 4;
// pub const MAX: u32 = 4;
//minimum amount of frames that should be played from attack animation
// minimum amount of frames that should be played from attack animation
pub const MIN: u32 = 2;
}
impl GentState for Attacking {}
Expand Down Expand Up @@ -1147,7 +1151,7 @@ fn player_update_passive_buffs(
defense *= 0.5;
}
if passives.contains(&Passive::HeavyBoots) {
//if we are moving
// if we are moving
if vel.length() > 0.0001 {
attack *= 0.5;
defense *= 0.5;
Expand Down Expand Up @@ -1178,7 +1182,7 @@ fn player_update_stats_mod(
&mut PlayerStats,
)>,
mut gfx_query: Query<(&PlayerGfx, &mut Sprite)>,
//TODO: switch to ticks
// TODO: switch to ticks
time: Res<Time<Virtual>>,
mut commands: Commands,
) {
Expand All @@ -1195,7 +1199,7 @@ fn player_update_stats_mod(

sprite.color = modifier.effect_col;

//TODO: switch to ticks
// TODO: switch to ticks
modifier.time_remaining -= time.delta_seconds();

if modifier.time_remaining < 0. {
Expand Down Expand Up @@ -1442,7 +1446,7 @@ fn track_hits(
mut damage_events: EventReader<DamageInfo>,
) {
if let Ok((player_e, passives, mut buff)) = query.get_single_mut() {
//tick falloff
// tick falloff
buff.falloff = buff.falloff.saturating_sub(1);
if passives.contains(&Passive::FrenziedAttack) {
for damage_info in damage_events.read() {
Expand Down