Enemy spawning

This commit is contained in:
Marco 2025-06-21 16:44:44 +02:00
commit 29dc9bebe0
20 changed files with 564 additions and 105 deletions

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=308 format=4 uid="uid://c8gtrjf2xeue7"]
[gd_scene load_steps=311 format=4 uid="uid://c8gtrjf2xeue7"]
[ext_resource type="Script" uid="uid://kno58homctew" path="res://addons/func_godot/src/map/func_godot_map.gd" id="1_n6h0p"]
[ext_resource type="Script" uid="uid://crpgy1o73rtlx" path="res://Scripts/Utils/MapProxy3D.cs" id="1_pvlbf"]
@ -66,6 +66,9 @@
[ext_resource type="PackedScene" uid="uid://dx4denbc7xkfm" path="res://3D/Scenes/Props/Posters/Poster_Warning.tscn" id="63_booe2"]
[ext_resource type="PackedScene" uid="uid://d4ek8xjuh6y11" path="res://3D/Scenes/Props/Floor_Emitter_3D.tscn" id="63_r8ono"]
[ext_resource type="Resource" uid="uid://bbogxl60hvdp1" path="res://Resources/BulletScripts/Emitter_Sprial_Test_Bullets.tres" id="64_fi82p"]
[ext_resource type="Script" uid="uid://00rbjdb4mnb0" path="res://Scripts/Actors/EnemyMarker3D.cs" id="65_65jyg"]
[ext_resource type="Resource" uid="uid://4qxicyti4hwr" path="res://Resources/Enemies/Base_Fairy_3D.tres" id="66_despu"]
[ext_resource type="Resource" uid="uid://ccym6mcq4fbul" path="res://Resources/Enemies/Fairy_Guard_3D.tres" id="67_despu"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_fi82p"]
albedo_texture = ExtResource("25_btjo4")
@ -2396,17 +2399,21 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 19.7148, 1, -14.9477)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 26.6877, 2.18087, -13.4121)
[node name="Marker3D" type="Marker3D" parent="Props"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 26.8658, 1.2586, 8.64575)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 26.8658, 1.2586, 9.38215)
script = ExtResource("52_0eudi")
Item = ExtResource("53_0tkve")
AutoSpawn = true
Billboard = true
PixelSize = 0.05
metadata/_edit_group_ = true
[node name="Marker3D2" type="Marker3D" parent="Props"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 14.9355, 1.8352, 17.2582)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 15.1112, 1.8352, 17.1936)
script = ExtResource("52_0eudi")
Item = ExtResource("53_0tkve")
AutoSpawn = true
Billboard = true
PixelSize = 0.05
metadata/_edit_group_ = true
[node name="Marker3D3" type="Marker3D" parent="Props"]
@ -2414,6 +2421,8 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 25.3178, 1.752, 10.5991)
script = ExtResource("52_0eudi")
Item = ExtResource("54_0tkve")
AutoSpawn = true
Billboard = true
PixelSize = 0.05
metadata/_edit_group_ = true
[node name="Door" parent="Props" instance=ExtResource("57_orfn6")]
@ -2424,6 +2433,22 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 24.9526, 1.32944, 25.5859)
Script = ExtResource("64_fi82p")
EmitOnStart = false
[node name="Enemy_Fairy_Test_1" type="Marker3D" parent="Props"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 23.8201, 1.7252, 25.0522)
script = ExtResource("65_65jyg")
Enemy = ExtResource("66_despu")
AutoSpawn = true
Billboard = true
PixelSize = 0.05
[node name="Enemy_Fairy_Test_2" type="Marker3D" parent="Props"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 25.4579, 1.7252, 23.1035)
script = ExtResource("65_65jyg")
Enemy = ExtResource("67_despu")
AutoSpawn = true
Billboard = true
PixelSize = 0.05
[node name="Light" type="Node3D" parent="."]
[node name="OmniLight3D4" type="OmniLight3D" parent="Light"]
@ -2480,4 +2505,5 @@ mesh = SubResource("PlaneMesh_k08ee")
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -4.4781, 5.34499, 23.0014)
[node name="NavigationRegion3D" type="NavigationRegion3D" parent="."]
visible = false
navigation_mesh = SubResource("NavigationMesh_fi82p")

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=60 format=3 uid="uid://ec4m3geediis"]
[gd_scene load_steps=59 format=3 uid="uid://ec4m3geediis"]
[ext_resource type="Script" uid="uid://cvisn0b641od4" path="res://addons/cyclops_level_builder/nodes/cyclops_block.gd" id="1_18fbr"]
[ext_resource type="Script" uid="uid://ba0tf7ihw4hpp" path="res://Scripts/Misc/CameraController3D.cs" id="1_g4gcm"]
@ -19,7 +19,6 @@
[ext_resource type="PackedScene" uid="uid://c8gtrjf2xeue7" path="res://3D/MapScenes/TestLevel.tscn" id="12_g83w3"]
[ext_resource type="Script" uid="uid://dnslcy71dgea" path="res://Scripts/Misc/CameraTarget3D.cs" id="16_e2nai"]
[ext_resource type="PackedScene" uid="uid://cupulrjeeivxm" path="res://3D/MapScenes/TestLevel2.tscn" id="18_e2nai"]
[ext_resource type="PackedScene" uid="uid://bh3vxmqflijgj" path="res://Scenes/Actors/Generic_Enemy_FSM_3D.tscn" id="20_1dvih"]
[sub_resource type="Resource" id="Resource_id3mo"]
script = ExtResource("2_kler0")
@ -501,6 +500,3 @@ TargetPath = NodePath("../CameraTarget")
[node name="TestLevel2" parent="." instance=ExtResource("18_e2nai")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 69.0028, 0, -23.3622)
[node name="FairyGuardFsm" parent="." instance=ExtResource("20_1dvih")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 20.7257, 1.4, 18.9936)

View file

@ -6,9 +6,9 @@
[resource]
script = ExtResource("2_5nrie")
BulletScene = ExtResource("1_l7ter")
BulletSpeed = 2.0
BulletSpeed = 1.8
Direction = Vector2(1, 0)
BulletDamage = 12.0
BulletDamage = 8.0
MaxDamage = 1.0
Knockback = 1.0
LifeTime = 10.0

View file

@ -0,0 +1,24 @@
[gd_resource type="Resource" script_class="BulletResource" load_steps=3 format=3 uid="uid://qrqsywgiij7i"]
[ext_resource type="PackedScene" uid="uid://c133312rx63ps" path="res://Scenes/Weapons/base_enemy_bullet_3D_small.tscn" id="1_pm333"]
[ext_resource type="Script" uid="uid://dslyrfcej3g2n" path="res://Scripts/Resources/BulletResource.cs" id="2_4bl80"]
[resource]
script = ExtResource("2_4bl80")
BulletScene = ExtResource("1_pm333")
BulletSpeed = 2.0
Direction = Vector2(1, 0)
BulletDamage = 12.0
MaxDamage = 1.0
Knockback = 1.0
LifeTime = 10.0
DestroyOnCollision = true
Owner = 2
DamageType = 0
RotateSprite = false
Controllable = false
Freezable = true
Grazeable = true
GrazeValue = 1.0
Attributes = 290
TimeModifiers = []

View file

@ -1,5 +1,6 @@
[gd_resource type="Resource" script_class="EnemyResource" load_steps=16 format=3 uid="uid://cocl3qontm3be"]
[gd_resource type="Resource" script_class="EnemyResource" load_steps=17 format=3 uid="uid://cocl3qontm3be"]
[ext_resource type="SpriteFrames" uid="uid://chjsokgyo0e33" path="res://Resources/Sprites/base_fairy.tres" id="1_ppsgt"]
[ext_resource type="Resource" uid="uid://ct1fa2huvy34n" path="res://Resources/Items/Ammo1.tres" id="1_q1ekm"]
[ext_resource type="Texture2D" uid="uid://xgxxdq37pykh" path="res://Sprites/Actors/Fairy.png" id="1_sxbtw"]
[ext_resource type="Script" uid="uid://cq65aed620ijo" path="res://Scripts/Resources/Loot/LootDrop.cs" id="2_sxbtw"]
@ -64,4 +65,5 @@ MaxStrafeDistance = 16.0
MinStrafeDistance = 8.0
ResponseTime = 0.5
IconSprite = SubResource("AtlasTexture_ppsgt")
AnimationFrames = ExtResource("1_ppsgt")
metadata/_custom_type_script = "uid://cd5o0ceb50jki"

View file

@ -0,0 +1,69 @@
[gd_resource type="Resource" script_class="EnemyResource" load_steps=17 format=3 uid="uid://4qxicyti4hwr"]
[ext_resource type="SpriteFrames" uid="uid://chjsokgyo0e33" path="res://Resources/Sprites/base_fairy.tres" id="1_gbbb4"]
[ext_resource type="Texture2D" uid="uid://xgxxdq37pykh" path="res://Sprites/Actors/Fairy.png" id="1_ihub2"]
[ext_resource type="Script" uid="uid://cq65aed620ijo" path="res://Scripts/Resources/Loot/LootDrop.cs" id="2_gbbb4"]
[ext_resource type="Resource" uid="uid://ct1fa2huvy34n" path="res://Resources/Items/Ammo1.tres" id="3_6fuej"]
[ext_resource type="Resource" uid="uid://dy53gia1tmkah" path="res://Resources/Items/Points_Pickup.tres" id="4_oni0r"]
[ext_resource type="Resource" uid="uid://bhbufxodybsw4" path="res://Resources/Items/Shield_Pickup.tres" id="5_kno8n"]
[ext_resource type="Resource" uid="uid://dodwpect0ldjf" path="res://Resources/Items/Heart_Pickup.tres" id="6_jnpnu"]
[ext_resource type="Resource" uid="uid://clr1gln7nxa1o" path="res://Resources/Items/Power_Pickup.tres" id="7_rx5mb"]
[ext_resource type="Resource" uid="uid://co6x2jq0fslql" path="res://Resources/Weapons/EnemyWeapon_Small_3D.tres" id="8_ihub2"]
[ext_resource type="Script" uid="uid://cd5o0ceb50jki" path="res://Scripts/Resources/EnemyResource.cs" id="9_fmns5"]
[sub_resource type="AtlasTexture" id="AtlasTexture_ppsgt"]
atlas = ExtResource("1_ihub2")
region = Rect2(0, 0, 16, 16)
[sub_resource type="Resource" id="Resource_c8nix"]
script = ExtResource("2_gbbb4")
Item = ExtResource("3_6fuej")
Chance = 40.0
metadata/_custom_type_script = "uid://cq65aed620ijo"
[sub_resource type="Resource" id="Resource_gs2l3"]
script = ExtResource("2_gbbb4")
Item = ExtResource("4_oni0r")
Chance = 10.0
metadata/_custom_type_script = "uid://cq65aed620ijo"
[sub_resource type="Resource" id="Resource_sqnvg"]
script = ExtResource("2_gbbb4")
Item = ExtResource("5_kno8n")
Chance = 5.0
metadata/_custom_type_script = "uid://cq65aed620ijo"
[sub_resource type="Resource" id="Resource_5tyar"]
script = ExtResource("2_gbbb4")
Item = ExtResource("6_jnpnu")
Chance = 5.0
metadata/_custom_type_script = "uid://cq65aed620ijo"
[sub_resource type="Resource" id="Resource_48xq6"]
script = ExtResource("2_gbbb4")
Item = ExtResource("7_rx5mb")
Chance = 6.0
metadata/_custom_type_script = "uid://cq65aed620ijo"
[resource]
script = ExtResource("9_fmns5")
EnemyName = &"Fairy"
EnemyKey = &"FAIRY_BASE"
PrefabPath = &"uid://bh3vxmqflijgj"
MaxHealth = 4.0
MovementSpeed = 1.5
Weapon = ExtResource("8_ihub2")
LootDrops = Array[ExtResource("2_gbbb4")]([SubResource("Resource_c8nix"), SubResource("Resource_gs2l3"), SubResource("Resource_sqnvg"), SubResource("Resource_5tyar"), SubResource("Resource_48xq6")])
MotivationReward = 4.0
PredictPlayer = false
PlayerDetectionRange = 4.0
ViewRange = 5.0
AlarmReactRange = 8.0
PlayerDisengageRange = 10.0
StrafeSpeed = 1.5
MaxStrafeDistance = 1.0
MinStrafeDistance = 0.2
ResponseTime = 0.5
IconSprite = SubResource("AtlasTexture_ppsgt")
AnimationFrames = ExtResource("1_gbbb4")
metadata/_custom_type_script = "uid://cd5o0ceb50jki"

View file

@ -0,0 +1,85 @@
[gd_resource type="SpriteFrames" load_steps=10 format=3 uid="uid://chjsokgyo0e33"]
[ext_resource type="Texture2D" uid="uid://xgxxdq37pykh" path="res://Sprites/Actors/Fairy.png" id="1_ierex"]
[sub_resource type="AtlasTexture" id="AtlasTexture_13sn2"]
atlas = ExtResource("1_ierex")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_qs3gm"]
atlas = ExtResource("1_ierex")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_fppxn"]
atlas = ExtResource("1_ierex")
region = Rect2(0, 32, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_b01sl"]
atlas = ExtResource("1_ierex")
region = Rect2(16, 32, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_jgccb"]
atlas = ExtResource("1_ierex")
region = Rect2(0, 16, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_v7nm4"]
atlas = ExtResource("1_ierex")
region = Rect2(16, 16, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_k8fan"]
atlas = ExtResource("1_ierex")
region = Rect2(0, 48, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_ierex"]
atlas = ExtResource("1_ierex")
region = Rect2(16, 48, 16, 16)
[resource]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_13sn2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qs3gm")
}],
"loop": true,
"name": &"down",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_fppxn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_b01sl")
}],
"loop": true,
"name": &"left",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_jgccb")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_v7nm4")
}],
"loop": true,
"name": &"right",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_k8fan")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_k8fan")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ierex")
}],
"loop": true,
"name": &"up",
"speed": 5.0
}]

View file

@ -1,30 +1,29 @@
[gd_resource type="SpriteFrames" load_steps=11 format=3 uid="uid://cnl6ju3qlr2bj"]
[gd_resource type="SpriteFrames" load_steps=10 format=3 uid="uid://cnl6ju3qlr2bj"]
[ext_resource type="Texture2D" uid="uid://xgxxdq37pykh" path="res://Sprites/Actors/Fairy.png" id="1_jhe43"]
[ext_resource type="Texture2D" uid="uid://callpd48wwnlw" path="res://Sprites/Actors/Fairy_Special.png" id="2_ucisl"]
[sub_resource type="AtlasTexture" id="AtlasTexture_13sn2"]
atlas = ExtResource("1_jhe43")
[sub_resource type="AtlasTexture" id="AtlasTexture_jhe43"]
atlas = ExtResource("2_ucisl")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_qs3gm"]
atlas = ExtResource("1_jhe43")
[sub_resource type="AtlasTexture" id="AtlasTexture_ucisl"]
atlas = ExtResource("2_ucisl")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_fppxn"]
atlas = ExtResource("1_jhe43")
[sub_resource type="AtlasTexture" id="AtlasTexture_t6dpn"]
atlas = ExtResource("2_ucisl")
region = Rect2(0, 32, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_b01sl"]
atlas = ExtResource("1_jhe43")
[sub_resource type="AtlasTexture" id="AtlasTexture_g84mp"]
atlas = ExtResource("2_ucisl")
region = Rect2(16, 32, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_jgccb"]
atlas = ExtResource("1_jhe43")
[sub_resource type="AtlasTexture" id="AtlasTexture_g3joa"]
atlas = ExtResource("2_ucisl")
region = Rect2(0, 16, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_v7nm4"]
atlas = ExtResource("1_jhe43")
[sub_resource type="AtlasTexture" id="AtlasTexture_geb4s"]
atlas = ExtResource("2_ucisl")
region = Rect2(16, 16, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_pt5ys"]
@ -39,10 +38,10 @@ region = Rect2(16, 48, 16, 16)
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_13sn2")
"texture": SubResource("AtlasTexture_jhe43")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qs3gm")
"texture": SubResource("AtlasTexture_ucisl")
}],
"loop": true,
"name": &"down",
@ -50,10 +49,10 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_fppxn")
"texture": SubResource("AtlasTexture_t6dpn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_b01sl")
"texture": SubResource("AtlasTexture_g84mp")
}],
"loop": true,
"name": &"left",
@ -61,10 +60,10 @@ animations = [{
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_jgccb")
"texture": SubResource("AtlasTexture_g3joa")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_v7nm4")
"texture": SubResource("AtlasTexture_geb4s")
}],
"loop": true,
"name": &"right",

View file

@ -0,0 +1,22 @@
[gd_resource type="Resource" script_class="WeaponResource" load_steps=3 format=3 uid="uid://co6x2jq0fslql"]
[ext_resource type="Resource" uid="uid://qrqsywgiij7i" path="res://Resources/Bullets/simple_enemy_bullet_small_3D.tres" id="1_mw07s"]
[ext_resource type="Script" uid="uid://b6fmrnipv88bk" path="res://Scripts/Resources/WeaponResource.cs" id="2_gpx82"]
[resource]
script = ExtResource("2_gpx82")
Name = &"Enemy weapon with big bullets"
BulletData = ExtResource("1_mw07s")
Priority = 0
AmmoPerShot = 1
RateOfFire = 0.6
BulletCapacity = 4
ReloadTime = 1.0
AutoReload = true
InfiniteAmmo = true
ItemKey = &""
AmmoKey = &""
BulletsPerShot = 1
SpreadAngle = 0.0
RandomSpread = 0.0
_rotationOffset = 0.0

View file

@ -24,7 +24,7 @@ height = 0.935884
height = 1.91858
radius = 3.04834
[node name="FairyGuardFsm" type="CharacterBody3D" node_paths=PackedStringArray("EnemyFSM")]
[node name="Enemy" type="CharacterBody3D" node_paths=PackedStringArray("EnemyFSM")]
collision_layer = 64
collision_mask = 17
script = ExtResource("1_a3crc")
@ -74,13 +74,14 @@ script = ExtResource("9_dm2sd")
Storage = NodePath("../../Storage")
_moduleNodes = [NodePath("")]
[node name="AnimatedSprite2D" type="AnimatedSprite3D" parent="."]
[node name="AnimatedSprite3D" type="AnimatedSprite3D" parent="." node_paths=PackedStringArray("EnemyProxy")]
pixel_size = 0.05
billboard = 1
texture_filter = 0
sprite_frames = ExtResource("10_hew1j")
animation = &"down"
script = ExtResource("11_jgarc")
EnemyProxy = NodePath("..")
[node name="Storage" type="Node" parent="." node_paths=PackedStringArray("Root")]
script = ExtResource("11_xne4s")

View file

@ -0,0 +1,29 @@
[gd_scene load_steps=4 format=3 uid="uid://c133312rx63ps"]
[ext_resource type="Script" uid="uid://cg6y36s7buapp" path="res://Scripts/Weapons/Bullet3D.cs" id="1_ojpd6"]
[ext_resource type="Texture2D" uid="uid://bdyd0bht18n47" path="res://Sprites/EnemyProjectile.png" id="2_ojpd6"]
[sub_resource type="SphereShape3D" id="SphereShape3D_pklkt"]
radius = 0.083358
[node name="Bullet" type="Area3D" groups=["bullets"]]
collision_layer = 128
collision_mask = 23
script = ExtResource("1_ojpd6")
Speed = 200.0
metadata/_edit_group_ = true
[node name="Sprite" type="Sprite3D" parent="."]
pixel_size = 0.05
billboard = 1
texture_filter = 0
texture = ExtResource("2_ojpd6")
[node name="CollisionShape" type="CollisionShape3D" parent="."]
shape = SubResource("SphereShape3D_pklkt")
[node name="VisibleOnScreenNotifier" type="VisibleOnScreenNotifier3D" parent="."]
[connection signal="area_entered" from="." to="." method="_on_area_entered"]
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
[connection signal="screen_exited" from="VisibleOnScreenNotifier" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]

View file

@ -0,0 +1,69 @@
using Cirno.Scripts.Components.FSM.Enemy._3D;
using Cirno.Scripts.Resources;
using Cirno.Scripts.Utils;
using Godot;
namespace Cirno.Scripts.Actors;
[Tool]
public partial class EnemyMarker3D : PreviewMarker3D
{
private EnemyResource _enemy;
[Export]
public EnemyResource Enemy
{
get => _enemy;
set
{
_enemy = value;
if (Engine.IsEditorHint())
{
//QueueRedraw();
this.Texture = _enemy.IconSprite;
}
}
}
[Export] public bool AutoSpawn { get; set; } = false;
private EnemyProxy3D _spawnedEnemy;
public override void _Ready()
{
base._Ready();
if (AutoSpawn)
{
Spawn(false);
}
}
public EnemyProxy3D Spawn(bool deleteMarker)
{
if (Engine.IsEditorHint()) return null ;
if (Enemy is null) return null;
if (_spawnedEnemy is not null) return _spawnedEnemy;
if (deleteMarker)
{
this.QueueFree();
}
var enemyScene = GD.Load<PackedScene>(Enemy.PrefabPath);
_spawnedEnemy = this.CreateSibling<EnemyProxy3D>(enemyScene);
_spawnedEnemy.Init(Enemy);
//Spawned = true;
_spawnedEnemy.Death += SpawnedEnemyOnDeath;
return _spawnedEnemy;
}
private void SpawnedEnemyOnDeath(EnemyProxy3D enemy)
{
_spawnedEnemy.Death -= SpawnedEnemyOnDeath;
_spawnedEnemy = null;
//Spawned = false;
}
}

View file

@ -0,0 +1 @@
uid://00rbjdb4mnb0

View file

@ -5,7 +5,7 @@ using Godot;
namespace Cirno.Scripts.Actors;
[Tool]
public partial class ItemMarker3D : Marker3D
public partial class ItemMarker3D : PreviewMarker3D
{
private LootItem _item;
@ -18,15 +18,16 @@ public partial class ItemMarker3D : Marker3D
_item = value;
if (Engine.IsEditorHint())
{
QueueRedraw();
//QueueRedraw();
this.Texture = _item.InventorySprite;
}
}
}
[Export] public bool AutoSpawn { get; set; } = false;
[ExportToolButton("Update Icon")] public Callable RedrawButton => Callable.From(Redraw);
[ExportToolButton("Clear Children")] public Callable ClearChildrenButton => Callable.From(ClearChildren);
// [ExportToolButton("Update Icon")] public Callable RedrawButton => Callable.From(Redraw);
// [ExportToolButton("Clear Children")] public Callable ClearChildrenButton => Callable.From(ClearChildren);
// public override void _Draw()
// {
@ -37,60 +38,61 @@ public partial class ItemMarker3D : Marker3D
// DrawTexture(Item.InventorySprite, - new Vector2(Item.InventorySprite.GetWidth() / 2f, Item.InventorySprite.GetHeight() / 2f));
// }
//
private void Redraw()
{
QueueRedraw();
}
// private void Redraw()
// {
// QueueRedraw();
// }
private void ClearChildren()
{
var children = GetChildren();
foreach (var child in children)
{
if (child is Sprite3D)
{
child.QueueFree();
}
}
_sprite = null;
}
// private void ClearChildren()
// {
// var children = GetChildren();
// foreach (var child in children)
// {
// if (child is Sprite3D)
// {
// child.QueueFree();
// }
// }
//
// _sprite = null;
// }
private void QueueRedraw()
{
if (!Engine.IsEditorHint()) return;
if (Item?.InventorySprite is null) return;
// private void QueueRedraw()
// {
// if (!Engine.IsEditorHint()) return;
// if (Item?.InventorySprite is null) return;
//
// if (_sprite is null)
// {
// GD.Print("Remaking sprite");
// _sprite = new EditorSprite3D();
// this.AddChild(_sprite);
// //_sprite.Owner = GetTree().EditedSceneRoot;
// }
//
// _sprite.Texture = Item.InventorySprite;
// //_sprite.SetRotationDegrees(new Vector3(-45, 45, 0));
// _sprite.FixedSize = true;
// _sprite.SetBillboardMode(BaseMaterial3D.BillboardModeEnum.Enabled);
// _sprite.TextureFilter = BaseMaterial3D.TextureFilterEnum.Nearest;
//
//
// }
if (_sprite is null)
{
GD.Print("Remaking sprite");
_sprite = new EditorSprite3D();
this.AddChild(_sprite);
//_sprite.Owner = GetTree().EditedSceneRoot;
}
_sprite.Texture = Item.InventorySprite;
//_sprite.SetRotationDegrees(new Vector3(-45, 45, 0));
_sprite.FixedSize = true;
_sprite.SetBillboardMode(BaseMaterial3D.BillboardModeEnum.Enabled);
_sprite.TextureFilter = BaseMaterial3D.TextureFilterEnum.Nearest;
}
private Sprite3D _sprite;
//private Sprite3D _sprite;
public override void _Ready()
{
_sprite = GetNodeOrNull<Sprite3D>("Sprite3D");
if (Engine.IsEditorHint())
{
QueueRedraw();
return;
}
ClearChildren();
base._Ready();
// _sprite = GetNodeOrNull<Sprite3D>("Sprite3D");
// if (Engine.IsEditorHint())
// {
// QueueRedraw();
//
// return;
// }
//
// ClearChildren();
if (AutoSpawn)
{

View file

@ -0,0 +1,124 @@
using Godot;
namespace Cirno.Scripts.Actors;
[Tool]
public partial class PreviewMarker3D : Marker3D
{
private Texture2D _texture;
protected Texture2D Texture
{
get => _texture;
set
{
_texture = value;
if (Engine.IsEditorHint())
{
QueueRedraw();
}
}
}
private bool _fixedSize;
private bool _billboard;
private float _pixelSize = 0.1f;
[Export]
protected bool FixedSize
{
get => _fixedSize;
set
{
_fixedSize = value;
if (Engine.IsEditorHint())
{
QueueRedraw();
}
}
}
[Export]
protected bool Billboard
{
get => _billboard;
set
{
_billboard = value;
if (Engine.IsEditorHint())
{
QueueRedraw();
}
}
}
[Export]
protected float PixelSize
{
get => _pixelSize;
set
{
_pixelSize = value;
if (Engine.IsEditorHint())
{
QueueRedraw();
}
}
}
[ExportToolButton("Update Icon")] public Callable RedrawButton => Callable.From(Redraw);
[ExportToolButton("Clear Children")] public Callable ClearChildrenButton => Callable.From(ClearChildren);
private Sprite3D _sprite;
public override void _Ready()
{
_sprite = GetNodeOrNull<Sprite3D>("Sprite3D");
ClearChildren();
if (Engine.IsEditorHint())
{
QueueRedraw();
return;
}
}
private void Redraw()
{
QueueRedraw();
}
private void ClearChildren()
{
var children = GetChildren();
foreach (var child in children)
{
if (child is Sprite3D)
{
child.QueueFree();
}
}
_sprite = null;
}
protected void QueueRedraw()
{
if (!Engine.IsEditorHint()) return;
if (_texture is null) return;
if (_sprite is null)
{
GD.Print("Remaking sprite");
_sprite = new EditorSprite3D();
this.AddChild(_sprite);
//_sprite.Owner = GetTree().EditedSceneRoot;
}
_sprite.Texture = _texture;
//_sprite.SetRotationDegrees(new Vector3(-45, 45, 0));
_sprite.FixedSize = FixedSize;
_sprite.SetBillboardMode(Billboard ? BaseMaterial3D.BillboardModeEnum.Enabled : BaseMaterial3D.BillboardModeEnum.Disabled);
_sprite.TextureFilter = BaseMaterial3D.TextureFilterEnum.Nearest;
_sprite.PixelSize = PixelSize;
}
}

View file

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

View file

@ -1,16 +1,20 @@
using Godot;
using Cirno.Scripts.Resources;
using Godot;
namespace Cirno.Scripts.Components.FSM.Enemy._3D;
public partial class EnemyFSMAnimatedSprite3D : AnimatedSprite3D
{
[Export] public EnemyProxy3D EnemyProxy { get; private set; }
public override void _Ready()
{
var enemyFsmProxy = this.GetParentOrNull<EnemyProxy3D>();
if (enemyFsmProxy?.EnemyResource?.AnimationFrames != null)
{
this.SpriteFrames = enemyFsmProxy.EnemyResource.AnimationFrames;
}
//EnemyProxy.Initialized += EnemyFsmProxyOnInitialized;
this.SpriteFrames = EnemyProxy.EnemyResource.AnimationFrames;
}
private void EnemyFsmProxyOnInitialized(EnemyResource resource)
{
this.SpriteFrames = resource.AnimationFrames;
}
}

View file

@ -26,10 +26,13 @@ public partial class EnemyProxy3D : CharacterBody3D, IActivable
[Signal] public delegate void DeathEventHandler(EnemyProxy3D enemy);
[Signal]
public delegate void InitializedEventHandler(EnemyResource resource);
public void Init(EnemyResource enemyResource)
{
this.EnemyResource = enemyResource;
EmitSignalInitialized(enemyResource);
}
public void TriggerDeath()

View file

@ -3,25 +3,26 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://xgxxdq37pykh"
path="res://.godot/imported/Fairy.png-9c311fb3b635cb0378274ba39e7e42ca.ctex"
path.s3tc="res://.godot/imported/Fairy.png-9c311fb3b635cb0378274ba39e7e42ca.s3tc.ctex"
metadata={
"vram_texture": false
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://Sprites/Actors/Fairy.png"
dest_files=["res://.godot/imported/Fairy.png-9c311fb3b635cb0378274ba39e7e42ca.ctex"]
dest_files=["res://.godot/imported/Fairy.png-9c311fb3b635cb0378274ba39e7e42ca.s3tc.ctex"]
[params]
compress/mode=0
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
@ -31,4 +32,4 @@ 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
detect_3d/compress_to=0

View file

@ -3,25 +3,26 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://bdyd0bht18n47"
path="res://.godot/imported/EnemyProjectile.png-daf1b2f5d48a8e44ecd2aa1375387b0b.ctex"
path.s3tc="res://.godot/imported/EnemyProjectile.png-daf1b2f5d48a8e44ecd2aa1375387b0b.s3tc.ctex"
metadata={
"vram_texture": false
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
}
[deps]
source_file="res://Sprites/EnemyProjectile.png"
dest_files=["res://.godot/imported/EnemyProjectile.png-daf1b2f5d48a8e44ecd2aa1375387b0b.ctex"]
dest_files=["res://.godot/imported/EnemyProjectile.png-daf1b2f5d48a8e44ecd2aa1375387b0b.s3tc.ctex"]
[params]
compress/mode=0
compress/mode=2
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/generate=true
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
@ -31,4 +32,4 @@ 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
detect_3d/compress_to=0