refactor BunchSpawner
This commit is contained in:
@@ -19,19 +19,22 @@ func _ready() -> void:
|
|||||||
0,
|
0,
|
||||||
randf_range(-gizmo_extents, gizmo_extents),
|
randf_range(-gizmo_extents, gizmo_extents),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var scene: PackedScene
|
||||||
|
var holder: Node
|
||||||
match what:
|
match what:
|
||||||
WhatToSpawn.APHID:
|
WhatToSpawn.APHID:
|
||||||
_spawn(
|
scene = aphid
|
||||||
aphid,
|
holder = StaticNodesManager.aphids_holder
|
||||||
global_position + pos_offset,
|
|
||||||
StaticNodesManager.aphids_holder
|
|
||||||
)
|
|
||||||
WhatToSpawn.HONEYDEW:
|
WhatToSpawn.HONEYDEW:
|
||||||
_spawn(
|
scene = honeydew
|
||||||
honeydew,
|
holder = StaticNodesManager.honeydew_holder
|
||||||
global_position + pos_offset,
|
|
||||||
StaticNodesManager.honeydew_holder
|
_spawn(
|
||||||
)
|
scene,
|
||||||
|
global_position + pos_offset,
|
||||||
|
holder,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
func _spawn(scene: PackedScene, where: Vector3, holder: Node) -> void:
|
func _spawn(scene: PackedScene, where: Vector3, holder: Node) -> void:
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
extends Camera3D
|
extends Camera3D
|
||||||
class_name MainCamera
|
class_name MainCamera
|
||||||
|
|
||||||
enum CameraState {
|
enum State {
|
||||||
FREE,
|
FREE,
|
||||||
HEADING_TO,
|
HEADING_TO,
|
||||||
}
|
}
|
||||||
@@ -48,7 +48,7 @@ var heading_from_position: Vector3 = Vector3.ZERO
|
|||||||
var heading_from_zoom: float = 0
|
var heading_from_zoom: float = 0
|
||||||
var heading_progress: float = 0
|
var heading_progress: float = 0
|
||||||
|
|
||||||
var state: CameraState = CameraState.FREE
|
var state: State = State.FREE
|
||||||
|
|
||||||
var window_out_of_focus: bool = false
|
var window_out_of_focus: bool = false
|
||||||
|
|
||||||
@@ -120,7 +120,7 @@ func head_to(to: Vector3, zoom: float = ZOOM_VALUE_DEFAULT) -> void:
|
|||||||
heading_progress = 0
|
heading_progress = 0
|
||||||
heading_from_zoom = zoom_value
|
heading_from_zoom = zoom_value
|
||||||
heading_to_zoom = zoom
|
heading_to_zoom = zoom
|
||||||
state = CameraState.HEADING_TO
|
state = State.HEADING_TO
|
||||||
|
|
||||||
|
|
||||||
func _handle_advance_anim_step() -> void:
|
func _handle_advance_anim_step() -> void:
|
||||||
@@ -161,7 +161,7 @@ func _handle_dof() -> void:
|
|||||||
func _handle_movement(delta: float) -> void:
|
func _handle_movement(delta: float) -> void:
|
||||||
if (
|
if (
|
||||||
window_out_of_focus
|
window_out_of_focus
|
||||||
or state != CameraState.FREE
|
or state != State.FREE
|
||||||
or CursorManager.disable_confinement
|
or CursorManager.disable_confinement
|
||||||
or SelectionManager.selecting
|
or SelectionManager.selecting
|
||||||
):
|
):
|
||||||
@@ -208,12 +208,12 @@ func _handle_movement(delta: float) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _handle_heading_to(delta: float) -> void:
|
func _handle_heading_to(delta: float) -> void:
|
||||||
if state != CameraState.HEADING_TO:
|
if state != State.HEADING_TO:
|
||||||
return
|
return
|
||||||
|
|
||||||
if heading_progress >= 1:
|
if heading_progress >= 1:
|
||||||
target_position = heading_to_position
|
target_position = heading_to_position
|
||||||
state = CameraState.FREE
|
state = State.FREE
|
||||||
|
|
||||||
heading_progress += HEADING_SPEED * delta
|
heading_progress += HEADING_SPEED * delta
|
||||||
var eased_progress := ease(heading_progress, -3)
|
var eased_progress := ease(heading_progress, -3)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ func _ready() -> void:
|
|||||||
assert(buy_gatherer_button != null, "buy_gatherer_button missing!")
|
assert(buy_gatherer_button != null, "buy_gatherer_button missing!")
|
||||||
assert(gatherer_price_counter != null, "gatherer_price_counter missing!")
|
assert(gatherer_price_counter != null, "gatherer_price_counter missing!")
|
||||||
assert(gatherer_info != null, "gatherer_info missing!")
|
assert(gatherer_info != null, "gatherer_info missing!")
|
||||||
|
assert(counter != null, "counter missing!")
|
||||||
super._ready()
|
super._ready()
|
||||||
buy_nitwit_button.pressed.connect(_on_buy_nitwit_button_pressed)
|
buy_nitwit_button.pressed.connect(_on_buy_nitwit_button_pressed)
|
||||||
nitwit_info.visible = false
|
nitwit_info.visible = false
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ var rect_size: float = RECT_SIZE
|
|||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
assert(atlas != null, "atlas missing!")
|
assert(atlas != null, "atlas missing!")
|
||||||
count_per_row = floor(size.x / (rect_size + GAP))
|
count_per_row = floori(size.x / (rect_size + GAP))
|
||||||
|
|
||||||
|
|
||||||
func initialize(
|
func initialize(
|
||||||
@@ -34,7 +34,7 @@ func initialize(
|
|||||||
|
|
||||||
for i in (ceil(init_max_count / SPRITES_PER_RECT) as int):
|
for i in (ceil(init_max_count / SPRITES_PER_RECT) as int):
|
||||||
var col: int = i % count_per_row
|
var col: int = i % count_per_row
|
||||||
var row: int = floor(i / count_per_row)
|
var row: int = floori(i / count_per_row)
|
||||||
var rect := _create_rect(col, row)
|
var rect := _create_rect(col, row)
|
||||||
rects.append(rect)
|
rects.append(rect)
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
extends FollowingUI
|
extends FollowingUI
|
||||||
class_name UnitInfo
|
class_name UnitInfo
|
||||||
|
|
||||||
enum InfoState {
|
enum State {
|
||||||
NONE,
|
NONE,
|
||||||
ANT_IDLE,
|
ANT_IDLE,
|
||||||
ANT_MOVING,
|
ANT_MOVING,
|
||||||
@@ -16,7 +16,7 @@ enum InfoState {
|
|||||||
const ANIMATION_SPEED: float = 0.25
|
const ANIMATION_SPEED: float = 0.25
|
||||||
|
|
||||||
var unit: Unit
|
var unit: Unit
|
||||||
var state: InfoState = InfoState.NONE
|
var state: State = State.NONE
|
||||||
var anim_time: float = 0
|
var anim_time: float = 0
|
||||||
|
|
||||||
@onready var texture_rect: TextureRect = $TextureRect
|
@onready var texture_rect: TextureRect = $TextureRect
|
||||||
@@ -53,44 +53,44 @@ func close() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _handle_pictogram() -> void:
|
func _handle_pictogram() -> void:
|
||||||
texture_rect.visible = state != InfoState.NONE
|
texture_rect.visible = state != State.NONE
|
||||||
atlas.region.position.y = (state - 1) * atlas.region.size.y
|
atlas.region.position.y = (state - 1) * atlas.region.size.y
|
||||||
atlas.region.position.x = floor(
|
atlas.region.position.x = floorf(
|
||||||
wrapf(anim_time / ANIMATION_SPEED, 0, 4)
|
wrapf(anim_time / ANIMATION_SPEED, 0, 4)
|
||||||
) * atlas.region.size.x
|
) * atlas.region.size.x
|
||||||
|
|
||||||
func _get_state() -> void:
|
func _get_state() -> void:
|
||||||
if unit is Aphid:
|
if unit is Aphid:
|
||||||
match (unit as Aphid).state:
|
match (unit as Aphid).state:
|
||||||
Aphid.AphidState.WANDERING:
|
Aphid.State.WANDERING:
|
||||||
state = InfoState.APHID_IDLE
|
state = State.APHID_IDLE
|
||||||
|
|
||||||
if unit is AntNitwit:
|
if unit is AntNitwit:
|
||||||
match (unit as AntNitwit).state:
|
match (unit as AntNitwit).state:
|
||||||
AntNitwit.AntNitwitState.WANDERING:
|
AntNitwit.State.WANDERING:
|
||||||
state = InfoState.ANT_IDLE
|
state = State.ANT_IDLE
|
||||||
AntNitwit.AntNitwitState.MOVING:
|
AntNitwit.State.MOVING:
|
||||||
state = InfoState.ANT_MOVING
|
state = State.ANT_MOVING
|
||||||
AntNitwit.AntNitwitState.GATHERING:
|
AntNitwit.State.GATHERING:
|
||||||
_get_gathering_state((unit as AntNitwit).gathering.state)
|
_get_gathering_state((unit as AntNitwit).gathering.state)
|
||||||
|
|
||||||
if unit is AntGatherer:
|
if unit is AntGatherer:
|
||||||
match (unit as AntGatherer).state:
|
match (unit as AntGatherer).state:
|
||||||
AntGatherer.AntGathererState.WANDERING:
|
AntGatherer.State.WANDERING:
|
||||||
state = InfoState.ANT_IDLE
|
state = State.ANT_IDLE
|
||||||
AntGatherer.AntGathererState.MOVING:
|
AntGatherer.State.MOVING:
|
||||||
state = InfoState.ANT_MOVING
|
state = State.ANT_MOVING
|
||||||
AntGatherer.AntGathererState.GATHERING:
|
AntGatherer.State.GATHERING:
|
||||||
_get_gathering_state((unit as AntGatherer).gathering.state)
|
_get_gathering_state((unit as AntGatherer).gathering.state)
|
||||||
|
|
||||||
|
|
||||||
func _get_gathering_state(gather_state: Gathering.GatherState) -> void:
|
func _get_gathering_state(gather_state: Gathering.State) -> void:
|
||||||
match gather_state:
|
match gather_state:
|
||||||
Gathering.GatherState.PICKING_UP:
|
Gathering.State.PICKING_UP:
|
||||||
state = InfoState.ANT_PICKING_UP
|
state = State.ANT_PICKING_UP
|
||||||
Gathering.GatherState.DEPOSITING:
|
Gathering.State.DEPOSITING:
|
||||||
state = InfoState.ANT_DEPOSITING
|
state = State.ANT_DEPOSITING
|
||||||
Gathering.GatherState.AWAITING:
|
Gathering.State.AWAITING:
|
||||||
state = InfoState.ANT_AWAITING
|
state = State.ANT_AWAITING
|
||||||
Gathering.GatherState.STOP:
|
Gathering.State.STOP:
|
||||||
state = InfoState.NONE
|
state = State.NONE
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
extends ControlledUnit
|
extends ControlledUnit
|
||||||
class_name AntGatherer
|
class_name AntGatherer
|
||||||
|
|
||||||
enum AntGathererState {
|
enum State {
|
||||||
WANDERING,
|
WANDERING,
|
||||||
MOVING,
|
MOVING,
|
||||||
GATHERING,
|
GATHERING,
|
||||||
@@ -10,7 +10,7 @@ enum AntGathererState {
|
|||||||
const ITEM_BONE_NAME = "Gatherer_item_"
|
const ITEM_BONE_NAME = "Gatherer_item_"
|
||||||
const MAX_CARRY: int = 8
|
const MAX_CARRY: int = 8
|
||||||
|
|
||||||
var state: AntGathererState = AntGathererState.WANDERING
|
var state: State = State.WANDERING
|
||||||
|
|
||||||
@onready var gathering: Gathering = $Gathering
|
@onready var gathering: Gathering = $Gathering
|
||||||
@onready var skeleton: Skeleton3D = $AntModel/Armature/Skeleton3D
|
@onready var skeleton: Skeleton3D = $AntModel/Armature/Skeleton3D
|
||||||
@@ -37,7 +37,7 @@ func _ready() -> void:
|
|||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
super._process(delta)
|
super._process(delta)
|
||||||
if is_relocating:
|
if is_relocating:
|
||||||
state = AntGathererState.MOVING
|
state = State.MOVING
|
||||||
|
|
||||||
_handle_wandering(delta)
|
_handle_wandering(delta)
|
||||||
_handle_gathering()
|
_handle_gathering()
|
||||||
@@ -45,12 +45,12 @@ func _process(delta: float) -> void:
|
|||||||
|
|
||||||
func _interact(with: Interactable) -> void:
|
func _interact(with: Interactable) -> void:
|
||||||
if with is Honeydew:
|
if with is Honeydew:
|
||||||
state = AntGathererState.GATHERING
|
state = State.GATHERING
|
||||||
gathering.start_gathering(with as Honeydew)
|
gathering.start_gathering(with as Honeydew)
|
||||||
|
|
||||||
|
|
||||||
func _handle_wandering(delta: float) -> void:
|
func _handle_wandering(delta: float) -> void:
|
||||||
if state != AntGathererState.WANDERING:
|
if state != State.WANDERING:
|
||||||
return
|
return
|
||||||
|
|
||||||
_wander(delta)
|
_wander(delta)
|
||||||
@@ -61,17 +61,17 @@ func _handle_gathering() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_moving_ended() -> void:
|
func _on_moving_ended() -> void:
|
||||||
state = AntGathererState.WANDERING
|
state = State.WANDERING
|
||||||
|
|
||||||
|
|
||||||
func _on_moving_started() -> void:
|
func _on_moving_started() -> void:
|
||||||
if state == AntGathererState.GATHERING:
|
if state == State.GATHERING:
|
||||||
gathering.stop_gathering()
|
gathering.stop_gathering()
|
||||||
state = AntGathererState.MOVING
|
state = State.MOVING
|
||||||
|
|
||||||
|
|
||||||
func _on_gathering_navigate_to(pos: Vector3) -> void:
|
func _on_gathering_navigate_to(pos: Vector3) -> void:
|
||||||
if state != AntGathererState.GATHERING:
|
if state != State.GATHERING:
|
||||||
return
|
return
|
||||||
|
|
||||||
navigate(pos)
|
navigate(pos)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
extends ControlledUnit
|
extends ControlledUnit
|
||||||
class_name AntNitwit
|
class_name AntNitwit
|
||||||
|
|
||||||
enum AntNitwitState {
|
enum State {
|
||||||
WANDERING,
|
WANDERING,
|
||||||
MOVING,
|
MOVING,
|
||||||
GATHERING,
|
GATHERING,
|
||||||
@@ -9,7 +9,7 @@ enum AntNitwitState {
|
|||||||
|
|
||||||
const ITEM_BONE_NAME = "Nitwit_item_"
|
const ITEM_BONE_NAME = "Nitwit_item_"
|
||||||
|
|
||||||
var state: AntNitwitState = AntNitwitState.WANDERING
|
var state: State = State.WANDERING
|
||||||
|
|
||||||
@onready var gathering: Gathering = $Gathering
|
@onready var gathering: Gathering = $Gathering
|
||||||
@onready var skeleton: Skeleton3D = $AntModel/Armature/Skeleton3D
|
@onready var skeleton: Skeleton3D = $AntModel/Armature/Skeleton3D
|
||||||
@@ -36,7 +36,7 @@ func _ready() -> void:
|
|||||||
func _process(delta: float) -> void:
|
func _process(delta: float) -> void:
|
||||||
super._process(delta)
|
super._process(delta)
|
||||||
if is_relocating:
|
if is_relocating:
|
||||||
state = AntNitwitState.MOVING
|
state = State.MOVING
|
||||||
|
|
||||||
_handle_wandering(delta)
|
_handle_wandering(delta)
|
||||||
_handle_gathering()
|
_handle_gathering()
|
||||||
@@ -44,12 +44,12 @@ func _process(delta: float) -> void:
|
|||||||
|
|
||||||
func _interact(with: Interactable) -> void:
|
func _interact(with: Interactable) -> void:
|
||||||
if with is Honeydew:
|
if with is Honeydew:
|
||||||
state = AntNitwitState.GATHERING
|
state = State.GATHERING
|
||||||
gathering.start_gathering(with as Honeydew)
|
gathering.start_gathering(with as Honeydew)
|
||||||
|
|
||||||
|
|
||||||
func _handle_wandering(delta: float) -> void:
|
func _handle_wandering(delta: float) -> void:
|
||||||
if state != AntNitwitState.WANDERING:
|
if state != State.WANDERING:
|
||||||
return
|
return
|
||||||
|
|
||||||
_wander(delta)
|
_wander(delta)
|
||||||
@@ -60,18 +60,18 @@ func _handle_gathering() -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_moving_ended() -> void:
|
func _on_moving_ended() -> void:
|
||||||
state = AntNitwitState.WANDERING
|
state = State.WANDERING
|
||||||
|
|
||||||
|
|
||||||
func _on_moving_started() -> void:
|
func _on_moving_started() -> void:
|
||||||
if state == AntNitwitState.GATHERING:
|
if state == State.GATHERING:
|
||||||
gathering.stop_gathering()
|
gathering.stop_gathering()
|
||||||
state = AntNitwitState.MOVING
|
state = State.MOVING
|
||||||
|
|
||||||
|
|
||||||
func _on_gathering_navigate_to(pos: Vector3) -> void:
|
func _on_gathering_navigate_to(pos: Vector3) -> void:
|
||||||
print('_on_gathering_navigate_to')
|
print('_on_gathering_navigate_to')
|
||||||
if state != AntNitwitState.GATHERING:
|
if state != State.GATHERING:
|
||||||
return
|
return
|
||||||
print('_on_gathering_navigate_to 2')
|
print('_on_gathering_navigate_to 2')
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
extends Unit
|
extends Unit
|
||||||
class_name Aphid
|
class_name Aphid
|
||||||
|
|
||||||
enum AphidState {
|
enum State {
|
||||||
WANDERING,
|
WANDERING,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ const HONEYDEW_INTERVAL_MAX: float = 60
|
|||||||
const HONEYDEW_SPAWN_SPREAD: float = 0.5
|
const HONEYDEW_SPAWN_SPREAD: float = 0.5
|
||||||
const HONEYDEWS_MAX: int = 5
|
const HONEYDEWS_MAX: int = 5
|
||||||
|
|
||||||
var state: AphidState = AphidState.WANDERING
|
var state: State = State.WANDERING
|
||||||
var honeydew_spawn_timer: float = 0
|
var honeydew_spawn_timer: float = 0
|
||||||
var spawned_honeydews: Dictionary = {}
|
var spawned_honeydews: Dictionary = {}
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ func erase_honeydew(item: Honeydew) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _handle_wandering(delta: float) -> void:
|
func _handle_wandering(delta: float) -> void:
|
||||||
if state != AphidState.WANDERING:
|
if state != State.WANDERING:
|
||||||
return
|
return
|
||||||
|
|
||||||
_wander(delta)
|
_wander(delta)
|
||||||
@@ -50,8 +50,7 @@ func _handle_honeydew_spawn(delta: float) -> void:
|
|||||||
if honeydew_spawn_timer >= 0:
|
if honeydew_spawn_timer >= 0:
|
||||||
honeydew_spawn_timer -= delta
|
honeydew_spawn_timer -= delta
|
||||||
return
|
return
|
||||||
|
|
||||||
audio_player.play_sound(SoundManager.pop())
|
|
||||||
var new_honeydew := honeydew_scene.instantiate() as Honeydew
|
var new_honeydew := honeydew_scene.instantiate() as Honeydew
|
||||||
new_honeydew.set_aphid(self)
|
new_honeydew.set_aphid(self)
|
||||||
|
|
||||||
|
|||||||
@@ -9,14 +9,14 @@ const DEFAULT_PICKUP_INTERVAL = 0.5
|
|||||||
const DROP_SPREAD: float = 0.1
|
const DROP_SPREAD: float = 0.1
|
||||||
const ANTHILL_DEPOSIT_RADIUS: float = 0.5
|
const ANTHILL_DEPOSIT_RADIUS: float = 0.5
|
||||||
|
|
||||||
enum GatherState {
|
enum State {
|
||||||
AWAITING,
|
AWAITING,
|
||||||
PICKING_UP,
|
PICKING_UP,
|
||||||
DEPOSITING,
|
DEPOSITING,
|
||||||
STOP,
|
STOP,
|
||||||
}
|
}
|
||||||
|
|
||||||
var state: GatherState = GatherState.STOP
|
var state: State = State.STOP
|
||||||
|
|
||||||
var nearby_items: Dictionary = {}
|
var nearby_items: Dictionary = {}
|
||||||
var carrying_items: Array[Honeydew] = []
|
var carrying_items: Array[Honeydew] = []
|
||||||
@@ -94,7 +94,7 @@ func handle_gathering(showing_info: bool) -> void:
|
|||||||
collision_shape.global_rotation = Vector3.ZERO
|
collision_shape.global_rotation = Vector3.ZERO
|
||||||
|
|
||||||
radius_indicator.visible = (
|
radius_indicator.visible = (
|
||||||
(state != GatherState.STOP and showing_info)
|
(state != State.STOP and showing_info)
|
||||||
or showing_after_set
|
or showing_after_set
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -102,40 +102,40 @@ func handle_gathering(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
|
||||||
state = GatherState.AWAITING
|
state = State.AWAITING
|
||||||
_go_pick_up(item)
|
_go_pick_up(item)
|
||||||
|
|
||||||
|
|
||||||
func stop_gathering() -> void:
|
func stop_gathering() -> void:
|
||||||
state = GatherState.STOP
|
state = State.STOP
|
||||||
target = null
|
target = null
|
||||||
|
|
||||||
|
|
||||||
func on_nav_agent_navigation_finished() -> void:
|
func on_nav_agent_navigation_finished() -> void:
|
||||||
if state == GatherState.PICKING_UP:
|
if state == State.PICKING_UP:
|
||||||
_pick_up()
|
_pick_up()
|
||||||
|
|
||||||
if (
|
if (
|
||||||
state == GatherState.DEPOSITING
|
state == State.DEPOSITING
|
||||||
and global_position.distance_to(anthill.global_position) < 1
|
and global_position.distance_to(anthill.global_position) < 1
|
||||||
):
|
):
|
||||||
_deposit()
|
_deposit()
|
||||||
|
|
||||||
|
|
||||||
func _go_pick_up(item: Honeydew) -> void:
|
func _go_pick_up(item: Honeydew) -> void:
|
||||||
state = GatherState.AWAITING
|
state = State.AWAITING
|
||||||
if anthill.space_left() <= 0:
|
if anthill.space_left() <= 0:
|
||||||
return
|
return
|
||||||
if carrying_items.size() >= max_carrying:
|
if carrying_items.size() >= max_carrying:
|
||||||
_go_deposit()
|
_go_deposit()
|
||||||
return
|
return
|
||||||
target = item
|
target = item
|
||||||
state = GatherState.PICKING_UP
|
state = State.PICKING_UP
|
||||||
navigate_to.emit(item.global_position)
|
navigate_to.emit(item.global_position)
|
||||||
|
|
||||||
|
|
||||||
func _go_deposit() -> void:
|
func _go_deposit() -> void:
|
||||||
state = GatherState.DEPOSITING
|
state = State.DEPOSITING
|
||||||
var dir := anthill.global_position.direction_to(global_position)
|
var dir := anthill.global_position.direction_to(global_position)
|
||||||
navigate_to.emit(
|
navigate_to.emit(
|
||||||
anthill.global_position
|
anthill.global_position
|
||||||
@@ -151,7 +151,7 @@ func _get_nth_pile_pos(n: int) -> Vector3:
|
|||||||
func _pick_up() -> void:
|
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:
|
||||||
state = GatherState.AWAITING
|
state = State.AWAITING
|
||||||
if nearest != null:
|
if nearest != null:
|
||||||
_go_pick_up(nearest)
|
_go_pick_up(nearest)
|
||||||
elif carrying_items.size() > 0:
|
elif carrying_items.size() > 0:
|
||||||
@@ -177,11 +177,11 @@ func _pick_up() -> void:
|
|||||||
func _deposit() -> void:
|
func _deposit() -> void:
|
||||||
await get_tree().create_timer(0.5).timeout
|
await get_tree().create_timer(0.5).timeout
|
||||||
while carrying_items.size() > 0:
|
while carrying_items.size() > 0:
|
||||||
if state != GatherState.DEPOSITING:
|
if state != State.DEPOSITING:
|
||||||
return
|
return
|
||||||
|
|
||||||
if anthill.space_left() <= 0:
|
if anthill.space_left() <= 0:
|
||||||
state = GatherState.AWAITING
|
state = State.AWAITING
|
||||||
await _drop_everything()
|
await _drop_everything()
|
||||||
return
|
return
|
||||||
|
|
||||||
@@ -200,7 +200,7 @@ func _deposit() -> void:
|
|||||||
_go_pick_up(nearest)
|
_go_pick_up(nearest)
|
||||||
return
|
return
|
||||||
|
|
||||||
state = GatherState.AWAITING
|
state = State.AWAITING
|
||||||
navigate_to.emit(gathering_center)
|
navigate_to.emit(gathering_center)
|
||||||
|
|
||||||
|
|
||||||
@@ -247,7 +247,7 @@ 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:
|
if state == State.AWAITING and anthill.space_left() > 0:
|
||||||
_go_pick_up(item as Honeydew)
|
_go_pick_up(item as Honeydew)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user