Clean up HarvesterDockSequence.

This commit is contained in:
Paul Chote
2013-07-21 09:55:38 +12:00
parent 031c17ab9c
commit 8a988e5e02

View File

@@ -20,7 +20,8 @@ namespace OpenRA.Mods.Cnc
{
public class HarvesterDockSequence : Activity
{
enum State { Wait, Turn, DragIn, Dock, Loop, Undock, DragOut };
enum State { Wait, Turn, DragIn, Dock, Loop, Undock, DragOut }
static readonly WVec DockOffset = new WVec(-640, 341, 0);
readonly Actor proc;
readonly Harvester harv;
@@ -34,8 +35,8 @@ namespace OpenRA.Mods.Cnc
state = State.Turn;
harv = self.Trait<Harvester>();
ru = self.Trait<RenderUnit>();
startDock = self.Trait<IHasLocation>().PxPosition.ToWPos(0);
endDock = (proc.Trait<IHasLocation>().PxPosition + new PVecInt(-15,8)).ToWPos(0);
startDock = self.CenterPosition;
endDock = proc.CenterPosition + DockOffset;
}
public override Activity Tick(Actor self)
@@ -51,7 +52,7 @@ namespace OpenRA.Mods.Cnc
state = State.Dock;
return Util.SequenceActivities(new Drag(startDock, endDock, 12), this);
case State.Dock:
ru.PlayCustomAnimation(self, "dock", () => {ru.PlayCustomAnimRepeating(self, "dock-loop"); state = State.Loop;});
ru.PlayCustomAnimation(self, "dock", () => { ru.PlayCustomAnimRepeating(self, "dock-loop"); state = State.Loop; });
state = State.Wait;
return this;
case State.Loop:
@@ -65,6 +66,7 @@ namespace OpenRA.Mods.Cnc
case State.DragOut:
return Util.SequenceActivities(new Drag(endDock, startDock, 12), NextActivity);
}
throw new InvalidOperationException("Invalid harvester dock state");
}
@@ -73,10 +75,9 @@ namespace OpenRA.Mods.Cnc
state = State.Undock;
}
public override IEnumerable<Target> GetTargets( Actor self )
public override IEnumerable<Target> GetTargets(Actor self)
{
yield return Target.FromActor(proc);
}
}
}
}