Spawn items
This commit is contained in:
@@ -1,59 +1,42 @@
|
||||
[gd_scene load_steps=11 format=3 uid="uid://bn4gslp2gk8ds"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://bn4gslp2gk8ds"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/SimpleDungeons/DungeonRoom3D.gd" id="1_y0rqi"]
|
||||
[ext_resource type="Texture2D" uid="uid://n4ds85jp0aq0" path="res://src/map/dungeon/textures/map_ceiling.jpg" id="2_6scux"]
|
||||
[ext_resource type="PackedScene" uid="uid://ckaw6wjmi0fom" path="res://src/map/dungeon/door/Door.tscn" id="2_vpnlr"]
|
||||
[ext_resource type="Script" path="res://src/map/dungeon/corridor/remove_unused_doors.gd" id="3_8i1ij"]
|
||||
[ext_resource type="Texture2D" uid="uid://bidlc5a6lft6" path="res://src/map/dungeon/textures/map_brickwall.jpg" id="4_6qf87"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nsah4"]
|
||||
transparency = 1
|
||||
albedo_texture = ExtResource("2_6scux")
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_kdikn"]
|
||||
albedo_color = Color(1, 1, 0, 1)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_18cgv"]
|
||||
albedo_texture = ExtResource("2_6scux")
|
||||
uv1_scale = Vector3(0.23, 0.23, 0.23)
|
||||
uv1_triplanar = true
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ej8w2"]
|
||||
albedo_texture = ExtResource("4_6qf87")
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_oy7nu"]
|
||||
albedo_texture = ExtResource("4_6qf87")
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_qay2n"]
|
||||
albedo_color = Color(1, 1, 0, 1)
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_7myha"]
|
||||
size = Vector2(10, 10)
|
||||
|
||||
[node name="Corridor" type="Node3D"]
|
||||
script = ExtResource("1_y0rqi")
|
||||
min_count = 1
|
||||
max_count = 1
|
||||
|
||||
[node name="CSGBox3D" type="CSGBox3D" parent="."]
|
||||
use_collision = true
|
||||
size = Vector3(10, 10, 10)
|
||||
material = SubResource("StandardMaterial3D_nsah4")
|
||||
material = SubResource("StandardMaterial3D_kdikn")
|
||||
|
||||
[node name="CSGBox3D" type="CSGBox3D" parent="CSGBox3D"]
|
||||
operation = 2
|
||||
size = Vector3(9, 9, 9)
|
||||
material = SubResource("StandardMaterial3D_18cgv")
|
||||
material = SubResource("StandardMaterial3D_qay2n")
|
||||
|
||||
[node name="DOOR?4" parent="CSGBox3D" instance=ExtResource("2_vpnlr")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.58627, 5)
|
||||
material = SubResource("StandardMaterial3D_ej8w2")
|
||||
|
||||
[node name="DOOR?5" parent="CSGBox3D" instance=ExtResource("2_vpnlr")]
|
||||
transform = Transform3D(-0.0899894, 0, 0.995943, 0, 1, 0, -0.995943, 0, -0.0899894, -4.7076, -2.586, 0)
|
||||
material = SubResource("StandardMaterial3D_ej8w2")
|
||||
|
||||
[node name="DOOR?6" parent="CSGBox3D" instance=ExtResource("2_vpnlr")]
|
||||
transform = Transform3D(-0.0899894, 0, 0.995943, 0, 1, 0, -0.995943, 0, -0.0899894, 4.73741, -2.586, 0)
|
||||
material = SubResource("StandardMaterial3D_ej8w2")
|
||||
|
||||
[node name="DOOR?2" parent="CSGBox3D" instance=ExtResource("2_vpnlr")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.58627, -5)
|
||||
material = SubResource("StandardMaterial3D_oy7nu")
|
||||
|
||||
[node name="RemoveUnusedDoors" type="Node" parent="."]
|
||||
script = ExtResource("3_8i1ij")
|
||||
|
||||
@@ -23,6 +23,10 @@ public partial class DungeonRoom : Node3D, IDungeonRoom, IProvide<DungeonRoomLog
|
||||
|
||||
[Node] public Marker3D PlayerSpawn { get; set; } = default!;
|
||||
|
||||
[Node] public Node3D ItemSpawnPoints { get; set; } = default!;
|
||||
|
||||
[Node] public ItemDatabase ItemDatabase { get; set; } = default!;
|
||||
|
||||
public DungeonRoomLogic.IBinding DungeonRoomBinding { get; set; } = default!;
|
||||
|
||||
public void Setup()
|
||||
@@ -30,6 +34,28 @@ public partial class DungeonRoom : Node3D, IDungeonRoom, IProvide<DungeonRoomLog
|
||||
DungeonRoomLogic = new DungeonRoomLogic();
|
||||
DungeonRoomLogic.Set(this as IDungeonRoom);
|
||||
DungeonRoomLogic.Set(GameRepo);
|
||||
PopulateRoom();
|
||||
}
|
||||
|
||||
private void PopulateRoom()
|
||||
{
|
||||
var itemSpawnPoints = ItemSpawnPoints.GetChildren();
|
||||
var rng = new RandomNumberGenerator();
|
||||
rng.Randomize();
|
||||
var numberOfItemsToSpawn = rng.RandiRange(0, itemSpawnPoints.Count);
|
||||
itemSpawnPoints.Shuffle();
|
||||
foreach (Marker3D spawnPoint in itemSpawnPoints)
|
||||
{
|
||||
if (numberOfItemsToSpawn <= 0)
|
||||
break;
|
||||
numberOfItemsToSpawn--;
|
||||
|
||||
var item = ItemDatabase.ItemScene[rng.RandWeighted(ItemDatabase.DropRate)];
|
||||
var instantiatedItem = item.Instantiate<Weapon>();
|
||||
instantiatedItem.Position = spawnPoint.Position;
|
||||
AddChild(instantiatedItem);
|
||||
GD.Print(instantiatedItem.InventoryInfo.Name);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnResolved()
|
||||
|
||||
@@ -1,42 +1,49 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://dhpwwqow1ahrc"]
|
||||
[gd_scene load_steps=10 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="Texture2D" uid="uid://bidlc5a6lft6" path="res://src/map/dungeon/textures/map_brickwall.jpg" id="2_rw3uc"]
|
||||
[ext_resource type="PackedScene" uid="uid://twrj4wixcbu7" path="res://src/items/ItemDatabase.tscn" id="4_2mnb7"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_gt3ar"]
|
||||
albedo_texture = ExtResource("2_rw3uc")
|
||||
uv1_scale = Vector3(0.105, 0.105, 0.105)
|
||||
uv1_triplanar = true
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_nin6j"]
|
||||
albedo_color = Color(1, 0, 0.0784314, 1)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_5j6ws"]
|
||||
albedo_color = Color(1, 0, 0.0784314, 1)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_it7n4"]
|
||||
albedo_color = Color(1, 0, 0.0784314, 1)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_05l2p"]
|
||||
albedo_color = Color(1, 0, 0.0784314, 1)
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_luhnj"]
|
||||
size = Vector2(10, 10)
|
||||
|
||||
[node name="DungeonRoom3D" type="Node3D"]
|
||||
script = ExtResource("1_0tfda")
|
||||
min_count = 1
|
||||
max_count = 3
|
||||
|
||||
[node name="DungeonRoom" type="Node3D" parent="."]
|
||||
script = ExtResource("1_ti7ur")
|
||||
|
||||
[node name="CSGBox3D" type="CSGBox3D" parent="."]
|
||||
material_override = SubResource("StandardMaterial3D_gt3ar")
|
||||
use_collision = true
|
||||
size = Vector3(10, 10, 10)
|
||||
material = SubResource("StandardMaterial3D_nin6j")
|
||||
|
||||
[node name="CSGBox3D2" type="CSGBox3D" parent="CSGBox3D"]
|
||||
material_override = SubResource("StandardMaterial3D_gt3ar")
|
||||
operation = 2
|
||||
use_collision = true
|
||||
size = Vector3(9, 9, 9)
|
||||
material = SubResource("StandardMaterial3D_5j6ws")
|
||||
|
||||
[node name="DOOR" parent="CSGBox3D" instance=ExtResource("2_mdawx")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.54039, 4.74571)
|
||||
material = SubResource("StandardMaterial3D_it7n4")
|
||||
|
||||
[node name="DOOR2" parent="CSGBox3D" instance=ExtResource("2_mdawx")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.58282, -4.73548)
|
||||
material = SubResource("StandardMaterial3D_05l2p")
|
||||
|
||||
[node name="PlayerSpawn" type="Marker3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
@@ -46,3 +53,13 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -4.23461, 0)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -4.9805, 0)
|
||||
layers = 2
|
||||
mesh = SubResource("PlaneMesh_luhnj")
|
||||
|
||||
[node name="ItemSpawnPoints" type="Node3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="ItemSpawn1" type="Marker3D" parent="ItemSpawnPoints"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2.54295, -4.48909, -2.92704)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="ItemDatabase" parent="." instance=ExtResource("4_2mnb7")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://bbwgmqy3evhh2"]
|
||||
[gd_scene load_steps=10 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://ckaw6wjmi0fom" path="res://src/map/dungeon/door/Door.tscn" id="4_nh0nj"]
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_b8kax"]
|
||||
@@ -10,14 +11,18 @@ albedo_color = Color(0.0470588, 0, 1, 1)
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_1h648"]
|
||||
albedo_color = Color(0.0470588, 0, 1, 1)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_u3mvg"]
|
||||
albedo_color = Color(0.0470588, 0, 1, 1)
|
||||
|
||||
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_ham86"]
|
||||
albedo_color = Color(0.0470588, 0, 1, 1)
|
||||
|
||||
[sub_resource type="PlaneMesh" id="PlaneMesh_j8q3j"]
|
||||
size = Vector2(50, 10)
|
||||
|
||||
[node name="DungeonRoom3D" type="Node3D"]
|
||||
script = ExtResource("1_o02dd")
|
||||
size_in_voxels = Vector3i(5, 1, 1)
|
||||
min_count = 1
|
||||
max_count = 2
|
||||
|
||||
[node name="DungeonRoom" type="Node3D" parent="."]
|
||||
script = ExtResource("2_jrlll")
|
||||
@@ -35,24 +40,42 @@ size = Vector3(49, 9, 9)
|
||||
material = SubResource("StandardMaterial3D_1h648")
|
||||
|
||||
[node name="DOOR" parent="CSGBox3D" instance=ExtResource("4_nh0nj")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.54039, 4.74571)
|
||||
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, 25, -2.5, 0)
|
||||
material = SubResource("StandardMaterial3D_u3mvg")
|
||||
|
||||
[node name="DOOR2" parent="CSGBox3D" instance=ExtResource("4_nh0nj")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.58282, -4.73548)
|
||||
transform = Transform3D(-4.37114e-08, 0, -1, 0, 1, 0, 1, 0, -4.37114e-08, -24.578, -2.5, 0)
|
||||
material = SubResource("StandardMaterial3D_ham86")
|
||||
|
||||
[node name="PlayerSpawn" type="Marker3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -4.23461, 0)
|
||||
|
||||
[node name="ItemSpawnPoints" type="Node3D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
[node name="ItemSpawn1" type="Marker3D" parent="ItemSpawnPoints"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -15.3383, -4.48909, -2.92704)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="ItemSpawn2" type="Marker3D" parent="ItemSpawnPoints"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 8.50278, -4.48909, -2.92704)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="ItemSpawn3" type="Marker3D" parent="ItemSpawnPoints"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 3.08441, -4.48909, 2.87214)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="ItemSpawn4" type="Marker3D" parent="ItemSpawnPoints"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -16.3726, -4.48909, 2.87214)
|
||||
gizmo_extents = 1.0
|
||||
|
||||
[node name="EnemySpawnPoints" type="Node3D" parent="."]
|
||||
|
||||
[node name="Minimap Texture" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -4.50433, 0)
|
||||
layers = 2
|
||||
mesh = SubResource("PlaneMesh_j8q3j")
|
||||
|
||||
[node name="ItemDatabase" parent="." instance=ExtResource("4_c51bx")]
|
||||
unique_name_in_owner = true
|
||||
|
||||
Reference in New Issue
Block a user