mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Chests and Loot Drops
This commit is contained in:
parent
8ec057faf7
commit
a2a18c69fc
20 changed files with 242 additions and 58 deletions
|
|
@ -5,7 +5,9 @@ using Cirno.Scripts.Components.FSM.Enemy;
|
|||
using Cirno.Scripts.Enums;
|
||||
using Cirno.Scripts.Interactables;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Cirno.Scripts.Resources.Loot;
|
||||
using Cirno.Scripts.Resources.Roguelite;
|
||||
using Cirno.Scripts.Utils;
|
||||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
|
|
@ -59,8 +61,9 @@ public partial class RogueliteRoom : Node2D
|
|||
public RogueliteRoom Spawn()
|
||||
{
|
||||
SpawnEnemies();
|
||||
SpawnFeatures();
|
||||
//HandleDoors(connectionChecker);
|
||||
AddDebugLabel();
|
||||
//AddDebugLabel();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -226,12 +229,55 @@ public partial class RogueliteRoom : Node2D
|
|||
var enemyScene = GD.Load<PackedScene>(e.PrefabPath);
|
||||
var spawnedEnemy = spawner.CreateChild<EnemyFSMProxy>(enemyScene);
|
||||
|
||||
spawnedEnemy.OverrideLoot = true;
|
||||
spawnedEnemy.ExtraLoot.Add(new LootDrop()
|
||||
{
|
||||
Item = MapTheme.EnemiesLootTable.Items.ToList().Shuffle().First(),
|
||||
Chance = MapTheme.EnemyDropChance
|
||||
});
|
||||
spawnedEnemy.ExtraLoot.Add(new LootDrop()
|
||||
{
|
||||
Item = MapTheme.PointItemResource,
|
||||
Chance = 100
|
||||
});
|
||||
|
||||
_enemies.Add(spawnedEnemy);
|
||||
|
||||
spawnedEnemy.Death += SpawnedEnemyOnDeath;
|
||||
}
|
||||
}
|
||||
|
||||
private void SpawnFeatures()
|
||||
{
|
||||
// Get feature markers
|
||||
// Roll for chances
|
||||
// Spawn the objects
|
||||
|
||||
var markersContainer = this.GetNodeOrNull("Features");
|
||||
if (markersContainer is null) return;
|
||||
|
||||
var markerNodes = markersContainer.GetChildren();
|
||||
|
||||
foreach (var markerNode in markerNodes)
|
||||
{
|
||||
if (markerNode is not Marker2D marker)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
double chance = GD.RandRange(0d, 100d);
|
||||
if (chance <= MapTheme.ChestChance)
|
||||
{
|
||||
var chest = marker.CreateChild<Chest>(MapTheme.ChestPrefab);
|
||||
|
||||
var loot = MapTheme.ChestLootTable.Items.ToList().Shuffle().First();
|
||||
|
||||
chest.LootTable.Add(loot);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void SpawnedEnemyOnDeath(EnemyFSMProxy enemy)
|
||||
{
|
||||
enemy.Death -= SpawnedEnemyOnDeath;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue