mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 11:15:33 +00:00
Chests and Loot Drops
This commit is contained in:
parent
8ec057faf7
commit
a2a18c69fc
20 changed files with 242 additions and 58 deletions
|
|
@ -6,7 +6,7 @@ namespace Cirno.Scripts.Components.FSM.Enemy;
|
|||
|
||||
public partial class EnemyDropsProvider : Node2D
|
||||
{
|
||||
private RandomNumberGenerator _rng = new();
|
||||
//private RandomNumberGenerator _rng = new();
|
||||
|
||||
[Export] public float DropRadius { get; private set; } = 8f;
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ public partial class EnemyDropsProvider : Node2D
|
|||
{
|
||||
if (loot is { Item: not null })
|
||||
{
|
||||
float roll = _rng.RandfRange(0f, 100f); // Generate a number between 0 and 100
|
||||
float roll = (float)GD.RandRange(0d, 100d); // Generate a number between 0 and 100
|
||||
if (roll <= loot.Chance) // Compare with drop chance
|
||||
{
|
||||
DropItem(loot.Item);
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@ public partial class EnemyFSMProxy : CharacterBody2D, IActivable
|
|||
[Export] public EnemyResource EnemyResource { get; private set; }
|
||||
|
||||
[Export] public Array<LootDrop> ExtraLoot { get; private set; } = [];
|
||||
|
||||
[Export] public bool OverrideLoot { get; set; } = false;
|
||||
|
||||
[Export]
|
||||
public AiState StartingAiState { get; private set; }
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public partial class EnemyStorageModule : Node2D, IFSMStorage
|
|||
|
||||
public float MovementSpeed => Root.EnemyResource.MovementSpeed;
|
||||
|
||||
public IEnumerable<LootDrop> LootDrops => Root.EnemyResource.LootDrops.Concat(Root.ExtraLoot);
|
||||
public IEnumerable<LootDrop> LootDrops => Root.OverrideLoot ? Root.ExtraLoot : Root.EnemyResource.LootDrops.Concat(Root.ExtraLoot);
|
||||
|
||||
public AiState AiState { get; set; }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue