Item spawning
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://u1e5ae7whhxg"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://bc1sp6xwe0j65"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/SimpleDungeons/DungeonGenerator3D.gd" id="1_sr15j"]
|
||||
[ext_resource type="PackedScene" uid="uid://dhpwwqow1ahrc" path="res://src/map/dungeon/rooms/Room1.tscn" id="2_dvdf4"]
|
||||
|
||||
@@ -14,12 +14,15 @@ public partial class Overworld : Node3D, IDungeonFloor
|
||||
|
||||
[Node] public Area3D NPCBox { get; set; } = default!;
|
||||
|
||||
[Node] public Marker3D PlayerSpawnPoint { get; set; } = default!;
|
||||
|
||||
[Export] public Resource Dialogue { get; set; }
|
||||
|
||||
public void InitializeDungeon()
|
||||
{
|
||||
NPCBox.AreaEntered += NPCBox_AreaEntered;
|
||||
NPCBox.AreaExited += NPCBox_AreaExited;
|
||||
GameRepo.SetPlayerGlobalPosition(PlayerSpawnPoint.GlobalPosition);
|
||||
}
|
||||
|
||||
private void NPCBox_AreaExited(Area3D area)
|
||||
|
||||
@@ -3,6 +3,7 @@ using Chickensoft.GodotNodeInterfaces;
|
||||
using Chickensoft.Introspection;
|
||||
using GameJamDungeon;
|
||||
using Godot;
|
||||
using System.Linq;
|
||||
|
||||
public interface IDungeonRoom : INode3D
|
||||
{
|
||||
@@ -38,6 +39,7 @@ public partial class DungeonRoom : Node3D, IDungeonRoom, IProvide<DungeonRoomLog
|
||||
DungeonRoomLogic = new DungeonRoomLogic();
|
||||
DungeonRoomLogic.Set(this as IDungeonRoom);
|
||||
DungeonRoomLogic.Set(GameRepo);
|
||||
ItemDatabase.SpawnItems();
|
||||
SpawnItems();
|
||||
SpawnEnemies();
|
||||
}
|
||||
@@ -55,11 +57,13 @@ public partial class DungeonRoom : Node3D, IDungeonRoom, IProvide<DungeonRoomLog
|
||||
break;
|
||||
numberOfItemsToSpawn--;
|
||||
|
||||
var item = ItemDatabase.ItemScene[rng.RandWeighted(ItemDatabase.DropRate)];
|
||||
var instantiatedItem = item.Instantiate<InventoryItem>();
|
||||
instantiatedItem.Position = spawnPoint.Position;
|
||||
AddChild(instantiatedItem);
|
||||
GD.Print(instantiatedItem.Info.Name);
|
||||
var weights = ItemDatabase.Database.Select(x => x.SpawnRate).ToArray();
|
||||
var database = ItemDatabase.Database.Select(x => x.Item).ToArray();
|
||||
var selectedItem = database[rng.RandWeighted(weights)];
|
||||
var duplicated = selectedItem.Duplicate((int)DuplicateFlags.UseInstantiation) as InventoryItem;
|
||||
duplicated.Position = spawnPoint.Position;
|
||||
AddChild(duplicated);
|
||||
GD.Print(duplicated.Info.Name);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
[gd_scene load_steps=14 format=3 uid="uid://dhpwwqow1ahrc"]
|
||||
[gd_scene load_steps=13 format=3 uid="uid://dhpwwqow1ahrc"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/SimpleDungeons/DungeonRoom3D.gd" id="1_0tfda"]
|
||||
[ext_resource type="Script" path="res://src/map/dungeon/rooms/DungeonRoom.cs" id="1_ti7ur"]
|
||||
[ext_resource type="PackedScene" uid="uid://ckaw6wjmi0fom" path="res://src/map/dungeon/door/Door.tscn" id="2_mdawx"]
|
||||
[ext_resource type="PackedScene" uid="uid://twrj4wixcbu7" path="res://src/items/ItemDatabase.tscn" id="4_2mnb7"]
|
||||
[ext_resource type="PackedScene" uid="uid://cgwtjleqvgubc" path="res://src/items/weapons/SealingRod.tscn" id="4_ivbn2"]
|
||||
[ext_resource type="PackedScene" uid="uid://dbvr8ewajja6a" path="res://src/enemy/EnemyDatabase.tscn" id="5_owpbq"]
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_luhnj"]
|
||||
@@ -61,11 +60,10 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.053, -3, 0)
|
||||
|
||||
[node name="ItemDatabase" parent="." instance=ExtResource("4_2mnb7")]
|
||||
unique_name_in_owner = true
|
||||
ItemScene = Array[PackedScene]([ExtResource("4_ivbn2")])
|
||||
DropRate = PackedFloat32Array(0)
|
||||
|
||||
[node name="EnemyDatabase" parent="." instance=ExtResource("5_owpbq")]
|
||||
unique_name_in_owner = true
|
||||
SpawnRate = PackedFloat32Array(1)
|
||||
|
||||
[node name="CSGBox3D" type="CSGBox3D" parent="."]
|
||||
use_collision = true
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
[gd_scene load_steps=15 format=3 uid="uid://bbwgmqy3evhh2"]
|
||||
[gd_scene load_steps=14 format=3 uid="uid://bbwgmqy3evhh2"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/SimpleDungeons/DungeonRoom3D.gd" id="1_o02dd"]
|
||||
[ext_resource type="Script" path="res://src/map/dungeon/rooms/DungeonRoom.cs" id="2_jrlll"]
|
||||
[ext_resource type="PackedScene" uid="uid://twrj4wixcbu7" path="res://src/items/ItemDatabase.tscn" id="4_c51bx"]
|
||||
[ext_resource type="PackedScene" uid="uid://cgwtjleqvgubc" path="res://src/items/weapons/SealingRod.tscn" id="4_n2mpv"]
|
||||
[ext_resource type="PackedScene" uid="uid://ckaw6wjmi0fom" path="res://src/map/dungeon/door/Door.tscn" id="4_nh0nj"]
|
||||
[ext_resource type="PackedScene" uid="uid://dbvr8ewajja6a" path="res://src/enemy/EnemyDatabase.tscn" id="5_fabiq"]
|
||||
|
||||
@@ -77,11 +76,10 @@ mesh = SubResource("PlaneMesh_j8q3j")
|
||||
|
||||
[node name="ItemDatabase" parent="." instance=ExtResource("4_c51bx")]
|
||||
unique_name_in_owner = true
|
||||
ItemScene = Array[PackedScene]([ExtResource("4_n2mpv")])
|
||||
DropRate = PackedFloat32Array(1)
|
||||
|
||||
[node name="EnemyDatabase" parent="." instance=ExtResource("5_fabiq")]
|
||||
unique_name_in_owner = true
|
||||
SpawnRate = PackedFloat32Array(1)
|
||||
|
||||
[node name="CSGBox3D" type="CSGBox3D" parent="."]
|
||||
use_collision = true
|
||||
|
||||
Reference in New Issue
Block a user