rationalizing some fail
This commit is contained in:
@@ -149,8 +149,8 @@ namespace OpenRa.Game
|
|||||||
return Cursor.Deploy;
|
return Cursor.Deploy;
|
||||||
else
|
else
|
||||||
return Cursor.DeployBlocked;
|
return Cursor.DeployBlocked;
|
||||||
case "ActivatePortableChronoshift": return Cursor.Deploy;
|
case "Deploy": return Cursor.Deploy;
|
||||||
case "UsePortableChronoshift":
|
case "Chronoshift":
|
||||||
if (movement.CanEnterCell(location))
|
if (movement.CanEnterCell(location))
|
||||||
return Cursor.Chronoshift;
|
return Cursor.Chronoshift;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -139,46 +139,6 @@ namespace OpenRa.Game
|
|||||||
{ IsImmediate = true };
|
{ 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)
|
public static Order StartProduction(Player subject, string item)
|
||||||
{
|
{
|
||||||
return new Order("StartProduction", subject.PlayerActor, null, int2.Zero, 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);
|
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 );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ namespace OpenRa.Game
|
|||||||
yield break;
|
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
|
else // rmb
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ namespace OpenRa.Game.Traits
|
|||||||
if (self == underCursor) return null;
|
if (self == underCursor) return null;
|
||||||
if (underCursor.Owner == self.Owner && !mi.Modifiers.HasModifier( Modifiers.Ctrl )) return null;
|
if (underCursor.Owner == self.Owner && !mi.Modifiers.HasModifier( Modifiers.Ctrl )) return null;
|
||||||
if (!Combat.HasAnyValidWeapons(self, underCursor)) 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)
|
public void ResolveOrder(Actor self, Order order)
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ namespace OpenRa.Game.Traits
|
|||||||
if (mi.Button == MouseButton.Left) return null;
|
if (mi.Button == MouseButton.Left) return null;
|
||||||
|
|
||||||
if (chronoshiftActive)
|
if (chronoshiftActive)
|
||||||
return Order.UsePortableChronoshift(self, xy);
|
return new Order("Chronoshift", self, null, xy, null);
|
||||||
|
|
||||||
else if (xy == self.Location && remainingChargeTime <= 0)
|
else if (xy == self.Location && remainingChargeTime <= 0)
|
||||||
return Order.ActivatePortableChronoshift(self);
|
return new Order("Deploy", self, null, int2.Zero, null);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -33,13 +33,13 @@ namespace OpenRa.Game.Traits
|
|||||||
public void ResolveOrder(Actor self, Order order)
|
public void ResolveOrder(Actor self, Order order)
|
||||||
{
|
{
|
||||||
var movement = self.traits.WithInterface<IMovement>().FirstOrDefault();
|
var movement = self.traits.WithInterface<IMovement>().FirstOrDefault();
|
||||||
if (order.OrderString == "ActivatePortableChronoshift" && remainingChargeTime <= 0)
|
if (order.OrderString == "Deploy" && remainingChargeTime <= 0)
|
||||||
{
|
{
|
||||||
chronoshiftActive = true;
|
chronoshiftActive = true;
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (order.OrderString == "UsePortableChronoshift" && movement.CanEnterCell(order.TargetLocation))
|
if (order.OrderString == "Chronoshift" && movement.CanEnterCell(order.TargetLocation))
|
||||||
{
|
{
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.QueueActivity(new Activities.Teleport(order.TargetLocation));
|
self.QueueActivity(new Activities.Teleport(order.TargetLocation));
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using OpenRa.Game.Traits.Activities;
|
||||||
namespace OpenRa.Game.Traits
|
namespace OpenRa.Game.Traits
|
||||||
{
|
{
|
||||||
class Harvester : IOrder, IPips
|
class Harvester : IOrder, IPips
|
||||||
@@ -32,10 +33,10 @@ namespace OpenRa.Game.Traits
|
|||||||
if (underCursor != null
|
if (underCursor != null
|
||||||
&& underCursor.Owner == self.Owner
|
&& underCursor.Owner == self.Owner
|
||||||
&& underCursor.traits.Contains<AcceptsOre>() && !IsEmpty)
|
&& 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))
|
if (underCursor == null && Rules.Map.ContainsResource(xy))
|
||||||
return Order.Harvest(self, xy);
|
return new Order("Harvest", self, null, xy, null);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -45,13 +46,13 @@ namespace OpenRa.Game.Traits
|
|||||||
if (order.OrderString == "Harvest")
|
if (order.OrderString == "Harvest")
|
||||||
{
|
{
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.QueueActivity(new Traits.Activities.Move(order.TargetLocation, 0));
|
self.QueueActivity(new Move(order.TargetLocation, 0));
|
||||||
self.QueueActivity(new Traits.Activities.Harvest());
|
self.QueueActivity(new Harvest());
|
||||||
}
|
}
|
||||||
else if (order.OrderString == "Enter")
|
else if (order.OrderString == "Enter")
|
||||||
{
|
{
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.QueueActivity(new Traits.Activities.DeliverOre(order.TargetActor));
|
self.QueueActivity(new DeliverOre(order.TargetActor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace OpenRa.Game.Traits
|
|||||||
if (mi.Button == MouseButton.Left) return null;
|
if (mi.Button == MouseButton.Left) return null;
|
||||||
|
|
||||||
if (underCursor == null)
|
if (underCursor == null)
|
||||||
return Order.Move(self, xy);
|
return new Order("Move", self, null, xy, null);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using OpenRa.Game.GameRules;
|
using OpenRa.Game.GameRules;
|
||||||
|
using OpenRa.Game.Traits.Activities;
|
||||||
|
|
||||||
namespace OpenRa.Game.Traits
|
namespace OpenRa.Game.Traits
|
||||||
{
|
{
|
||||||
@@ -11,7 +12,7 @@ namespace OpenRa.Game.Traits
|
|||||||
if (mi.Button == MouseButton.Left) return null;
|
if (mi.Button == MouseButton.Left) return null;
|
||||||
if( xy != self.Location ) 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 )
|
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 ) )
|
if( Game.CanPlaceBuilding( factBuildingInfo, self.Location - new int2( 1, 1 ), self, false ) )
|
||||||
{
|
{
|
||||||
self.CancelActivity();
|
self.CancelActivity();
|
||||||
self.QueueActivity( new Traits.Activities.Turn( 96 ) );
|
self.QueueActivity( new Turn( 96 ) );
|
||||||
self.QueueActivity( new Traits.Activities.DeployMcv() );
|
self.QueueActivity( new DeployMcv() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace OpenRa.Game.Traits
|
|||||||
|
|
||||||
if (Util.GetEffectiveSpeed(self) == 0) return null; /* allow disabling move orders from modifiers */
|
if (Util.GetEffectiveSpeed(self) == 0) return null; /* allow disabling move orders from modifiers */
|
||||||
if (xy == toCell) return null;
|
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)
|
public void ResolveOrder(Actor self, Order order)
|
||||||
|
|||||||
@@ -16,10 +16,12 @@ namespace OpenRa.Game.Traits
|
|||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Left) return null;
|
if (mi.Button == MouseButton.Left) return null;
|
||||||
if (underCursor == null)
|
if (underCursor == null)
|
||||||
return Order.Move(self, xy);
|
return new Order("Move", self, null, xy, null);
|
||||||
|
|
||||||
if (underCursor.Info == Rules.UnitInfo["AFLD"]
|
if (underCursor.Info == Rules.UnitInfo["AFLD"]
|
||||||
&& underCursor.Owner == self.Owner)
|
&& underCursor.Owner == self.Owner)
|
||||||
return Order.Enter(self, underCursor);
|
return new Order("Enter", self, underCursor, int2.Zero, null);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace OpenRa.Game.Traits
|
|||||||
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
|
||||||
{
|
{
|
||||||
if (mi.Button == MouseButton.Left || underCursor != null) return null;
|
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 )
|
public void ResolveOrder( Actor self, Order order )
|
||||||
|
|||||||
@@ -13,22 +13,6 @@ namespace OpenRa.Game
|
|||||||
{
|
{
|
||||||
switch( order.OrderString )
|
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":
|
case "PlaceBuilding":
|
||||||
{
|
{
|
||||||
Game.world.AddFrameEndTask( _ =>
|
Game.world.AddFrameEndTask( _ =>
|
||||||
@@ -114,7 +98,11 @@ namespace OpenRa.Game
|
|||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new NotImplementedException();
|
{
|
||||||
|
foreach (var t in order.Subject.traits.WithInterface<IOrder>())
|
||||||
|
t.ResolveOrder(order.Subject, order);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user