#87 CNC buildings should show Critical anim while dying
This commit is contained in:
38
OpenRA.Mods.Cnc/CriticalBuildingState.cs
Normal file
38
OpenRA.Mods.Cnc/CriticalBuildingState.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using OpenRA.Traits;
|
||||
using OpenRA.Effects;
|
||||
|
||||
namespace OpenRA.Mods.Cnc
|
||||
{
|
||||
class CriticalBuildingStateInfo : ITraitInfo
|
||||
{
|
||||
public readonly int LingerTime = 20;
|
||||
public object Create(Actor self) { return new CriticalBuildingState(self, this); }
|
||||
}
|
||||
|
||||
class CriticalBuildingState : INotifyDamage
|
||||
{
|
||||
CriticalBuildingStateInfo info;
|
||||
|
||||
public CriticalBuildingState(Actor self, CriticalBuildingStateInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
self.RemoveOnDeath = false;
|
||||
}
|
||||
|
||||
public void Damaged(Actor self, AttackInfo e)
|
||||
{
|
||||
if (e.DamageStateChanged && e.DamageState == DamageState.Dead)
|
||||
{
|
||||
self.traits.Get<RenderSimple>().anim.PlayRepeating("critical-idle");
|
||||
self.World.AddFrameEndTask(
|
||||
w => w.Add(
|
||||
new DelayedAction(info.LingerTime,
|
||||
() => w.Remove(self))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CriticalBuildingState.cs" />
|
||||
<Compile Include="Effects\IonCannon.cs" />
|
||||
<Compile Include="IonCannonPower.cs" />
|
||||
<Compile Include="ProductionAirdrop.cs" />
|
||||
|
||||
Reference in New Issue
Block a user