Fix crates not showing their water animation

when they are not paradropped.
This commit is contained in:
abcdefg30
2016-01-23 13:21:29 +01:00
parent 7aa6921c72
commit 4a67104603

View File

@@ -37,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits
} }
} }
class WithCrateBody : INotifyParachuteLanded class WithCrateBody : INotifyParachuteLanded, INotifyAddedToWorld
{ {
readonly Actor self; readonly Actor self;
readonly Animation anim; readonly Animation anim;
@@ -57,7 +57,21 @@ namespace OpenRA.Mods.Common.Traits
rs.Add(anim); rs.Add(anim);
} }
void INotifyAddedToWorld.AddedToWorld(Actor self)
{
// Don't change animations while still in air
if (!self.IsAtGroundLevel())
return;
PlaySequence();
}
public void OnLanded() public void OnLanded()
{
PlaySequence();
}
void PlaySequence()
{ {
var sequence = self.World.Map.GetTerrainInfo(self.Location).IsWater ? info.WaterSequence : info.LandSequence; var sequence = self.World.Map.GetTerrainInfo(self.Location).IsWater ? info.WaterSequence : info.LandSequence;
if (!string.IsNullOrEmpty(sequence)) if (!string.IsNullOrEmpty(sequence))