rationalizing some fail

This commit is contained in:
Chris Forbes
2009-12-28 14:49:43 +13:00
parent 8696273a5c
commit 8fc344adb7
12 changed files with 30 additions and 83 deletions

View File

@@ -149,8 +149,8 @@ namespace OpenRa.Game
return Cursor.Deploy;
else
return Cursor.DeployBlocked;
case "ActivatePortableChronoshift": return Cursor.Deploy;
case "UsePortableChronoshift":
case "Deploy": return Cursor.Deploy;
case "Chronoshift":
if (movement.CanEnterCell(location))
return Cursor.Chronoshift;
else

View File

@@ -139,46 +139,6 @@ namespace OpenRa.Game
{ IsImmediate = true };
}
public static Order Attack(Actor subject, Actor target)
{
return new Order("Attack", subject, target, int2.Zero, null);
}
public static Order Move(Actor subject, int2 target)
{
return new Order("Move", subject, null, target, null);
}
public static Order ActivatePortableChronoshift(Actor subject)
{
return new Order("ActivatePortableChronoshift", subject, null, int2.Zero, null);
}
public static Order UsePortableChronoshift(Actor subject, int2 target)
{
return new Order("UsePortableChronoshift", subject, null, target, null);
}
public static Order DeployMcv(Actor subject)
{
return new Order("DeployMcv", subject, null, int2.Zero, null);
}
public static Order PlaceBuilding(Player subject, int2 target, string buildingName)
{
return new Order("PlaceBuilding", subject.PlayerActor, null, target, buildingName);
}
public static Order Enter(Actor subject, Actor target)
{
return new Order("Enter", subject, target, int2.Zero, null);
}
public static Order Harvest(Actor subject, int2 target)
{
return new Order("Harvest", subject, null, target, null);
}
public static Order StartProduction(Player subject, string item)
{
return new Order("StartProduction", subject.PlayerActor, null, int2.Zero, item );
@@ -193,10 +153,5 @@ namespace OpenRa.Game
{
return new Order("CancelProduction", subject.PlayerActor, null, int2.Zero, item);
}
public static Order SetRallyPoint(Actor subject, int2 target)
{
return new Order("SetRallyPoint", subject, null, target, null );
}
}
}

View File

@@ -30,7 +30,7 @@ namespace OpenRa.Game
yield break;
}
yield return OpenRa.Game.Order.PlaceBuilding( Producer.Owner, xy, Building.Name );
yield return new Order("PlaceBuilding", Producer.Owner.PlayerActor, null, xy, Building.Name);
}
else // rmb
{

View File

@@ -139,7 +139,7 @@ namespace OpenRa.Game.Traits
if (self == underCursor) return null;
if (underCursor.Owner == self.Owner && !mi.Modifiers.HasModifier( Modifiers.Ctrl )) return null;
if (!Combat.HasAnyValidWeapons(self, underCursor)) return null;
return Order.Attack(self, underCursor);
return new Order("Attack", self, underCursor, int2.Zero, null);
}
public void ResolveOrder(Actor self, Order order)

View File

@@ -22,10 +22,10 @@ namespace OpenRa.Game.Traits
if (mi.Button == MouseButton.Left) return null;
if (chronoshiftActive)
return Order.UsePortableChronoshift(self, xy);
return new Order("Chronoshift", self, null, xy, null);
else if (xy == self.Location && remainingChargeTime <= 0)
return Order.ActivatePortableChronoshift(self);
return new Order("Deploy", self, null, int2.Zero, null);
return null;
}
@@ -33,13 +33,13 @@ namespace OpenRa.Game.Traits
public void ResolveOrder(Actor self, Order order)
{
var movement = self.traits.WithInterface<IMovement>().FirstOrDefault();
if (order.OrderString == "ActivatePortableChronoshift" && remainingChargeTime <= 0)
if (order.OrderString == "Deploy" && remainingChargeTime <= 0)
{
chronoshiftActive = true;
self.CancelActivity();
}
if (order.OrderString == "UsePortableChronoshift" && movement.CanEnterCell(order.TargetLocation))
if (order.OrderString == "Chronoshift" && movement.CanEnterCell(order.TargetLocation))
{
self.CancelActivity();
self.QueueActivity(new Activities.Teleport(order.TargetLocation));

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using OpenRa.Game.Traits.Activities;
namespace OpenRa.Game.Traits
{
class Harvester : IOrder, IPips
@@ -32,10 +33,10 @@ namespace OpenRa.Game.Traits
if (underCursor != null
&& underCursor.Owner == self.Owner
&& underCursor.traits.Contains<AcceptsOre>() && !IsEmpty)
return Order.Enter(self, underCursor);
return new Order("Enter", self, underCursor, int2.Zero, null);
if (underCursor == null && Rules.Map.ContainsResource(xy))
return Order.Harvest(self, xy);
return new Order("Harvest", self, null, xy, null);
return null;
}
@@ -45,13 +46,13 @@ namespace OpenRa.Game.Traits
if (order.OrderString == "Harvest")
{
self.CancelActivity();
self.QueueActivity(new Traits.Activities.Move(order.TargetLocation, 0));
self.QueueActivity(new Traits.Activities.Harvest());
self.QueueActivity(new Move(order.TargetLocation, 0));
self.QueueActivity(new Harvest());
}
else if (order.OrderString == "Enter")
{
self.CancelActivity();
self.QueueActivity(new Traits.Activities.DeliverOre(order.TargetActor));
self.QueueActivity(new DeliverOre(order.TargetActor));
}
}

View File

@@ -20,7 +20,7 @@ namespace OpenRa.Game.Traits
if (mi.Button == MouseButton.Left) return null;
if (underCursor == null)
return Order.Move(self, xy);
return new Order("Move", self, null, xy, null);
return null;
}

View File

@@ -1,4 +1,5 @@
using OpenRa.Game.GameRules;
using OpenRa.Game.Traits.Activities;
namespace OpenRa.Game.Traits
{
@@ -11,7 +12,7 @@ namespace OpenRa.Game.Traits
if (mi.Button == MouseButton.Left) return null;
if( xy != self.Location ) return null;
return Order.DeployMcv(self);
return new Order("DeployMcv", self, null, int2.Zero, null);
}
public void ResolveOrder( Actor self, Order order )
@@ -22,8 +23,8 @@ namespace OpenRa.Game.Traits
if( Game.CanPlaceBuilding( factBuildingInfo, self.Location - new int2( 1, 1 ), self, false ) )
{
self.CancelActivity();
self.QueueActivity( new Traits.Activities.Turn( 96 ) );
self.QueueActivity( new Traits.Activities.DeployMcv() );
self.QueueActivity( new Turn( 96 ) );
self.QueueActivity( new DeployMcv() );
}
}
}

View File

@@ -47,7 +47,7 @@ namespace OpenRa.Game.Traits
if (Util.GetEffectiveSpeed(self) == 0) return null; /* allow disabling move orders from modifiers */
if (xy == toCell) return null;
return Order.Move(self, xy);
return new Order("Move", self, null, xy, null);
}
public void ResolveOrder(Actor self, Order order)

View File

@@ -16,10 +16,12 @@ namespace OpenRa.Game.Traits
{
if (mi.Button == MouseButton.Left) return null;
if (underCursor == null)
return Order.Move(self, xy);
return new Order("Move", self, null, xy, null);
if (underCursor.Info == Rules.UnitInfo["AFLD"]
&& underCursor.Owner == self.Owner)
return Order.Enter(self, underCursor);
return new Order("Enter", self, underCursor, int2.Zero, null);
return null;
}

View File

@@ -27,7 +27,7 @@ namespace OpenRa.Game.Traits
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
if (mi.Button == MouseButton.Left || underCursor != null) return null;
return Order.SetRallyPoint(self, xy);
return new Order("SetRallyPoint", self, null, xy, null);
}
public void ResolveOrder( Actor self, Order order )

View File

@@ -13,22 +13,6 @@ namespace OpenRa.Game
{
switch( order.OrderString )
{
case "Move":
case "Attack":
case "DeployMcv":
case "Enter":
case "Harvest":
case "SetRallyPoint":
case "StartProduction":
case "PauseProduction":
case "CancelProduction":
case "ActivatePortableChronoshift":
case "UsePortableChronoshift":
{
foreach( var t in order.Subject.traits.WithInterface<IOrder>() )
t.ResolveOrder( order.Subject, order );
break;
}
case "PlaceBuilding":
{
Game.world.AddFrameEndTask( _ =>
@@ -114,7 +98,11 @@ namespace OpenRa.Game
}
default:
throw new NotImplementedException();
{
foreach (var t in order.Subject.traits.WithInterface<IOrder>())
t.ResolveOrder(order.Subject, order);
break;
}
}
}
}