Add more NPCs, update dialogue manager to 4.4 compatible version

This commit is contained in:
2025-03-12 00:29:39 -07:00
parent 76b94f7be3
commit 22c9590442
167 changed files with 5874 additions and 5697 deletions

View File

@@ -58,66 +58,66 @@ public partial class Map : Node3D, IMap
public void OnResolved()
{
FloorScenes = [];
FloorScenes = [];
MapChunk = new SaveChunk<MapData>(
onSave: (chunk) => new MapData()
{
FloorScenes = FloorScenes,
},
onLoad: (chunk, data) =>
{
FloorScenes = data.FloorScenes;
}
);
MapChunk = new SaveChunk<MapData>(
onSave: (chunk) => new MapData()
{
FloorScenes = FloorScenes,
},
onLoad: (chunk, data) =>
{
FloorScenes = data.FloorScenes;
}
);
GameChunk.AddChunk(MapChunk);
GameChunk.AddChunk(MapChunk);
this.Provide();
this.Provide();
}
public void LoadMap()
{
foreach (var floor in _floors)
FloorScenes.Add(floor.ResourcePath);
foreach (var floor in _floors)
FloorScenes.Add(floor.ResourcePath);
LoadFloor();
CurrentFloor.InitializeDungeon();
var transform = GetPlayerSpawnPosition();
Player.TeleportPlayer(transform);
CurrentFloor.FloorIsLoaded = true;
Game.NextFloorLoaded();
LoadFloor();
CurrentFloor.InitializeDungeon();
var transform = GetPlayerSpawnPosition();
Player.TeleportPlayer(transform);
CurrentFloor.FloorIsLoaded = true;
Game.NextFloorLoaded();
}
public void SpawnNextFloor()
{
var oldFloor = CurrentFloor;
oldFloor.CallDeferred(MethodName.QueueFree, []);
LoadFloor();
CurrentFloor.InitializeDungeon();
var transform = GetPlayerSpawnPosition();
Player.TeleportPlayer(transform);
CurrentFloor.FloorIsLoaded = true;
Game.NextFloorLoaded();
CurrentFloorNumber += 1;
var oldFloor = CurrentFloor;
oldFloor.CallDeferred(MethodName.QueueFree, []);
LoadFloor();
CurrentFloor.InitializeDungeon();
var transform = GetPlayerSpawnPosition();
Player.TeleportPlayer(transform);
CurrentFloor.FloorIsLoaded = true;
Game.NextFloorLoaded();
CurrentFloorNumber += 1;
}
public IDungeonRoom GetPlayersCurrentRoom()
{
var rooms = CurrentFloor.Rooms;
var playersRoom = rooms.SingleOrDefault(x => x.IsPlayerInRoom);
return playersRoom;
var rooms = CurrentFloor.Rooms;
var playersRoom = rooms.SingleOrDefault(x => x.IsPlayerInRoom);
return playersRoom;
}
public Transform3D GetPlayerSpawnPosition() => CurrentFloor.GetPlayerSpawnPoint();
private void LoadFloor()
{
var currentFloorScene = FloorScenes.First();
var instantiator = new Instantiator(GetTree());
var loadedScene = instantiator.LoadAndInstantiate<Node3D>(currentFloorScene);
AddChild(loadedScene);
CurrentFloor = (IDungeonFloor)loadedScene;
FloorScenes.Remove(currentFloorScene);
var currentFloorScene = FloorScenes.First();
var instantiator = new Instantiator(GetTree());
var loadedScene = instantiator.LoadAndInstantiate<Node3D>(currentFloorScene);
AddChild(loadedScene);
CurrentFloor = (IDungeonFloor)loadedScene;
FloorScenes.Remove(currentFloorScene);
}
}

View File

@@ -14,6 +14,6 @@
[node name="Map" type="Node3D"]
script = ExtResource("1_bw70o")
_floors = Array[PackedScene]([ExtResource("2_0m8h8"), ExtResource("2_merfv"), ExtResource("4_8y0oy"), ExtResource("5_uag72"), ExtResource("6_55rmo"), ExtResource("7_f6kwn"), ExtResource("8_ne2vg"), ExtResource("9_abpbr"), ExtResource("10_caf7v"), ExtResource("11_y74f3")])
_floors = Array[PackedScene]([ExtResource("2_0m8h8"), ExtResource("11_y74f3"), ExtResource("2_merfv"), ExtResource("4_8y0oy"), ExtResource("5_uag72"), ExtResource("6_55rmo"), ExtResource("7_f6kwn"), ExtResource("8_ne2vg"), ExtResource("9_abpbr"), ExtResource("10_caf7v")])
[node name="WorldEnvironment" type="WorldEnvironment" parent="."]

View File

@@ -24,41 +24,41 @@ public partial class DungeonFloor : Node3D, IDungeonFloor
public void InitializeDungeon()
{
Rooms = [];
Rooms = FindAllDungeonRooms([.. GetChildren()], Rooms);
_playerSpawnPoint = RandomizePlayerSpawnPoint();
var monsterRooms = Rooms.OfType<MonsterRoom>();
foreach (var room in monsterRooms)
room.SpawnEnemies(EnemyDatabase);
DungeonGenerator.EmitSignal("done_generating");
Rooms = [];
Rooms = FindAllDungeonRooms([.. GetChildren()], Rooms);
_playerSpawnPoint = RandomizePlayerSpawnPoint();
var monsterRooms = Rooms.OfType<MonsterRoom>();
foreach (var room in monsterRooms)
room.SpawnEnemies(EnemyDatabase);
DungeonGenerator.EmitSignal("done_generating");
}
public Transform3D GetPlayerSpawnPoint() => new Transform3D(_playerSpawnPoint.Basis, new Vector3(_playerSpawnPoint.Origin.X, -1.75f, _playerSpawnPoint.Origin.Z));
private Transform3D RandomizePlayerSpawnPoint()
{
var randomSpawnLocations = Rooms
.OfType<MonsterRoom>()
.Select(x => x.PlayerSpawn);
var godotCollection = new Godot.Collections.Array<Marker3D>(randomSpawnLocations);
var result = godotCollection.PickRandom();
return result.GlobalTransform;
var randomSpawnLocations = Rooms
.OfType<MonsterRoom>()
.Select(x => x.PlayerSpawn);
var godotCollection = new Godot.Collections.Array<Marker3D>(randomSpawnLocations);
var result = godotCollection.PickRandom();
return result.GlobalTransform;
}
private static ImmutableList<IDungeonRoom> FindAllDungeonRooms(List<Node> nodesToSearch, ImmutableList<IDungeonRoom> roomsFound)
{
if (nodesToSearch.Count == 0)
return roomsFound;
if (nodesToSearch.Count == 0)
return roomsFound;
foreach (var node in nodesToSearch)
{
if (node is IDungeonRoom dungeonRoom)
roomsFound = roomsFound.Add(dungeonRoom);
foreach (var node in nodesToSearch)
{
if (node is IDungeonRoom dungeonRoom)
roomsFound = roomsFound.Add(dungeonRoom);
if (node.HasSignal("dungeon_done_generating"))
node.EmitSignal("dungeon_done_generating");
}
if (node.HasSignal("dungeon_done_generating"))
node.EmitSignal("dungeon_done_generating");
}
return FindAllDungeonRooms(nodesToSearch.SelectMany(x => x.GetChildren()).ToList(), roomsFound);
return FindAllDungeonRooms(nodesToSearch.SelectMany(x => x.GetChildren()).ToList(), roomsFound);
}
}

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=99 format=4 uid="uid://crf30tibwsnri"]
[gd_scene load_steps=100 format=4 uid="uid://crf30tibwsnri"]
[ext_resource type="Script" uid="uid://ce73fuh74l81l" path="res://addons/SimpleDungeons/DungeonRoom3D.gd" id="1_bglxp"]
[ext_resource type="Script" uid="uid://dhollu4j3pynq" path="res://src/map/dungeon/code/MonsterRoom.cs" id="2_5aadh"]
@@ -30,6 +30,7 @@
[ext_resource type="Texture2D" uid="uid://da42up4mv46kj" path="res://src/map/dungeon/models/Set A/16. Seshat's Room/16_A1_SESHATS_ROOM_claude-monet.jpg" id="24_t8nkf"]
[ext_resource type="Material" uid="uid://bsafm3t4drpl" path="res://src/map/dungeon/textures/MinimapTexture.tres" id="25_25af7"]
[ext_resource type="Texture2D" uid="uid://b5hbvxvxl8gn6" path="res://src/map/dungeon/models/Set A/16. Seshat's Room/16_A1_SESHATS_ROOM_Single-Peacock-Feather-Transparent-Free-PNG.png" id="25_77sl0"]
[ext_resource type="Texture2D" uid="uid://bt1n54xtem20m" path="res://src/npc/Seshat/seshat.png" id="31_1cfoy"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_qg4wx"]
resource_name = "Material.024"
@@ -1073,6 +1074,7 @@ skeleton = NodePath("")
[node name="ROOM" type="MeshInstance3D" parent="Model/Seshat\'s Room/16_A1_SESHATS_ROOM"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -7.18809, 14.7067, 47.3259)
visible = false
mesh = SubResource("ArrayMesh_1wv4u")
skeleton = NodePath("")
@@ -1280,3 +1282,9 @@ mesh = SubResource("PlaneMesh_s0txx")
skeleton = NodePath("../..")
[node name="NPC" type="Node3D" parent="."]
[node name="Sprite3D" type="Sprite3D" parent="NPC"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.967271, 0.0981301, -0.047853)
pixel_size = 0.005
billboard = 2
texture = ExtResource("31_1cfoy")

View File

@@ -1,4 +1,4 @@
[gd_scene load_steps=78 format=4 uid="uid://cw33vpar237pm"]
[gd_scene load_steps=79 format=4 uid="uid://cw33vpar237pm"]
[ext_resource type="Script" uid="uid://ce73fuh74l81l" path="res://addons/SimpleDungeons/DungeonRoom3D.gd" id="1_m4la0"]
[ext_resource type="Script" uid="uid://dhollu4j3pynq" path="res://src/map/dungeon/code/MonsterRoom.cs" id="2_56tk6"]
@@ -28,6 +28,7 @@
[ext_resource type="Texture2D" uid="uid://dgmxl2uu287k4" path="res://src/map/dungeon/models/Set A/17. Gesthemii's Room/17_A1_GESTHEMIIS_ROOM_outside_desert.png" id="21_6gfr6"]
[ext_resource type="Texture2D" uid="uid://d0q55hxiafsye" path="res://src/map/dungeon/models/Set A/17. Gesthemii's Room/17_A1_GESTHEMIIS_ROOM_RUG_GETHSTEMI.png" id="22_uayj1"]
[ext_resource type="Texture2D" uid="uid://dix6yhpcu52jv" path="res://src/map/dungeon/models/Set A/17. Gesthemii's Room/17_A1_GESTHEMIIS_ROOM_mottled.png" id="23_rrfdh"]
[ext_resource type="PackedScene" uid="uid://b5tl2jawmvwtd" path="res://src/npc/Gesthesemii/Gesthemii.tscn" id="29_43nhx"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_loa1y"]
resource_name = "Material.014"
@@ -1036,3 +1037,8 @@ visible = false
layers = 2
mesh = SubResource("PlaneMesh_s0txx")
skeleton = NodePath("../..")
[node name="NPC" type="Node3D" parent="."]
[node name="Gesthemii" parent="NPC" instance=ExtResource("29_43nhx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0431279, -0.710172, 2.12679)