Recover gracefully if proc goes away while harv is docking
This commit is contained in:
@@ -33,6 +33,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
class TiberiumRefineryDockAction : IAcceptOreDockAction, INotifyDamage, INotifySold, INotifyCapture, ITraitPrerequisite<IAcceptOre>
|
class TiberiumRefineryDockAction : IAcceptOreDockAction, INotifyDamage, INotifySold, INotifyCapture, ITraitPrerequisite<IAcceptOre>
|
||||||
{
|
{
|
||||||
Actor dockedHarv = null;
|
Actor dockedHarv = null;
|
||||||
|
bool preventDock = false;
|
||||||
public void OnDock(Actor self, Actor harv, DeliverResources dockOrder)
|
public void OnDock(Actor self, Actor harv, DeliverResources dockOrder)
|
||||||
{
|
{
|
||||||
float2 startDock = harv.CenterLocation;
|
float2 startDock = harv.CenterLocation;
|
||||||
@@ -41,6 +42,8 @@ namespace OpenRA.Mods.Cnc
|
|||||||
|
|
||||||
harv.QueueActivity( new Turn(112) );
|
harv.QueueActivity( new Turn(112) );
|
||||||
harv.QueueActivity( new CallFunc( () =>
|
harv.QueueActivity( new CallFunc( () =>
|
||||||
|
{
|
||||||
|
if (!preventDock)
|
||||||
{
|
{
|
||||||
dockedHarv = harv;
|
dockedHarv = harv;
|
||||||
self.traits.Get<RenderBuilding>().PlayCustomAnim(self, "active");
|
self.traits.Get<RenderBuilding>().PlayCustomAnim(self, "active");
|
||||||
@@ -50,6 +53,7 @@ namespace OpenRA.Mods.Cnc
|
|||||||
{
|
{
|
||||||
self.World.AddFrameEndTask( w1 =>
|
self.World.AddFrameEndTask( w1 =>
|
||||||
{
|
{
|
||||||
|
if (!preventDock)
|
||||||
harvester.Visible = false;
|
harvester.Visible = false;
|
||||||
harvester.Deliver(harv, self);
|
harvester.Deliver(harv, self);
|
||||||
});
|
});
|
||||||
@@ -60,13 +64,19 @@ namespace OpenRA.Mods.Cnc
|
|||||||
harv.QueueActivity( new CallFunc( () => dockedHarv = null, false ) );
|
harv.QueueActivity( new CallFunc( () => dockedHarv = null, false ) );
|
||||||
if (harvester.LastHarvestedCell != int2.Zero)
|
if (harvester.LastHarvestedCell != int2.Zero)
|
||||||
harv.QueueActivity( new Move(harvester.LastHarvestedCell, 5) );
|
harv.QueueActivity( new Move(harvester.LastHarvestedCell, 5) );
|
||||||
|
}
|
||||||
harv.QueueActivity( new Harvest() );
|
harv.QueueActivity( new Harvest() );
|
||||||
}) );
|
}) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void CancelDock(Actor self, Actor harv)
|
void CancelDock(Actor self, Actor harv)
|
||||||
{
|
{
|
||||||
// Todo: Cancel the above activities that are non-cancelable
|
preventDock = true;
|
||||||
|
if (dockedHarv == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// invisible harvester makes ceiling cat cry
|
||||||
|
harv.traits.Get<Harvester>().Visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Selling (Actor self) { CancelDock(self, dockedHarv); }
|
public void Selling (Actor self) { CancelDock(self, dockedHarv); }
|
||||||
|
|||||||
Reference in New Issue
Block a user