Skip to content

Commit

Permalink
navigation debug draw
Browse files Browse the repository at this point in the history
  • Loading branch information
aratama committed Feb 1, 2025
1 parent 56c4486 commit 2e93fdd
Show file tree
Hide file tree
Showing 8 changed files with 734 additions and 168 deletions.
436 changes: 436 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ aseprite-loader = "0.3.3"
bevy_aseprite_ultra = "0.4.1"
bevy_asset_loader = "0.22.0"
bevy_common_assets = { version = "0.12.0", features = ["ron"] }
bevy_egui = "0.32.0"
bevy_embedded_assets = "0.12.0"
bevy_light_2d = "0.5.0"
bevy_pkv = "0.12.0"
Expand Down
2 changes: 1 addition & 1 deletion assets/registry.game.ron
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#![enable(implicit_some)]
GameRegistry(
debug_wands: [
["SummonEnemySlime"],
["QuickCast", "QuickCast", "TripleCast", "Slash", "Slash", "MagicBolt"],
["RockFall"],
["DualCast", "Levitation", "MagicBolt"],
["DualCast", "Dash", "Jump", "Lantern"]
],
Expand Down
7 changes: 4 additions & 3 deletions assets/registry.tile.ron
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,10 @@ TileRegistry(
(53, 24): "Bomb",
},
// itemsで指定する以外のエンティティの生成はspawnで指定します
// spawn: {
// (50, 52): Actor ("ExplosiveMashroom")
// },
spawn: {
// (55, 52): Actor("Slime"),
// (50, 52): Actor ("ExplosiveMashroom")
},
next: ["library"],
),

Expand Down
21 changes: 19 additions & 2 deletions src/actor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ use std::collections::HashSet;
use std::f32::consts::PI;
use uuid::Uuid;
use vleue_navigator::prelude::PrimitiveObstacle;
use vleue_navigator::Path;
use witch::WitchWandSprite;

/// アクターの種類を表します
Expand Down Expand Up @@ -273,6 +274,8 @@ pub struct Actor {
pub gravity: f32,
pub just_landed: bool,
pub v: f32,

pub navigation_path: Vec<Vec2>,
}

#[derive(Default, Component, Reflect)]
Expand Down Expand Up @@ -463,6 +466,7 @@ impl Default for Actor {
gravity: -0.2,
just_landed: false,
v: 0.0,
navigation_path: vec![],
}
}
}
Expand Down Expand Up @@ -1351,11 +1355,11 @@ pub fn spawn_actor(
match props.collider {
ActorCollider::Ball(radius) => (
Collider::ball(radius),
PrimitiveObstacle::Circle(Circle::new(radius)),
// PrimitiveObstacle::Circle(Circle::new(radius)),
),
ActorCollider::Cuboid(width, height) => (
Collider::cuboid(width, height),
PrimitiveObstacle::Rectangle(Rectangle::new(width * 2.0, height * 2.0)),
// PrimitiveObstacle::Rectangle(Rectangle::new(width * 2.0, height * 2.0)),
),
},
actor_group.to_groups(0.0, 0),
Expand All @@ -1366,6 +1370,19 @@ pub fn spawn_actor(
},
));

if actor_group == ActorGroup::Entity {
let scale = 1.0;
builder.insert(match props.collider {
ActorCollider::Ball(radius) => {
(PrimitiveObstacle::Circle(Circle::new(radius * scale)),)
}
ActorCollider::Cuboid(width, height) => (PrimitiveObstacle::Rectangle(Rectangle::new(
width * 2.0 * scale,
height * 2.0 * scale,
)),),
});
}

builder.with_children(|mut parent| {
// 影
if let Some(shadow) = &props.shadow {
Expand Down
5 changes: 4 additions & 1 deletion src/controller/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ use crate::se::SEEvent;
use crate::se::PICK_UP;
use crate::se::SEN;
use crate::se::SWITCH;
use crate::set::FixedUpdateGameActiveSet;
use crate::set::FixedUpdateInGameSet;
use crate::set::FixedUpdatePlayerActiveSet;
use crate::spell::Spell;
Expand Down Expand Up @@ -265,6 +266,8 @@ fn pick_gold(
if let Ok((mut actor, player_transform)) = player_query.get_single_mut() {
let mut got_gold = false;

// info!("player pos: {:?}", player_transform.translation.truncate());

for (gold_entity, mut gold, gold_transform) in gold_query.iter_mut() {
let diff =
player_transform.translation.truncate() - gold_transform.translation.truncate();
Expand Down Expand Up @@ -416,7 +419,7 @@ impl Plugin for PlayerPlugin {
move_player,
sync_wands,
)
.in_set(FixedUpdateInGameSet),
.in_set(FixedUpdateGameActiveSet),
);

app.add_systems(
Expand Down
2 changes: 2 additions & 0 deletions src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ use bevy::window::WindowMode;
use bevy_aseprite_ultra::AsepriteUltraPlugin;
use bevy_asset_loader::prelude::*;
use bevy_common_assets::ron::RonAssetPlugin;
use bevy_egui::EguiPlugin;
#[cfg(all(not(debug_assertions), not(target_arch = "wasm32")))]
use bevy_embedded_assets::EmbeddedAssetPlugin;
#[cfg(all(not(debug_assertions), not(target_arch = "wasm32")))]
Expand Down Expand Up @@ -198,6 +199,7 @@ pub fn run_game() {
.add_plugins(TextInputPlugin)
.add_plugins(VleueNavigatorPlugin)
.add_plugins(NavmeshUpdaterPlugin::<PrimitiveObstacle>::default())
.add_plugins(EguiPlugin)
//
// 以下はこのゲーム本体で定義されたプラグイン
//
Expand Down
Loading

0 comments on commit 2e93fdd

Please sign in to comment.