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

@@ -27,12 +27,21 @@ public class WeaponSystem : ISystem
if (input.IsFiring && weapon.CooldownTimer <= 0f)
{
// Check for ammo if applicable
var context = new EffectContext { World = world, Owner = entity };
foreach (var effect in weapon.OnFireEffects) effect.Execute(context);
var canFire = true;
foreach (var cost in weapon.FireCosts)
if (!cost.CanAfford(context))
{
canFire = false;
//TODO: Publish an event or notify the player they can't fire
break;
}
if (!canFire) continue;
foreach (var cost in weapon.FireCosts) cost.Execute(context);
foreach (var effect in weapon.OnFireEffects) effect.Execute(context);
world.PublishEvent(new WeaponFiredEvent(entity, input.MuzzlePosition));
weapon.CooldownTimer = 1f / weapon.FireRate;
}