harvester actually sortof works now
This commit is contained in:
34
OpenRa.Game/Traits/Activities/DeliverOre.cs
Normal file
34
OpenRa.Game/Traits/Activities/DeliverOre.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenRa.Game.Traits.Activities
|
||||
{
|
||||
class DeliverOre : Activity
|
||||
{
|
||||
public Activity NextActivity { get; set; }
|
||||
|
||||
bool isDone;
|
||||
|
||||
public void Tick(Actor self, Mobile mobile)
|
||||
{
|
||||
if (isDone)
|
||||
{
|
||||
mobile.InternalSetActivity(NextActivity);
|
||||
/* todo: return to the ore patch */
|
||||
return;
|
||||
}
|
||||
|
||||
var renderUnit = self.traits.WithInterface<RenderUnit>().First();
|
||||
if (renderUnit.anim.CurrentSequence.Name != "empty")
|
||||
renderUnit.PlayCustomAnimation(self, "empty",
|
||||
() => isDone = true);
|
||||
}
|
||||
|
||||
public void Cancel(Actor self, Mobile mobile)
|
||||
{
|
||||
mobile.InternalSetActivity(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ namespace OpenRa.Game.Traits.Activities
|
||||
class Harvest : Activity
|
||||
{
|
||||
public Activity NextActivity { get; set; }
|
||||
bool isHarvesting = false;
|
||||
|
||||
public void Tick(Actor self, Mobile mobile)
|
||||
{
|
||||
@@ -18,10 +19,16 @@ namespace OpenRa.Game.Traits.Activities
|
||||
Game.map.ContainsResource(self.Location) &&
|
||||
Game.map.Harvest(self.Location, out isGem))
|
||||
{
|
||||
var harvestAnim = "harvest" + Util.QuantizeFacing(mobile.facing, 8);
|
||||
var renderUnit = self.traits.WithInterface<RenderUnit>().First(); /* better have one of these! */
|
||||
if (harvestAnim != renderUnit.anim.CurrentSequence.Name)
|
||||
renderUnit.PlayCustomAnimation(self, harvestAnim, () => isHarvesting = false);
|
||||
harv.AcceptResource(isGem);
|
||||
return;
|
||||
}
|
||||
|
||||
if (isHarvesting) return;
|
||||
|
||||
if (harv.IsFull)
|
||||
PlanReturnToBase(self, mobile);
|
||||
else
|
||||
@@ -47,7 +54,7 @@ namespace OpenRa.Game.Traits.Activities
|
||||
|
||||
mobile.QueueActivity(new Move(proc.Location + new int2(1, 2)));
|
||||
mobile.QueueActivity(new Turn(64));
|
||||
/* todo: DeliverOre activity */
|
||||
mobile.QueueActivity(new DeliverOre());
|
||||
|
||||
mobile.InternalSetActivity(NextActivity);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user