Add DeathTypes to ShakeOnDeath.

This commit is contained in:
Mustafa Alperen Seki
2020-09-21 15:24:31 +03:00
committed by Paul Chote
parent 1a4b773fda
commit 761d3583c4

View File

@@ -9,12 +9,16 @@
*/
#endregion
using OpenRA.Primitives;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
public class ShakeOnDeathInfo : TraitInfo
{
[Desc("DeathType(s) that trigger the shake. Leave empty to always trigger a shake.")]
public readonly BitSet<DamageType> DeathTypes = default(BitSet<DamageType>);
public readonly int Duration = 10;
public readonly int Intensity = 1;
public override object Create(ActorInitializer init) { return new ShakeOnDeath(this); }
@@ -31,6 +35,9 @@ namespace OpenRA.Mods.Common.Traits
void INotifyKilled.Killed(Actor self, AttackInfo e)
{
if (!info.DeathTypes.IsEmpty && !e.Damage.DamageTypes.Overlaps(info.DeathTypes))
return;
self.World.WorldActor.Trait<ScreenShaker>().AddEffect(info.Duration, self.CenterPosition, info.Intensity);
}
}