Add DamageTypes to SoundOnDamageTransition.
This commit is contained in:
committed by
Paul Chote
parent
761d3583c4
commit
3e83346915
@@ -9,6 +9,7 @@
|
|||||||
*/
|
*/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits.Sound
|
namespace OpenRA.Mods.Common.Traits.Sound
|
||||||
@@ -21,6 +22,9 @@ namespace OpenRA.Mods.Common.Traits.Sound
|
|||||||
[Desc("Play a random sound from this list when destroyed.")]
|
[Desc("Play a random sound from this list when destroyed.")]
|
||||||
public readonly string[] DestroyedSounds = { };
|
public readonly string[] DestroyedSounds = { };
|
||||||
|
|
||||||
|
[Desc("DamageType(s) that trigger the sounds. Leave empty to always trigger a sound.")]
|
||||||
|
public readonly BitSet<DamageType> DamageTypes = default(BitSet<DamageType>);
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new SoundOnDamageTransition(this); }
|
public override object Create(ActorInitializer init) { return new SoundOnDamageTransition(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,6 +39,9 @@ namespace OpenRA.Mods.Common.Traits.Sound
|
|||||||
|
|
||||||
void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e)
|
void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
|
if (!info.DamageTypes.IsEmpty && !e.Damage.DamageTypes.Overlaps(info.DamageTypes))
|
||||||
|
return;
|
||||||
|
|
||||||
var rand = Game.CosmeticRandom;
|
var rand = Game.CosmeticRandom;
|
||||||
|
|
||||||
if (e.DamageState == DamageState.Dead)
|
if (e.DamageState == DamageState.Dead)
|
||||||
|
|||||||
Reference in New Issue
Block a user