Controllable enemies

This commit is contained in:
Marco 2025-03-21 17:52:01 +01:00
commit 0aad79a0f8
18 changed files with 893 additions and 23 deletions

View file

@ -11,6 +11,7 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ADisposablesTracker_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FDecompilerCache_003Fdecompiler_003F4fd22cd129a84c16b5d8004b467c426f518800_003Fb8_003Fee061233_003FDisposablesTracker_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AEnemy_005FScriptProperties_002Egenerated_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003Fd6739058209280d46591ab296d6b49dfcf7ecd2_003FEnemy_005FScriptProperties_002Egenerated_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AGameManager_005FScriptMethods_002Egenerated_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003F642294f86639b2f8d4cb4d14e791d697e55369_003FGameManager_005FScriptMethods_002Egenerated_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AInput_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003F3e43a674e8a96aa8b4abdf97a31f18732060401d8285a17ee7109827a69cd18b_003FInput_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANode2D_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fe37dc1faf08a4d5ea030ad59bdf77522523400_003F49_003F8f2ede17_003FNode2D_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANode_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003Fbb1b701f3c7411227a9d2e09f965d857ff3e771557650c4f513e427d77c_003FNode_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ANode_002Ecs_002Fl_003AC_0021_003FUsers_003FMaddo_003FAppData_003FLocal_003FJetBrains_003FShared_003FvAny_003FSourcesCache_003Ff1d69ec2da76ccf9bc8a75c8e0fdca9a7ba1adf8c8c9d5047e2fa5991c02eca_003FNode_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>

View file

@ -45,10 +45,11 @@ EnemyName = &"Fairy Guard"
EnemyKey = &"FAIRY_GUARD"
PrefabPath = &"res://Scenes/Actors/FairyGuard_New.tscn"
MaxHealth = 4.0
MovementSpeed = 20.0
MovementSpeed = 30.0
Weapon = ExtResource("7_xlxdc")
LootDrops = Array[Object]([SubResource("Resource_c8nix"), SubResource("Resource_gs2l3"), SubResource("Resource_sqnvg"), SubResource("Resource_5tyar"), SubResource("Resource_48xq6")])
PlayerDetectionRange = 90.0
ViewRange = 120.0
AlarmReactRange = 200.0
PlayerDisengageRange = 500.0
metadata/_custom_type_script = "uid://cd5o0ceb50jki"

View file

@ -1,5 +1,6 @@
[gd_resource type="Resource" script_class="EnemyResource" load_steps=3 format=3 uid="uid://cfdvg162u65sr"]
[gd_resource type="Resource" script_class="EnemyResource" load_steps=4 format=3 uid="uid://cfdvg162u65sr"]
[ext_resource type="Script" uid="uid://cq65aed620ijo" path="res://Scripts/Resources/Loot/LootDrop.cs" id="1_f3huq"]
[ext_resource type="Resource" uid="uid://cdfmedtgp2rcn" path="res://Resources/Weapons/EnemyWeapon.tres" id="7_filx8"]
[ext_resource type="Script" uid="uid://cd5o0ceb50jki" path="res://Scripts/Resources/EnemyResource.cs" id="8_x8scf"]
@ -9,10 +10,11 @@ EnemyName = &"Robot 1"
EnemyKey = &"ROBOT_1"
PrefabPath = &"res://Scenes/Actors/Thermathron.tscn"
MaxHealth = 8.0
MovementSpeed = 20.0
MovementSpeed = 35.0
Weapon = ExtResource("7_filx8")
LootDrops = Array[Object]([])
LootDrops = Array[ExtResource("1_f3huq")]([])
PlayerDetectionRange = 90.0
ViewRange = 120.0
AlarmReactRange = 200.0
PlayerDisengageRange = 500.0
metadata/_custom_type_script = "uid://cd5o0ceb50jki"

View file

@ -1,4 +1,4 @@
[gd_resource type="SpriteFrames" load_steps=10 format=3 uid="uid://bcc5mlwwnkvri"]
[gd_resource type="SpriteFrames" load_steps=11 format=3 uid="uid://bcc5mlwwnkvri"]
[ext_resource type="Texture2D" uid="uid://xgxxdq37pykh" path="res://Sprites/Actors/Fairy.png" id="1_dnfgi"]
@ -30,7 +30,11 @@ region = Rect2(16, 16, 16, 16)
atlas = ExtResource("1_dnfgi")
region = Rect2(0, 48, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_c2w8n"]
[sub_resource type="AtlasTexture" id="AtlasTexture_6os6y"]
atlas = ExtResource("1_dnfgi")
region = Rect2(0, 48, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_m2qbo"]
atlas = ExtResource("1_dnfgi")
region = Rect2(16, 48, 16, 16)
@ -74,7 +78,10 @@ animations = [{
"texture": SubResource("AtlasTexture_cciyq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_c2w8n")
"texture": SubResource("AtlasTexture_6os6y")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_m2qbo")
}],
"loop": true,
"name": &"up",

View file

@ -0,0 +1,110 @@
[gd_resource type="SpriteFrames" load_steps=14 format=3 uid="uid://tei88ni5rpc"]
[ext_resource type="Texture2D" uid="uid://hukxr2e63gky" path="res://Sprites/Actors/Robot3.png" id="1_rrwlm"]
[sub_resource type="AtlasTexture" id="AtlasTexture_rrwlm"]
atlas = ExtResource("1_rrwlm")
region = Rect2(0, 0, 16, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_bpw12"]
atlas = ExtResource("1_rrwlm")
region = Rect2(16, 0, 16, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_jbf8a"]
atlas = ExtResource("1_rrwlm")
region = Rect2(32, 0, 16, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_ifusk"]
atlas = ExtResource("1_rrwlm")
region = Rect2(0, 192, 16, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_a8tyn"]
atlas = ExtResource("1_rrwlm")
region = Rect2(16, 192, 16, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_suo30"]
atlas = ExtResource("1_rrwlm")
region = Rect2(32, 192, 16, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_hr00v"]
atlas = ExtResource("1_rrwlm")
region = Rect2(0, 64, 16, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_edorv"]
atlas = ExtResource("1_rrwlm")
region = Rect2(16, 64, 16, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_2f6bp"]
atlas = ExtResource("1_rrwlm")
region = Rect2(32, 64, 16, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_yfk7l"]
atlas = ExtResource("1_rrwlm")
region = Rect2(0, 128, 16, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_xk2rf"]
atlas = ExtResource("1_rrwlm")
region = Rect2(16, 128, 16, 32)
[sub_resource type="AtlasTexture" id="AtlasTexture_8f6o6"]
atlas = ExtResource("1_rrwlm")
region = Rect2(32, 128, 16, 32)
[resource]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_rrwlm")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_bpw12")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_jbf8a")
}],
"loop": true,
"name": &"down",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ifusk")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_a8tyn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_suo30")
}],
"loop": true,
"name": &"left",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_hr00v")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_edorv")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_2f6bp")
}],
"loop": true,
"name": &"right",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_yfk7l")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_xk2rf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8f6o6")
}],
"loop": true,
"name": &"up",
"speed": 5.0
}]

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=27 format=3 uid="uid://clieeuln36a7a"]
[gd_scene load_steps=36 format=3 uid="uid://clieeuln36a7a"]
[ext_resource type="Script" uid="uid://dn6dbog1s2818" path="res://Scripts/Components/FSM/Enemy/EnemyStateMachine.cs" id="1_27djw"]
[ext_resource type="SpriteFrames" uid="uid://bcc5mlwwnkvri" path="res://Resources/Sprites/Fairy.tres" id="1_ho0th"]
@ -11,6 +11,7 @@
[ext_resource type="Script" uid="uid://7mig30eneu8x" path="res://Scripts/Components/FSM/Enemy/Shooting.cs" id="7_br0mr"]
[ext_resource type="Script" uid="uid://bflvr26h52c55" path="res://Scripts/Components/FSM/Enemy/EnemyStorageModule.cs" id="8_fu65u"]
[ext_resource type="Script" uid="uid://4hwtlc1ftjsc" path="res://Scripts/Components/FSM/Enemy/Dead.cs" id="8_pi7ab"]
[ext_resource type="Script" uid="uid://dj37rup1ibnn6" path="res://Scripts/Components/FSM/Enemy/Controlled.cs" id="9_f3gn5"]
[ext_resource type="Script" uid="uid://cq3hkweplldbr" path="res://Scripts/Components/Actors/GenericDamageReceiver.cs" id="10_l7aey"]
[ext_resource type="PackedScene" uid="uid://dmumxecckh42r" path="res://Scenes/Activable/BrokenFloorEmitter.tscn" id="11_br0mr"]
[ext_resource type="Script" uid="uid://cqwvssstkrdmw" path="res://Scripts/Components/Actors/ActorResourceProvider.cs" id="12_w08b8"]
@ -22,6 +23,10 @@
[ext_resource type="Material" uid="uid://dnvwgyt2tbqmr" path="res://Resources/Materials/Player_Blink_Teleport_Material.tres" id="20_8kl2e"]
[ext_resource type="Script" uid="uid://dncdgq843sj2f" path="res://Scripts/Components/FSM/Enemy/AnimationModule.cs" id="21_8kl2e"]
[ext_resource type="Script" uid="uid://bw4t2clyr6lib" path="res://Scripts/Components/FSM/Enemy/EnemyDropsProvider.cs" id="22_poxpj"]
[ext_resource type="Script" uid="uid://dq338w2lw5phl" path="res://Scripts/Components/Actors/KeyboardInputProvider.cs" id="24_f3gn5"]
[ext_resource type="Texture2D" uid="uid://b2v6j7lsyltrc" path="res://Sprites/Actors/CirnoWings.png" id="25_hnfyq"]
[ext_resource type="Script" uid="uid://d208gvthkstvc" path="res://Scripts/Components/Actors/PlayerCrosshairProvider.cs" id="26_hnfyq"]
[ext_resource type="Texture2D" uid="uid://cf2855sd3hqty" path="res://Sprites/Actors/Aiming_Reticule_Small.png" id="27_wafqr"]
[sub_resource type="CircleShape2D" id="CircleShape2D_pnkma"]
@ -40,6 +45,36 @@ orbit_velocity_max = 1.098
gravity = Vector3(0, 0, 0)
color = Color(0.0392157, 0.380392, 1, 1)
[sub_resource type="AtlasTexture" id="AtlasTexture_urwql"]
atlas = ExtResource("25_hnfyq")
region = Rect2(0, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_wafqr"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_urwql")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[sub_resource type="AtlasTexture" id="AtlasTexture_12erk"]
atlas = ExtResource("27_wafqr")
region = Rect2(0, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_biwfl"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_12erk")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[node name="FairyFsm" type="CharacterBody2D" node_paths=PackedStringArray("EnemyFSM")]
collision_layer = 16
collision_mask = 33
@ -86,9 +121,18 @@ script = ExtResource("8_pi7ab")
StorageModule = NodePath("../../Storage")
DropsProvider = NodePath("../../DropsProvider")
[node name="Controlled" type="Node2D" parent="StateMachine" node_paths=PackedStringArray("StorageModule", "DamageReceiver", "_inputProvider", "CrosshairProvider", "EquippedWeapon", "_moduleNodes")]
script = ExtResource("9_f3gn5")
StorageModule = NodePath("../../Storage")
DamageReceiver = NodePath("../../DamageReceiver")
_inputProvider = NodePath("../../InputProvider")
CrosshairProvider = NodePath("../../CrosshairProvider")
EquippedWeapon = NodePath("../../EnemyWeapon")
_moduleNodes = [NodePath("../../AnimationModule")]
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = ExtResource("1_ho0th")
animation = &"down"
animation = &"up"
[node name="PlayerDetection" type="Area2D" parent="."]
collision_layer = 0
@ -165,6 +209,21 @@ StorageModule = NodePath("../Storage")
script = ExtResource("22_poxpj")
StorageModule = NodePath("../Storage")
[node name="PossessionWings" type="AnimatedSprite2D" parent="."]
visible = false
sprite_frames = SubResource("SpriteFrames_wafqr")
[node name="InputProvider" type="Node2D" parent="."]
script = ExtResource("24_f3gn5")
[node name="CrosshairProvider" type="Node2D" parent="." node_paths=PackedStringArray("AnimatedSprite")]
script = ExtResource("26_hnfyq")
AnimatedSprite = NodePath("Crosshair")
CrosshairDistance = 35.0
[node name="Crosshair" type="AnimatedSprite2D" parent="CrosshairProvider"]
sprite_frames = SubResource("SpriteFrames_biwfl")
[connection signal="area_entered" from="PlayerDetection" to="PlayerDetection" method="_on_area_entered"]
[connection signal="area_exited" from="PlayerDetection" to="PlayerDetection" method="_on_area_exited"]
[connection signal="area_entered" from="DamageReceiver" to="DamageReceiver" method="_on_damage_hitbox_area_entered"]

View file

@ -0,0 +1,230 @@
[gd_scene load_steps=36 format=3 uid="uid://bb32f4p5e671j"]
[ext_resource type="Script" uid="uid://bi2edpdosngll" path="res://Scripts/Components/FSM/Enemy/EnemyFSMProxy.cs" id="1_514kd"]
[ext_resource type="Resource" uid="uid://qbo6avc7x64b" path="res://Resources/Enemies/Fairy_Guard.tres" id="2_514kd"]
[ext_resource type="Script" uid="uid://dn6dbog1s2818" path="res://Scripts/Components/FSM/Enemy/EnemyStateMachine.cs" id="3_1d0cr"]
[ext_resource type="Script" uid="uid://rrelumir3g6n" path="res://Scripts/Components/FSM/Enemy/Init.cs" id="4_hwyax"]
[ext_resource type="Script" uid="uid://bjrh5q24nuoec" path="res://Scripts/Components/FSM/Enemy/Idle.cs" id="5_xxkf8"]
[ext_resource type="Script" uid="uid://dbmc3klko5x18" path="res://Scripts/Components/FSM/Enemy/Alert.cs" id="6_kji07"]
[ext_resource type="Script" uid="uid://7mig30eneu8x" path="res://Scripts/Components/FSM/Enemy/Shooting.cs" id="7_w6ssf"]
[ext_resource type="Script" uid="uid://4hwtlc1ftjsc" path="res://Scripts/Components/FSM/Enemy/Dead.cs" id="8_8jlfa"]
[ext_resource type="Script" uid="uid://dj37rup1ibnn6" path="res://Scripts/Components/FSM/Enemy/Controlled.cs" id="9_hu08i"]
[ext_resource type="SpriteFrames" uid="uid://ch2ll1on8im2p" path="res://Resources/Sprites/FairyGuard.tres" id="10_514kd"]
[ext_resource type="Script" uid="uid://mb4ugq74a17c" path="res://Scripts/Components/FSM/Enemy/PlayerDetectionModule.cs" id="11_uimt1"]
[ext_resource type="Script" uid="uid://bflvr26h52c55" path="res://Scripts/Components/FSM/Enemy/EnemyStorageModule.cs" id="12_k3g3k"]
[ext_resource type="Script" uid="uid://cq3hkweplldbr" path="res://Scripts/Components/Actors/GenericDamageReceiver.cs" id="13_tmpee"]
[ext_resource type="PackedScene" uid="uid://cm564ue740cpx" path="res://Scenes/Actors/DeadFairyGuard.tscn" id="14_5gayb"]
[ext_resource type="Script" uid="uid://cqwvssstkrdmw" path="res://Scripts/Components/Actors/ActorResourceProvider.cs" id="15_57pi6"]
[ext_resource type="Script" uid="uid://ik7s65de723k" path="res://Scripts/Components/FSM/Enemy/NavigationMovementModule.cs" id="16_hg2oh"]
[ext_resource type="PackedScene" uid="uid://cj63k0dmk7tl1" path="res://Scenes/Weapons/enemy_weapon_base.tscn" id="17_i8o8t"]
[ext_resource type="Resource" uid="uid://csdlihliv4cr8" path="res://Resources/Weapons/EnemyWeapon_simple.tres" id="18_bhoke"]
[ext_resource type="Script" uid="uid://dhsqsajq537qn" path="res://Scripts/Components/FSM/Enemy/EnemyAlarmModule.cs" id="19_i0ais"]
[ext_resource type="Script" uid="uid://bo5sgbv1t8ril" path="res://Scripts/Components/Actors/PlayerAnimationProvider.cs" id="20_f422k"]
[ext_resource type="Material" uid="uid://dnvwgyt2tbqmr" path="res://Resources/Materials/Player_Blink_Teleport_Material.tres" id="21_76bkd"]
[ext_resource type="Script" uid="uid://dncdgq843sj2f" path="res://Scripts/Components/FSM/Enemy/AnimationModule.cs" id="22_ipl8g"]
[ext_resource type="Script" uid="uid://bw4t2clyr6lib" path="res://Scripts/Components/FSM/Enemy/EnemyDropsProvider.cs" id="23_1llhk"]
[ext_resource type="Texture2D" uid="uid://b2v6j7lsyltrc" path="res://Sprites/Actors/CirnoWings.png" id="24_jlj2a"]
[ext_resource type="Script" uid="uid://dq338w2lw5phl" path="res://Scripts/Components/Actors/KeyboardInputProvider.cs" id="25_5xyu0"]
[ext_resource type="Script" uid="uid://d208gvthkstvc" path="res://Scripts/Components/Actors/PlayerCrosshairProvider.cs" id="26_u2sah"]
[ext_resource type="Texture2D" uid="uid://cf2855sd3hqty" path="res://Sprites/Actors/Aiming_Reticule_Small.png" id="27_na4im"]
[sub_resource type="CircleShape2D" id="CircleShape2D_pnkma"]
[sub_resource type="CircleShape2D" id="CircleShape2D_5wstg"]
radius = 29.0
[sub_resource type="CircleShape2D" id="CircleShape2D_6x22m"]
radius = 5.0
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_poxpj"]
particle_flag_disable_z = true
emission_shape = 2
emission_sphere_radius = 16.0
orbit_velocity_min = -1.0
orbit_velocity_max = 1.098
gravity = Vector3(0, 0, 0)
color = Color(0.0392157, 0.380392, 1, 1)
[sub_resource type="AtlasTexture" id="AtlasTexture_urwql"]
atlas = ExtResource("24_jlj2a")
region = Rect2(0, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_wafqr"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_urwql")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[sub_resource type="AtlasTexture" id="AtlasTexture_12erk"]
atlas = ExtResource("27_na4im")
region = Rect2(0, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_biwfl"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_12erk")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[node name="FairyGuardFsm" type="CharacterBody2D" node_paths=PackedStringArray("EnemyFSM")]
collision_layer = 16
collision_mask = 33
script = ExtResource("1_514kd")
EnemyFSM = NodePath("StateMachine")
EnemyResource = ExtResource("2_514kd")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_pnkma")
[node name="StateMachine" type="Node2D" parent="."]
script = ExtResource("3_1d0cr")
[node name="Init" type="Node2D" parent="StateMachine" node_paths=PackedStringArray("DamageReceiver", "StorageModule")]
script = ExtResource("4_hwyax")
DamageReceiver = NodePath("../../DamageReceiver")
StorageModule = NodePath("../../Storage")
[node name="Idle" type="Node2D" parent="StateMachine" node_paths=PackedStringArray("StorageModule", "PlayerDetection", "DamageReceiver", "_moduleNodes")]
script = ExtResource("5_xxkf8")
StorageModule = NodePath("../../Storage")
PlayerDetection = NodePath("../../PlayerDetection")
DamageReceiver = NodePath("../../DamageReceiver")
_moduleNodes = [NodePath("../../AlarmModule"), NodePath("../../AnimationModule")]
[node name="Alert" type="Node2D" parent="StateMachine" node_paths=PackedStringArray("StorageModule", "PlayerDetection", "DamageReceiver", "NavigationModule", "_moduleNodes")]
script = ExtResource("6_kji07")
StorageModule = NodePath("../../Storage")
PlayerDetection = NodePath("../../PlayerDetection")
DamageReceiver = NodePath("../../DamageReceiver")
NavigationModule = NodePath("../../NavigationModule")
_moduleNodes = [NodePath("../../AnimationModule")]
[node name="Shooting" type="Node2D" parent="StateMachine" node_paths=PackedStringArray("StorageModule", "PlayerDetection", "DamageReceiver", "EquippedWeapon", "_moduleNodes")]
script = ExtResource("7_w6ssf")
StorageModule = NodePath("../../Storage")
PlayerDetection = NodePath("../../PlayerDetection")
DamageReceiver = NodePath("../../DamageReceiver")
EquippedWeapon = NodePath("../../EnemyWeapon")
_moduleNodes = [NodePath("../../AnimationModule")]
[node name="Dead" type="Node2D" parent="StateMachine" node_paths=PackedStringArray("StorageModule", "DropsProvider")]
script = ExtResource("8_8jlfa")
StorageModule = NodePath("../../Storage")
DropsProvider = NodePath("../../DropsProvider")
[node name="Controlled" type="Node2D" parent="StateMachine" node_paths=PackedStringArray("StorageModule", "DamageReceiver", "_inputProvider", "CrosshairProvider", "EquippedWeapon", "_moduleNodes")]
script = ExtResource("9_hu08i")
StorageModule = NodePath("../../Storage")
DamageReceiver = NodePath("../../DamageReceiver")
_inputProvider = NodePath("../../InputProvider")
CrosshairProvider = NodePath("../../CrosshairProvider")
EquippedWeapon = NodePath("../../EnemyWeapon")
_moduleNodes = [NodePath("../../AnimationModule")]
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = ExtResource("10_514kd")
animation = &"right"
[node name="PlayerDetection" type="Area2D" parent="."]
collision_layer = 0
collision_mask = 2
script = ExtResource("11_uimt1")
ObstaclesCollisionMask = 81
[node name="CollisionShape2D" type="CollisionShape2D" parent="PlayerDetection"]
shape = SubResource("CircleShape2D_5wstg")
[node name="Storage" type="Node2D" parent="." node_paths=PackedStringArray("Root")]
script = ExtResource("12_k3g3k")
Root = NodePath("..")
[node name="DamageReceiver" type="Area2D" parent="." node_paths=PackedStringArray("HealthProvider")]
collision_layer = 64
collision_mask = 136
script = ExtResource("13_tmpee")
HealthProvider = NodePath("Health")
BulletGroup = 2
Debris = ExtResource("14_5gayb")
DeleteParentOnDeath = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="DamageReceiver"]
position = Vector2(0, 3.865)
shape = SubResource("CircleShape2D_6x22m")
[node name="Health" type="Node2D" parent="DamageReceiver"]
script = ExtResource("15_57pi6")
ResourceName = "Health"
[node name="NavigationModule" type="Node2D" parent="." node_paths=PackedStringArray("StorageModule")]
script = ExtResource("16_hg2oh")
StorageModule = NodePath("../Storage")
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="NavigationModule"]
target_desired_distance = 8.0
path_max_distance = 800.0
path_postprocessing = 1
avoidance_enabled = true
debug_enabled = true
debug_path_custom_color = Color(1, 0, 0, 1)
[node name="EnemyWeapon" parent="." instance=ExtResource("17_i8o8t")]
WeaponData = ExtResource("18_bhoke")
[node name="AlarmModule" type="Node2D" parent="." node_paths=PackedStringArray("PlayerDetection")]
script = ExtResource("19_i0ais")
PlayerDetection = NodePath("../PlayerDetection")
[node name="AnimationProvider" type="Node2D" parent="." node_paths=PackedStringArray("_animatedSprite", "_shieldParticles")]
script = ExtResource("20_f422k")
_animatedSprite = NodePath("../AnimatedSprite2D")
_shieldParticles = NodePath("ShieldParticles")
WalkRightAnimationName = &"right"
WalkLeftAnimationName = &"left"
WalkDownAnimationName = &"down"
WalkUpAnimationName = &"up"
BlinkMaterial = ExtResource("21_76bkd")
[node name="ShieldParticles" type="GPUParticles2D" parent="AnimationProvider"]
emitting = false
amount = 32
lifetime = 0.4
one_shot = true
process_material = SubResource("ParticleProcessMaterial_poxpj")
[node name="AnimationModule" type="Node2D" parent="." node_paths=PackedStringArray("AnimationProvider", "StorageModule")]
script = ExtResource("22_ipl8g")
AnimationProvider = NodePath("../AnimationProvider")
StorageModule = NodePath("../Storage")
[node name="DropsProvider" type="Node2D" parent="." node_paths=PackedStringArray("StorageModule")]
script = ExtResource("23_1llhk")
StorageModule = NodePath("../Storage")
[node name="PossessionWings" type="AnimatedSprite2D" parent="."]
visible = false
sprite_frames = SubResource("SpriteFrames_wafqr")
[node name="InputProvider" type="Node2D" parent="."]
script = ExtResource("25_5xyu0")
[node name="CrosshairProvider" type="Node2D" parent="." node_paths=PackedStringArray("AnimatedSprite")]
script = ExtResource("26_u2sah")
AnimatedSprite = NodePath("Crosshair")
CrosshairDistance = 35.0
[node name="Crosshair" type="AnimatedSprite2D" parent="CrosshairProvider"]
sprite_frames = SubResource("SpriteFrames_biwfl")
[connection signal="area_entered" from="PlayerDetection" to="PlayerDetection" method="_on_area_entered"]
[connection signal="area_exited" from="PlayerDetection" to="PlayerDetection" method="_on_area_exited"]
[connection signal="area_entered" from="DamageReceiver" to="DamageReceiver" method="_on_damage_hitbox_area_entered"]
[connection signal="velocity_computed" from="NavigationModule/NavigationAgent2D" to="NavigationModule" method="_on_navigation_agent_2d_velocity_computed"]

View file

@ -50,7 +50,7 @@ EnemyData = ExtResource("2_jukx0")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = ExtResource("2_7asxc")
animation = &"down"
animation = &"dead"
[node name="PosessionMovementProvider" type="Node2D" parent="." node_paths=PackedStringArray("PossessionSprite", "DamageReceiver", "EquippedWeapon")]
script = ExtResource("3_81a26")

View file

@ -0,0 +1,231 @@
[gd_scene load_steps=36 format=3 uid="uid://dky13otbks8cm"]
[ext_resource type="Script" uid="uid://bi2edpdosngll" path="res://Scripts/Components/FSM/Enemy/EnemyFSMProxy.cs" id="1_ypjty"]
[ext_resource type="Resource" uid="uid://cfdvg162u65sr" path="res://Resources/Enemies/Thermathron.tres" id="2_ypjty"]
[ext_resource type="Script" uid="uid://dn6dbog1s2818" path="res://Scripts/Components/FSM/Enemy/EnemyStateMachine.cs" id="3_vwbuk"]
[ext_resource type="Script" uid="uid://rrelumir3g6n" path="res://Scripts/Components/FSM/Enemy/Init.cs" id="4_h5l0p"]
[ext_resource type="Script" uid="uid://bjrh5q24nuoec" path="res://Scripts/Components/FSM/Enemy/Idle.cs" id="5_0h47h"]
[ext_resource type="Script" uid="uid://dbmc3klko5x18" path="res://Scripts/Components/FSM/Enemy/Alert.cs" id="6_6jnl3"]
[ext_resource type="Script" uid="uid://7mig30eneu8x" path="res://Scripts/Components/FSM/Enemy/Shooting.cs" id="7_0b4ec"]
[ext_resource type="Script" uid="uid://4hwtlc1ftjsc" path="res://Scripts/Components/FSM/Enemy/Dead.cs" id="8_vnfdp"]
[ext_resource type="Script" uid="uid://dj37rup1ibnn6" path="res://Scripts/Components/FSM/Enemy/Controlled.cs" id="9_3mqch"]
[ext_resource type="SpriteFrames" uid="uid://tei88ni5rpc" path="res://Resources/Sprites/Thermathron.tres" id="10_ypjty"]
[ext_resource type="Script" uid="uid://mb4ugq74a17c" path="res://Scripts/Components/FSM/Enemy/PlayerDetectionModule.cs" id="11_fr0ok"]
[ext_resource type="Script" uid="uid://bflvr26h52c55" path="res://Scripts/Components/FSM/Enemy/EnemyStorageModule.cs" id="12_owlkt"]
[ext_resource type="Script" uid="uid://cq3hkweplldbr" path="res://Scripts/Components/Actors/GenericDamageReceiver.cs" id="13_dawgb"]
[ext_resource type="PackedScene" uid="uid://cm564ue740cpx" path="res://Scenes/Actors/DeadFairyGuard.tscn" id="14_u1bck"]
[ext_resource type="Script" uid="uid://cqwvssstkrdmw" path="res://Scripts/Components/Actors/ActorResourceProvider.cs" id="15_7irjb"]
[ext_resource type="Script" uid="uid://ik7s65de723k" path="res://Scripts/Components/FSM/Enemy/NavigationMovementModule.cs" id="16_sdbo2"]
[ext_resource type="PackedScene" uid="uid://cj63k0dmk7tl1" path="res://Scenes/Weapons/enemy_weapon_base.tscn" id="17_fd7xe"]
[ext_resource type="Resource" uid="uid://csdlihliv4cr8" path="res://Resources/Weapons/EnemyWeapon_simple.tres" id="18_w3tna"]
[ext_resource type="Script" uid="uid://dhsqsajq537qn" path="res://Scripts/Components/FSM/Enemy/EnemyAlarmModule.cs" id="19_c3uga"]
[ext_resource type="Script" uid="uid://bo5sgbv1t8ril" path="res://Scripts/Components/Actors/PlayerAnimationProvider.cs" id="20_ugc72"]
[ext_resource type="Material" uid="uid://dnvwgyt2tbqmr" path="res://Resources/Materials/Player_Blink_Teleport_Material.tres" id="21_47d4e"]
[ext_resource type="Script" uid="uid://dncdgq843sj2f" path="res://Scripts/Components/FSM/Enemy/AnimationModule.cs" id="22_fwg5l"]
[ext_resource type="Script" uid="uid://bw4t2clyr6lib" path="res://Scripts/Components/FSM/Enemy/EnemyDropsProvider.cs" id="23_iws4h"]
[ext_resource type="Texture2D" uid="uid://b2v6j7lsyltrc" path="res://Sprites/Actors/CirnoWings.png" id="24_wy318"]
[ext_resource type="Script" uid="uid://dq338w2lw5phl" path="res://Scripts/Components/Actors/KeyboardInputProvider.cs" id="25_5b7ew"]
[ext_resource type="Script" uid="uid://d208gvthkstvc" path="res://Scripts/Components/Actors/PlayerCrosshairProvider.cs" id="26_k7vny"]
[ext_resource type="Texture2D" uid="uid://cf2855sd3hqty" path="res://Sprites/Actors/Aiming_Reticule_Small.png" id="27_tgmsl"]
[sub_resource type="CircleShape2D" id="CircleShape2D_pnkma"]
[sub_resource type="CircleShape2D" id="CircleShape2D_5wstg"]
radius = 29.0
[sub_resource type="CircleShape2D" id="CircleShape2D_6x22m"]
radius = 5.0
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_poxpj"]
particle_flag_disable_z = true
emission_shape = 2
emission_sphere_radius = 16.0
orbit_velocity_min = -1.0
orbit_velocity_max = 1.098
gravity = Vector3(0, 0, 0)
color = Color(0.0392157, 0.380392, 1, 1)
[sub_resource type="AtlasTexture" id="AtlasTexture_urwql"]
atlas = ExtResource("24_wy318")
region = Rect2(0, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_wafqr"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_urwql")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[sub_resource type="AtlasTexture" id="AtlasTexture_12erk"]
atlas = ExtResource("27_tgmsl")
region = Rect2(0, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_biwfl"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_12erk")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[node name="ThermatronFsm" type="CharacterBody2D" node_paths=PackedStringArray("EnemyFSM")]
collision_layer = 16
collision_mask = 33
script = ExtResource("1_ypjty")
EnemyFSM = NodePath("StateMachine")
EnemyResource = ExtResource("2_ypjty")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_pnkma")
[node name="StateMachine" type="Node2D" parent="."]
script = ExtResource("3_vwbuk")
[node name="Init" type="Node2D" parent="StateMachine" node_paths=PackedStringArray("DamageReceiver", "StorageModule")]
script = ExtResource("4_h5l0p")
DamageReceiver = NodePath("../../DamageReceiver")
StorageModule = NodePath("../../Storage")
[node name="Idle" type="Node2D" parent="StateMachine" node_paths=PackedStringArray("StorageModule", "PlayerDetection", "DamageReceiver", "_moduleNodes")]
script = ExtResource("5_0h47h")
StorageModule = NodePath("../../Storage")
PlayerDetection = NodePath("../../PlayerDetection")
DamageReceiver = NodePath("../../DamageReceiver")
_moduleNodes = [NodePath("../../AlarmModule"), NodePath("../../AnimationModule")]
[node name="Alert" type="Node2D" parent="StateMachine" node_paths=PackedStringArray("StorageModule", "PlayerDetection", "DamageReceiver", "NavigationModule", "_moduleNodes")]
script = ExtResource("6_6jnl3")
StorageModule = NodePath("../../Storage")
PlayerDetection = NodePath("../../PlayerDetection")
DamageReceiver = NodePath("../../DamageReceiver")
NavigationModule = NodePath("../../NavigationModule")
_moduleNodes = [NodePath("../../AnimationModule")]
[node name="Shooting" type="Node2D" parent="StateMachine" node_paths=PackedStringArray("StorageModule", "PlayerDetection", "DamageReceiver", "EquippedWeapon", "_moduleNodes")]
script = ExtResource("7_0b4ec")
StorageModule = NodePath("../../Storage")
PlayerDetection = NodePath("../../PlayerDetection")
DamageReceiver = NodePath("../../DamageReceiver")
EquippedWeapon = NodePath("../../EnemyWeapon")
_moduleNodes = [NodePath("../../AnimationModule")]
[node name="Dead" type="Node2D" parent="StateMachine" node_paths=PackedStringArray("StorageModule", "DropsProvider")]
script = ExtResource("8_vnfdp")
StorageModule = NodePath("../../Storage")
DropsProvider = NodePath("../../DropsProvider")
[node name="Controlled" type="Node2D" parent="StateMachine" node_paths=PackedStringArray("StorageModule", "DamageReceiver", "_inputProvider", "CrosshairProvider", "EquippedWeapon", "_moduleNodes")]
script = ExtResource("9_3mqch")
StorageModule = NodePath("../../Storage")
DamageReceiver = NodePath("../../DamageReceiver")
_inputProvider = NodePath("../../InputProvider")
CrosshairProvider = NodePath("../../CrosshairProvider")
EquippedWeapon = NodePath("../../EnemyWeapon")
_moduleNodes = [NodePath("../../AnimationModule")]
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = ExtResource("10_ypjty")
animation = &"right"
autoplay = "down"
[node name="PlayerDetection" type="Area2D" parent="."]
collision_layer = 0
collision_mask = 2
script = ExtResource("11_fr0ok")
ObstaclesCollisionMask = 81
[node name="CollisionShape2D" type="CollisionShape2D" parent="PlayerDetection"]
shape = SubResource("CircleShape2D_5wstg")
[node name="Storage" type="Node2D" parent="." node_paths=PackedStringArray("Root")]
script = ExtResource("12_owlkt")
Root = NodePath("..")
[node name="DamageReceiver" type="Area2D" parent="." node_paths=PackedStringArray("HealthProvider")]
collision_layer = 64
collision_mask = 136
script = ExtResource("13_dawgb")
HealthProvider = NodePath("Health")
BulletGroup = 2
Debris = ExtResource("14_u1bck")
DeleteParentOnDeath = false
[node name="CollisionShape2D" type="CollisionShape2D" parent="DamageReceiver"]
position = Vector2(0, 3.865)
shape = SubResource("CircleShape2D_6x22m")
[node name="Health" type="Node2D" parent="DamageReceiver"]
script = ExtResource("15_7irjb")
ResourceName = "Health"
[node name="NavigationModule" type="Node2D" parent="." node_paths=PackedStringArray("StorageModule")]
script = ExtResource("16_sdbo2")
StorageModule = NodePath("../Storage")
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="NavigationModule"]
target_desired_distance = 8.0
path_max_distance = 800.0
path_postprocessing = 1
avoidance_enabled = true
debug_enabled = true
debug_path_custom_color = Color(1, 0, 0, 1)
[node name="EnemyWeapon" parent="." instance=ExtResource("17_fd7xe")]
WeaponData = ExtResource("18_w3tna")
[node name="AlarmModule" type="Node2D" parent="." node_paths=PackedStringArray("PlayerDetection")]
script = ExtResource("19_c3uga")
PlayerDetection = NodePath("../PlayerDetection")
[node name="AnimationProvider" type="Node2D" parent="." node_paths=PackedStringArray("_animatedSprite", "_shieldParticles")]
script = ExtResource("20_ugc72")
_animatedSprite = NodePath("../AnimatedSprite2D")
_shieldParticles = NodePath("ShieldParticles")
WalkRightAnimationName = &"right"
WalkLeftAnimationName = &"left"
WalkDownAnimationName = &"down"
WalkUpAnimationName = &"up"
BlinkMaterial = ExtResource("21_47d4e")
[node name="ShieldParticles" type="GPUParticles2D" parent="AnimationProvider"]
emitting = false
amount = 32
lifetime = 0.4
one_shot = true
process_material = SubResource("ParticleProcessMaterial_poxpj")
[node name="AnimationModule" type="Node2D" parent="." node_paths=PackedStringArray("AnimationProvider", "StorageModule")]
script = ExtResource("22_fwg5l")
AnimationProvider = NodePath("../AnimationProvider")
StorageModule = NodePath("../Storage")
[node name="DropsProvider" type="Node2D" parent="." node_paths=PackedStringArray("StorageModule")]
script = ExtResource("23_iws4h")
StorageModule = NodePath("../Storage")
[node name="PossessionWings" type="AnimatedSprite2D" parent="."]
visible = false
sprite_frames = SubResource("SpriteFrames_wafqr")
[node name="InputProvider" type="Node2D" parent="."]
script = ExtResource("25_5b7ew")
[node name="CrosshairProvider" type="Node2D" parent="." node_paths=PackedStringArray("AnimatedSprite")]
script = ExtResource("26_k7vny")
AnimatedSprite = NodePath("Crosshair")
CrosshairDistance = 35.0
[node name="Crosshair" type="AnimatedSprite2D" parent="CrosshairProvider"]
sprite_frames = SubResource("SpriteFrames_biwfl")
[connection signal="area_entered" from="PlayerDetection" to="PlayerDetection" method="_on_area_entered"]
[connection signal="area_exited" from="PlayerDetection" to="PlayerDetection" method="_on_area_exited"]
[connection signal="area_entered" from="DamageReceiver" to="DamageReceiver" method="_on_damage_hitbox_area_entered"]
[connection signal="velocity_computed" from="NavigationModule/NavigationAgent2D" to="NavigationModule" method="_on_navigation_agent_2d_velocity_computed"]

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,140 @@
using Cirno.Scripts.Components.Actors;
using Cirno.Scripts.Enums;
using Godot;
namespace Cirno.Scripts.Components.FSM.Enemy;
public partial class Controlled : EnemyStateBase
{
public override EnemyState StateId => EnemyState.Controlled;
[Export]
public EnemyStorageModule StorageModule { get; private set; }
[Export]
public GenericDamageReceiver DamageReceiver { get; private set; }
[Export]
private InputProvider _inputProvider;
[Export]
public PlayerCrosshairProvider CrosshairProvider { get; private set; }
[Export] public Weapon EquippedWeapon { get; private set; }
[Export] public StringName ControlEndAction { get; private set; } = "pause";
[Export] public StringName ShootAction { get; private set; } = "shoot";
private bool _isStrafing = false;
public override void EnterState()
{
base.EnterState();
GD.Print($"{StorageModule.Root.Name} Controlled");
DamageReceiver.ChangeState(true);
DamageReceiver.HealthProvider.ResourceDepleted += HealthProviderOnResourceDepleted;
GameManager.Instance.CameraTargetObject(MainObject);
GameManager.Instance.Player.SetState(PlayerState.Controlling);
DamageReceiver.BulletGroup = BulletOwner.Player;
_isStrafing = false;
CrosshairProvider.Visible = true;
// Show possession sprite
}
private void HealthProviderOnResourceDepleted()
{
ChangeState(EnemyState.Dead);
}
public override void ExitState()
{
base.ExitState();
DamageReceiver.HealthProvider.ResourceDepleted -= HealthProviderOnResourceDepleted;
DamageReceiver.ChangeState(false);
GameManager.Instance.CameraTargetPlayer();
GameManager.Instance.Player.SetState(PlayerState.Active);
DamageReceiver.BulletGroup = BulletOwner.Enemy;
CrosshairProvider.Visible = false;
// Hide possession sprite
}
public override void PhysicsProcessState(double delta)
{
base.PhysicsProcessState(delta);
if (_inputProvider.GetShootPressed())
{
Shoot();
}
if (Input.IsActionJustPressed(ControlEndAction))
{
// if (GameManager.Instance.ToggleControlMode() is GameState.Playing)
// {
// ResumeControl();
// }
StateMachine.SetState(EnemyState.Idle);
}
HandlePhysics(delta);
StorageModule.FacingDirection = MainObject.Velocity.SnapToCardinal().Normalized();
}
private void HandlePhysics(double delta)
{
StorageModule.MovementDirection = _inputProvider.GetMovementInput().Normalized();
_isStrafing = _inputProvider.GetStrafePressed();
var rightStickInput = _inputProvider.GetAimInput().Normalized();
if (rightStickInput.Length() > 0.1f) // If the right stick is moved
{
StorageModule.AimingDirection = rightStickInput;
}
else if (StorageModule.MovementDirection != Vector2.Zero) // Fall back to movement direction
{
StorageModule.AimingDirection = StorageModule.MovementDirection;
}
// Update crosshair
CrosshairProvider.UpdatePosition(StorageModule.AimingDirection);
MainObject.Velocity = StorageModule.MovementDirection * StorageModule.MovementSpeed;
MainObject.MoveAndSlide();
}
private void Shoot()
{
if (EquippedWeapon == null) return;
var direction = StorageModule.AimingDirection;
// Shoot at the player's last known position
EquippedWeapon.ShootDirection = direction;
//StorageModule.FacingDirection = direction;
//StorageModule.FacingDirection = direction.SnapToCardinal().Normalized();
EquippedWeapon.Shoot(BulletOwner.Player);
}
public override void ProcessState(double delta)
{
base.ProcessState(delta);
}
}

View file

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

View file

@ -1,4 +1,5 @@
using Cirno.Scripts.Enums;
using System;
using Cirno.Scripts.Enums;
using Cirno.Scripts.Resources;
using Cirno.Scripts.Resources.Loot;
using Godot;
@ -6,7 +7,7 @@ using Godot.Collections;
namespace Cirno.Scripts.Components.FSM.Enemy;
public partial class EnemyFSMProxy : CharacterBody2D
public partial class EnemyFSMProxy : CharacterBody2D, IActivable
{
[Export] public EnemyStateMachine EnemyFSM { get; private set; }
@ -21,4 +22,31 @@ public partial class EnemyFSMProxy : CharacterBody2D
[Export] public Node2D DefeatScript { get; set; }
[Export] public ActivationType ActivationType { get; private set; } = ActivationType.Toggle;
public bool Activate(ActivationType activationType = ActivationType.Toggle)
{
switch (activationType)
{
case ActivationType.Toggle:
EnemyFSM.SetState(EnemyState.Controlled);
break;
case ActivationType.Enable:
// Enable or disable AI
break;
case ActivationType.Disable:
// Enable or disable AI
break;
case ActivationType.Use:
break;
case ActivationType.Destroy:
EnemyFSM.SetState(EnemyState.Dead);
break;
case ActivationType.Open:
break;
case ActivationType.Close:
break;
}
return true;
}
}

View file

@ -13,11 +13,13 @@ public partial class EnemyStorageModule : Node2D
public Vector2 MovementDirection { get; set; }
public Vector2 FacingDirection { get; set; }
public Vector2 AimingDirection { get; set; }
public float MovementSpeed => Root.EnemyResource.MovementSpeed;
public IEnumerable<LootDrop> LootDrops => Root.EnemyResource.LootDrops.Concat(Root.ExtraLoot);
public AiState AiState { get; set; }
}

View file

@ -47,6 +47,7 @@ public partial class Idle : EnemyStateBase
private void HealthProviderOnResourceDecreased(float oldvalue, float newvalue, float maxvalue)
{
StorageModule.AiState = AiState.Enabled;
ChangeState(EnemyState.Alert);
}
@ -85,7 +86,7 @@ public partial class Idle : EnemyStateBase
public override void PhysicsProcessState(double delta)
{
base.PhysicsProcessState(delta);
if (_isPlayerInRange)
if (StorageModule.AiState is AiState.Enabled && _isPlayerInRange)
{
if (PlayerDetection.IsPlayerInSight())
{

View file

@ -18,6 +18,11 @@ public partial class Init : EnemyStateBase
{
GD.Print("Enemy init");
DamageReceiver.HealthProvider.MaxResource = StorageModule.Root.EnemyResource.MaxHealth;
StorageModule.AiState = StorageModule.Root.StartingAiState;
// TODO: Hide wings
// TODO: Hide aiming reticule
StateMachine.SetState(EnemyState.Idle);
}

BIN
Sprites/Actors/Fairy.aseprite (Stored with Git LFS)

Binary file not shown.

BIN
Sprites/Actors/Fairy.png (Stored with Git LFS)

Binary file not shown.