Fix cancellation issues and animation flicker
This commit is contained in:
@@ -44,21 +44,22 @@ namespace OpenRA.Mods.Cnc
|
|||||||
{
|
{
|
||||||
dockedHarv = harv;
|
dockedHarv = harv;
|
||||||
self.traits.Get<RenderBuilding>().PlayCustomAnim(self, "active");
|
self.traits.Get<RenderBuilding>().PlayCustomAnim(self, "active");
|
||||||
}) );
|
|
||||||
harv.QueueActivity( new Drag(startDock, endDock, 11) );
|
harv.QueueActivity( new Drag(startDock, endDock, 12) );
|
||||||
harv.QueueActivity( new CallFunc( () =>
|
harv.QueueActivity( new CallFunc( () =>
|
||||||
{
|
|
||||||
self.World.AddFrameEndTask( w1 =>
|
|
||||||
{
|
{
|
||||||
harvester.Visible = false;
|
self.World.AddFrameEndTask( w1 =>
|
||||||
harvester.Deliver(harv, self);
|
{
|
||||||
});
|
harvester.Visible = false;
|
||||||
|
harvester.Deliver(harv, self);
|
||||||
|
});
|
||||||
|
}, false ) );
|
||||||
|
harv.QueueActivity( new Wait(18, false ) );
|
||||||
|
harv.QueueActivity( new CallFunc( () => harvester.Visible = true, false ) );
|
||||||
|
harv.QueueActivity( new Drag(endDock, startDock, 12) );
|
||||||
|
harv.QueueActivity( new CallFunc( () => dockedHarv = null, false ) );
|
||||||
|
harv.QueueActivity( new Harvest() );
|
||||||
}) );
|
}) );
|
||||||
harv.QueueActivity( new Wait(18) );
|
|
||||||
harv.QueueActivity( new CallFunc( () => harvester.Visible = true) );
|
|
||||||
harv.QueueActivity( new Drag(endDock, startDock, 11) );
|
|
||||||
harv.QueueActivity( new CallFunc( () => dockedHarv = null) );
|
|
||||||
harv.QueueActivity( new Harvest() );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
* Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford.
|
||||||
* This file is part of OpenRA.
|
* This file is part of OpenRA.
|
||||||
@@ -26,8 +26,14 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
public class CallFunc : IActivity
|
public class CallFunc : IActivity
|
||||||
{
|
{
|
||||||
public CallFunc(Action a) { this.a = a; }
|
public CallFunc(Action a) { this.a = a; }
|
||||||
|
public CallFunc(Action a, bool interruptable)
|
||||||
|
{
|
||||||
|
this.a = a;
|
||||||
|
this.interruptable = interruptable;
|
||||||
|
}
|
||||||
|
|
||||||
Action a;
|
Action a;
|
||||||
|
bool interruptable;
|
||||||
public IActivity NextActivity { get; set; }
|
public IActivity NextActivity { get; set; }
|
||||||
|
|
||||||
public IActivity Tick(Actor self)
|
public IActivity Tick(Actor self)
|
||||||
@@ -36,6 +42,13 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Cancel(Actor self) { a = null; NextActivity = null; }
|
public void Cancel(Actor self)
|
||||||
|
{
|
||||||
|
if (!interruptable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
a = null;
|
||||||
|
NextActivity = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,16 +25,29 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
public class Wait : IActivity
|
public class Wait : IActivity
|
||||||
{
|
{
|
||||||
int remainingTicks;
|
int remainingTicks;
|
||||||
|
bool interruptable = true;
|
||||||
|
|
||||||
public Wait(int period) { remainingTicks = period; }
|
public Wait(int period) { remainingTicks = period; }
|
||||||
|
public Wait(int period, bool interruptable)
|
||||||
|
{
|
||||||
|
remainingTicks = period;
|
||||||
|
this.interruptable = interruptable;
|
||||||
|
}
|
||||||
|
|
||||||
public IActivity Tick(Actor self)
|
public IActivity Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (remainingTicks-- == 0) return NextActivity;
|
if (remainingTicks-- == 0) return NextActivity;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Cancel(Actor self) { remainingTicks = 0; NextActivity = null; }
|
public void Cancel(Actor self)
|
||||||
|
{
|
||||||
|
if (!interruptable)
|
||||||
|
return;
|
||||||
|
|
||||||
|
remainingTicks = 0;
|
||||||
|
NextActivity = null;
|
||||||
|
}
|
||||||
public IActivity NextActivity { get; set; }
|
public IActivity NextActivity { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user