fixed some annoying path edit tool bugs

This commit is contained in:
2025-06-23 16:33:34 +10:00
parent 6f4f465e37
commit c6763afd62
3 changed files with 23 additions and 19 deletions

View File

@ -32,13 +32,12 @@ func _ready() -> void:
func _process(delta: float) -> void:
if !enabled:
ray_collider = null
wall_preview.set_visible(false)
reset()
return
if interact_key_held:
if !interacted_once:
if valid_point and hero.currency >= Data.wall_cost and ray.is_colliding() and point.buildable:
if valid_point and hero.currency >= Data.wall_cost and ray_collider and point.buildable:
interact_held_time += delta
set_progress_percent(interact_held_time / interact_hold_time)
wall_preview.set_float(interact_held_time / interact_hold_time)
@ -46,13 +45,13 @@ func _process(delta: float) -> void:
set_progress_percent(0)
interacted_once = true
build_wall()
elif ray.is_colliding() and ray.get_collider() is TowerBase:
elif ray_collider is TowerBase:
interact_held_time += delta
set_progress_percent(interact_held_time / interact_hold_time)
if interact_held_time >= interact_hold_time:
set_progress_percent(0)
interacted_once = true
refund_wall(ray.get_collider())
refund_wall(ray_collider)
else:
interact_held_time = 0.0
interacted_once = false
@ -75,7 +74,16 @@ func _process(delta: float) -> void:
process_looking_at_tower()
elif Game.level:
process_looking_at_level()
else:
elif !interact_key_held:
reset()
if !valid_point:
wall_preview.set_visible(false)
if point:
wall_preview.global_position = point.global_position
wall_preview.global_rotation = Vector3.ZERO
func reset() -> void:
if is_instance_valid(ray_collider) and ray_collider is TowerBase and Game.level.walls.has(ray_collider.point):
Game.level.walls[ray_collider.point].set_float(1.0)
ray_collider = null
@ -83,8 +91,6 @@ func _process(delta: float) -> void:
wall_preview.set_visible(false)
clear_previous_point()
last_point = null
if !valid_point:
wall_preview.set_visible(false)
func process_looking_at_level() -> void:
@ -97,8 +103,6 @@ func process_looking_at_level() -> void:
clear_previous_point()
last_point = point
else:
wall_preview.global_position = point.global_position
wall_preview.global_rotation = Vector3.ZERO
if last_point != point:
clear_previous_point()
last_point = point

View File

@ -41,8 +41,8 @@ func enable_non_path_tower_frames() -> void:
func disable_path_tower_frames() -> void:
for node: FlowNode in tower_frames:
if !node.traversable and flow_field.traversable_after_blocking_point(node):
tower_frames[node].visible = true
if node.traversable and !flow_field.traversable_after_blocking_point(node):
tower_frames[node].visible = false
func set_wall(point: FlowNode, caller_id: int) -> void:

View File

@ -63,7 +63,7 @@ static func generate_wave(spawn_power: int, spawn_pool: Array[Enemy], spawners:
#a different enemy and try this process again
var enemy_id: int = spawn_pool.find(new_card.enemy)
enemy_id -= 1
if enemy_id <= 0:
if enemy_id < 0:
new_card.enemy = spawn_pool[spawn_pool.size() - 1]
else:
new_card.enemy = spawn_pool[enemy_id]