pollen-not-included/entities/bee/states/bee_gather.gd
Dan Baker a62cd6018e Updated bee nectar gathering and game levels
The bee's nectar gathering now depends on the current flower nectar level. The return, deposit_nectar, die, and other functions have been updated to return void. Nectar requirements for each game level have been increased tenfold. A new variable 'flower_nectar_level' has been added to manage the amount of nectar in flowers. Also, several functions in GameStateManager were updated to include specific input parameters or return void.
2024-05-14 19:05:47 +01:00

36 lines
1 KiB
GDScript

extends State
class_name BeeGathering
@export var animator : AnimationPlayer
@onready var bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
var time_at_patch : float = 0.0
var target : Vector2 = Vector2.ZERO
func enter(_msg := {}):
bee.just_gathering = true
Log.pr("Gathering now...")
randomize()
target = bee.get_global_position() + Vector2(randi_range(-100, 100), randi_range(-100, 100))
func update(_delta : float):
if bee.in_range_of_flowers:
#animator.play("Gathering")
time_at_patch += _delta
if time_at_patch > 5.0:
Log.pr("Gathered nectar!")
bee.nectar += GameState.flower_nectar_level # Add nectar to the bee based on current flower nectar level
state_transition.emit(self, "Idle")
else:
state_transition.emit(self, "Idle")
func physics_update(delta : float) -> void:
if target:
if bee.position.distance_to(target) > 2:
bee.velocity = (target - bee.position).normalized() * bee.speed / 2 * delta
bee.move_and_collide(bee.velocity)
bee.bee_body.look_at(target)