fixed #42 -- show harvester fullness in sprites
This commit is contained in:
@@ -88,6 +88,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public bool IsFull { get { return contents.Values.Sum() == Info.Capacity; } }
|
public bool IsFull { get { return contents.Values.Sum() == Info.Capacity; } }
|
||||||
public bool IsEmpty { get { return contents.Values.Sum() == 0; } }
|
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)
|
public void AcceptResource(ResourceType type)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -354,6 +354,7 @@
|
|||||||
<Compile Include="AnnounceOnKill.cs" />
|
<Compile Include="AnnounceOnKill.cs" />
|
||||||
<Compile Include="CrushableInfantry.cs" />
|
<Compile Include="CrushableInfantry.cs" />
|
||||||
<Compile Include="Render\WithSmoke.cs" />
|
<Compile Include="Render\WithSmoke.cs" />
|
||||||
|
<Compile Include="Render\RenderHarvester.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">
|
||||||
|
|||||||
50
OpenRA.Mods.RA/Render/RenderHarvester.cs
Normal file
50
OpenRA.Mods.RA/Render/RenderHarvester.cs
Normal file
@@ -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<HarvesterInfo>
|
||||||
|
{
|
||||||
|
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<Harvester>();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
mods/ra/bits/harvempty.shp
Normal file
BIN
mods/ra/bits/harvempty.shp
Normal file
Binary file not shown.
BIN
mods/ra/bits/harvhalf.shp
Normal file
BIN
mods/ra/bits/harvhalf.shp
Normal file
Binary file not shown.
@@ -224,7 +224,7 @@ HARV:
|
|||||||
Speed: 6
|
Speed: 6
|
||||||
RevealsShroud:
|
RevealsShroud:
|
||||||
Range: 4
|
Range: 4
|
||||||
RenderUnit:
|
RenderHarvester:
|
||||||
-AttackMove:
|
-AttackMove:
|
||||||
GpsDot:
|
GpsDot:
|
||||||
String:Harvester
|
String:Harvester
|
||||||
|
|||||||
@@ -396,6 +396,37 @@ harv:
|
|||||||
dock-loop:
|
dock-loop:
|
||||||
Start: 104
|
Start: 104
|
||||||
Length: 7
|
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:
|
1tnk:
|
||||||
idle:
|
idle:
|
||||||
Start: 0
|
Start: 0
|
||||||
|
|||||||
Reference in New Issue
Block a user