Fix chronoshift + chronotank = crash (Yo Dawg)

This commit is contained in:
Paul Chote
2010-01-06 23:17:12 +13:00
parent 33da7f73d7
commit d6c2c19316
3 changed files with 53 additions and 3 deletions

View File

@@ -96,6 +96,7 @@
<Compile Include="GameRules\VoiceInfo.cs" />
<Compile Include="Effects\IEffect.cs" />
<Compile Include="Graphics\Minimap.cs" />
<Compile Include="Orders\ChronoshiftSelfDestinationOrderGenerator.cs" />
<Compile Include="Orders\ChronosphereSelectOrderGenerator.cs" />
<Compile Include="Orders\IOrderSource.cs" />
<Compile Include="Orders\LocalOrderSource.cs" />
@@ -304,4 +305,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using OpenRa.Game.Traits;
namespace OpenRa.Game.Orders
{
class ChronoshiftSelfDestinationOrderGenerator : IOrderGenerator
{
public readonly Actor self;
public ChronoshiftSelfDestinationOrderGenerator(Actor self)
{
this.self = self;
}
public IEnumerable<Order> Order(int2 xy, MouseInput mi)
{
if (mi.Button == MouseButton.Left)
{
Game.controller.CancelInputMode();
yield break;
}
yield return new Order("ChronoshiftSelf", self, null, xy, null);
}
public void Tick() { }
public void Render()
{
Game.worldRenderer.DrawSelectionBox(self, Color.White, true);
}
public Cursor GetCursor(int2 xy, MouseInput mi)
{
if (!Game.LocalPlayer.Shroud.IsExplored(xy))
return Cursor.MoveBlocked;
var movement = self.traits.WithInterface<IMovement>().FirstOrDefault();
return (movement.CanEnterCell(xy)) ? Cursor.Chronoshift : Cursor.MoveBlocked;
}
}
}

View File

@@ -30,13 +30,17 @@ namespace OpenRa.Game.Traits
{
if (order.OrderString == "Deploy")
{
Game.controller.orderGenerator = new ChronoshiftDestinationOrderGenerator(self);
Game.controller.orderGenerator = new ChronoshiftSelfDestinationOrderGenerator(self);
return;
}
var movement = self.traits.WithInterface<IMovement>().FirstOrDefault();
if (order.OrderString == "Chronoshift" && movement.CanEnterCell(order.TargetLocation))
if (order.OrderString == "ChronoshiftSelf" && movement.CanEnterCell(order.TargetLocation))
{
// Cannot chronoshift into unexplored location
if (!Game.LocalPlayer.Shroud.IsExplored(order.TargetLocation))
return;
Game.controller.CancelInputMode();
self.CancelActivity();
self.QueueActivity(new Activities.Teleport(order.TargetLocation));