Adding targeting cursor when placing drone

This commit is contained in:
Dan 2024-05-02 15:00:48 +01:00
parent b0583bd97f
commit 0f5640d789
4 changed files with 50 additions and 10 deletions

View file

@ -4,6 +4,7 @@ var spawning_drone : bool = false
var spawning_type : String = ""
@onready var drone_controls = %DroneControls
@onready var cursor = preload("res://resources/cursors/launch_drone.png")
func _ready() -> void:
Log.pr("Drone Manager Ready...")
@ -23,12 +24,14 @@ func spawn_drone(drone_type : String) -> void:
func place_drone(drone_type : String) -> void:
if !spawning_drone:
Input.set_custom_mouse_cursor(cursor, Input.CURSOR_ARROW, Vector2(32, 32))
drone_controls.disable_buttons()
Log.pr("Placing " + drone_type + "...")
spawning_drone = true
spawning_type = drone_type
func cancel_spawning() -> void:
Input.set_custom_mouse_cursor(null)
drone_controls.reset_button_focus()
drone_controls.enable_buttons()
spawning_drone = false

View file

@ -49,8 +49,7 @@ grow_horizontal = 2
grow_vertical = 2
metadata/_edit_use_anchors_ = true
[node name="DroneControls" type="HBoxContainer" parent="DroneManager/Control"]
unique_name_in_owner = true
[node name="MarginContainer" type="MarginContainer" parent="DroneManager/Control"]
layout_mode = 1
anchors_preset = 7
anchor_left = 0.5
@ -62,31 +61,35 @@ offset_top = -31.0
offset_right = 155.5
grow_horizontal = 2
grow_vertical = 0
[node name="DroneControls" type="HBoxContainer" parent="DroneManager/Control/MarginContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_vertical = 10
alignment = 1
script = ExtResource("3_rqkyv")
[node name="SpawnDirector" type="Button" parent="DroneManager/Control/DroneControls"]
[node name="SpawnDirector" type="Button" parent="DroneManager/Control/MarginContainer/DroneControls"]
layout_mode = 2
tooltip_text = "Place a director drone, these are the main drones that define the path bees should follow. The order bees should visit these drones can be defined by clicking on them."
text = "Director"
[node name="SpawnCollector" type="Button" parent="DroneManager/Control/DroneControls"]
[node name="SpawnCollector" type="Button" parent="DroneManager/Control/MarginContainer/DroneControls"]
layout_mode = 2
tooltip_text = "Place a drone that encourages bees to collect pollen near this area."
text = "Collector"
[node name="SpawnDistractor" type="Button" parent="DroneManager/Control/DroneControls"]
[node name="SpawnDistractor" type="Button" parent="DroneManager/Control/MarginContainer/DroneControls"]
layout_mode = 2
tooltip_text = "Place a distracting drone that will (hopefully) divert threats attention so they ignore the bees."
text = "Distractor"
[node name="SpawnDancer" type="Button" parent="DroneManager/Control/DroneControls"]
[node name="SpawnDancer" type="Button" parent="DroneManager/Control/MarginContainer/DroneControls"]
layout_mode = 2
tooltip_text = "Spawn a dancing drone that will encourage bees to leave the hive. Best to put this near to the hive. "
text = "Dancer"
[connection signal="pressed" from="DroneManager/Control/DroneControls/SpawnDirector" to="DroneManager" method="_on_spawn_director_pressed"]
[connection signal="pressed" from="DroneManager/Control/DroneControls/SpawnCollector" to="DroneManager" method="_on_spawn_collector_pressed"]
[connection signal="pressed" from="DroneManager/Control/DroneControls/SpawnDistractor" to="DroneManager" method="_on_spawn_distractor_pressed"]
[connection signal="pressed" from="DroneManager/Control/DroneControls/SpawnDancer" to="DroneManager" method="_on_spawn_dancer_pressed"]
[connection signal="pressed" from="DroneManager/Control/MarginContainer/DroneControls/SpawnDirector" to="DroneManager" method="_on_spawn_director_pressed"]
[connection signal="pressed" from="DroneManager/Control/MarginContainer/DroneControls/SpawnCollector" to="DroneManager" method="_on_spawn_collector_pressed"]
[connection signal="pressed" from="DroneManager/Control/MarginContainer/DroneControls/SpawnDistractor" to="DroneManager" method="_on_spawn_distractor_pressed"]
[connection signal="pressed" from="DroneManager/Control/MarginContainer/DroneControls/SpawnDancer" to="DroneManager" method="_on_spawn_dancer_pressed"]