diff --git a/rust/src/boid/boid_2d.rs b/rust/src/boid/boid_2d.rs index ad732d1..aedb366 100644 --- a/rust/src/boid/boid_2d.rs +++ b/rust/src/boid/boid_2d.rs @@ -10,7 +10,7 @@ pub struct Boid2D { #[export] /// The properties of this boid. /// Note: this cannot be changed in runtime, aside from removing and readding the node. - properties: Gd, + properties: Option>, props: BoidProperties, vel: Vec2, flock_id: Option, @@ -67,7 +67,9 @@ impl INode2D for Boid2D { } fn ready(&mut self) { - self.props = self.properties.bind().clone(); + if let Some(props) = self.properties.as_ref() { + self.props = props.bind().clone(); + } } fn exit_tree(&mut self) { diff --git a/rust/src/boid/boid_3d.rs b/rust/src/boid/boid_3d.rs index 6647d52..516ed67 100644 --- a/rust/src/boid/boid_3d.rs +++ b/rust/src/boid/boid_3d.rs @@ -10,7 +10,7 @@ pub struct Boid3D { #[export] /// The properties of this boid. /// Note: this cannot be changed in runtime, aside from removing and readding the node. - properties: Gd, + properties: Option>, props: BoidProperties, vel: Vec3, flock_id: Option, @@ -66,7 +66,9 @@ impl INode3D for Boid3D { } fn ready(&mut self) { - self.props = self.properties.bind().clone(); + if let Some(props) = self.properties.as_ref() { + self.props = props.bind().clone(); + } } fn exit_tree(&mut self) { diff --git a/rust/src/boid/boid_properties.rs b/rust/src/boid/boid_properties.rs index aebd960..2bec1f1 100644 --- a/rust/src/boid/boid_properties.rs +++ b/rust/src/boid/boid_properties.rs @@ -1,7 +1,7 @@ use godot::prelude::*; #[derive(Default, Clone, Debug, GodotClass)] -#[class(tool, init, base=Resource)] +#[class(init, base=Resource)] /// Properties for a 2D/3D boid. pub struct BoidProperties { #[export] diff --git a/rust/src/flock/flock_2d.rs b/rust/src/flock/flock_2d.rs index 27fdac3..3279862 100644 --- a/rust/src/flock/flock_2d.rs +++ b/rust/src/flock/flock_2d.rs @@ -13,7 +13,7 @@ pub struct Flock2D { #[export] /// Properties of this flock. /// Note: this cannot be changed in runtime, aside from removing and readding the node. - properties: Gd, + properties: Option>, props: FlockProperties, #[export] /// A target node for the flock to follow. @@ -46,7 +46,9 @@ impl INode2D for Flock2D { } fn ready(&mut self) { - self.props = self.properties.bind().clone(); + if let Some(props) = self.properties.as_ref() { + self.props = props.bind().clone(); + } } fn exit_tree(&mut self) { diff --git a/rust/src/flock/flock_3d.rs b/rust/src/flock/flock_3d.rs index a47e50d..bfed5cd 100644 --- a/rust/src/flock/flock_3d.rs +++ b/rust/src/flock/flock_3d.rs @@ -15,7 +15,7 @@ pub struct Flock3D { #[export] /// Properties of this flock. /// Note: this cannot be changed in runtime, aside from removing and readding the node. - properties: Gd, + properties: Option>, props: FlockProperties, #[export] /// A target node for the flock to follow. @@ -48,7 +48,9 @@ impl INode3D for Flock3D { } fn ready(&mut self) { - self.props = self.properties.bind().clone(); + if let Some(props) = self.properties.as_ref() { + self.props = props.bind().clone(); + } } fn exit_tree(&mut self) {