diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-10-24 21:25:15 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-10-24 21:25:15 -0300 |
| commit | 639cd8cef403e9e66bf31e7888e786effac2b292 (patch) | |
| tree | a1b3872a91ad599a71629d0d62c72125138c5c14 /scripts/Map/DungeonGenerator.cs | |
| parent | 52c32a24044aa574c9e7bf7aa4e2499349cc36b2 (diff) | |
refactor: Sistema de itens reescrito
Em tese, este novo sistema é mais fácil de serializar.
Descanse em paz pergaminhos, eu não quero reimplementá-los
neste novo sistema.
Diffstat (limited to 'scripts/Map/DungeonGenerator.cs')
| -rw-r--r-- | scripts/Map/DungeonGenerator.cs | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/scripts/Map/DungeonGenerator.cs b/scripts/Map/DungeonGenerator.cs index 7dee0b4..7e447b0 100644 --- a/scripts/Map/DungeonGenerator.cs +++ b/scripts/Map/DungeonGenerator.cs @@ -21,10 +21,9 @@ public partial class DungeonGenerator : Node GD.Load<EnemyDefinition>("res://assets/definitions/actor/Shadow.tres"), ]; - private static readonly Godot.Collections.Array<ConsumableItemDefinition> items = [ - GD.Load<HealingConsumableDefinition>("res://assets/definitions/Items/small_healing_potion.tres"), - GD.Load<ScrollConsumableDefinition>("res://assets/definitions/Items/mana_bolt_scroll.tres"), - GD.Load<GrimoireConsumableDefinition>("res://assets/definitions/Items/mana_bolt_grimoire.tres") + private static readonly Godot.Collections.Array<ItemResource> items = [ + GD.Load<ItemResource>("res://assets/definitions/Items/small_healing_potion.tres"), + GD.Load<ItemResource>("res://assets/definitions/Items/mana_bolt_grimoire.tres") ]; /// <summary> @@ -275,7 +274,7 @@ public partial class DungeonGenerator : Node rng.RandiRange(room.Position.Y, room.End.Y - 1) ); - bool canPlace = true; + bool canPlace = items.Count > 0; foreach (Entity entity in data.Entities) { if (entity.GridPosition == position) @@ -288,21 +287,10 @@ public partial class DungeonGenerator : Node // Se possível, criamos um inimigo aleatório na posição escolhida. if (canPlace) { - ConsumableItemDefinition definition = items.PickRandom(); - if (definition is HealingConsumableDefinition hcDefinition) - { - HealingConsumable item = new(position, data, hcDefinition); - data.InsertEntity(item); - } - else if (definition is ScrollConsumableDefinition scroll) - { - ScrollConsumable item = new(position, data, scroll); - data.InsertEntity(item); - } else if (definition is GrimoireConsumableDefinition grimoire) - { - GrimoireConsumable item = new(position, data, grimoire); - data.InsertEntity(item); - } + ItemResource itemRes = items.PickRandom(); + Item item = new(itemRes); + ItemEntity itemEnt = new(position, data, item); + data.InsertEntity(itemEnt); } } } |
