unhardcode and self-document render sequences

This commit is contained in:
Matthias Mailänder
2015-04-06 21:12:07 +02:00
parent cd9589eaa0
commit 7157cc0a9f
9 changed files with 48 additions and 23 deletions

View File

@@ -17,6 +17,9 @@ namespace OpenRA.Mods.Common.Traits
class RenderHarvesterInfo : RenderUnitInfo, Requires<HarvesterInfo>
{
public readonly string[] ImagesByFullness = { "harv" };
public readonly string HarvestSequence = "harvest";
public override object Create(ActorInitializer init) { return new RenderHarvester(init, this); }
}
@@ -42,15 +45,15 @@ namespace OpenRA.Mods.Common.Traits
var desiredImage = info.ImagesByFullness[desiredState];
if (DefaultAnimation.Name != desiredImage)
DefaultAnimation.ChangeImage(desiredImage, "idle");
DefaultAnimation.ChangeImage(desiredImage, info.Sequence);
base.Tick(self);
}
public void Harvested(Actor self, ResourceType resource)
{
if (DefaultAnimation.CurrentSequence.Name != "harvest")
PlayCustomAnim(self, "harvest");
if (DefaultAnimation.CurrentSequence.Name != info.HarvestSequence)
PlayCustomAnim(self, info.HarvestSequence);
}
public void MovingToResources(Actor self, CPos targetCell, Activity next) { }