Created ShakeScreenWarhead and removed the hardcoded shaking from NukeLaunch and MadTank

This commit is contained in:
Pavel Penev
2019-10-27 11:43:55 +02:00
committed by abcdefg30
parent 6220d7e62e
commit b00154e2bc
3 changed files with 34 additions and 10 deletions

View File

@@ -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)

View File

@@ -151,8 +151,6 @@ namespace OpenRA.Mods.Common.Effects
weapon.Impact(target, warheadArgs);
world.WorldActor.Trait<ScreenShaker>().AddEffect(20, pos, 5);
foreach (var flash in world.WorldActor.TraitsImplementing<FlashPaletteEffect>())
if (flash.Info.Type == flashType)
flash.Enable(-1);

View File

@@ -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<ScreenShaker>().AddEffect(Duration, target.CenterPosition, Intensity, Multiplier);
}
}
}