mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Random weapons from pool
This commit is contained in:
parent
a2a18c69fc
commit
57ff504628
6 changed files with 71 additions and 8 deletions
|
|
@ -62,6 +62,7 @@ public partial class RogueliteRoom : Node2D
|
|||
{
|
||||
SpawnEnemies();
|
||||
SpawnFeatures();
|
||||
SpawnFixedWeapons();
|
||||
//HandleDoors(connectionChecker);
|
||||
//AddDebugLabel();
|
||||
return this;
|
||||
|
|
@ -203,8 +204,6 @@ public partial class RogueliteRoom : Node2D
|
|||
|
||||
_connections.Add(connection);
|
||||
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -247,6 +246,56 @@ public partial class RogueliteRoom : Node2D
|
|||
}
|
||||
}
|
||||
|
||||
private void SpawnFixedWeapons()
|
||||
{
|
||||
var markersContainer = this.GetNodeOrNull("Treasures");
|
||||
if (markersContainer == null) return;
|
||||
|
||||
var markerNodes = markersContainer.GetChildren();
|
||||
|
||||
var itemsPool = MapTheme.WeaponsLootTable.Items.ToList().Shuffle().ToList();
|
||||
|
||||
var playerItems = InventoryManager.Instance.Items;
|
||||
|
||||
foreach (var itemContainer in playerItems)
|
||||
{
|
||||
if (itemsPool.Contains(itemContainer.Item))
|
||||
{
|
||||
itemsPool.Remove(itemContainer.Item);
|
||||
}
|
||||
}
|
||||
|
||||
if (itemsPool.Count == 0)
|
||||
{
|
||||
GD.Print("No items to spawn in the item room found");
|
||||
return;
|
||||
}
|
||||
|
||||
Queue<LootItem> spawnQueue = new();
|
||||
foreach (var item in itemsPool)
|
||||
{
|
||||
spawnQueue.Enqueue(item);
|
||||
}
|
||||
|
||||
foreach (var markerNode in markerNodes)
|
||||
{
|
||||
if (markerNode is not Marker2D marker)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var itemFound = spawnQueue.TryDequeue(out var item);
|
||||
|
||||
if (!itemFound) return;
|
||||
|
||||
GD.Print($"Spawning {item.ItemKey} in treasure spot");
|
||||
|
||||
// Spawn
|
||||
var dropScene = GD.Load<PackedScene>(item.DropScenePath);
|
||||
var dropInstance = marker.CreateChild<Node2D>(dropScene);
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnFeatures()
|
||||
{
|
||||
// Get feature markers
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue