ft (Wip): FSM behaviour prey

This commit is contained in:
2026-01-23 10:48:14 +01:00
parent 0b9b1e75d4
commit c11afd9ddd
24 changed files with 154 additions and 54 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -1,40 +0,0 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bfjf6dxvbq5cj"
path="res://.godot/imported/dirt-specs.png-ef6f8fd578fedf9d185ca3625a87c7c3.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://molecular/assets/background/dirt-specs.png"
dest_files=["res://.godot/imported/dirt-specs.png-ef6f8fd578fedf9d185ca3625a87c7c3.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -19,8 +19,6 @@ func _ready() -> void:
attack_area.monitoring = false # no collision until attacking
attack_timer.wait_time = attack_duration
attack_cooldown_timer.wait_time = attack_cooldown_duration
func _process(delta):
velocity = Vector2.ZERO

View File

@@ -14,7 +14,7 @@ tile_data = PackedInt32Array(0, 65536, 2, 65536, 65536, 3, 1, 131072, 2, 65537,
tile_data = PackedInt32Array(0, 196608, 2, 65536, 196608, 3, 1, 262144, 2, 65537, 262144, 3)
[sub_resource type="TileMapPattern" id="TileMapPattern_mys4o"]
tile_data = PackedInt32Array(0, 196608, 0, 65536, 196608, 1, 1, 262144, 0, 65537, 262144, 1)
tile_data = PackedInt32Array(0, 196608, 0, 65536, 196608, 1)
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_b1jr0"]
resource_name = "Background tileset"
@@ -76,6 +76,7 @@ tile_map_data = PackedByteArray("AAAAAAAAAAAAAAIAAAAAAAEAAAAAAAIAAAAAAAIAAAAAAAI
tile_set = SubResource("TileSet_mys4o")
[node name="ParallaxNear" type="Parallax2D" parent="Background"]
z_index = 5
scroll_scale = Vector2(0.9, 0.9)
repeat_times = 7

View File

@@ -11,8 +11,7 @@ var mirrorSprite3: Node2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
health = maxHealth
sprite.animation = "Healthy"
sprite.play()
sprite.play("Healthy")
mirrorSprite1 = sprite.duplicate()
mirrorSprite2 = sprite.duplicate()

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=10 format=3 uid="uid://c3iw2v3x6ngrb"]
[gd_scene load_steps=12 format=3 uid="uid://c3iw2v3x6ngrb"]
[ext_resource type="PackedScene" uid="uid://bvsdg1v3ksixy" path="res://shared/npc/prey2D.tscn" id="1_qvulj"]
[ext_resource type="Script" uid="uid://bgossk6xo31gi" path="res://molecular/nucleotide_prey.gd" id="2_0227s"]
@@ -8,11 +8,13 @@
[ext_resource type="Texture2D" uid="uid://uy28y3mkk6nt" path="res://molecular/assets/prey/prey-healthy-frame1.png" id="5_ae5nf"]
[ext_resource type="Texture2D" uid="uid://btnyajci8ptb2" path="res://molecular/assets/prey/prey-injured-frame0.png" id="6_0f87h"]
[ext_resource type="Texture2D" uid="uid://bqll8ge4cr2uf" path="res://molecular/assets/prey/prey-injured-frame1.png" id="7_w7inl"]
[ext_resource type="Script" uid="uid://c7o7sp02u0wkv" path="res://molecular/nucleotide_prey_state.gd" id="9_guu3v"]
[ext_resource type="Script" uid="uid://ubcu8fdfxxj1" path="res://molecular/nucleotide_prey_foraging.gd" id="10_rgguv"]
[sub_resource type="SpriteFrames" id="SpriteFrames_66x8p"]
animations = [{
"frames": [{
"duration": 20.0,
"duration": 1.0,
"texture": ExtResource("2_lkj7f")
}, {
"duration": 20.0,
@@ -23,7 +25,7 @@ animations = [{
"speed": 1.0
}, {
"frames": [{
"duration": 20.0,
"duration": 1.0,
"texture": ExtResource("4_ee1gb")
}, {
"duration": 20.0,
@@ -34,7 +36,7 @@ animations = [{
"speed": 1.0
}, {
"frames": [{
"duration": 20.0,
"duration": 1.0,
"texture": ExtResource("6_0f87h")
}, {
"duration": 20.0,
@@ -54,4 +56,17 @@ maxHealth = 20
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="." index="0"]
scale = Vector2(0.1, 0.1)
sprite_frames = SubResource("SpriteFrames_66x8p")
animation = &"Dying"
animation = &"Injured"
[node name="State" type="Node" parent="." index="2"]
script = ExtResource("9_guu3v")
metadata/_custom_type_script = "uid://co2xp7gauamql"
[node name="Foraging" type="Node" parent="State" index="0"]
script = ExtResource("10_rgguv")
metadata/_custom_type_script = "uid://c7o7sp02u0wkv"
[node name="Timer" type="Timer" parent="State/Foraging" index="0"]
one_shot = true
[connection signal="timeout" from="State/Foraging/Timer" to="State/Foraging" method="_on_timer_timeout"]

View File

@@ -0,0 +1,17 @@
extends NucleotidePreyState
@onready var timer = $Timer
var dir: float = 0.0
func enter(previous_state_path: String, data := {}) -> void:
timer.start(randi() % 5)
dir = randi() % 360
func physics_update(_delta: float) -> void:
# TODO: move in direction of dir
pass
func _on_timer_timeout() -> void:
dir = randi() % 360
timer.start(randi() % 5)

View File

@@ -0,0 +1 @@
uid://ubcu8fdfxxj1

View File

@@ -0,0 +1,6 @@
class_name NucleotidePreyState extends State
enum State {IDLE, FORAGING, FEEDING, FLEEING}
func _ready() -> void:
await owner.ready

View File

@@ -0,0 +1 @@
uid://c7o7sp02u0wkv

View File

@@ -1,10 +1,11 @@
extends SpawnManager2D
@export var cam: Camera2D
#@export var cam: Camera2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
spawnRange = cam.get_viewport_rect()
spawnRange = GameManager.extent
#spawnRange = cam.get_viewport_rect()
_spawn_minimum()