Add configurable DamageState/Type filters to WithSmoke.
This commit is contained in:
@@ -9,20 +9,30 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using OpenRA.Graphics;
|
||||
using OpenRA.Mods.Common.Warheads;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
[Desc("Renders an overlay when the actor is taking heavy damage.")]
|
||||
public class WithSmokeInfo : ITraitInfo, Requires<RenderSpritesInfo>
|
||||
public class WithSmokeInfo : ITraitInfo, Requires<RenderSpritesInfo> // TODO: rename to WithDamageOverlay
|
||||
{
|
||||
public readonly string Sequence = "smoke_m";
|
||||
public readonly string Sequence = "smoke_m"; // TODO: rename to image
|
||||
|
||||
[SequenceReference("Sequence")] public readonly string IdleSequence = "idle";
|
||||
[SequenceReference("Sequence")] public readonly string LoopSequence = "loop";
|
||||
[SequenceReference("Sequence")] public readonly string EndSequence = "end";
|
||||
|
||||
[Desc("Damage types that this should be used for (defined on the warheads).",
|
||||
"Leave empty to disable all filtering.")]
|
||||
public readonly HashSet<string> DamageTypes = new HashSet<string>();
|
||||
|
||||
[Desc("Trigger when Undamaged, Light, Medium, Heavy, Critical or Dead.")]
|
||||
public readonly DamageState MinimumDamageState = DamageState.Heavy;
|
||||
public readonly DamageState MaximumDamageState = DamageState.Dead;
|
||||
|
||||
public object Create(ActorInitializer init) { return new WithSmoke(init.Self, this); }
|
||||
}
|
||||
|
||||
@@ -45,9 +55,14 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
var warhead = e.Warhead as DamageWarhead;
|
||||
if (info.DamageTypes.Count > 0 && (warhead != null && !warhead.DamageTypes.Overlaps(info.DamageTypes)))
|
||||
return;
|
||||
|
||||
if (isSmoking) return;
|
||||
if (e.Damage < 0) return; /* getting healed */
|
||||
if (e.DamageState < DamageState.Heavy) return;
|
||||
if (e.DamageState < info.MinimumDamageState) return;
|
||||
if (e.DamageState > info.MaximumDamageState) return;
|
||||
|
||||
isSmoking = true;
|
||||
anim.PlayThen(info.IdleSequence,
|
||||
|
||||
Reference in New Issue
Block a user