add gathering awaiting
This commit is contained in:
Binary file not shown.
@@ -30,3 +30,6 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.15587, 0)
|
|||||||
transform = Transform3D(1.62268, 0, 0, 0, 1.62268, 0, 0, 0, 1.62268, 0, 0, 0)
|
transform = Transform3D(1.62268, 0, 0, 0, 1.62268, 0, 0, 0, 1.62268, 0, 0, 0)
|
||||||
cast_shadow = 0
|
cast_shadow = 0
|
||||||
mesh = SubResource("QuadMesh_2gykr")
|
mesh = SubResource("QuadMesh_2gykr")
|
||||||
|
|
||||||
|
[node name="NavigationObstacle3D" type="NavigationObstacle3D" parent="."]
|
||||||
|
radius = 0.57
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=12 format=3 uid="uid://dhtofjn8dnuw3"]
|
[gd_scene load_steps=13 format=3 uid="uid://dhtofjn8dnuw3"]
|
||||||
|
|
||||||
[ext_resource type="Texture2D" uid="uid://cc40vkh4nc6pk" path="res://assets/textures/gui/think_bubble.png" id="1_hsifm"]
|
[ext_resource type="Texture2D" uid="uid://cc40vkh4nc6pk" path="res://assets/textures/gui/think_bubble.png" id="1_hsifm"]
|
||||||
[ext_resource type="Script" path="res://scripts/ui/unit_info.gd" id="2_b6c6l"]
|
[ext_resource type="Script" path="res://scripts/ui/unit_info.gd" id="2_b6c6l"]
|
||||||
@@ -20,9 +20,13 @@ region = Rect2(476.79, 88.6228, 77.4275, 53.8488)
|
|||||||
atlas = ExtResource("6_vrqjx")
|
atlas = ExtResource("6_vrqjx")
|
||||||
region = Rect2(572.197, 83.8424, 60.0876, 64.636)
|
region = Rect2(572.197, 83.8424, 60.0876, 64.636)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_o8jta"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_0t4ki"]
|
||||||
atlas = ExtResource("6_vrqjx")
|
atlas = ExtResource("6_vrqjx")
|
||||||
region = Rect2(654.844, 86.7453, 91.2445, 50.4017)
|
region = Rect2(656.569, 88.7656, 91.2443, 48.374)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_mcquw"]
|
||||||
|
atlas = ExtResource("6_vrqjx")
|
||||||
|
region = Rect2(758.514, 84.6555, 89.4846, 61.9183)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ndwb1"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_ndwb1"]
|
||||||
atlas = ExtResource("6_vrqjx")
|
atlas = ExtResource("6_vrqjx")
|
||||||
@@ -98,13 +102,28 @@ anchor_left = 0.5
|
|||||||
anchor_top = 0.5
|
anchor_top = 0.5
|
||||||
anchor_right = 0.5
|
anchor_right = 0.5
|
||||||
anchor_bottom = 0.5
|
anchor_bottom = 0.5
|
||||||
offset_left = -45.0
|
offset_left = -47.0
|
||||||
offset_top = -38.0
|
offset_top = -37.0
|
||||||
offset_right = 46.0
|
offset_right = 44.0
|
||||||
offset_bottom = 12.0
|
offset_bottom = 11.0
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
texture = SubResource("AtlasTexture_o8jta")
|
texture = SubResource("AtlasTexture_0t4ki")
|
||||||
|
|
||||||
|
[node name="AntAwaiting" type="TextureRect" parent="."]
|
||||||
|
layout_mode = 1
|
||||||
|
anchors_preset = 8
|
||||||
|
anchor_left = 0.5
|
||||||
|
anchor_top = 0.5
|
||||||
|
anchor_right = 0.5
|
||||||
|
anchor_bottom = 0.5
|
||||||
|
offset_left = -44.0
|
||||||
|
offset_top = -42.0
|
||||||
|
offset_right = 45.0
|
||||||
|
offset_bottom = 19.0
|
||||||
|
grow_horizontal = 2
|
||||||
|
grow_vertical = 2
|
||||||
|
texture = SubResource("AtlasTexture_mcquw")
|
||||||
|
|
||||||
[node name="AphidIdle" type="TextureRect" parent="."]
|
[node name="AphidIdle" type="TextureRect" parent="."]
|
||||||
layout_mode = 1
|
layout_mode = 1
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ enum InfoState {
|
|||||||
ANT_MOVING,
|
ANT_MOVING,
|
||||||
ANT_PICKING_UP,
|
ANT_PICKING_UP,
|
||||||
ANT_DEPOSITING,
|
ANT_DEPOSITING,
|
||||||
|
ANT_AWAITING,
|
||||||
APHID_IDLE,
|
APHID_IDLE,
|
||||||
APHID_PANIC,
|
APHID_PANIC,
|
||||||
APHID_EAT,
|
APHID_EAT,
|
||||||
@@ -19,6 +20,7 @@ var state: InfoState = InfoState.NONE
|
|||||||
@onready var ant_moving: Control = $AntMoving
|
@onready var ant_moving: Control = $AntMoving
|
||||||
@onready var ant_picking_up: Control = $AntPickingUp
|
@onready var ant_picking_up: Control = $AntPickingUp
|
||||||
@onready var ant_depositing: Control = $AntDepositing
|
@onready var ant_depositing: Control = $AntDepositing
|
||||||
|
@onready var ant_awaiting: Control = $AntAwaiting
|
||||||
@onready var aphid_idle: Control = $AphidIdle
|
@onready var aphid_idle: Control = $AphidIdle
|
||||||
@onready var aphid_panic: Control = $AphidPanic
|
@onready var aphid_panic: Control = $AphidPanic
|
||||||
@onready var aphid_eat: Control = $AphidEat
|
@onready var aphid_eat: Control = $AphidEat
|
||||||
@@ -29,6 +31,7 @@ func _ready() -> void:
|
|||||||
assert(ant_moving != null, "ant_moving missing!")
|
assert(ant_moving != null, "ant_moving missing!")
|
||||||
assert(ant_picking_up != null, "ant_picking_up missing!")
|
assert(ant_picking_up != null, "ant_picking_up missing!")
|
||||||
assert(ant_depositing != null, "ant_depositing missing!")
|
assert(ant_depositing != null, "ant_depositing missing!")
|
||||||
|
assert(ant_awaiting != null, "ant_awaiting missing!")
|
||||||
assert(aphid_idle != null, "aphid_idle missing!")
|
assert(aphid_idle != null, "aphid_idle missing!")
|
||||||
assert(aphid_panic != null, "aphid_panic missing!")
|
assert(aphid_panic != null, "aphid_panic missing!")
|
||||||
assert(aphid_eat != null, "aphid_eat missing!")
|
assert(aphid_eat != null, "aphid_eat missing!")
|
||||||
@@ -56,8 +59,8 @@ func close() -> void:
|
|||||||
super.close()
|
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
|
||||||
|
|
||||||
match state:
|
match state:
|
||||||
@@ -69,6 +72,8 @@ func _set_image()->void:
|
|||||||
ant_picking_up.visible = true
|
ant_picking_up.visible = true
|
||||||
InfoState.ANT_DEPOSITING:
|
InfoState.ANT_DEPOSITING:
|
||||||
ant_depositing.visible = true
|
ant_depositing.visible = true
|
||||||
|
InfoState.ANT_AWAITING:
|
||||||
|
ant_awaiting.visible = true
|
||||||
InfoState.APHID_IDLE:
|
InfoState.APHID_IDLE:
|
||||||
aphid_idle.visible = true
|
aphid_idle.visible = true
|
||||||
InfoState.APHID_PANIC:
|
InfoState.APHID_PANIC:
|
||||||
@@ -90,13 +95,7 @@ func _get_state() -> void:
|
|||||||
AntNitwit.AntNitwitState.MOVING:
|
AntNitwit.AntNitwitState.MOVING:
|
||||||
state = InfoState.ANT_MOVING
|
state = InfoState.ANT_MOVING
|
||||||
AntNitwit.AntNitwitState.GATHERING:
|
AntNitwit.AntNitwitState.GATHERING:
|
||||||
match (unit as AntNitwit).gathering.state:
|
_get_gathering_state((unit as AntNitwit).gathering.state)
|
||||||
Gathering.GatherState.PICKING_UP:
|
|
||||||
state = InfoState.ANT_PICKING_UP
|
|
||||||
Gathering.GatherState.DEPOSITING:
|
|
||||||
state = InfoState.ANT_DEPOSITING
|
|
||||||
Gathering.GatherState.STOP:
|
|
||||||
state = InfoState.NONE
|
|
||||||
|
|
||||||
if unit is AntGatherer:
|
if unit is AntGatherer:
|
||||||
match (unit as AntGatherer).state:
|
match (unit as AntGatherer).state:
|
||||||
@@ -105,10 +104,16 @@ func _get_state() -> void:
|
|||||||
AntGatherer.AntGathererState.MOVING:
|
AntGatherer.AntGathererState.MOVING:
|
||||||
state = InfoState.ANT_MOVING
|
state = InfoState.ANT_MOVING
|
||||||
AntGatherer.AntGathererState.GATHERING:
|
AntGatherer.AntGathererState.GATHERING:
|
||||||
match (unit as AntGatherer).gathering.state:
|
_get_gathering_state((unit as AntGatherer).gathering.state)
|
||||||
Gathering.GatherState.PICKING_UP:
|
|
||||||
state = InfoState.ANT_PICKING_UP
|
|
||||||
Gathering.GatherState.DEPOSITING:
|
func _get_gathering_state(gather_state: Gathering.GatherState) -> void:
|
||||||
state = InfoState.ANT_DEPOSITING
|
match gather_state:
|
||||||
Gathering.GatherState.STOP:
|
Gathering.GatherState.PICKING_UP:
|
||||||
state = InfoState.NONE
|
state = InfoState.ANT_PICKING_UP
|
||||||
|
Gathering.GatherState.DEPOSITING:
|
||||||
|
state = InfoState.ANT_DEPOSITING
|
||||||
|
Gathering.GatherState.AWAITING:
|
||||||
|
state = InfoState.ANT_AWAITING
|
||||||
|
Gathering.GatherState.STOP:
|
||||||
|
state = InfoState.NONE
|
||||||
|
|||||||
@@ -31,13 +31,12 @@ func _ready() -> void:
|
|||||||
for i in MAX_CARRY:
|
for i in MAX_CARRY:
|
||||||
item_bones.append(skeleton.find_bone(ITEM_BONE_NAME + str(i)))
|
item_bones.append(skeleton.find_bone(ITEM_BONE_NAME + str(i)))
|
||||||
gathering.initialize(anthill, skeleton, item_bones, MAX_CARRY, 0.4, 1)
|
gathering.initialize(anthill, skeleton, item_bones, MAX_CARRY, 0.4, 1)
|
||||||
gathering.target_set.connect(_on_gathering_target_set)
|
gathering.navigate_to.connect(_on_gathering_navigate_to)
|
||||||
gathering.stopped_gathering.connect(_on_stopped_gathering)
|
|
||||||
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
super._process(delta)
|
super._process(delta)
|
||||||
if moving_to_target:
|
if is_relocating:
|
||||||
state = AntGathererState.MOVING
|
state = AntGathererState.MOVING
|
||||||
|
|
||||||
_handle_wandering(delta)
|
_handle_wandering(delta)
|
||||||
@@ -58,7 +57,7 @@ func _handle_wandering(delta: float) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _handle_gathering() -> void:
|
func _handle_gathering() -> void:
|
||||||
gathering.handle_gathering(state != AntGathererState.GATHERING, showing_info)
|
gathering.handle_gathering(showing_info)
|
||||||
|
|
||||||
|
|
||||||
func _on_moving_ended() -> void:
|
func _on_moving_ended() -> void:
|
||||||
@@ -71,12 +70,8 @@ func _on_moving_started() -> void:
|
|||||||
state = AntGathererState.MOVING
|
state = AntGathererState.MOVING
|
||||||
|
|
||||||
|
|
||||||
func _on_gathering_target_set(pos: Vector3) -> void:
|
func _on_gathering_navigate_to(pos: Vector3) -> void:
|
||||||
if state != AntGathererState.GATHERING:
|
if state != AntGathererState.GATHERING:
|
||||||
return
|
return
|
||||||
|
|
||||||
nav_agent.set_target_position(pos)
|
navigate(pos)
|
||||||
|
|
||||||
|
|
||||||
func _on_stopped_gathering() -> void:
|
|
||||||
state = AntGathererState.WANDERING
|
|
||||||
|
|||||||
@@ -30,13 +30,12 @@ func _ready() -> void:
|
|||||||
for i in gathering.DEFAULT_MAX_CARRYING:
|
for i in gathering.DEFAULT_MAX_CARRYING:
|
||||||
item_bones.append(skeleton.find_bone(ITEM_BONE_NAME + str(i)))
|
item_bones.append(skeleton.find_bone(ITEM_BONE_NAME + str(i)))
|
||||||
gathering.initialize(anthill, skeleton, item_bones)
|
gathering.initialize(anthill, skeleton, item_bones)
|
||||||
gathering.target_set.connect(_on_gathering_target_set)
|
gathering.navigate_to.connect(_on_gathering_navigate_to)
|
||||||
gathering.stopped_gathering.connect(_on_stopped_gathering)
|
|
||||||
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
super._process(delta)
|
super._process(delta)
|
||||||
if moving_to_target:
|
if is_relocating:
|
||||||
state = AntNitwitState.MOVING
|
state = AntNitwitState.MOVING
|
||||||
|
|
||||||
_handle_wandering(delta)
|
_handle_wandering(delta)
|
||||||
@@ -57,7 +56,7 @@ func _handle_wandering(delta: float) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _handle_gathering() -> void:
|
func _handle_gathering() -> void:
|
||||||
gathering.handle_gathering(state != AntNitwitState.GATHERING, showing_info)
|
gathering.handle_gathering(showing_info)
|
||||||
|
|
||||||
|
|
||||||
func _on_moving_ended() -> void:
|
func _on_moving_ended() -> void:
|
||||||
@@ -70,12 +69,10 @@ func _on_moving_started() -> void:
|
|||||||
state = AntNitwitState.MOVING
|
state = AntNitwitState.MOVING
|
||||||
|
|
||||||
|
|
||||||
func _on_gathering_target_set(pos: Vector3) -> void:
|
func _on_gathering_navigate_to(pos: Vector3) -> void:
|
||||||
|
print('_on_gathering_navigate_to')
|
||||||
if state != AntNitwitState.GATHERING:
|
if state != AntNitwitState.GATHERING:
|
||||||
return
|
return
|
||||||
|
print('_on_gathering_navigate_to 2')
|
||||||
|
|
||||||
nav_agent.set_target_position(pos)
|
navigate(pos)
|
||||||
|
|
||||||
|
|
||||||
func _on_stopped_gathering() -> void:
|
|
||||||
state = AntNitwitState.WANDERING
|
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ func _handle_honeydew_spawn(delta: float) -> void:
|
|||||||
holder.add_child(new_honeydew)
|
holder.add_child(new_honeydew)
|
||||||
new_honeydew.global_position = global_position + new_pos
|
new_honeydew.global_position = global_position + new_pos
|
||||||
_put_honeydew(new_honeydew)
|
_put_honeydew(new_honeydew)
|
||||||
audio_player.play_polyphonic(SoundManager.pop())
|
|
||||||
|
|
||||||
_set_spawn_timer()
|
_set_spawn_timer()
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
extends Area3D
|
extends Area3D
|
||||||
class_name Gathering
|
class_name Gathering
|
||||||
|
|
||||||
signal target_set(pos: Vector3)
|
signal navigate_to(pos: Vector3)
|
||||||
signal stopped_gathering
|
|
||||||
|
|
||||||
const DEFAULT_MAX_CARRYING = 3
|
const DEFAULT_MAX_CARRYING = 3
|
||||||
const DEFAULT_DROP_INTERVAL = 0.25
|
const DEFAULT_DROP_INTERVAL = 0.25
|
||||||
@@ -11,6 +10,7 @@ const DROP_SPREAD: float = 0.1
|
|||||||
const ANTHILL_DEPOSIT_RADIUS: float = 0.5
|
const ANTHILL_DEPOSIT_RADIUS: float = 0.5
|
||||||
|
|
||||||
enum GatherState {
|
enum GatherState {
|
||||||
|
AWAITING,
|
||||||
PICKING_UP,
|
PICKING_UP,
|
||||||
DEPOSITING,
|
DEPOSITING,
|
||||||
STOP,
|
STOP,
|
||||||
@@ -89,11 +89,9 @@ func initialize(
|
|||||||
item_bones = bones
|
item_bones = bones
|
||||||
|
|
||||||
|
|
||||||
func handle_gathering(stop: bool, showing_info: bool) -> void:
|
func handle_gathering(showing_info: bool) -> void:
|
||||||
collision_shape.global_position = gathering_center
|
collision_shape.global_position = gathering_center
|
||||||
collision_shape.global_rotation = Vector3.ZERO
|
collision_shape.global_rotation = Vector3.ZERO
|
||||||
if stop:
|
|
||||||
state = GatherState.STOP
|
|
||||||
|
|
||||||
radius_indicator.visible = (
|
radius_indicator.visible = (
|
||||||
(state != GatherState.STOP and showing_info)
|
(state != GatherState.STOP and showing_info)
|
||||||
@@ -104,7 +102,8 @@ func handle_gathering(stop: bool, showing_info: bool) -> void:
|
|||||||
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
|
showing_after_set = true
|
||||||
_go_gather(item)
|
state = GatherState.AWAITING
|
||||||
|
_go_pick_up(item)
|
||||||
|
|
||||||
|
|
||||||
func stop_gathering() -> void:
|
func stop_gathering() -> void:
|
||||||
@@ -123,7 +122,7 @@ func on_nav_agent_navigation_finished() -> void:
|
|||||||
_deposit()
|
_deposit()
|
||||||
|
|
||||||
|
|
||||||
func _go_gather(item: Honeydew) -> void:
|
func _go_pick_up(item: Honeydew) -> void:
|
||||||
if anthill.space_left() <= 0:
|
if anthill.space_left() <= 0:
|
||||||
return
|
return
|
||||||
if carrying_items.size() >= max_carrying:
|
if carrying_items.size() >= max_carrying:
|
||||||
@@ -131,13 +130,13 @@ func _go_gather(item: Honeydew) -> void:
|
|||||||
return
|
return
|
||||||
target = item
|
target = item
|
||||||
state = GatherState.PICKING_UP
|
state = GatherState.PICKING_UP
|
||||||
target_set.emit(item.global_position)
|
navigate_to.emit(item.global_position)
|
||||||
|
|
||||||
|
|
||||||
func _go_deposit() -> void:
|
func _go_deposit() -> void:
|
||||||
state = GatherState.DEPOSITING
|
state = GatherState.DEPOSITING
|
||||||
var dir := anthill.global_position.direction_to(global_position)
|
var dir := anthill.global_position.direction_to(global_position)
|
||||||
target_set.emit(
|
navigate_to.emit(
|
||||||
anthill.global_position
|
anthill.global_position
|
||||||
+ dir
|
+ dir
|
||||||
* ANTHILL_DEPOSIT_RADIUS
|
* ANTHILL_DEPOSIT_RADIUS
|
||||||
@@ -152,7 +151,7 @@ func _pick_up() -> void:
|
|||||||
var nearest := _find_nearest(nearby_items.values())
|
var nearest := _find_nearest(nearby_items.values())
|
||||||
if target == null or target.carried:
|
if target == null or target.carried:
|
||||||
if nearest != null:
|
if nearest != null:
|
||||||
_go_gather(nearest)
|
_go_pick_up(nearest)
|
||||||
elif carrying_items.size() > 0:
|
elif carrying_items.size() > 0:
|
||||||
_go_deposit()
|
_go_deposit()
|
||||||
return
|
return
|
||||||
@@ -170,7 +169,7 @@ func _pick_up() -> void:
|
|||||||
_go_deposit()
|
_go_deposit()
|
||||||
return
|
return
|
||||||
|
|
||||||
_go_gather(nearest)
|
_go_pick_up(nearest)
|
||||||
|
|
||||||
|
|
||||||
func _deposit() -> void:
|
func _deposit() -> void:
|
||||||
@@ -180,10 +179,8 @@ func _deposit() -> void:
|
|||||||
return
|
return
|
||||||
|
|
||||||
if anthill.space_left() <= 0:
|
if anthill.space_left() <= 0:
|
||||||
print('DROP!')
|
state = GatherState.AWAITING
|
||||||
_drop_everything()
|
await _drop_everything()
|
||||||
stop_gathering()
|
|
||||||
stopped_gathering.emit()
|
|
||||||
return
|
return
|
||||||
|
|
||||||
var item := carrying_items.pop_back() as Honeydew
|
var item := carrying_items.pop_back() as Honeydew
|
||||||
@@ -198,11 +195,11 @@ func _deposit() -> void:
|
|||||||
|
|
||||||
var nearest := _find_nearest(nearby_items.values())
|
var nearest := _find_nearest(nearby_items.values())
|
||||||
if nearest != null:
|
if nearest != null:
|
||||||
_go_gather(nearest)
|
_go_pick_up(nearest)
|
||||||
return
|
return
|
||||||
|
|
||||||
stop_gathering()
|
state = GatherState.AWAITING
|
||||||
stopped_gathering.emit()
|
navigate_to.emit(gathering_center)
|
||||||
|
|
||||||
|
|
||||||
func _drop_everything() -> void:
|
func _drop_everything() -> void:
|
||||||
@@ -248,6 +245,8 @@ func _on_body_entered(item: Node3D) -> void:
|
|||||||
return
|
return
|
||||||
|
|
||||||
nearby_items[item_id] = item as Honeydew
|
nearby_items[item_id] = item as Honeydew
|
||||||
|
if state == GatherState.AWAITING and anthill.space_left() > 0:
|
||||||
|
_go_pick_up(item as Honeydew)
|
||||||
|
|
||||||
|
|
||||||
func _on_body_exited(item: Node3D) -> void:
|
func _on_body_exited(item: Node3D) -> void:
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ var anthill: Anthill
|
|||||||
|
|
||||||
var hovered_rect: bool = false
|
var hovered_rect: bool = false
|
||||||
var selected: bool = false
|
var selected: bool = false
|
||||||
var moving_to_target: bool = false
|
var is_relocating: bool = false
|
||||||
var ground_plane: Plane = Plane(Vector3.UP, 0)
|
var ground_plane: Plane = Plane(Vector3.UP, 0)
|
||||||
|
|
||||||
@onready var camera: Camera3D = get_viewport().get_camera_3d()
|
@onready var camera: Camera3D = get_viewport().get_camera_3d()
|
||||||
@@ -40,8 +40,8 @@ func _process(delta: float) -> void:
|
|||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
super._physics_process(delta)
|
super._physics_process(delta)
|
||||||
if moving_to_target and nav_agent.is_navigation_finished():
|
if is_relocating and nav_agent.is_navigation_finished():
|
||||||
moving_to_target = false
|
is_relocating = false
|
||||||
moving_ended.emit()
|
moving_ended.emit()
|
||||||
|
|
||||||
|
|
||||||
@@ -59,7 +59,6 @@ func _input(event: InputEvent) -> void:
|
|||||||
if HoveringManager.hovered_node is Interactable:
|
if HoveringManager.hovered_node is Interactable:
|
||||||
_interact(HoveringManager.hovered_node as Interactable)
|
_interact(HoveringManager.hovered_node as Interactable)
|
||||||
else:
|
else:
|
||||||
moving_to_target = true
|
|
||||||
moving_started.emit()
|
moving_started.emit()
|
||||||
_set_target_click(button_event.position)
|
_set_target_click(button_event.position)
|
||||||
|
|
||||||
@@ -78,6 +77,11 @@ func set_selected(on: bool) -> void:
|
|||||||
selected = on
|
selected = on
|
||||||
|
|
||||||
|
|
||||||
|
func navigate(to: Vector3, relocating: bool = false) -> void:
|
||||||
|
is_relocating = relocating
|
||||||
|
nav_agent.set_target_position(to)
|
||||||
|
|
||||||
|
|
||||||
func _interact(with: Interactable) -> void:
|
func _interact(with: Interactable) -> void:
|
||||||
print(self, ' interacting with ', with)
|
print(self, ' interacting with ', with)
|
||||||
|
|
||||||
@@ -87,7 +91,7 @@ func _set_target_click(mouse_pos: Vector2) -> void:
|
|||||||
if click_pos == null:
|
if click_pos == null:
|
||||||
return
|
return
|
||||||
|
|
||||||
nav_agent.set_target_position(click_pos)
|
navigate(click_pos, true)
|
||||||
|
|
||||||
|
|
||||||
func _click_raycast(mouse_pos: Vector2) -> Vector3:
|
func _click_raycast(mouse_pos: Vector2) -> Vector3:
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ func toggle_info(on: bool) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _click() -> void:
|
func _click() -> void:
|
||||||
toggle_info(true)
|
|
||||||
UiManager.unit_info.open(self)
|
UiManager.unit_info.open(self)
|
||||||
|
toggle_info(true)
|
||||||
|
|
||||||
|
|
||||||
func _navigate() -> void:
|
func _navigate() -> void:
|
||||||
|
|||||||
Reference in New Issue
Block a user