Fix WithWallSpriteBody hijacking WithSpriteBody's DefaultAnimation before/during the "make" animation

This commit is contained in:
Pavel Penev
2015-10-03 20:59:31 +03:00
parent 22183fd5c7
commit 8b83fac306

View File

@@ -17,7 +17,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.Common.Traits
{
[Desc("Render trait for actors that change sprites if neighbors with the same trait are present.")]
class WithWallSpriteBodyInfo : WithSpriteBodyInfo
class WithWallSpriteBodyInfo : WithSpriteBodyInfo, Requires<BuildingInfo>
{
public readonly string Type = "wall";
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits
}
}
class WithWallSpriteBody : WithSpriteBody, INotifyAddedToWorld, INotifyRemovedFromWorld, ITick
class WithWallSpriteBody : WithSpriteBody, INotifyRemovedFromWorld, ITick
{
readonly WithWallSpriteBodyInfo wallInfo;
int adjacent = 0;
@@ -78,7 +78,6 @@ namespace OpenRA.Mods.Common.Traits
: base(init, info, () => 0)
{
wallInfo = info;
DefaultAnimation.PlayFetchIndex(NormalizeSequence(init.Self, Info.Sequence), () => adjacent);
}
public override void DamageStateChanged(Actor self, AttackInfo e)
@@ -118,6 +117,12 @@ namespace OpenRA.Mods.Common.Traits
dirty = false;
}
public override void BuildingComplete(Actor self)
{
DefaultAnimation.PlayFetchIndex(NormalizeSequence(self, Info.Sequence), () => adjacent);
UpdateNeighbours(self);
}
static void UpdateNeighbours(Actor self)
{
var adjacentActors = CVec.Directions.SelectMany(dir =>
@@ -129,12 +134,6 @@ namespace OpenRA.Mods.Common.Traits
rb.dirty = true;
}
public void AddedToWorld(Actor self)
{
DefaultAnimation.PlayFetchIndex(NormalizeSequence(self, Info.Sequence), () => adjacent);
UpdateNeighbours(self);
}
public void RemovedFromWorld(Actor self)
{
UpdateNeighbours(self);