From b00154e2bc4afdc9bf1d3a8a7d9d2c46b499d161 Mon Sep 17 00:00:00 2001 From: Pavel Penev Date: Sun, 27 Oct 2019 11:43:55 +0200 Subject: [PATCH] Created ShakeScreenWarhead and removed the hardcoded shaking from NukeLaunch and MadTank --- OpenRA.Mods.Cnc/Traits/MadTank.cs | 8 ----- OpenRA.Mods.Common/Projectiles/NukeLaunch.cs | 2 -- .../Warheads/ShakeScreenWarhead.cs | 34 +++++++++++++++++++ 3 files changed, 34 insertions(+), 10 deletions(-) create mode 100644 OpenRA.Mods.Common/Warheads/ShakeScreenWarhead.cs diff --git a/OpenRA.Mods.Cnc/Traits/MadTank.cs b/OpenRA.Mods.Cnc/Traits/MadTank.cs index f408e61c2e..558c3addbb 100644 --- a/OpenRA.Mods.Cnc/Traits/MadTank.cs +++ b/OpenRA.Mods.Cnc/Traits/MadTank.cs @@ -33,12 +33,6 @@ namespace OpenRA.Mods.Cnc.Traits [WeaponReference] public readonly string ThumpDamageWeapon = "MADTankThump"; - public readonly int ThumpShakeIntensity = 3; - - public readonly float2 ThumpShakeMultiplier = new float2(1, 0); - - public readonly int ThumpShakeTime = 10; - [Desc("Measured in ticks.")] public readonly int ChargeDelay = 96; @@ -219,8 +213,6 @@ namespace OpenRA.Mods.Cnc.Traits // Use .FromPos since this weapon needs to affect more than just the MadTank actor mad.info.ThumpDamageWeaponInfo.Impact(Target.FromPos(self.CenterPosition), self); } - - screenShaker.AddEffect(mad.info.ThumpShakeTime, self.CenterPosition, mad.info.ThumpShakeIntensity, mad.info.ThumpShakeMultiplier); } if (ticks == mad.info.ChargeDelay) diff --git a/OpenRA.Mods.Common/Projectiles/NukeLaunch.cs b/OpenRA.Mods.Common/Projectiles/NukeLaunch.cs index 1752fa7d04..bd7c36bbf0 100644 --- a/OpenRA.Mods.Common/Projectiles/NukeLaunch.cs +++ b/OpenRA.Mods.Common/Projectiles/NukeLaunch.cs @@ -151,8 +151,6 @@ namespace OpenRA.Mods.Common.Effects weapon.Impact(target, warheadArgs); - world.WorldActor.Trait().AddEffect(20, pos, 5); - foreach (var flash in world.WorldActor.TraitsImplementing()) if (flash.Info.Type == flashType) flash.Enable(-1); diff --git a/OpenRA.Mods.Common/Warheads/ShakeScreenWarhead.cs b/OpenRA.Mods.Common/Warheads/ShakeScreenWarhead.cs new file mode 100644 index 0000000000..c30c8f06f4 --- /dev/null +++ b/OpenRA.Mods.Common/Warheads/ShakeScreenWarhead.cs @@ -0,0 +1,34 @@ +#region Copyright & License Information +/* + * Copyright 2007-2020 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of + * the License, or (at your option) any later version. For more + * information, see COPYING. + */ +#endregion + +using OpenRA.GameRules; +using OpenRA.Traits; + +namespace OpenRA.Mods.Common.Warheads +{ + [Desc("Makes the screen shake.")] + public class ShakeScreenWarhead : Warhead + { + [Desc("Duration of the shaking.")] + public readonly int Duration = 0; + + [Desc("Shake intensity.")] + public readonly int Intensity = 0; + + [Desc("Shake multipliers by the X and Y axis, comma-separated.")] + public readonly float2 Multiplier = new float2(0, 0); + + public override void DoImpact(Target target, WarheadArgs args) + { + args.SourceActor.World.WorldActor.Trait().AddEffect(Duration, target.CenterPosition, Intensity, Multiplier); + } + } +}