Skip to content

Commit

Permalink
rm room onready field in favor of room getter
Browse files Browse the repository at this point in the history
  • Loading branch information
Lamby777 committed Jun 16, 2024
1 parent 2d709c0 commit 810061d
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions pets-lib/src/world/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ fn cue_battle_intro_fx() {
pub struct World {
base: Base<Node2D>,

#[init(default = onready_node(&base, "YSort/Room"))]
room: OnReady<Gd<Node2D>>,

#[init(default = onready_node(&base, "ZoneAudio/Active"))]
active_audio: OnReady<Gd<AudioStreamPlayer>>,

Expand Down Expand Up @@ -96,11 +93,11 @@ impl World {
// ---------------------------------------- Room stuff

pub fn room() -> Gd<Node2D> {
World::singleton().bind().room.clone()
World::singleton().get_node_as("YSort/Room")
}

pub fn change_room(&mut self, new_room: Gd<Node2D>) {
let old_room = &mut self.room;
let mut old_room = Self::room();

for mut child in old_room.get_children().iter_shared() {
old_room.remove_child(child.clone());
Expand Down Expand Up @@ -243,7 +240,7 @@ impl World {

#[func]
fn reconnect_musiczones(&mut self) {
let room = self.room.clone();
let room = Self::room();
let mzones = subchildren_of_type::<MusicZone, _>(room);

for mut zone in mzones {
Expand All @@ -263,7 +260,7 @@ impl World {

#[func]
fn reconnect_waterzones(&mut self) {
let room = self.room.clone();
let room = Self::room();
let wzones = subchildren_of_type::<WaterZone, _>(room);

for mut zone in wzones {
Expand Down

0 comments on commit 810061d

Please sign in to comment.