Add event publishing for inventory and combat interactions
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using GameCore.Combat.Interfaces;
|
||||
using GameCore.Events;
|
||||
using GameCore.Inventory;
|
||||
|
||||
namespace GameCore.Combat.Effects;
|
||||
@@ -8,7 +9,12 @@ 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);
|
||||
if (inventory == null) return;
|
||||
|
||||
inventory.RemoveItem(ammoId, amount);
|
||||
|
||||
var newQuantity = inventory.GetItemCount(ammoId);
|
||||
context.World.PublishEvent(new InventoryItemChangedEvent(context.Owner, ammoId, newQuantity));
|
||||
}
|
||||
|
||||
public bool CanAfford(EffectContext context)
|
||||
|
||||
Reference in New Issue
Block a user