Harvesters return to last used field

This commit is contained in:
Paul Chote
2010-06-16 19:22:59 +12:00
parent 5822caf7a8
commit f0a2bf128c
4 changed files with 13 additions and 2 deletions

View File

@@ -58,6 +58,8 @@ namespace OpenRA.Mods.Cnc
harv.QueueActivity( new CallFunc( () => harvester.Visible = true, false ) );
harv.QueueActivity( new Drag(endDock, startDock, 12) );
harv.QueueActivity( new CallFunc( () => dockedHarv = null, false ) );
if (harvester.LastHarvestedCell != int2.Zero)
harv.QueueActivity( new Move(harvester.LastHarvestedCell, 5) );
harv.QueueActivity( new Harvest() );
}) );
}

View File

@@ -36,6 +36,7 @@ namespace OpenRA.Mods.RA.Activities
if( NextActivity != null ) return NextActivity;
var harv = self.traits.Get<Harvester>();
harv.LastHarvestedCell = self.Location;
if( harv.IsFull )
return new DeliverResources { NextActivity = NextActivity };

View File

@@ -47,6 +47,9 @@ namespace OpenRA.Mods.RA
[Sync]
public Actor LinkedProc = null;
[Sync]
public int2 LastHarvestedCell = int2.Zero;
readonly HarvesterInfo Info;
public Harvester(Actor self, HarvesterInfo info)
{

View File

@@ -34,6 +34,8 @@ namespace OpenRA.Mods.RA
public void OnDock(Actor self, Actor harv, DeliverResources dockOrder)
{
var unit = harv.traits.Get<Unit>();
var harvester = harv.traits.Get<Harvester>();
if (unit.Facing != 64)
harv.QueueActivity (new Turn (64));
@@ -43,8 +45,11 @@ namespace OpenRA.Mods.RA
if (renderUnit.anim.CurrentSequence.Name != "empty")
renderUnit.PlayCustomAnimation (harv, "empty", () =>
{
harv.traits.Get<Harvester>().Deliver(harv, self);
harv.QueueActivity (new Harvest ());
harvester.Deliver(harv, self);
if (harvester.LastHarvestedCell != int2.Zero)
harv.QueueActivity( new Move(harvester.LastHarvestedCell, 5) );
harv.QueueActivity( new Harvest() );
});
}));
}