use godot::prelude::*; use shared::collision::Circle; use godot::classes::{ Node2D, INode2D }; #[derive(GodotClass)] #[class(base=Node2D)] pub struct DanmakuCircle { pub circle_state: Circle, base: Base, } #[godot_api] impl INode2D for DanmakuCircle { fn init(base: Base) -> Self { Self { circle_state: Circle::new(0.0, 0.0, 0.0), base, } } } #[godot_api] impl DanmakuCircle { #[func] fn setup_circle(&mut self, x: f64, y: f64, radius: f64) { self.circle_state = Circle::new(x, y, radius); } #[func] fn get_position(&self) -> Vector2 { Vector2::new(self.circle_state.x as f32, self.circle_state.y as f32) } #[func] fn set_position(&mut self, new_x: f64, new_y: f64) { self.circle_state.x = new_x; self.circle_state.y = new_y; } #[func] fn get_radius(&self) -> f64 { self.circle_state.radius } #[func] fn set_radius(&mut self, new_radius: f64) { self.circle_state.radius = new_radius; } #[func] fn collides_with(&self, other: Gd) -> bool { self.circle_state.collides_with(&other.bind().circle_state) } }