From c71af0e6133f3ceff17f079236052e21a4870a82 Mon Sep 17 00:00:00 2001 From: Mustafa Alperen Seki Date: Mon, 14 Mar 2022 18:45:59 +0300 Subject: [PATCH] Make NukePower MissileImage optional. --- OpenRA.Mods.Common/Projectiles/NukeLaunch.cs | 27 +++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/OpenRA.Mods.Common/Projectiles/NukeLaunch.cs b/OpenRA.Mods.Common/Projectiles/NukeLaunch.cs index a788076c8a..1bc6b66506 100644 --- a/OpenRA.Mods.Common/Projectiles/NukeLaunch.cs +++ b/OpenRA.Mods.Common/Projectiles/NukeLaunch.cs @@ -47,7 +47,7 @@ namespace OpenRA.Mods.Common.Effects bool isLaunched; bool detonated; - public NukeLaunch(Player firedBy, string name, WeaponInfo weapon, string weaponPalette, string upSequence, string downSequence, + public NukeLaunch(Player firedBy, string image, WeaponInfo weapon, string weaponPalette, string upSequence, string downSequence, WPos launchPos, WPos targetPos, WDist detonationAltitude, bool removeOnDetonation, WDist velocity, int launchDelay, int impactDelay, bool skipAscent, string trailImage, string[] trailSequences, string trailPalette, bool trailUsePlayerPalette, int trailDelay, int trailInterval) @@ -78,7 +78,8 @@ namespace OpenRA.Mods.Common.Effects this.detonationAltitude = detonationAltitude; this.removeOnDetonation = removeOnDetonation; - anim = new Animation(firedBy.World, name); + if (!string.IsNullOrEmpty(image)) + anim = new Animation(firedBy.World, image); pos = skipAscent ? descendSource : ascendSource; } @@ -90,18 +91,25 @@ namespace OpenRA.Mods.Common.Effects if (!isLaunched) { - anim.PlayRepeating(upSequence); if (weapon.Report != null && weapon.Report.Any()) Game.Sound.Play(SoundType.World, weapon.Report, world, pos); - world.ScreenMap.Add(this, pos, anim.Image); + if (anim != null) + { + anim.PlayRepeating(upSequence); + world.ScreenMap.Add(this, pos, anim.Image); + } + isLaunched = true; } - anim.Tick(); + if (anim != null) + { + anim.Tick(); - if (ticks == turn) - anim.PlayRepeating(downSequence); + if (ticks == turn) + anim.PlayRepeating(downSequence); + } var isDescending = ticks >= turn; if (!isDescending) @@ -124,7 +132,8 @@ namespace OpenRA.Mods.Common.Effects if (ticks == impactDelay || (isDescending && dat <= detonationAltitude)) Explode(world, ticks == impactDelay || removeOnDetonation); - world.ScreenMap.Update(this, pos, anim.Image); + if (anim != null) + world.ScreenMap.Update(this, pos, anim.Image); ticks++; } @@ -153,7 +162,7 @@ namespace OpenRA.Mods.Common.Effects public IEnumerable Render(WorldRenderer wr) { - if (!isLaunched) + if (!isLaunched || anim == null) return Enumerable.Empty(); return anim.Render(pos, wr.Palette(weaponPalette));