Centralized Energy Generation
Energy consumption is now handled by the entity code via the TryConsumeEnergy function, will return false when out of power.
This commit is contained in:
parent
ee0bba31b1
commit
56f97d82f9
7 changed files with 120 additions and 54 deletions
|
|
@ -153,6 +153,11 @@ public class InstantWeapon : Weapon, IProgressBehavior
|
|||
_burstTimer += delta;
|
||||
while (_burstRemaining > 0 && _burstTimer > 0)
|
||||
{
|
||||
if (!Entity.TryConsumeEnergy(Energy))
|
||||
{
|
||||
_burstRemaining = 0;
|
||||
return false;
|
||||
}
|
||||
// If 1 ammo is consumed per shot in the burst, perform ammo consumption here
|
||||
// UseAmmo returns false when triggering reload; cancel firing if that is the case
|
||||
if (!_data.SingleAmmoBurst && !UseAmmo()) return false;
|
||||
|
|
@ -162,7 +167,6 @@ public class InstantWeapon : Weapon, IProgressBehavior
|
|||
OnFire?.Invoke();
|
||||
Item.AddHeat(Heat);
|
||||
Entity.VisibilitySources[this] = Visibility;
|
||||
Entity.Energy -= Energy;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue