Merge pull request #7098 from penev92/bleed_fixRefineryHierarchy

Clean up refinery and harvester docking sequence logic
This commit is contained in:
Oliver Brakmann
2015-01-25 18:08:14 +01:00
19 changed files with 229 additions and 314 deletions

View File

@@ -1,94 +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.Activities;
using OpenRA.Mods.RA.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Activities
{
public class HarvesterDockSequence : 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 HarvesterDockSequence(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\HarvesterDockSequence.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\TiberiumRefinery.cs" />
<Compile Include="Traits\PoisonedByTiberium.cs" />
<Compile Include="Traits\Render\RenderGunboat.cs" />
<Compile Include="Traits\Render\WithCargo.cs" />

View File

@@ -1,32 +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;
using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Traits
{
public class TiberiumRefineryInfo : OreRefineryInfo
{
public override object Create(ActorInitializer init) { return new TiberiumRefinery(init.Self, this); }
}
public class TiberiumRefinery : OreRefinery
{
public TiberiumRefinery(Actor self, TiberiumRefineryInfo info) : base(self, info) { }
public override Activity DockSequence(Actor harv, Actor self)
{
return new HarvesterDockSequence(harv, self);
}
}
}

View File

@@ -695,9 +695,9 @@ namespace OpenRA.Mods.Common.UtilityCommands
if (depth == 1 && node.Key == "MustBeDestroyed")
node.Value.Nodes.Add(new MiniYamlNode("RequiredForShortGame", "true"));
// Remove PlayMusicOnMapLoad
if (engineVersion < 20150125)
{
// Remove PlayMusicOnMapLoad
if (depth == 0 && node.Value.Nodes.Exists(n => n.Key == "PlayMusicOnMapLoad"))
{
node.Value.Nodes.RemoveAll(n => n.Key == "PlayMusicOnMapLoad");
@@ -705,6 +705,10 @@ namespace OpenRA.Mods.Common.UtilityCommands
Console.WriteLine("Please use the Lua API function 'PlayMusic' instead.");
Console.WriteLine("See http://wiki.openra.net/Lua-API for details.");
}
// Remove TiberiumRefinery and OreRefinery
if (node.Key == "TiberiumRefinery" || node.Key == "OreRefinery")
node.Key = "Refinery";
}
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);

View File

@@ -81,7 +81,7 @@ namespace OpenRA.Mods.RA.AI
var type = BuildingType.Building;
if (world.Map.Rules.Actors[currentBuilding.Item].Traits.Contains<AttackBaseInfo>())
type = BuildingType.Defense;
else if (world.Map.Rules.Actors[currentBuilding.Item].Traits.Contains<OreRefineryInfo>())
else if (world.Map.Rules.Actors[currentBuilding.Item].Traits.Contains<RefineryInfo>())
type = BuildingType.Refinery;
var location = ai.ChooseBuildLocation(currentBuilding.Item, true, type);

View File

@@ -54,17 +54,17 @@ namespace OpenRA.Mods.RA.Activities
return Util.SequenceActivities(new Wait(25), this);
var proc = harv.LinkedProc;
var iao = proc.Trait<IAcceptOre>();
var iao = proc.Trait<IAcceptResources>();
self.SetTargetLine(Target.FromActor(proc), Color.Green, false);
if (self.Location != proc.Location + iao.DeliverOffset)
if (self.Location != proc.Location + iao.DeliveryOffset)
{
var notify = self.TraitsImplementing<INotifyHarvesterAction>();
var next = new DeliverResources();
foreach (var n in notify)
n.MovingToRefinery(self, proc.Location + iao.DeliverOffset, next);
n.MovingToRefinery(self, proc.Location + iao.DeliveryOffset, next);
return Util.SequenceActivities(movement.MoveTo(proc.Location + iao.DeliverOffset, 0), this);
return Util.SequenceActivities(movement.MoveTo(proc.Location + iao.DeliveryOffset, 0), this);
}
if (!isDocking)

View File

@@ -0,0 +1,105 @@
#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.RA.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Activities
{
public class HarvesterDockSequence : Activity
{
protected enum State { Wait, Turn, Dock, Loop, Undock, Complete }
protected readonly Actor Refinery;
protected readonly Harvester Harv;
protected readonly int DockAngle;
protected readonly bool IsDragRequired;
protected readonly WVec DragOffset;
protected readonly int DragLength;
protected readonly WPos StartDrag;
protected readonly WPos EndDrag;
protected State dockingState;
public HarvesterDockSequence(Actor self, Actor refinery, int dockAngle, bool isDragRequired, WVec dragOffset, int dragLength)
{
dockingState = State.Turn;
Refinery = refinery;
DockAngle = dockAngle;
IsDragRequired = isDragRequired;
DragOffset = dragOffset;
DragLength = dragLength;
Harv = self.Trait<Harvester>();
StartDrag = self.CenterPosition;
EndDrag = refinery.CenterPosition + DragOffset;
}
public override Activity Tick(Actor self)
{
switch (dockingState)
{
case State.Wait:
return this;
case State.Turn:
dockingState = State.Dock;
if (IsDragRequired)
return Util.SequenceActivities(new Turn(self, DockAngle), new Drag(self, StartDrag, EndDrag, DragLength), this);
return Util.SequenceActivities(new Turn(self, DockAngle), this);
case State.Dock:
if (Refinery.IsInWorld && !Refinery.IsDead)
foreach (var nd in Refinery.TraitsImplementing<INotifyDocking>())
nd.Docked(Refinery, self);
return OnStateDock(self);
case State.Loop:
if (!Refinery.IsInWorld || Refinery.IsDead || Harv.TickUnload(self, Refinery))
dockingState = State.Undock;
return this;
case State.Undock:
return OnStateUndock(self);
case State.Complete:
if (Refinery.IsInWorld && !Refinery.IsDead)
foreach (var nd in Refinery.TraitsImplementing<INotifyDocking>())
nd.Undocked(Refinery, self);
Harv.LastLinkedProc = Harv.LinkedProc;
Harv.LinkProc(self, null);
if (IsDragRequired)
return Util.SequenceActivities(new Drag(self, EndDrag, StartDrag, DragLength), NextActivity);
return NextActivity;
}
throw new InvalidOperationException("Invalid harvester dock state");
}
public override void Cancel(Actor self)
{
dockingState = State.Undock;
base.Cancel(self);
}
public override IEnumerable<Target> GetTargets(Actor self)
{
yield return Target.FromActor(Refinery);
}
public virtual Activity OnStateDock(Actor self)
{
throw new NotImplementedException("Base class HarvesterDockSequence does not implement method OnStateDock!");
}
public virtual Activity OnStateUndock(Actor self)
{
throw new NotImplementedException("Base class HarvesterDockSequence does not implement method OnStateUndock!");
}
}
}

View File

@@ -1,91 +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.RA
{
public class RAHarvesterDockSequence : Activity
{
enum State { Wait, Turn, Dock, Loop, Undock, Complete }
readonly Actor proc;
readonly int angle;
readonly Harvester harv;
readonly RenderUnit ru;
State state;
public RAHarvesterDockSequence(Actor self, Actor proc, int angle)
{
this.proc = proc;
this.angle = angle;
state = State.Turn;
harv = self.Trait<Harvester>();
ru = self.Trait<RenderUnit>();
}
public override Activity Tick(Actor self)
{
switch (state)
{
case State.Wait:
return this;
case State.Turn:
state = State.Dock;
return Util.SequenceActivities(new Turn(self, angle), 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.Complete);
state = State.Wait;
return this;
case State.Complete:
harv.LastLinkedProc = harv.LinkedProc;
harv.LinkProc(self, null);
if (proc.IsInWorld && !proc.IsDead)
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
nd.Undocked(proc, self);
return NextActivity;
}
throw new InvalidOperationException("Invalid harvester dock state");
}
public override void Cancel(Actor self)
{
state = State.Undock;
base.Cancel(self);
}
public override IEnumerable<Target> GetTargets(Actor self)
{
yield return Target.FromActor(proc);
}
}
}

View File

@@ -0,0 +1,40 @@
#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.Common.Traits;
namespace OpenRA.Mods.RA.Activities
{
public class SpriteHarvesterDockSequence : HarvesterDockSequence
{
readonly RenderUnit ru;
public SpriteHarvesterDockSequence(Actor self, Actor refinery, int dockAngle, bool isDragRequired, WVec dragOffset, int dragLength)
: base(self, refinery, dockAngle, isDragRequired, dragOffset, dragLength)
{
ru = self.Trait<RenderUnit>();
}
public override Activity OnStateDock(Actor self)
{
ru.PlayCustomAnimation(self, "dock", () => ru.PlayCustomAnimRepeating(self, "dock-loop"));
dockingState = State.Loop;
return this;
}
public override Activity OnStateUndock(Actor self)
{
ru.PlayCustomAnimBackwards(self, "dock", () => dockingState = State.Complete);
dockingState = State.Wait;
return this;
}
}
}

View File

@@ -70,6 +70,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Activities\SpriteHarvesterDockSequence.cs" />
<Compile Include="AI\AttackOrFleeFuzzy.cs" />
<Compile Include="AI\BaseBuilder.cs" />
<Compile Include="AI\HackyAI.cs" />
@@ -80,7 +81,7 @@
<Compile Include="Activities\Infiltrate.cs" />
<Compile Include="Activities\LayMines.cs" />
<Compile Include="Activities\Leap.cs" />
<Compile Include="Activities\RAHarvesterDockSequence.cs" />
<Compile Include="Activities\HarvesterDockSequence.cs" />
<Compile Include="Activities\Teleport.cs" />
<Compile Include="AI\SupportPowerDecision.cs" />
<Compile Include="Effects\GpsSatellite.cs" />
@@ -111,7 +112,7 @@
<Compile Include="Traits\SupportPowers\ParatroopersPower.cs" />
<Compile Include="TraitsInterfaces.cs" />
<Compile Include="Traits\Buildings\Fake.cs" />
<Compile Include="Traits\Buildings\OreRefinery.cs" />
<Compile Include="Traits\Buildings\Refinery.cs" />
<Compile Include="Traits\Harvester.cs" />
<Compile Include="Traits\HarvesterHuskModifier.cs" />
<Compile Include="Traits\LeavesHusk.cs" />

View File

@@ -11,7 +11,6 @@
using System.Collections.Generic;
using System.Linq;
using OpenRA.Activities;
using OpenRA.Mods.Common.Activities;
using OpenRA.Mods.Common.Effects;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.RA.Activities;
@@ -19,25 +18,35 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Traits
{
public class OreRefineryInfo : ITraitInfo
public class RefineryInfo : ITraitInfo
{
[Desc("Actual harvester facing when docking, 0-255 counter-clock-wise.")]
public readonly int DockAngle = 0;
[Desc("Docking cell relative to top-left cell.")]
public readonly CVec DockOffset = new CVec(1, 2);
public readonly CVec DockOffset = CVec.Zero;
[Desc("Does the refinery require the harvester to be dragged in?")]
public readonly bool IsDragRequired = false;
[Desc("Vector by which the harvester will be dragged when docking.")]
public readonly WVec DragOffset = WVec.Zero;
[Desc("In how many steps to perform the dragging?")]
public readonly int DragLength = 0;
public readonly bool ShowTicks = true;
public readonly int TickLifetime = 30;
public readonly int TickVelocity = 2;
public readonly int TickRate = 10;
[Desc("Actually harvester facing when docking, 0-255 counter-clock-wise.")]
public readonly int DockAngle = 64;
public virtual object Create(ActorInitializer init) { return new OreRefinery(init.Self, this); }
public virtual object Create(ActorInitializer init) { return new Refinery(init.Self, this); }
}
public class OreRefinery : ITick, IAcceptOre, INotifyKilled, INotifySold, INotifyCapture, INotifyOwnerChanged, IExplodeModifier, ISync
public class Refinery : ITick, IAcceptResources, INotifyKilled, INotifySold, INotifyCapture, INotifyOwnerChanged, IExplodeModifier, ISync
{
readonly Actor self;
readonly OreRefineryInfo info;
readonly RefineryInfo info;
PlayerResources playerResources;
int currentDisplayTick = 0;
@@ -48,11 +57,13 @@ namespace OpenRA.Mods.RA.Traits
[Sync] bool preventDock = false;
public bool AllowDocking { get { return !preventDock; } }
public CVec DeliverOffset { get { return info.DockOffset; } }
public CVec DeliveryOffset { get { return info.DockOffset; } }
public int DeliveryAngle { get { return info.DockAngle; } }
public bool IsDragRequired { get { return info.IsDragRequired; } }
public WVec DragOffset { get { return info.DragOffset; } }
public int DragLength { get { return info.DragLength; } }
public virtual Activity DockSequence(Actor harv, Actor self) { return new RAHarvesterDockSequence(harv, self, info.DockAngle); }
public OreRefinery(Actor self, OreRefineryInfo info)
public Refinery(Actor self, RefineryInfo info)
{
this.self = self;
this.info = info;
@@ -60,15 +71,20 @@ namespace OpenRA.Mods.RA.Traits
currentDisplayTick = info.TickRate;
}
public virtual Activity DockSequence(Actor harv, Actor self)
{
return new SpriteHarvesterDockSequence(harv, self, DeliveryAngle, IsDragRequired, DragOffset, DragLength);
}
public IEnumerable<TraitPair<Harvester>> GetLinkedHarvesters()
{
return self.World.ActorsWithTrait<Harvester>()
.Where(a => a.Trait.LinkedProc == self);
}
public bool CanGiveOre(int amount) { return playerResources.CanGiveResources(amount); }
public bool CanGiveResource(int amount) { return playerResources.CanGiveResources(amount); }
public void GiveOre(int amount)
public void GiveResource(int amount)
{
playerResources.GiveResources(amount);
if (info.ShowTicks)

View File

@@ -115,10 +115,10 @@ namespace OpenRA.Mods.RA.Traits
{
// Find all refineries and their occupancy count:
var refs = (
from r in self.World.ActorsWithTrait<IAcceptOre>()
from r in self.World.ActorsWithTrait<IAcceptResources>()
where r.Actor != ignore && r.Actor.Owner == self.Owner && IsAcceptableProcType(r.Actor)
let linkedHarvs = self.World.ActorsWithTrait<Harvester>().Where(a => a.Trait.LinkedProc == r.Actor).Count()
select new { Location = r.Actor.Location + r.Trait.DeliverOffset, Actor = r.Actor, Occupancy = linkedHarvs }).ToDictionary(r => r.Location);
select new { Location = r.Actor.Location + r.Trait.DeliveryOffset, Actor = r.Actor, Occupancy = linkedHarvs }).ToDictionary(r => r.Location);
// Start a search from each refinery's delivery location:
var mi = self.Info.Traits.Get<MobileInfo>();
@@ -162,7 +162,7 @@ namespace OpenRA.Mods.RA.Traits
var lastproc = LastLinkedProc ?? LinkedProc;
if (lastproc != null && !lastproc.Destroyed)
{
var deliveryLoc = lastproc.Location + lastproc.Trait<IAcceptOre>().DeliverOffset;
var deliveryLoc = lastproc.Location + lastproc.Trait<IAcceptResources>().DeliveryOffset;
if (self.Location == deliveryLoc)
{
// Get out of the way:
@@ -236,11 +236,11 @@ namespace OpenRA.Mods.RA.Traits
if (contents.Keys.Count > 0)
{
var type = contents.First().Key;
var iao = proc.Trait<IAcceptOre>();
if (!iao.CanGiveOre(type.ValuePerUnit))
var iao = proc.Trait<IAcceptResources>();
if (!iao.CanGiveResource(type.ValuePerUnit))
return false;
iao.GiveOre(type.ValuePerUnit);
iao.GiveResource(type.ValuePerUnit);
if (--contents[type] == 0)
contents.Remove(type);
@@ -254,9 +254,9 @@ namespace OpenRA.Mods.RA.Traits
{
get
{
yield return new EnterAlliedActorTargeter<IAcceptOre>("Deliver", 5,
yield return new EnterAlliedActorTargeter<IAcceptResources>("Deliver", 5,
proc => IsAcceptableProcType(proc),
proc => !IsEmpty && proc.Trait<IAcceptOre>().AllowDocking);
proc => !IsEmpty && proc.Trait<IAcceptResources>().AllowDocking);
yield return new HarvestOrderTargeter();
}
}
@@ -337,7 +337,7 @@ namespace OpenRA.Mods.RA.Traits
else if (order.OrderString == "Deliver")
{
// NOTE: An explicit deliver order forces the harvester to always deliver to this refinery.
var iao = order.TargetActor.TraitOrDefault<IAcceptOre>();
var iao = order.TargetActor.TraitOrDefault<IAcceptResources>();
if (iao == null || !iao.AllowDocking || !IsAcceptableProcType(order.TargetActor))
return;

View File

@@ -9,17 +9,15 @@
#endregion
using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.RA.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
public interface IAcceptOre
public interface IAcceptResources
{
void OnDock(Actor harv, DeliverResources dockOrder);
void GiveOre(int amount);
bool CanGiveOre(int amount);
CVec DeliverOffset { get; }
void GiveResource(int amount);
bool CanGiveResource(int amount);
CVec DeliveryOffset { get; }
bool AllowDocking { get; }
}

View File

@@ -8,70 +8,34 @@
*/
#endregion
using System;
using System.Collections.Generic;
using OpenRA.Activities;
using OpenRA.Mods.Common.Activities;
using OpenRA.Mods.RA.Traits;
using OpenRA.Mods.RA.Activities;
using OpenRA.Mods.TS.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.TS.Activities
{
public class VoxelHarvesterDockSequence : Activity
public class VoxelHarvesterDockSequence : HarvesterDockSequence
{
enum State { Turn, Dock, Loop, Undock }
readonly Actor proc;
readonly Harvester harv;
readonly WithVoxelUnloadBody body;
State state;
public VoxelHarvesterDockSequence(Actor self, Actor proc)
public VoxelHarvesterDockSequence(Actor self, Actor refinery, int dockAngle, bool isDragRequired, WVec dragOffset, int dragLength)
: base(self, refinery, dockAngle, isDragRequired, dragOffset, dragLength)
{
this.proc = proc;
state = State.Turn;
harv = self.Trait<Harvester>();
body = self.Trait<WithVoxelUnloadBody>();
}
public override Activity Tick(Actor self)
public override Activity OnStateDock(Actor self)
{
switch (state)
{
case State.Turn:
state = State.Dock;
return Util.SequenceActivities(new Turn(self, 160), this);
case State.Dock:
if (proc.IsInWorld && !proc.IsDead)
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
nd.Docked(proc, self);
state = State.Loop;
body.Docked = true;
return this;
case State.Loop:
if (!proc.IsInWorld || proc.IsDead || harv.TickUnload(self, proc))
state = State.Undock;
return this;
case State.Undock:
if (proc.IsInWorld && !proc.IsDead)
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
nd.Undocked(proc, self);
body.Docked = false;
return NextActivity;
}
throw new InvalidOperationException("Invalid harvester dock state");
body.Docked = true;
dockingState = State.Loop;
return this;
}
public override void Cancel(Actor self)
public override Activity OnStateUndock(Actor self)
{
state = State.Undock;
}
public override IEnumerable<Target> GetTargets(Actor self)
{
yield return Target.FromActor(proc);
body.Docked = false;
dockingState = State.Complete;
return this;
}
}
}
}

View File

@@ -11,22 +11,21 @@
using OpenRA.Activities;
using OpenRA.Mods.RA.Traits;
using OpenRA.Mods.TS.Activities;
using OpenRA.Traits;
namespace OpenRA.Mods.TS.Traits
{
public class TiberianSunRefineryInfo : OreRefineryInfo
public class TiberianSunRefineryInfo : RefineryInfo
{
public override object Create(ActorInitializer init) { return new TiberianSunRefinery(init.Self, this); }
}
public class TiberianSunRefinery : OreRefinery
public class TiberianSunRefinery : Refinery
{
public TiberianSunRefinery(Actor self, TiberianSunRefineryInfo info) : base(self, info) { }
public TiberianSunRefinery(Actor self, RefineryInfo info) : base(self, info) { }
public override Activity DockSequence(Actor harv, Actor self)
{
return new VoxelHarvesterDockSequence(harv, self);
return new VoxelHarvesterDockSequence(harv, self, DeliveryAngle, IsDragRequired, DragOffset, DragLength);
}
}
}

View File

@@ -146,8 +146,12 @@ PROC:
RevealsShroud:
Range: 6c0
Bib:
TiberiumRefinery:
Refinery:
DockAngle: 112
DockOffset: 0,2
IsDragRequired: True
DragOffset: -640,341,0
DragLength: 12
TickRate: 15
StoresResources:
PipColor: Green

View File

@@ -171,9 +171,9 @@ CONCRETEB:
Type: Wood
RevealsShroud:
Range: 6c0
OreRefinery:
DockOffset: 2,1
Refinery:
DockAngle: 160
DockOffset: 2,1
TickRate: 20
StoresResources:
PipColor: green

View File

@@ -933,7 +933,9 @@ PROC:
RevealsShroud:
Range: 6c0
Bib:
OreRefinery:
Refinery:
DockAngle: 64
DockOffset: 1,2
StoresResources:
PipCount: 17
Capacity: 2000

View File

@@ -147,6 +147,7 @@ PROC:
RevealsShroud:
Range: 6c0
TiberianSunRefinery:
DockAngle: 160
DockOffset: 2,1
StoresResources:
PipColor: Green