From c520bf1c2fff87597a2680a8cb93d5956d78be9a Mon Sep 17 00:00:00 2001 From: limuy Date: Sun, 30 Jun 2024 12:36:55 +0800 Subject: [PATCH] fix:make fight.tscn work --- gdrust/src/fight.rs | 8 ++++++-- gdrust/src/weapons/star_wrath.rs | 3 --- scripts/weapons/star_wrath.gd | 2 +- scripts/weapons/star_wrath_root.gd | 6 ++++++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/gdrust/src/fight.rs b/gdrust/src/fight.rs index 4e5ed8f..66f72c5 100644 --- a/gdrust/src/fight.rs +++ b/gdrust/src/fight.rs @@ -84,8 +84,12 @@ impl Fight { fn check_sword(&self) { for i in get_fight_list() { let obj = self.base().get_node_as::(*i); - assert!(obj.has_method(START.into()), "**{}**", *i); - assert!(obj.has_signal(ATTACK_FINISHED.into()), "**{}**", *i); + assert!(obj.has_method(START.into()), "**{}** misses start", *i); + assert!( + obj.has_signal(ATTACK_FINISHED.into()), + "**{}** misses attack finished", + *i + ); } } diff --git a/gdrust/src/weapons/star_wrath.rs b/gdrust/src/weapons/star_wrath.rs index 5074458..fccd572 100644 --- a/gdrust/src/weapons/star_wrath.rs +++ b/gdrust/src/weapons/star_wrath.rs @@ -94,9 +94,6 @@ impl StarWrath { anmi.play_ex().name("enter_scene".into()).done(); } - #[signal] - fn attack_finished() {} - #[func] fn fall_star(&mut self) { let bullet = self.get_bullet_scene(); diff --git a/scripts/weapons/star_wrath.gd b/scripts/weapons/star_wrath.gd index eca9e97..895a383 100644 --- a/scripts/weapons/star_wrath.gd +++ b/scripts/weapons/star_wrath.gd @@ -17,7 +17,7 @@ func _process(_delta: float) -> void: func next_operation(): if operation_idx >= operations.size(): - attack_finished.emit() + $"..".attack_finished.emit() return operations[operation_idx].call() operation_idx += 1 diff --git a/scripts/weapons/star_wrath_root.gd b/scripts/weapons/star_wrath_root.gd index b205749..b0dc366 100644 --- a/scripts/weapons/star_wrath_root.gd +++ b/scripts/weapons/star_wrath_root.gd @@ -1,5 +1,7 @@ extends Node +signal attack_finished + # Called when the node enters the scene tree for the first time. func _ready() -> void: @@ -9,6 +11,10 @@ func _ready() -> void: $StarWrath.hide() +func start(): + $StarWrath.start() + + # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(_delta: float) -> void: pass