add displaying gathering radius when showing unit info
This commit is contained in:
@@ -44,11 +44,18 @@ func _process(delta: float) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func open(who: Unit) -> void:
|
func open(who: Unit) -> void:
|
||||||
|
if unit != null:
|
||||||
|
close()
|
||||||
visible = true
|
visible = true
|
||||||
unit = who
|
unit = who
|
||||||
set_target(unit.ui_origin)
|
set_target(unit.ui_origin)
|
||||||
|
|
||||||
|
|
||||||
|
func close() -> void:
|
||||||
|
unit.toggle_info(false)
|
||||||
|
super.close()
|
||||||
|
|
||||||
|
|
||||||
func _set_image()->void:
|
func _set_image()->void:
|
||||||
for child:Control in get_children():
|
for child:Control in get_children():
|
||||||
child.visible = false
|
child.visible = false
|
||||||
@@ -104,4 +111,4 @@ func _get_state() -> void:
|
|||||||
Gathering.GatherState.DEPOSITING:
|
Gathering.GatherState.DEPOSITING:
|
||||||
state = InfoState.ANT_DEPOSITING
|
state = InfoState.ANT_DEPOSITING
|
||||||
Gathering.GatherState.STOP:
|
Gathering.GatherState.STOP:
|
||||||
state = InfoState.NONE
|
state = InfoState.NONE
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ func _handle_wandering(delta: float) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _handle_gathering() -> void:
|
func _handle_gathering() -> void:
|
||||||
gathering.handle_gathering(state != AntGathererState.GATHERING)
|
gathering.handle_gathering(state != AntGathererState.GATHERING, showing_info)
|
||||||
|
|
||||||
|
|
||||||
func _on_moving_ended() -> void:
|
func _on_moving_ended() -> void:
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ func _handle_wandering(delta: float) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _handle_gathering() -> void:
|
func _handle_gathering() -> void:
|
||||||
gathering.handle_gathering(state != AntNitwitState.GATHERING)
|
gathering.handle_gathering(state != AntNitwitState.GATHERING, showing_info)
|
||||||
|
|
||||||
|
|
||||||
func _on_moving_ended() -> void:
|
func _on_moving_ended() -> void:
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ var skeleton: Skeleton3D
|
|||||||
var drop_interval: float = DEFAULT_DROP_INTERVAL
|
var drop_interval: float = DEFAULT_DROP_INTERVAL
|
||||||
var pickup_interval: float = DEFAULT_PICKUP_INTERVAL
|
var pickup_interval: float = DEFAULT_PICKUP_INTERVAL
|
||||||
var item_bones: Array[int] = []
|
var item_bones: Array[int] = []
|
||||||
|
var showing_after_set: bool = false
|
||||||
|
|
||||||
@onready var gathering_center: Vector3 = global_position
|
@onready var gathering_center: Vector3 = global_position
|
||||||
@onready var collision_shape: CollisionShape3D = $NearbyItemsSearch
|
@onready var collision_shape: CollisionShape3D = $NearbyItemsSearch
|
||||||
@@ -53,6 +54,21 @@ func _process(_delta: float) -> void:
|
|||||||
DebugDraw.circle(target.global_position)
|
DebugDraw.circle(target.global_position)
|
||||||
|
|
||||||
|
|
||||||
|
func _input(event: InputEvent) -> void:
|
||||||
|
if not visible:
|
||||||
|
return
|
||||||
|
|
||||||
|
if event is InputEventMouseButton and showing_after_set:
|
||||||
|
var button_event := event as InputEventMouseButton
|
||||||
|
if not button_event.pressed:
|
||||||
|
return
|
||||||
|
if (
|
||||||
|
button_event.button_index == MOUSE_BUTTON_LEFT
|
||||||
|
or button_event.button_index == MOUSE_BUTTON_RIGHT
|
||||||
|
):
|
||||||
|
showing_after_set = false
|
||||||
|
|
||||||
|
|
||||||
func initialize(
|
func initialize(
|
||||||
from: Anthill,
|
from: Anthill,
|
||||||
skeleton_3d: Skeleton3D,
|
skeleton_3d: Skeleton3D,
|
||||||
@@ -69,8 +85,21 @@ func initialize(
|
|||||||
item_bones = bones
|
item_bones = bones
|
||||||
|
|
||||||
|
|
||||||
|
func handle_gathering(stop: bool, showing_info: bool) -> void:
|
||||||
|
collision_shape.global_position = gathering_center
|
||||||
|
collision_shape.global_rotation = Vector3.ZERO
|
||||||
|
if stop:
|
||||||
|
state = GatherState.STOP
|
||||||
|
|
||||||
|
radius_indicator.visible = (
|
||||||
|
(state != GatherState.STOP and showing_info)
|
||||||
|
or showing_after_set
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
func start_gathering(item: Honeydew) -> void:
|
func start_gathering(item: Honeydew) -> void:
|
||||||
gathering_center = item.global_position
|
gathering_center = item.global_position
|
||||||
|
showing_after_set = true
|
||||||
_go_gather(item)
|
_go_gather(item)
|
||||||
|
|
||||||
|
|
||||||
@@ -79,13 +108,6 @@ func stop_gathering() -> void:
|
|||||||
target = null
|
target = null
|
||||||
|
|
||||||
|
|
||||||
func handle_gathering(stop: bool) -> void:
|
|
||||||
collision_shape.global_position = gathering_center
|
|
||||||
collision_shape.global_rotation = Vector3.ZERO
|
|
||||||
if stop:
|
|
||||||
state = GatherState.STOP
|
|
||||||
|
|
||||||
|
|
||||||
func on_nav_agent_navigation_finished() -> void:
|
func on_nav_agent_navigation_finished() -> void:
|
||||||
if state == GatherState.PICKING_UP and target != null:
|
if state == GatherState.PICKING_UP and target != null:
|
||||||
_pick_up()
|
_pick_up()
|
||||||
@@ -205,7 +227,6 @@ func _erase_honeydew(item: Honeydew) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_body_entered(item: Node3D) -> void:
|
func _on_body_entered(item: Node3D) -> void:
|
||||||
print(item, ' entered')
|
|
||||||
if item is not Honeydew:
|
if item is not Honeydew:
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -217,7 +238,6 @@ func _on_body_entered(item: Node3D) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_body_exited(item: Node3D) -> void:
|
func _on_body_exited(item: Node3D) -> void:
|
||||||
print(item, ' exited')
|
|
||||||
if item is not Honeydew:
|
if item is not Honeydew:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ var wandering_center: Vector3 = Vector3.ZERO
|
|||||||
var spawn_pos: Vector3
|
var spawn_pos: Vector3
|
||||||
|
|
||||||
var locomotion_value: float = 0
|
var locomotion_value: float = 0
|
||||||
|
var showing_info: bool = false
|
||||||
|
|
||||||
@onready var nav_agent: NavigationAgent3D = $NavigationAgent3D
|
@onready var nav_agent: NavigationAgent3D = $NavigationAgent3D
|
||||||
@onready var ui_origin: Node3D = $UiOrigin
|
@onready var ui_origin: Node3D = $UiOrigin
|
||||||
@@ -54,7 +55,12 @@ func _physics_process(_delta: float) -> void:
|
|||||||
_navigate()
|
_navigate()
|
||||||
|
|
||||||
|
|
||||||
|
func toggle_info(on: bool) -> void:
|
||||||
|
showing_info = on
|
||||||
|
|
||||||
|
|
||||||
func _click() ->void:
|
func _click() ->void:
|
||||||
|
toggle_info(true)
|
||||||
UiManager.unit_info.open(self)
|
UiManager.unit_info.open(self)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user