Skip to content

Commit

Permalink
register more types
Browse files Browse the repository at this point in the history
reflect component on more types
remove logging noise
fix missing change from last commit
  • Loading branch information
Hellzbellz123 committed Oct 23, 2024
1 parent 4b9d3ef commit 128981f
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 12 deletions.
13 changes: 13 additions & 0 deletions crates/aspenlib/src/debug/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,19 @@ pub mod debug_plugin {
Handle<LdtkProject>
]
);
// BigBrain unregistered types
register_types!(
app,
[
Actor,
big_brain::prelude::Action,
Scorer,
Score,
Choice,
Thinker,
HasThinker
]
);
// add inspector plugins
app.add_plugins((
StateInspectorPlugin::<AppState>::default()
Expand Down
1 change: 1 addition & 0 deletions crates/aspenlib/src/game/attributes_stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ pub struct CharacterStats {
//TODO: reuse "BuffQueue" of Buff for weapon upgrade system
/// stats for equipment or items
#[derive(Debug, Component, Reflect, Clone, Copy)]
#[reflect(Component)]
pub struct EquipmentStats {
/// amount of upgrades too this equipment
pub upgrade_amount: u32,
Expand Down
2 changes: 1 addition & 1 deletion crates/aspenlib/src/game/interface/playing_ui/gun_hud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ pub fn update_ui_ammo_counter(
};

if style.width != Val::Percent(percentage) {
info!("setting bar width too {}%", percentage);
// info!("setting bar width too {}%", percentage);
style.width = Val::Percent(percentage);
}
}
1 change: 1 addition & 0 deletions crates/aspenlib/src/game/items/weapons/components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ impl Default for WeaponDescriptor {

/// timers used for weapon attacks
#[derive(Debug, Clone, Default, Reflect, Component, serde::Deserialize, serde::Serialize)]
#[reflect(Component)]
pub struct WeaponTimers {
/// time between weapon attacks
pub attack: Timer,
Expand Down
6 changes: 3 additions & 3 deletions crates/aspenlib/src/game/items/weapons/forms/gun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn update_gun_timers(
firing_timers.refill.tick(time.delta());

if firing_timers.refill.finished() {
warn!("finished reloading");
// warn!("finished reloading");
firing_timers.refill.reset();
current_ammo.current = current_ammo.max;
}
Expand Down Expand Up @@ -105,10 +105,10 @@ pub fn receive_gun_shots(
actor: weapon,
});
}
warn!("reloading");
// warn!("reloading");
continue;
} else if timers.attack.finished() || current_ammo.current == cfg.max_ammo {
info!("bang!");
// info!("bang!");
anim_events.send(EventAnimationChange {
anim_handle: AnimHandle::from_index(GunAnimations::FIRE),
actor: weapon,
Expand Down
2 changes: 1 addition & 1 deletion crates/aspenlib/src/game/items/weapons/forms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ mod flail;
/// holds gun style weapon plugin
mod gun;

pub use gun::{format_gun_animations, GunShootEvent, GunWeaponsPlugin};
pub use gun::{format_gun_animations, GunShootEvent, GunWeaponsPlugin, create_bullet};
16 changes: 13 additions & 3 deletions crates/aspenlib/src/game/items/weapons/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::{
AppState,
},
loading::registry::RegistryIdentifier,
register_types,
};

/// combat related components
Expand All @@ -32,11 +33,20 @@ pub struct WeaponItemPlugin;

impl Plugin for WeaponItemPlugin {
fn build(&self, app: &mut App) {
register_types!(
app,
[
AttackDamage,
EquipmentStats,
WeaponCarrier,
CurrentAmmo,
WeaponTimers,
WeaponHolder,
WeaponDescriptor
]
);
app.add_plugins(forms::GunWeaponsPlugin);

app.register_type::<AttackDamage>()
.register_type::<EquipmentStats>();

app.add_event::<EventAttackWeapon>()
.add_systems(
PreUpdate,
Expand Down
6 changes: 4 additions & 2 deletions crates/aspenlib/src/game/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use bevy::prelude::*;

use crate::{
game::components::TimeToLive,
loading::{
game::components::{ActorColliderType, TimeToLive}, loading::{
custom_assets::actor_definitions::{CharacterDefinition, ItemDefinition},
registry::RegistryIdentifier,
},
utilities::{scale_to_fit, EntityCreator},
AppState,
register_types,
};

/// animation functionality
Expand Down Expand Up @@ -60,6 +60,8 @@ pub struct AspenHallsPlugin;

impl Plugin for AspenHallsPlugin {
fn build(&self, app: &mut App) {
register_types!(app, [ActorColliderType, EntityCreator]);

app
// actual game plugin
.add_plugins((
Expand Down
1 change: 0 additions & 1 deletion crates/aspenlib/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ pub fn start_app(cfg_file: ConfigFile) -> App {
(
utilities::set_window_icon
.run_if(resource_exists::<AspenInitHandles>.and_then(run_once())),
utilities::cursor_grab_system,
),
);

Expand Down
4 changes: 3 additions & 1 deletion crates/aspenlib/src/loading/splashscreen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use bevy::{
render::{camera::ScalingMode, primitives::Frustum},
};

use crate::{loading::assets::AspenInitHandles, utilities::despawn_with, AppState};
use crate::{loading::assets::AspenInitHandles, register_types, utilities::despawn_with, AppState};

/// Identifies the Main Camera
#[derive(Component, Reflect, Default)]
Expand Down Expand Up @@ -42,6 +42,8 @@ pub struct SplashPlugin;

impl Plugin for SplashPlugin {
fn build(&self, app: &mut App) {
register_types!(app, [MainCamera]);

app.add_systems(Startup, spawn_main_camera);
app.add_systems(OnEnter(AppState::Loading), splash_setup);
app.add_systems(
Expand Down

0 comments on commit 128981f

Please sign in to comment.