fix crash when docking with a voxel harvester
This commit is contained in:
73
OpenRA.Mods.TS/Activities/VoxelHarvesterDockSequence.cs
Normal file
73
OpenRA.Mods.TS/Activities/VoxelHarvesterDockSequence.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2014 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.Mods.RA;
|
||||
using OpenRA.Mods.RA.Activities;
|
||||
using OpenRA.Mods.RA.Move;
|
||||
using OpenRA.Mods.RA.Render;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.TS
|
||||
{
|
||||
public class SimpleHarvesterDockSequence : Activity
|
||||
{
|
||||
enum State { Turn, Dock, Loop, Undock }
|
||||
|
||||
readonly Actor proc;
|
||||
readonly Harvester harv;
|
||||
State state;
|
||||
|
||||
public SimpleHarvesterDockSequence(Actor self, Actor proc)
|
||||
{
|
||||
this.proc = proc;
|
||||
state = State.Turn;
|
||||
harv = self.Trait<Harvester>();
|
||||
}
|
||||
|
||||
public override Activity Tick(Actor self)
|
||||
{
|
||||
switch (state)
|
||||
{
|
||||
case State.Turn:
|
||||
state = State.Dock;
|
||||
return Util.SequenceActivities(new Turn(160), this);
|
||||
case State.Dock:
|
||||
if (proc.IsInWorld && !proc.IsDead())
|
||||
foreach (var nd in proc.TraitsImplementing<INotifyDocking>())
|
||||
nd.Docked(proc, self);
|
||||
state = State.Loop;
|
||||
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);
|
||||
return 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,10 +40,16 @@
|
||||
<Project>{0DFB103F-2962-400F-8C6D-E2C28CCBA633}</Project>
|
||||
<Name>OpenRA.Game</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\OpenRA.Mods.RA\OpenRA.Mods.RA.csproj">
|
||||
<Project>{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}</Project>
|
||||
<Name>OpenRA.Mods.RA</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Widgets\Logic\TSInstallFromCDLogic.cs" />
|
||||
<Compile Include="ShroudPalette.cs" />
|
||||
<Compile Include="Activities\VoxelHarvesterDockSequence.cs" />
|
||||
<Compile Include="TiberianSunRefinery.cs" />
|
||||
</ItemGroup>
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
30
OpenRA.Mods.TS/TiberianSunRefinery.cs
Normal file
30
OpenRA.Mods.TS/TiberianSunRefinery.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2011 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.Mods.RA;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.TS
|
||||
{
|
||||
public class TiberianSunRefineryInfo : OreRefineryInfo
|
||||
{
|
||||
public override object Create(ActorInitializer init) { return new TiberianSunRefinery(init.self, this); }
|
||||
}
|
||||
|
||||
public class TiberianSunRefinery : OreRefinery
|
||||
{
|
||||
public TiberianSunRefinery(Actor self, TiberianSunRefineryInfo info) : base(self, info) { }
|
||||
|
||||
public override Activity DockSequence(Actor harv, Actor self)
|
||||
{
|
||||
return new SimpleHarvesterDockSequence(harv, self);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -133,7 +133,7 @@ PROC:
|
||||
RevealsShroud:
|
||||
Range: 6
|
||||
# Bib:
|
||||
TiberiumRefinery:
|
||||
TiberianSunRefinery:
|
||||
StoresResources:
|
||||
PipColor: Green
|
||||
PipCount: 15
|
||||
|
||||
Reference in New Issue
Block a user