who the fuck knows
This commit is contained in:
parent
1c33ea2f59
commit
1da411cacd
31 changed files with 1372 additions and 78 deletions
|
|
@ -6,10 +6,17 @@ class_name BeeGathering
|
|||
|
||||
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))
|
||||
|
||||
|
||||
#animator.play("Idle")
|
||||
|
||||
#if !bee.in_range_of_flowers:
|
||||
|
|
@ -30,3 +37,9 @@ func update(_delta : float):
|
|||
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.look_at(target)
|
||||
|
|
|
|||
|
|
@ -5,12 +5,25 @@ class_name BeeIdle
|
|||
|
||||
var idle_time : float = 0.0
|
||||
|
||||
var target : Vector2 = Vector2.ZERO
|
||||
|
||||
var acquire_new_target : bool = false
|
||||
|
||||
|
||||
func enter(_msg := {}):
|
||||
#animator.play("Idle")
|
||||
pass
|
||||
if acquire_new_target:
|
||||
target = bee.get_global_position() + Vector2(randi_range(-60, 60), randi_range(-60, 60))
|
||||
|
||||
func exit():
|
||||
acquire_new_target = true
|
||||
|
||||
func update(delta : float):
|
||||
|
||||
if target == Vector2.ZERO:
|
||||
randomize()
|
||||
target = bee.get_global_position() + Vector2(randi_range(-60, 60), randi_range(-60, 60))
|
||||
|
||||
|
||||
idle_time += delta
|
||||
|
||||
if idle_time > 2.0:
|
||||
|
|
@ -18,6 +31,14 @@ func update(delta : float):
|
|||
idle_time = 0.0
|
||||
pass
|
||||
|
||||
func physics_update(delta : float) -> void:
|
||||
if target:
|
||||
if bee.position.distance_to(target) > 3:
|
||||
|
||||
bee.velocity = (target - bee.position).normalized() * bee.speed / 2 * delta
|
||||
bee.move_and_collide(bee.velocity)
|
||||
bee.look_at(target)
|
||||
|
||||
func find_something_to_do():
|
||||
if bee.nectar > 0:
|
||||
Log.pr("I have pollen, time to move..")
|
||||
|
|
|
|||
|
|
@ -6,10 +6,13 @@ class_name BeeReturning
|
|||
|
||||
func enter(_msg := {}):
|
||||
Log.pr("Returning to the hive")
|
||||
bee.animation_player.play("Flying")
|
||||
bee.bee_position_animation.play("Flying")
|
||||
|
||||
func update(delta : float) -> void:
|
||||
func update(_delta : float) -> void:
|
||||
pass
|
||||
|
||||
|
||||
func physics_update(delta : float) -> void:
|
||||
if target:
|
||||
if bee.position.distance_to(target.position) > 3:
|
||||
|
||||
|
|
@ -20,4 +23,4 @@ func update(delta : float) -> void:
|
|||
else:
|
||||
# Deposit the nectar and return it idle state
|
||||
bee.deposit_nectar()
|
||||
state_transition.emit(self, "Idle")
|
||||
state_transition.emit(self, "Idle")
|
||||
|
|
@ -1,12 +1,15 @@
|
|||
extends State
|
||||
class_name BeeSleeping
|
||||
|
||||
@onready var bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
|
||||
@onready var bee : 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
|
||||
|
||||
func enter(_msg := {}):
|
||||
func enter(_msg := {}) -> void:
|
||||
pass
|
||||
|
||||
func update(_delta):
|
||||
func update(_delta) -> void:
|
||||
pass
|
||||
|
||||
func physics_update(_delta : float) -> void:
|
||||
pass
|
||||
|
|
@ -6,6 +6,7 @@ class_name BeeTravelling
|
|||
@onready var bee = get_parent().get_parent() as Bee # I think this is bad but I dont care it works
|
||||
|
||||
var return_to_hive : bool = false
|
||||
var moving_to : Vector2 = Vector2(0,0)
|
||||
|
||||
func enter(_msg := {}):
|
||||
return_to_hive = false
|
||||
|
|
@ -23,20 +24,22 @@ func enter(_msg := {}):
|
|||
# If we have no target, we are returning to the hive
|
||||
if !target:
|
||||
return_to_hive = true
|
||||
else:
|
||||
moving_to = target.get_global_position()
|
||||
|
||||
bee.animation_player.play("Flying")
|
||||
bee.bee_position_animation.play("Flying")
|
||||
|
||||
|
||||
func update(delta : float) -> void:
|
||||
|
||||
func update(_delta : float) -> void:
|
||||
if return_to_hive:
|
||||
state_transition.emit(self, "Returning")
|
||||
return
|
||||
|
||||
func physics_update(delta : float) -> void:
|
||||
if target:
|
||||
if bee.position.distance_to(target.position) > 3:
|
||||
|
||||
bee.velocity = (target.get_global_position() - bee.position).normalized() * bee.speed * delta
|
||||
bee.velocity = (moving_to - bee.position).normalized() * bee.speed * delta
|
||||
bee.move_and_collide(bee.velocity)
|
||||
bee.look_at(target.position)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue