Implement ReloadAmmoDelay multiplier.
This commit is contained in:
committed by
reaperrr
parent
c9ff54bfd5
commit
d36973138c
@@ -46,6 +46,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public class ReloadAmmoPool : PausableConditionalTrait<ReloadAmmoPoolInfo>, ITick, INotifyCreated, INotifyAttack, ISync
|
||||
{
|
||||
AmmoPool ammoPool;
|
||||
IReloadAmmoModifier[] modifiers;
|
||||
|
||||
[Sync]
|
||||
int remainingTicks;
|
||||
@@ -56,6 +57,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
void INotifyCreated.Created(Actor self)
|
||||
{
|
||||
ammoPool = self.TraitsImplementing<AmmoPool>().Single(ap => ap.Info.Name == Info.AmmoPool);
|
||||
modifiers = self.TraitsImplementing<IReloadAmmoModifier>().ToArray();
|
||||
remainingTicks = Info.Delay;
|
||||
}
|
||||
|
||||
@@ -79,7 +81,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
if (!ammoPool.FullAmmo() && --remainingTicks == 0)
|
||||
{
|
||||
remainingTicks = reloadDelay;
|
||||
remainingTicks = Util.ApplyPercentageModifiers(reloadDelay, modifiers.Select(m => m.GetReloadAmmoModifier()));
|
||||
if (!string.IsNullOrEmpty(sound))
|
||||
Game.Sound.PlayToPlayer(SoundType.World, self.Owner, sound, self.CenterPosition);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user