Enemy loot table, start revamping floor node code structure

This commit is contained in:
2026-06-10 17:07:49 -07:00
parent e889709a91
commit fc598ab48f
18 changed files with 103 additions and 20 deletions
@@ -45,6 +45,8 @@ namespace Zennysoft.Ma.Adapter.Entity
public void SetEnemySpeedByMultiplier(double multiplier); public void SetEnemySpeedByMultiplier(double multiplier);
public IEnemyLootTable LootTable { get; }
public int InitialHP { get; } public int InitialHP { get; }
public int InitialAttack { get; } public int InitialAttack { get; }
@@ -0,0 +1,6 @@
namespace Zennysoft.Ma.Adapter.Entity;
public interface IEnemyLootTable
{
}
+4
View File
@@ -40,6 +40,10 @@ public abstract partial class Enemy : CharacterBody3D, IEnemy, IProvide<IEnemyLo
public virtual IEnemyModelView EnemyModelView { get; set; } = default!; public virtual IEnemyModelView EnemyModelView { get; set; } = default!;
public IEnemyLootTable LootTable => _lootTable;
[Export] public EnemyLootTable _lootTable { get; set; }
public Vector3 TargetPosition { get; private set; } public Vector3 TargetPosition { get; private set; }
[ExportGroup("Enemy Stats")] [ExportGroup("Enemy Stats")]
@@ -0,0 +1,13 @@
using Godot;
using Godot.Collections;
using Zennysoft.Ma.Adapter.Entity;
namespace Zennysoft.Game.Ma;
[GlobalClass]
public partial class EnemyLootTable : Resource, IEnemyLootTable
{
[Export]
public Array<InventoryItemStats> Items { get; set; } = [];
}
@@ -0,0 +1 @@
uid://bei3s7yr6xkc0
@@ -1,8 +1,12 @@
[gd_scene load_steps=16 format=3 uid="uid://crsy7gygjy317"] [gd_scene load_steps=21 format=3 uid="uid://crsy7gygjy317"]
[ext_resource type="Script" uid="uid://cq6b4ma3sy1en" path="res://src/enemy/enemy_types/01. sproingy/Sproingy.cs" id="1_xsluo"] [ext_resource type="Script" uid="uid://cq6b4ma3sy1en" path="res://src/enemy/enemy_types/01. sproingy/Sproingy.cs" id="1_xsluo"]
[ext_resource type="Resource" uid="uid://d0cxrf0nldona" path="res://src/items/consumable/resources/Somalata Electuary.tres" id="3_4i0u2"]
[ext_resource type="Resource" uid="uid://75fpkwfp0t0k" path="res://src/items/consumable/resources/Catholicon Draught.tres" id="3_515no"]
[ext_resource type="Script" uid="uid://bei3s7yr6xkc0" path="res://src/enemy/EnemyLootTable.cs" id="4_515no"]
[ext_resource type="PackedScene" uid="uid://cn4fv2gv6raql" path="res://src/enemy/behaviors/PatrolBehavior.tscn" id="4_drfkj"] [ext_resource type="PackedScene" uid="uid://cn4fv2gv6raql" path="res://src/enemy/behaviors/PatrolBehavior.tscn" id="4_drfkj"]
[ext_resource type="PackedScene" uid="uid://bjcqrhtifpcvr" path="res://src/enemy/enemy_types/01. sproingy/SproingyModelView.tscn" id="4_o3b7p"] [ext_resource type="PackedScene" uid="uid://bjcqrhtifpcvr" path="res://src/enemy/enemy_types/01. sproingy/SproingyModelView.tscn" id="4_o3b7p"]
[ext_resource type="Resource" uid="uid://d2rdaghcccw0f" path="res://src/items/jewels/resources/MeditativeOrb.tres" id="4_orghr"]
[ext_resource type="PackedScene" uid="uid://cmhem5xknjsvc" path="res://src/enemy/behaviors/EngagePlayerBehavior.tscn" id="5_drfkj"] [ext_resource type="PackedScene" uid="uid://cmhem5xknjsvc" path="res://src/enemy/behaviors/EngagePlayerBehavior.tscn" id="5_drfkj"]
[ext_resource type="PackedScene" uid="uid://cve5oouhowtff" path="res://src/enemy/behaviors/FollowBehavior.tscn" id="6_moun4"] [ext_resource type="PackedScene" uid="uid://cve5oouhowtff" path="res://src/enemy/behaviors/FollowBehavior.tscn" id="6_moun4"]
[ext_resource type="AudioStream" uid="uid://ba8xendacec6" path="res://src/audio/sfx/item_kyuu_layer_2.ogg" id="6_ungov"] [ext_resource type="AudioStream" uid="uid://ba8xendacec6" path="res://src/audio/sfx/item_kyuu_layer_2.ogg" id="6_ungov"]
@@ -10,6 +14,11 @@
[ext_resource type="AudioStream" uid="uid://bf7adfdd857hw" path="res://src/audio/sfx/enemy_morph.ogg" id="8_agkuf"] [ext_resource type="AudioStream" uid="uid://bf7adfdd857hw" path="res://src/audio/sfx/enemy_morph.ogg" id="8_agkuf"]
[ext_resource type="AudioStream" uid="uid://bn6ns3jxkw03b" path="res://src/audio/sfx/ENEMY_SPROING_death.ogg" id="9_icstk"] [ext_resource type="AudioStream" uid="uid://bn6ns3jxkw03b" path="res://src/audio/sfx/ENEMY_SPROING_death.ogg" id="9_icstk"]
[sub_resource type="Resource" id="Resource_fa44e"]
script = ExtResource("4_515no")
Items = [ExtResource("3_4i0u2"), ExtResource("3_515no"), ExtResource("4_orghr")]
metadata/_custom_type_script = "uid://bei3s7yr6xkc0"
[sub_resource type="CapsuleShape3D" id="CapsuleShape3D_cwfph"] [sub_resource type="CapsuleShape3D" id="CapsuleShape3D_cwfph"]
radius = 0.106078 radius = 0.106078
height = 1.23076 height = 1.23076
@@ -39,6 +48,7 @@ axis_lock_linear_y = true
axis_lock_angular_x = true axis_lock_angular_x = true
axis_lock_angular_z = true axis_lock_angular_z = true
script = ExtResource("1_xsluo") script = ExtResource("1_xsluo")
_lootTable = SubResource("Resource_fa44e")
[node name="CollisionShape" type="CollisionShape3D" parent="."] [node name="CollisionShape" type="CollisionShape3D" parent="."]
unique_name_in_owner = true unique_name_in_owner = true
@@ -96,7 +106,6 @@ unique_name_in_owner = true
[node name="FollowBehavior" parent="Components" instance=ExtResource("6_moun4")] [node name="FollowBehavior" parent="Components" instance=ExtResource("6_moun4")]
unique_name_in_owner = true unique_name_in_owner = true
_followSpeed = 150.0
[node name="EngagePlayerBehavior" parent="Components" instance=ExtResource("5_drfkj")] [node name="EngagePlayerBehavior" parent="Components" instance=ExtResource("5_drfkj")]
unique_name_in_owner = true unique_name_in_owner = true
@@ -31,8 +31,12 @@ ATK = ""
DEF = "" DEF = ""
Affinity = "" Affinity = ""
Weakness = "" Weakness = ""
Drop1 = "" PrimaryAttackName = ""
Drop2 = "" PrimaryAttackType = 0
SecondaryAttackName = ""
SecondaryAttackType = 0
TertiaryAttackName = ""
TertiaryAttackType = 0
metadata/_custom_type_script = ExtResource("4_5eid5") metadata/_custom_type_script = ExtResource("4_5eid5")
[sub_resource type="CylinderShape3D" id="CylinderShape3D_qbmfg"] [sub_resource type="CylinderShape3D" id="CylinderShape3D_qbmfg"]
@@ -100,7 +104,6 @@ unique_name_in_owner = true
[node name="FollowBehavior" parent="Components" instance=ExtResource("6_fccr3")] [node name="FollowBehavior" parent="Components" instance=ExtResource("6_fccr3")]
unique_name_in_owner = true unique_name_in_owner = true
_followSpeed = 150.0
[node name="EngagePlayerBehavior" parent="Components" instance=ExtResource("7_8l567")] [node name="EngagePlayerBehavior" parent="Components" instance=ExtResource("7_8l567")]
unique_name_in_owner = true unique_name_in_owner = true
+9 -4
View File
@@ -479,10 +479,15 @@ public partial class Game : Node3D, IGame
restorative.GlobalPosition = new Vector3(vector.X, 2f, vector.Z) + (-_player.GetGlobalBasis().Z); restorative.GlobalPosition = new Vector3(vector.X, 2f, vector.Z) + (-_player.GetGlobalBasis().Z);
} }
private void DropItem(Vector3 vector) private void DropItem(IEnemyLootTable lootTable, Vector3 vector)
{ {
var randomItem = ItemDatabase.Instance.PickItem<IBaseInventoryItem>() as Node3D; var enemyLootTable = lootTable as EnemyLootTable;
var duplicated = randomItem.Duplicate((int)DuplicateFlags.UseInstantiation) as Node3D;
if (lootTable == null || enemyLootTable.Items.Count <= 0)
return;
var randomItem = enemyLootTable.Items.PickRandom();
var pickedItem = ItemDatabase.Instance.Items.Single(x => x.ItemName == randomItem.Name) as Node3D;
var duplicated = pickedItem.Duplicate((int)DuplicateFlags.UseInstantiation) as Node3D;
AddChild(duplicated); AddChild(duplicated);
duplicated.GlobalPosition = new Vector3(vector.X, 2f, vector.Z) + (-_player.GetGlobalBasis().Z); duplicated.GlobalPosition = new Vector3(vector.X, 2f, vector.Z) + (-_player.GetGlobalBasis().Z);
} }
@@ -898,7 +903,7 @@ public partial class Game : Node3D, IGame
var rng = new RandomNumberGenerator(); var rng = new RandomNumberGenerator();
rng.Randomize(); rng.Randomize();
if (rng.Randf() < 0.15f) if (rng.Randf() < 0.15f)
DropItem(obj.GlobalPosition); DropItem(obj.LootTable, obj.GlobalPosition);
else else
DropRestorative(obj.GlobalPosition); DropRestorative(obj.GlobalPosition);
} }
@@ -0,0 +1,11 @@
using Godot;
namespace Zennysoft.Game.Ma;
[GlobalClass]
public partial class FloorResourceType : Resource
{
[Export] public string FloorDisplayName { get; set; }
[Export] public string FolderPath { get; set; }
}
@@ -0,0 +1 @@
uid://bvacb3ih0qt6u
+4
View File
@@ -2,6 +2,7 @@ using Chickensoft.AutoInject;
using Chickensoft.Collections; using Chickensoft.Collections;
using Chickensoft.Introspection; using Chickensoft.Introspection;
using Godot; using Godot;
using Godot.Collections;
using System; using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -35,6 +36,9 @@ public partial class Map : Node3D, IMap
public event Action<(Vector3 Rotation, Vector3 Position)> SpawnPointCreated; public event Action<(Vector3 Rotation, Vector3 Position)> SpawnPointCreated;
[Export]
public Array<FloorResourceType> FloorOrder { get; set; } = [];
public event Action FloorLoaded; public event Action FloorLoaded;
private string _sceneName; private string _sceneName;
+13 -5
View File
@@ -1,9 +1,16 @@
[gd_scene load_steps=8 format=3 uid="uid://by67pn7fdsg1m"] [gd_scene load_steps=10 format=3 uid="uid://by67pn7fdsg1m"]
[ext_resource type="Script" uid="uid://14e8mu48ed4" path="res://src/map/Map.cs" id="1_bw70o"] [ext_resource type="Script" uid="uid://14e8mu48ed4" path="res://src/map/Map.cs" id="1_bw70o"]
[ext_resource type="Script" uid="uid://bvacb3ih0qt6u" path="res://src/map/FloorResourceType.cs" id="2_0qcd2"]
[ext_resource type="Script" uid="uid://dbe3wf3ywtjqh" path="res://src/map/DungeonFloorNode.cs" id="2_00xd7"] [ext_resource type="Script" uid="uid://dbe3wf3ywtjqh" path="res://src/map/DungeonFloorNode.cs" id="2_00xd7"]
[ext_resource type="Script" uid="uid://dpj4qg0ip6yui" path="res://src/map/SpecialFloorNode.cs" id="3_v14r0"] [ext_resource type="Script" uid="uid://dpj4qg0ip6yui" path="res://src/map/SpecialFloorNode.cs" id="3_v14r0"]
[sub_resource type="Resource" id="Resource_s7lwc"]
script = ExtResource("2_0qcd2")
FloorDisplayName = ""
FolderPath = ""
metadata/_custom_type_script = "uid://bvacb3ih0qt6u"
[sub_resource type="Animation" id="Animation_00xd7"] [sub_resource type="Animation" id="Animation_00xd7"]
length = 0.001 length = 0.001
tracks/0/type = "value" tracks/0/type = "value"
@@ -58,6 +65,7 @@ _data = {
[node name="Map" type="Node3D"] [node name="Map" type="Node3D"]
script = ExtResource("1_bw70o") script = ExtResource("1_bw70o")
FloorOrder = Array[ExtResource("2_0qcd2")]([SubResource("Resource_s7lwc")])
[node name="AnimationPlayer" type="AnimationPlayer" parent="."] [node name="AnimationPlayer" type="AnimationPlayer" parent="."]
unique_name_in_owner = true unique_name_in_owner = true
@@ -155,7 +163,7 @@ DisplayedFloorNumber = "07"
[node name="Boss Floor 1" type="Node" parent="MapOrder"] [node name="Boss Floor 1" type="Node" parent="MapOrder"]
script = ExtResource("3_v14r0") script = ExtResource("3_v14r0")
FloorName = 2 FloorName = 2
DisplayedFloorNumber = "???" DisplayedFloorNumber = "08"
[node name="Floor09" type="Node" parent="MapOrder"] [node name="Floor09" type="Node" parent="MapOrder"]
script = ExtResource("2_00xd7") script = ExtResource("2_00xd7")
@@ -223,17 +231,17 @@ DisplayedFloorNumber = "15"
[node name="Boss Floor 2" type="Node" parent="MapOrder"] [node name="Boss Floor 2" type="Node" parent="MapOrder"]
script = ExtResource("3_v14r0") script = ExtResource("3_v14r0")
FloorName = 3 FloorName = 3
DisplayedFloorNumber = "???" DisplayedFloorNumber = "16"
[node name="Goddess of Guidance Floor" type="Node" parent="MapOrder"] [node name="Goddess of Guidance Floor" type="Node" parent="MapOrder"]
script = ExtResource("3_v14r0") script = ExtResource("3_v14r0")
FloorName = 4 FloorName = 4
DisplayedFloorNumber = "???" DisplayedFloorNumber = "17"
[node name="Final Floor" type="Node" parent="MapOrder"] [node name="Final Floor" type="Node" parent="MapOrder"]
script = ExtResource("3_v14r0") script = ExtResource("3_v14r0")
FloorName = 6 FloorName = 6
DisplayedFloorNumber = "???" DisplayedFloorNumber = "18"
[node name="ColorRect" type="ColorRect" parent="."] [node name="ColorRect" type="ColorRect" parent="."]
anchors_preset = 15 anchors_preset = 15
@@ -6,4 +6,4 @@ public partial class SpecialFloorNode : FloorNode
{ {
[Export] [Export]
public SpecialFloorType FloorName { get; set; } public SpecialFloorType FloorName { get; set; }
} }
@@ -0,0 +1,9 @@
using Godot;
namespace Zennysoft.Game.Ma;
[GlobalClass]
public partial class SpecialFloorObject : FloorResourceType
{
//[Export] public SpecialFloorType specialFloorType { get; set; }
}
@@ -0,0 +1 @@
uid://ckwwyj2f7rmih
@@ -8,5 +8,10 @@ public enum SpecialFloorType
BossFloorB, BossFloorB,
GoddessOfGuidanceFloor, GoddessOfGuidanceFloor,
TrueGoddessOfGuidanceFloor, TrueGoddessOfGuidanceFloor,
FinalFloor FinalFloor,
Server,
Cellular,
River,
Grassy,
Space
} }
@@ -16,9 +16,9 @@ public partial class SpecialFloor : Node3D, IDungeonFloor
public virtual void InitializeDungeon() public virtual void InitializeDungeon()
{ {
FloorIsLoaded = true; FloorIsLoaded = true;
} }
public bool FloorIsLoaded { get; set; } public bool FloorIsLoaded { get; set; }
public virtual (Vector3 Rotation, Vector3 Position) GetPlayerSpawnPoint() => (PlayerSpawnPoint.Rotation, new Vector3(PlayerSpawnPoint.Position.X, 0, PlayerSpawnPoint.Position.Z)); public virtual (Vector3 Rotation, Vector3 Position) GetPlayerSpawnPoint() => (PlayerSpawnPoint.Rotation, new Vector3(PlayerSpawnPoint.Position.X, 0, PlayerSpawnPoint.Position.Z));
} }
File diff suppressed because one or more lines are too long