diff --git a/pets-lib/src/world/pchar_node.rs b/pets-lib/src/world/pchar_node.rs index e3ac614d..753b4a30 100644 --- a/pets-lib/src/world/pchar_node.rs +++ b/pets-lib/src/world/pchar_node.rs @@ -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) => {{ diff --git a/pets-lib/src/world/playercb.rs b/pets-lib/src/world/playercb.rs index e15d0a3a..b42b8f69 100644 --- a/pets-lib/src/world/playercb.rs +++ b/pets-lib/src/world/playercb.rs @@ -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; @@ -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) {