Fixed a crash in the boss fight

This commit is contained in:
Melvin Weiß 2025-10-21 17:54:43 +02:00
parent 42ea2d3d75
commit 1ea01c30d6
7 changed files with 13 additions and 11 deletions

View file

@ -15,10 +15,10 @@ func _ready() -> void:
if blocks_area: if blocks_area:
Grid.buildings.append(self) Grid.buildings.append(self)
await get_tree().create_timer(0.2).timeout #await get_tree().create_timer(0.2).timeout
if get_node_or_null("ObjectList") != null: if get_node_or_null("ObjectList") != null:
var obj_list = $ObjectList var obj_list = $ObjectList
obj_list.reparent(get_tree().get_root().get_node("main"), false) obj_list.call_deferred("reparent", get_tree().get_root().get_node("main"), false)
await get_tree().create_timer(0.2).timeout await get_tree().create_timer(0.2).timeout
var objects_to_be_placed = obj_list.get_children() var objects_to_be_placed = obj_list.get_children()
for object in objects_to_be_placed: for object in objects_to_be_placed:

View file

@ -102,7 +102,7 @@ func destroy_below():
func wave(): func wave():
# Raise a wave from the water at the boundary of the screen and move it towards the center. # Raise a wave from the water at the boundary of the screen and move it towards the center.
var angle = player.position.angle var angle = player.position.angle()
var dir = randi_range(0, 1) * 2 - 1 var dir = randi_range(0, 1) * 2 - 1
var speed = 3000 / water.radius_base var speed = 3000 / water.radius_base
water.create_tsunami(angle - speed * dir * TAU/30, dir, speed) water.create_tsunami(angle - speed * dir * TAU/30, dir, speed)

View file

@ -1,18 +1,20 @@
class_name VineNode extends Node2D class_name GridNode extends Node2D
@export var vine : Vine @export var vine : Vine
@export var location : Vector2 : @export var location : Vector2 :
set(new_loc): set(new_loc):
location = Global.vec_mod(new_loc, Grid.num_collumns, true) location = Global.vec_mod(new_loc, Grid.num_collumns, true)
@export var offset : Vector2 update_position()
@export var offset : Vector2 :
set(new_offset):
offset = new_offset
update_position()
@export var depth : int @export var depth : int
func _get(property: StringName) -> Variant: func _get(property: StringName) -> Variant:
if property == "position": if property == "position":
update_position()
return position return position
if property == "global_position": if property == "global_position":
update_position()
return global_position return global_position
return null return null

View file

@ -1,4 +1,4 @@
class_name Bud extends VineNode class_name Bud extends GridNode
signal opened signal opened
var img_path var img_path

View file

@ -1,4 +1,4 @@
class_name Petal extends VineNode class_name Petal extends GridNode
@export var vine_resource : PackedScene @export var vine_resource : PackedScene
var activated = false var activated = false

View file

@ -59,7 +59,7 @@ func draw_vine(pos1 : Vector2, pos2 : Vector2, depth : int):
sprite.z_index = -1 sprite.z_index = -1
# Grows a sequence of vine segments from grid position 1 to grid position 2, starting at given depth. # Grows a sequence of vine segments from grid position 1 to grid position 2, starting at given depth.
func grow_vine_sequence(start : VineNode, target: VineNode, grow_bud = false, quick_spawn = false): func grow_vine_sequence(start : GridNode, target: GridNode, grow_bud = false, quick_spawn = false):
var depth = min(start.depth, max_depth) var depth = min(start.depth, max_depth)
# Calculate the number and length of segments from the distance of source and target # Calculate the number and length of segments from the distance of source and target
@ -152,7 +152,7 @@ func _enter_tree() -> void:
func random_vine_node_at(location): func random_vine_node_at(location):
var offset = random_offset() var offset = random_offset()
return VineNode.new(self, location, offset) return GridNode.new(self, location, offset)
func init_random(): func init_random():
Grid.add_vine_to(self, petal.location) Grid.add_vine_to(self, petal.location)