Skip to content

Commit

Permalink
more pointless bikeshed (load pchar scenes macro)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamby777 committed Dec 17, 2023
1 parent 0c470d3 commit cd625a9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
13 changes: 13 additions & 0 deletions pets-lib/src/world/pchar_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,19 @@ impl PCharNode {
}
}

#[macro_export]
macro_rules! load_pchar_scenes_under {
($parent:expr; $($name:expr),*) => {{
let mut res = vec![];

$({
res.push(crate::load_pchar_scene_under!($parent, $name));
})*

res
}};
}

#[macro_export]
macro_rules! load_pchar_scene_under {
($parent:expr, $name:expr) => {{
Expand Down
19 changes: 10 additions & 9 deletions pets-lib/src/world/playercb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use godot::engine::{CharacterBody2D, ICharacterBody2D};
use godot::prelude::*;

use crate::consts::playercb::*;
use crate::{load_pchar_scene_under, prelude::*};
use crate::{load_pchar_scenes_under, prelude::*};

use super::pchar_node::PCharNode;

Expand Down Expand Up @@ -55,14 +55,15 @@ impl ICharacterBody2D for PlayerCB {
}

fn ready(&mut self) {
self.party = vec![
load_pchar_scene_under!(self, "agent_e"),
load_pchar_scene_under!(self, "agent_s"),
load_pchar_scene_under!(self, "agent_t"),
load_pchar_scene_under!(self, "mira"),
load_pchar_scene_under!(self, "dubs"),
load_pchar_scene_under!(self, "yoyo"),
];
self.party = load_pchar_scenes_under!(
self;
"agent_e",
"agent_s",
"agent_t",
"mira",
"dubs",
"yoyo"
);
}

fn physics_process(&mut self, delta: f64) {
Expand Down

0 comments on commit cd625a9

Please sign in to comment.