Add custom DeathTypes/DamageTypes support to RevealOnDeath

This commit is contained in:
reaperrr
2017-04-24 19:07:31 +02:00
parent 7dddc7fc44
commit a9676235db

View File

@@ -9,6 +9,7 @@
*/ */
#endregion #endregion
using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.Mods.Common.Effects; using OpenRA.Mods.Common.Effects;
using OpenRA.Traits; using OpenRA.Traits;
@@ -30,6 +31,10 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Can this actor be revealed through shroud generated by the GeneratesShroud trait?")] [Desc("Can this actor be revealed through shroud generated by the GeneratesShroud trait?")]
public readonly bool RevealGeneratedShroud = true; public readonly bool RevealGeneratedShroud = true;
[Desc("DeathTypes for which shroud will be revealed.",
"Use an empty list (the default) to allow all DeathTypes.")]
public readonly HashSet<string> DeathTypes = new HashSet<string>();
public override object Create(ActorInitializer init) { return new RevealOnDeath(init.Self, this); } public override object Create(ActorInitializer init) { return new RevealOnDeath(init.Self, this); }
} }
@@ -51,6 +56,9 @@ namespace OpenRA.Mods.Common.Traits
if (!self.IsInWorld) if (!self.IsInWorld)
return; return;
if (info.DeathTypes.Count > 0 && !attack.Damage.DamageTypes.Overlaps(info.DeathTypes))
return;
var owner = self.Owner; var owner = self.Owner;
if (owner != null && owner.WinState == WinState.Undefined) if (owner != null && owner.WinState == WinState.Undefined)
{ {