Add ammo consumption and item pickup systems

This commit is contained in:
2025-10-29 00:13:19 +01:00
parent 56ffa8e126
commit 09fa293c81
8 changed files with 113 additions and 9 deletions

View File

@@ -0,0 +1,19 @@
using GameCore.Combat.Interfaces;
using GameCore.Inventory;
namespace GameCore.Combat.Effects;
public class ConsumeAmmoCost(string ammoId, int amount) : ICostEffect
{
public void Execute(EffectContext context)
{
var inventory = context.World.GetComponent<InventoryComponent>(context.Owner);
inventory?.RemoveItem(ammoId, amount);
}
public bool CanAfford(EffectContext context)
{
var inventory = context.World.GetComponent<InventoryComponent>(context.Owner);
return inventory != null && inventory.HasItem(ammoId, amount);
}
}