Add SpriteHarvesterDockSequence and VoxelHarvesterDockSequence

Pass drag-related info from Refinery to HarvesterDockSequence
This commit is contained in:
penev92
2015-01-19 16:25:50 +02:00
parent c18da7abb0
commit 502ed6a0e7
9 changed files with 126 additions and 219 deletions

View File

@@ -1,93 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using System;
using System.Collections.Generic;
using OpenRA.Activities;
using OpenRA.Mods.Common.Activities;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.RA.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Activities
{
public class TDHarvesterDockSequence : Activity
{
enum State { Wait, Turn, DragIn, Dock, Loop, Undock, DragOut }
static readonly WVec DockOffset = new WVec(-640, 341, 0);
readonly Actor proc;
readonly Harvester harv;
readonly RenderUnit ru;
State state;
WPos startDock, endDock;
public TDHarvesterDockSequence(Actor self, Actor proc)
{
this.proc = proc;
state = State.Turn;
harv = self.Trait<Harvester>();
ru = self.Trait<RenderUnit>();
startDock = self.CenterPosition;
endDock = proc.CenterPosition + DockOffset;
}
public override Activity Tick(Actor self)
{
switch (state)
{
case State.Wait:
return this;
case State.Turn:
state = State.DragIn;
return Util.SequenceActivities(new Turn(self, 112), this);
case State.DragIn:
state = State.Dock;
return Util.SequenceActivities(new Drag(self, startDock, endDock, 12), this);
case State.Dock:
ru.PlayCustomAnimation(self, "dock", () =>
{
ru.PlayCustomAnimRepeating(self, "dock-loop");
if (proc.IsInWorld && !proc.IsDead)
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
nd.Docked(proc, self);
state = State.Loop;
});
state = State.Wait;
return this;
case State.Loop:
if (!proc.IsInWorld || proc.IsDead || harv.TickUnload(self, proc))
state = State.Undock;
return this;
case State.Undock:
ru.PlayCustomAnimBackwards(self, "dock", () => state = State.DragOut);
if (proc.IsInWorld && !proc.IsDead)
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
nd.Undocked(proc, self);
state = State.Wait;
return this;
case State.DragOut:
return Util.SequenceActivities(new Drag(self, endDock, startDock, 12), NextActivity);
}
throw new InvalidOperationException("Invalid harvester dock state");
}
public override void Cancel(Actor self)
{
state = State.Undock;
}
public override IEnumerable<Target> GetTargets(Actor self)
{
yield return Target.FromActor(proc);
}
}
}

View File

@@ -67,12 +67,10 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Activities\TDHarvesterDockSequence.cs" />
<Compile Include="CncLoadScreen.cs" />
<Compile Include="Effects\IonCannon.cs" />
<Compile Include="Traits\AttackPopupTurreted.cs" />
<Compile Include="Traits\Buildings\ProductionAirdrop.cs" />
<Compile Include="Traits\Buildings\TiberianDawnRefinery.cs" />
<Compile Include="Traits\PoisonedByTiberium.cs" />
<Compile Include="Traits\Render\RenderGunboat.cs" />
<Compile Include="Traits\Render\WithCargo.cs" />

View File

@@ -1,31 +0,0 @@
#region Copyright & License Information
/*
* Copyright 2007-2015 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation. For more information,
* see COPYING.
*/
#endregion
using OpenRA.Activities;
using OpenRA.Mods.Cnc.Activities;
using OpenRA.Mods.RA.Traits;
namespace OpenRA.Mods.Cnc.Traits
{
public class TiberianDawnRefineryInfo : RefineryInfo
{
public override object Create(ActorInitializer init) { return new TiberianDawnRefinery(init.Self, this); }
}
public class TiberianDawnRefinery : Refinery
{
public TiberianDawnRefinery(Actor self, RefineryInfo info) : base(self, info) { }
public override Activity DockSequence(Actor harv, Actor self)
{
return new TDHarvesterDockSequence(harv, self);
}
}
}