Files
OpenRA/OpenRa.Game/Harvester.cs
(no author) ced4d24793 refinery comes with a harvester
git-svn-id: svn://svn.ijw.co.nz/svn/OpenRa@1344 993157c7-ee19-0410-b2c4-bb4e9862e678
2007-07-24 10:22:34 +00:00

61 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Text;
namespace OpenRa.Game
{
class Harvester : Unit
{
public Harvester( int2 cell, Player owner, Game game )
: base( "harv", cell, owner, new float2( 12, 12 ), game )
{
}
public override IOrder Order( Game game, int2 xy )
{
if( ( fromCell == toCell || moveFraction == 0 ) && fromCell == xy )
return new HarvestOrder( this );
return base.Order( game, xy );
}
void AcceptHarvestOrder()
{
TickFunc order = null;
order = nextOrder = delegate
{
// TODO: check that there's actually some ore in this cell :)
// face in one of the 8 directions
if( Turn( ( facing + 1 ) & ~3 ) )
return;
currentOrder = delegate { };
if( nextOrder == null )
nextOrder = order;
string sequenceName = string.Format( "harvest{0}", facing / 4 );
animation.PlayThen( sequenceName, delegate
{
currentOrder = null;
animation.PlayFetchIndex( "idle", delegate { return facing; } );
} );
};
}
public class HarvestOrder : IOrder
{
Harvester harvester;
public HarvestOrder( Harvester harv )
{
harvester = harv;
}
public void Apply( Game game )
{
harvester.AcceptHarvestOrder();
}
}
}
}