diff --git a/OpenRA.Mods.RA/Harvester.cs b/OpenRA.Mods.RA/Harvester.cs index 7269964234..d86e2428f5 100644 --- a/OpenRA.Mods.RA/Harvester.cs +++ b/OpenRA.Mods.RA/Harvester.cs @@ -88,6 +88,7 @@ namespace OpenRA.Mods.RA public bool IsFull { get { return contents.Values.Sum() == Info.Capacity; } } public bool IsEmpty { get { return contents.Values.Sum() == 0; } } + public float Fullness { get { return (float)contents.Values.Sum() / Info.Capacity; } } public void AcceptResource(ResourceType type) { diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 625085e99d..b3eb56524b 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -354,6 +354,7 @@ + diff --git a/OpenRA.Mods.RA/Render/RenderHarvester.cs b/OpenRA.Mods.RA/Render/RenderHarvester.cs new file mode 100644 index 0000000000..feed8a5ecc --- /dev/null +++ b/OpenRA.Mods.RA/Render/RenderHarvester.cs @@ -0,0 +1,50 @@ +#region Copyright & License Information +/* + * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * This file is part of OpenRA, which is free software. It is made + * available to you under the terms of the GNU General Public License + * as published by the Free Software Foundation. For more information, + * see COPYING. + */ +#endregion + +using System.Collections.Generic; +using System.Linq; +using OpenRA.Graphics; +using OpenRA.Traits; +using OpenRA.Mods.RA.Orders; + +namespace OpenRA.Mods.RA.Render +{ + class RenderHarvesterInfo : RenderUnitInfo, Requires + { + public readonly string[] ImagesByFullness = { "harvempty", "harvhalf", "harv" }; + public override object Create(ActorInitializer init) { return new RenderHarvester(init.self, this); } + } + + class RenderHarvester : RenderUnit + { + Harvester harv; + RenderHarvesterInfo info; + + public RenderHarvester(Actor self, RenderHarvesterInfo info) : base(self) + { + this.info = info; + + harv = self.Trait(); + foreach( var image in info.ImagesByFullness ) + new Animation( image ); /* just force these to get loaded upfront */ + } + + public override void Tick(Actor self) + { + var desiredState = (int)(harv.Fullness * (info.ImagesByFullness.Length - 1)); + var desiredImage = info.ImagesByFullness[desiredState]; + + if (anim.Name != desiredImage) + anim.ChangeImage( desiredImage, "idle" ); + + base.Tick(self); + } + } +} \ No newline at end of file diff --git a/mods/ra/bits/harvempty.shp b/mods/ra/bits/harvempty.shp new file mode 100644 index 0000000000..4b92b083e1 Binary files /dev/null and b/mods/ra/bits/harvempty.shp differ diff --git a/mods/ra/bits/harvhalf.shp b/mods/ra/bits/harvhalf.shp new file mode 100644 index 0000000000..4b5e403d98 Binary files /dev/null and b/mods/ra/bits/harvhalf.shp differ diff --git a/mods/ra/rules/vehicles.yaml b/mods/ra/rules/vehicles.yaml index c26d8fbb0b..f01c1eb7b2 100644 --- a/mods/ra/rules/vehicles.yaml +++ b/mods/ra/rules/vehicles.yaml @@ -224,7 +224,7 @@ HARV: Speed: 6 RevealsShroud: Range: 4 - RenderUnit: + RenderHarvester: -AttackMove: GpsDot: String:Harvester diff --git a/mods/ra/sequences.yaml b/mods/ra/sequences.yaml index ecdcc398fb..b78a70e09b 100644 --- a/mods/ra/sequences.yaml +++ b/mods/ra/sequences.yaml @@ -396,6 +396,37 @@ harv: dock-loop: Start: 104 Length: 7 + +harvhalf: + idle: + Start: 0 + Facings: 32 + harvest: + Start: 32 + Length: 8 + Facings: 8 + dock: harv + Start: 96 + Length: 8 + dock-loop: harv + Start: 104 + Length: 7 + +harvempty: + idle: + Start: 0 + Facings: 32 + harvest: + Start: 32 + Length: 8 + Facings: 8 + dock: harv + Start: 96 + Length: 8 + dock-loop: harv + Start: 104 + Length: 7 + 1tnk: idle: Start: 0