fix: get rid of the resource init warnings

This commit is contained in:
dusk 2024-12-06 22:14:38 +03:00
parent 729473dc75
commit c7879ddc05
Signed by: dusk
SSH Key Fingerprint: SHA256:Abmvag+juovVufZTxyWY8KcVgrznxvBjQpJesv071Aw
5 changed files with 17 additions and 9 deletions

View File

@ -10,7 +10,7 @@ pub struct Boid2D {
#[export] #[export]
/// The properties of this boid. /// The properties of this boid.
/// Note: this cannot be changed in runtime, aside from removing and readding the node. /// Note: this cannot be changed in runtime, aside from removing and readding the node.
properties: Gd<BoidProperties>, properties: Option<Gd<BoidProperties>>,
props: BoidProperties, props: BoidProperties,
vel: Vec2, vel: Vec2,
flock_id: Option<InstanceId>, flock_id: Option<InstanceId>,
@ -67,7 +67,9 @@ impl INode2D for Boid2D {
} }
fn ready(&mut self) { 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) { fn exit_tree(&mut self) {

View File

@ -10,7 +10,7 @@ pub struct Boid3D {
#[export] #[export]
/// The properties of this boid. /// The properties of this boid.
/// Note: this cannot be changed in runtime, aside from removing and readding the node. /// Note: this cannot be changed in runtime, aside from removing and readding the node.
properties: Gd<BoidProperties>, properties: Option<Gd<BoidProperties>>,
props: BoidProperties, props: BoidProperties,
vel: Vec3, vel: Vec3,
flock_id: Option<InstanceId>, flock_id: Option<InstanceId>,
@ -66,7 +66,9 @@ impl INode3D for Boid3D {
} }
fn ready(&mut self) { 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) { fn exit_tree(&mut self) {

View File

@ -1,7 +1,7 @@
use godot::prelude::*; use godot::prelude::*;
#[derive(Default, Clone, Debug, GodotClass)] #[derive(Default, Clone, Debug, GodotClass)]
#[class(tool, init, base=Resource)] #[class(init, base=Resource)]
/// Properties for a 2D/3D boid. /// Properties for a 2D/3D boid.
pub struct BoidProperties { pub struct BoidProperties {
#[export] #[export]

View File

@ -13,7 +13,7 @@ pub struct Flock2D {
#[export] #[export]
/// Properties of this flock. /// Properties of this flock.
/// Note: this cannot be changed in runtime, aside from removing and readding the node. /// Note: this cannot be changed in runtime, aside from removing and readding the node.
properties: Gd<FlockProperties>, properties: Option<Gd<FlockProperties>>,
props: FlockProperties, props: FlockProperties,
#[export] #[export]
/// A target node for the flock to follow. /// A target node for the flock to follow.
@ -46,7 +46,9 @@ impl INode2D for Flock2D {
} }
fn ready(&mut self) { 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) { fn exit_tree(&mut self) {

View File

@ -15,7 +15,7 @@ pub struct Flock3D {
#[export] #[export]
/// Properties of this flock. /// Properties of this flock.
/// Note: this cannot be changed in runtime, aside from removing and readding the node. /// Note: this cannot be changed in runtime, aside from removing and readding the node.
properties: Gd<FlockProperties>, properties: Option<Gd<FlockProperties>>,
props: FlockProperties, props: FlockProperties,
#[export] #[export]
/// A target node for the flock to follow. /// A target node for the flock to follow.
@ -48,7 +48,9 @@ impl INode3D for Flock3D {
} }
fn ready(&mut self) { 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) { fn exit_tree(&mut self) {