who the fuck knows
This commit is contained in:
parent
1c33ea2f59
commit
1da411cacd
31 changed files with 1372 additions and 78 deletions
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=14 format=3 uid="uid://deek6uv574xas"]
|
||||
[gd_scene load_steps=18 format=3 uid="uid://deek6uv574xas"]
|
||||
|
||||
[ext_resource type="Script" path="res://entities/scripts/bee.gd" id="1_pnu7x"]
|
||||
[ext_resource type="Script" path="res://entities/scripts/finite_state_machine.gd" id="1_t3s5d"]
|
||||
|
|
@ -8,23 +8,25 @@
|
|||
[ext_resource type="Script" path="res://entities/bee/states/bee_travelling.gd" id="5_qtx0r"]
|
||||
[ext_resource type="Script" path="res://entities/bee/states/bee_sleeping.gd" id="7_6qlbu"]
|
||||
[ext_resource type="Script" path="res://entities/bee/states/bee_returning.gd" id="8_dptvu"]
|
||||
[ext_resource type="Texture2D" uid="uid://ch3qalaaky8ng" path="res://resources/textures/bee_body.png" id="10_yi42o"]
|
||||
[ext_resource type="Texture2D" uid="uid://bsskcrayofs8n" path="res://resources/textures/bee_wings.png" id="11_utbwk"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_iys4n"]
|
||||
resource_name = "Flying"
|
||||
length = 5.0
|
||||
loop_mode = 1
|
||||
step = 0.5
|
||||
step = 0.25
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Polygon2D:position")
|
||||
tracks/0/path = NodePath("BeeBody:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 1.5, 2.5, 3.5, 5),
|
||||
"transitions": PackedFloat32Array(1, 1, 1, 1, 1),
|
||||
"times": PackedFloat32Array(0, 1, 2, 3, 4, 5),
|
||||
"transitions": PackedFloat32Array(-2, -2, -2, -2, -2, -2),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0), Vector2(0, 10), Vector2(0, -10), Vector2(0, 10), Vector2(0, 0)]
|
||||
"values": [Vector2(0, 0), Vector2(0, 10), Vector2(0, 5), Vector2(0, -5), Vector2(0, 10), Vector2(0, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_t75ra"]
|
||||
|
|
@ -32,18 +34,6 @@ resource_name = "Idle"
|
|||
|
||||
[sub_resource type="Animation" id="Animation_0encb"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("Polygon2D:position")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Vector2(0, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_m27po"]
|
||||
_data = {
|
||||
|
|
@ -52,6 +42,29 @@ _data = {
|
|||
"RESET": SubResource("Animation_0encb")
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_muxdj"]
|
||||
resource_name = "Fly"
|
||||
length = 0.5
|
||||
loop_mode = 1
|
||||
step = 0.05
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("BeeBody/BeeWings:scale")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = false
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45),
|
||||
"transitions": PackedFloat32Array(-2, -2, -2, -2, -2, -2, -2, -2, -2, -2),
|
||||
"update": 0,
|
||||
"values": [Vector2(1, 1), Vector2(1, 0.1), Vector2(1, 1), Vector2(1, 0.1), Vector2(1, 1), Vector2(1, 0.1), Vector2(1, 1), Vector2(1, 0.1), Vector2(1, 1), Vector2(1, 0.1)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_yvewf"]
|
||||
_data = {
|
||||
"Fly": SubResource("Animation_muxdj")
|
||||
}
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_86nxf"]
|
||||
radius = 22.0907
|
||||
|
||||
|
|
@ -60,11 +73,16 @@ z_index = 99
|
|||
collision_mask = 0
|
||||
script = ExtResource("1_pnu7x")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
[node name="BeePositionAnimation" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_m27po")
|
||||
}
|
||||
|
||||
[node name="WingAnimation" type="AnimationPlayer" parent="."]
|
||||
libraries = {
|
||||
"": SubResource("AnimationLibrary_yvewf")
|
||||
}
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
light_mask = 0
|
||||
shape = SubResource("CircleShape2D_86nxf")
|
||||
|
|
@ -97,52 +115,21 @@ script = ExtResource("7_6qlbu")
|
|||
[node name="Returning" type="Node" parent="StateMachine"]
|
||||
script = ExtResource("8_dptvu")
|
||||
|
||||
[node name="Polygon2D" type="Polygon2D" parent="."]
|
||||
scale = Vector2(0.152885, 0.15978)
|
||||
color = Color(1, 1, 0.0745098, 1)
|
||||
polygon = PackedVector2Array(-18, -11, -6, -21, 17, -19, 23, 1, 3, 12, -18, 7)
|
||||
[node name="BeeBody" type="Sprite2D" parent="."]
|
||||
scale = Vector2(0.1, 0.1)
|
||||
texture = ExtResource("10_yi42o")
|
||||
|
||||
[node name="CPUParticles2D" type="CPUParticles2D" parent="Polygon2D"]
|
||||
position = Vector2(0, 2.46663)
|
||||
[node name="BeeWings" type="Sprite2D" parent="BeeBody"]
|
||||
scale = Vector2(1, 0.1)
|
||||
texture = ExtResource("11_utbwk")
|
||||
|
||||
[node name="CPUParticles2D" type="CPUParticles2D" parent="BeeBody"]
|
||||
position = Vector2(0, 3.94118)
|
||||
scale = Vector2(1.52885, 1.5978)
|
||||
lifetime_randomness = 0.33
|
||||
gravity = Vector2(0, 0)
|
||||
linear_accel_min = 5.0
|
||||
linear_accel_max = 10.0
|
||||
|
||||
[node name="Polygon2D" type="Polygon2D" parent="Polygon2D"]
|
||||
position = Vector2(-13.0817, -6.25862)
|
||||
scale = Vector2(0.5, 0.5)
|
||||
color = Color(0, 0, 0, 1)
|
||||
offset = Vector2(-9.53674e-07, -9.53674e-07)
|
||||
polygon = PackedVector2Array(32.7043, -12.5172, 39.2451, -18.7759, 45.786, -12.5172, 39.2451, -6.25862)
|
||||
|
||||
[node name="Polygon2D5" type="Polygon2D" parent="Polygon2D"]
|
||||
position = Vector2(-13.0817, 18.7759)
|
||||
scale = Vector2(0.5, 0.5)
|
||||
color = Color(0, 0, 0, 1)
|
||||
offset = Vector2(-9.53674e-07, -9.53674e-07)
|
||||
polygon = PackedVector2Array(32.7043, -12.5172, 39.2451, -18.7759, 45.786, -12.5172, 39.2451, -6.25862)
|
||||
|
||||
[node name="Polygon2D4" type="Polygon2D" parent="Polygon2D"]
|
||||
position = Vector2(-26.1634, 18.7759)
|
||||
scale = Vector2(0.5, 0.5)
|
||||
color = Color(0, 0, 0, 1)
|
||||
offset = Vector2(-9.53674e-07, -9.53674e-07)
|
||||
polygon = PackedVector2Array(32.7043, -12.5172, 39.2451, -18.7759, 45.786, -12.5172, 39.2451, -6.25862)
|
||||
|
||||
[node name="Polygon2D3" type="Polygon2D" parent="Polygon2D"]
|
||||
position = Vector2(-26.1634, -6.25862)
|
||||
scale = Vector2(0.5, 0.5)
|
||||
color = Color(0.30032, 0.200213, 0.0690995, 1)
|
||||
offset = Vector2(-9.53674e-07, -9.53674e-07)
|
||||
polygon = PackedVector2Array(32.7043, -12.5172, 39.2451, -18.7759, 78.4903, 12.5172, 65.4086, 25.0345)
|
||||
|
||||
[node name="Polygon2D2" type="Polygon2D" parent="Polygon2D"]
|
||||
position = Vector2(-6.54086, 0)
|
||||
scale = Vector2(0.5, 0.5)
|
||||
color = Color(0, 0, 0, 1)
|
||||
offset = Vector2(-9.53674e-07, -9.53674e-07)
|
||||
polygon = PackedVector2Array(32.7043, -12.5172, 39.2451, -18.7759, 45.786, -12.5172, 39.2451, -6.25862)
|
||||
|
||||
[connection signal="area_entered" from="HitBox" to="HitBox" method="_on_area_entered"]
|
||||
[connection signal="area_exited" from="HitBox" to="HitBox" method="_on_area_exited"]
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@ class_name Bee
|
|||
|
||||
@onready var fsm = $StateMachine as FiniteStateMachine
|
||||
@onready var drone_manager = get_tree().get_first_node_in_group("dronemanager") as DroneManager
|
||||
@onready var animation_player = $AnimationPlayer as AnimationPlayer
|
||||
@onready var bee_position_animation = $BeePositionAnimation as AnimationPlayer
|
||||
@onready var bee_wing_animation = $WingAnimation as AnimationPlayer
|
||||
|
||||
@export var nectar : int = 0
|
||||
@export var speed : int = 30
|
||||
|
|
@ -16,6 +17,7 @@ var just_gathering : bool = false # Used to check if the bee has just been gathe
|
|||
|
||||
func _ready():
|
||||
speed = randi_range(35,55) # Randomise the bee speed a bit
|
||||
bee_wing_animation.play("Fly")
|
||||
|
||||
func get_current_director():
|
||||
return drone_manager.get_director(latest_target_director)
|
||||
|
|
@ -51,10 +53,11 @@ func get_next_target():
|
|||
return null
|
||||
|
||||
func deposit_nectar():
|
||||
GameState.add_nectar()
|
||||
nectar = 0
|
||||
latest_target_director = 0
|
||||
just_gathering = false
|
||||
if nectar > 0:
|
||||
GameState.add_nectar()
|
||||
nectar = 0
|
||||
latest_target_director = 0
|
||||
just_gathering = false
|
||||
|
||||
func die():
|
||||
# Move to the death state
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@ func _process(delta):
|
|||
if current_state:
|
||||
current_state.update(delta)
|
||||
|
||||
func _physics_process(delta):
|
||||
if current_state:
|
||||
current_state.physics_update(delta)
|
||||
|
||||
# Use force_change_state cautiously, it immediately switches to a state regardless of any transitions.
|
||||
# This is used to force us into a 'death state' when killed
|
||||
func force_change_state(new_state : String):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue