void Reload(Actor self, AmmoPool ammoPool) { if (--ammoPool.RemainingTicks == 0) { // HACK to check if we are on the helipad/airfield/etc. var hostBuilding = self.World.ActorMap.GetActorsAt(self.Location) .FirstOrDefault(a => a.Info.HasTraitInfo <BuildingInfo>()); if (hostBuilding == null || !hostBuilding.IsInWorld) { return; } foreach (var host in hostBuilding.TraitsImplementing <INotifyRearm>()) { host.Rearming(hostBuilding, self); } ammoPool.RemainingTicks = ammoPool.Info.ReloadDelay; if (!string.IsNullOrEmpty(ammoPool.Info.RearmSound)) { Game.Sound.PlayToPlayer(SoundType.World, self.Owner, ammoPool.Info.RearmSound, self.CenterPosition); } ammoPool.GiveAmmo(self, ammoPool.Info.ReloadCount); } }
void ITick.Tick(Actor self) { if (IsTraitDisabled) { return; } if (--delay < 0) { pool.GiveAmmo(self, 1); delay = info.ReloadDelay; } }
void ITick.Tick(Actor self) { if (IsTraitDisabled) { return; } if (--delay < 0) { if (pool.GiveAmmo(self, info.ReloadCount) && pool.Info.RearmSound != null) { Game.Sound.Play(SoundType.World, pool.Info.RearmSound, self.CenterPosition); } delay = info.ReloadDelay; } }
void Reload(Actor self, Actor host, AmmoPool ammoPool) { if (--ammoPool.RemainingTicks <= 0) { foreach (var notify in host.TraitsImplementing <INotifyRearm>()) { notify.Rearming(host, self); } ammoPool.RemainingTicks = ammoPool.Info.ReloadDelay; if (!string.IsNullOrEmpty(ammoPool.Info.RearmSound)) { Game.Sound.PlayToPlayer(SoundType.World, self.Owner, ammoPool.Info.RearmSound, self.CenterPosition); } ammoPool.GiveAmmo(self, ammoPool.Info.ReloadCount); } }
protected virtual void Reload(Actor self, int reloadDelay, int reloadCount, string sound) { if (--remainingDelay > 0 && ammoPool.HasAmmo) { return; } if (!ammoPool.HasFullAmmo && --remainingTicks == 0) { remainingTicks = Util.ApplyPercentageModifiers(reloadDelay, modifiers.Select(m => m.GetReloadAmmoModifier())); if (!string.IsNullOrEmpty(sound)) { Game.Sound.PlayToPlayer(SoundType.World, self.Owner, sound, self.CenterPosition); } ammoPool.GiveAmmo(self, reloadCount); } }