#29 fixed
This commit is contained in:
@@ -111,10 +111,7 @@ namespace OpenRa.Game
|
|||||||
Game.PlaySound("unitlst1.aud", false);
|
Game.PlaySound("unitlst1.aud", false);
|
||||||
|
|
||||||
if (traits.Contains<Building>())
|
if (traits.Contains<Building>())
|
||||||
{
|
|
||||||
Game.PlaySound("kaboom22.aud", false);
|
Game.PlaySound("kaboom22.aud", false);
|
||||||
// todo: spawn explosion sprites
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var halfStrength = unitInfo.Strength * Rules.General.ConditionYellow;
|
var halfStrength = unitInfo.Strength * Rules.General.ConditionYellow;
|
||||||
@@ -124,6 +121,9 @@ namespace OpenRa.Game
|
|||||||
foreach (var nd in traits.WithInterface<INotifyDamage>())
|
foreach (var nd in traits.WithInterface<INotifyDamage>())
|
||||||
nd.Damaged(this, DamageState.Half);
|
nd.Damaged(this, DamageState.Half);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var ndx in traits.WithInterface<INotifyDamageEx>())
|
||||||
|
ndx.Damaged(this, damage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,19 +7,21 @@ using IjwFramework.Types;
|
|||||||
|
|
||||||
namespace OpenRa.Game.Traits
|
namespace OpenRa.Game.Traits
|
||||||
{
|
{
|
||||||
class RenderUnit : RenderSimple
|
class RenderUnit : RenderSimple, INotifyDamageEx
|
||||||
{
|
{
|
||||||
public RenderUnit(Actor self)
|
public RenderUnit(Actor self)
|
||||||
: base(self)
|
: base(self)
|
||||||
{
|
{
|
||||||
PlayFacingAnim(self);
|
PlayFacingAnim(self);
|
||||||
|
smoke = new Animation("smoke_m");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayFacingAnim(Actor self)
|
void PlayFacingAnim(Actor self)
|
||||||
{
|
{
|
||||||
anim.PlayFetchIndex("idle",
|
anim.PlayFetchIndex("idle",
|
||||||
() => self.traits.Get<Mobile>().facing
|
() => Util.QuantizeFacing(
|
||||||
/ (256 / anim.CurrentSequence.Length));
|
self.traits.Get<Mobile>().facing,
|
||||||
|
anim.CurrentSequence.Length ));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PlayCustomAnimation(Actor self, string newAnim, Action after)
|
public void PlayCustomAnimation(Actor self, string newAnim, Action after)
|
||||||
@@ -30,6 +32,34 @@ namespace OpenRa.Game.Traits
|
|||||||
public override IEnumerable<Pair<Sprite, float2>> Render(Actor self)
|
public override IEnumerable<Pair<Sprite, float2>> Render(Actor self)
|
||||||
{
|
{
|
||||||
yield return Util.Centered(anim.Image, self.CenterLocation);
|
yield return Util.Centered(anim.Image, self.CenterLocation);
|
||||||
|
if (isSmoking)
|
||||||
|
yield return Util.Centered(smoke.Image, self.CenterLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isSmoking;
|
||||||
|
DamageState currentDs;
|
||||||
|
Animation smoke;
|
||||||
|
|
||||||
|
public void Damaged(Actor self, DamageState ds) { currentDs = ds; }
|
||||||
|
|
||||||
|
public void Damaged(Actor self, int damage)
|
||||||
|
{
|
||||||
|
if (currentDs != DamageState.Half) return;
|
||||||
|
if (!isSmoking)
|
||||||
|
{
|
||||||
|
isSmoking = true;
|
||||||
|
smoke.PlayThen("idle",
|
||||||
|
() => smoke.PlayThen("loop",
|
||||||
|
() => smoke.PlayBackwardsThen("end",
|
||||||
|
() => isSmoking = false)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Tick(Actor self)
|
||||||
|
{
|
||||||
|
base.Tick(self);
|
||||||
|
if (isSmoking)
|
||||||
|
smoke.Tick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,5 @@ namespace OpenRa.Game.Traits
|
|||||||
interface IRender { IEnumerable<Pair<Sprite, float2>> Render(Actor self); }
|
interface IRender { IEnumerable<Pair<Sprite, float2>> Render(Actor self); }
|
||||||
interface IOrder { Order Order(Actor self, int2 xy, bool lmb, Actor underCursor); }
|
interface IOrder { Order Order(Actor self, int2 xy, bool lmb, Actor underCursor); }
|
||||||
interface INotifyDamage { void Damaged(Actor self, DamageState ds); }
|
interface INotifyDamage { void Damaged(Actor self, DamageState ds); }
|
||||||
|
interface INotifyDamageEx : INotifyDamage { void Damaged(Actor self, int damage); }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -510,4 +510,9 @@
|
|||||||
<unit name="flagfly">
|
<unit name="flagfly">
|
||||||
<sequence name="idle" start="0" length="14" />
|
<sequence name="idle" start="0" length="14" />
|
||||||
</unit>
|
</unit>
|
||||||
|
<unit name="smoke_m">
|
||||||
|
<sequence name="idle" start="0" length="91" />
|
||||||
|
<sequence name="loop" start="49" length="42" />
|
||||||
|
<sequence name="end" start="0" length="26" />
|
||||||
|
</unit>
|
||||||
</sequences>
|
</sequences>
|
||||||
Reference in New Issue
Block a user