split IOrder

This commit is contained in:
Chris Forbes
2010-01-09 11:49:12 +13:00
parent 6f28dade1e
commit c344045955
25 changed files with 28 additions and 52 deletions

View File

@@ -101,7 +101,7 @@ namespace OpenRa.Game
if (underCursor != null && !underCursor.Info.Selectable) if (underCursor != null && !underCursor.Info.Selectable)
underCursor = null; underCursor = null;
return traits.WithInterface<IOrder>() return traits.WithInterface<IIssueOrder>()
.Select( x => x.IssueOrder( this, xy, mi, underCursor ) ) .Select( x => x.IssueOrder( this, xy, mi, underCursor ) )
.FirstOrDefault( x => x != null ); .FirstOrDefault( x => x != null );
} }

View File

@@ -97,7 +97,7 @@ namespace OpenRa.Game.Orders
default: default:
{ {
foreach (var t in order.Subject.traits.WithInterface<IOrder>()) foreach (var t in order.Subject.traits.WithInterface<IResolveOrder>())
t.ResolveOrder(order.Subject, order); t.ResolveOrder(order.Subject, order);
break; break;
} }

View File

@@ -6,7 +6,7 @@ using OpenRa.Game.Effects;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class AttackBase : IOrder, ITick class AttackBase : IIssueOrder, IResolveOrder, ITick
{ {
public Actor target; public Actor target;

View File

@@ -9,7 +9,7 @@ using OpenRa.Game.Graphics;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class Building : INotifyDamage, IOrder, ITick class Building : INotifyDamage, IResolveOrder, ITick
{ {
readonly Actor self; readonly Actor self;
public readonly BuildingInfo unitInfo; public readonly BuildingInfo unitInfo;
@@ -44,11 +44,6 @@ namespace OpenRa.Game.Traits
Sound.Play("kaboom22.aud"); Sound.Play("kaboom22.aud");
} }
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
return null; // sell/repair orders are issued through Chrome, not here.
}
public void ResolveOrder(Actor self, Order order) public void ResolveOrder(Actor self, Order order)
{ {
if (order.OrderString == "Sell") if (order.OrderString == "Sell")

View File

@@ -2,7 +2,7 @@
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class C4Demolition : IOrder class C4Demolition : IIssueOrder, IResolveOrder
{ {
public C4Demolition(Actor self) { } public C4Demolition(Actor self) { }

View File

@@ -7,7 +7,7 @@ using OpenRa.Game.Traits.Activities;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class Cargo : IPips, IOrder class Cargo : IPips, IIssueOrder, IResolveOrder
{ {
List<Actor> cargo = new List<Actor>(); List<Actor> cargo = new List<Actor>();

View File

@@ -4,7 +4,7 @@ using OpenRa.Game.Orders;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class ChronoshiftDeploy : IOrder, ISpeedModifier, ITick, IPips class ChronoshiftDeploy : IIssueOrder, IResolveOrder, ISpeedModifier, ITick, IPips
{ {
// Recharge logic // Recharge logic
int chargeTick = 0; // How long until we can chronoshift again? int chargeTick = 0; // How long until we can chronoshift again?

View File

@@ -5,7 +5,7 @@ using System.Linq;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class Chronoshiftable : IOrder, ISpeedModifier, ITick class Chronoshiftable : IResolveOrder, ISpeedModifier, ITick
{ {
// Return-to-sender logic // Return-to-sender logic
int2 chronoshiftOrigin; int2 chronoshiftOrigin;
@@ -30,11 +30,6 @@ namespace OpenRa.Game.Traits
} }
} }
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
return null; // Chronoshift order is issued through Chrome.
}
public void ResolveOrder(Actor self, Order order) public void ResolveOrder(Actor self, Order order)
{ {
if (order.OrderString == "ChronosphereSelect") if (order.OrderString == "ChronosphereSelect")

View File

@@ -3,7 +3,7 @@ using OpenRa.Game.Traits.Activities;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class ConstructionYard : IOrder, IMovement class ConstructionYard : IIssueOrder, IResolveOrder, IMovement
{ {
readonly Actor self; readonly Actor self;

View File

@@ -6,7 +6,7 @@ using OpenRa.Game.Orders;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class DemoTruck : Chronoshiftable, IOrder, INotifyDamage class DemoTruck : Chronoshiftable, IResolveOrder, INotifyDamage
{ {
readonly Actor self; readonly Actor self;
public DemoTruck(Actor self) public DemoTruck(Actor self)

View File

@@ -2,7 +2,7 @@
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class EngineerCapture : IOrder class EngineerCapture : IIssueOrder, IResolveOrder
{ {
public const int EngineerDamage = 300; // todo: push into rules, as a weapon public const int EngineerDamage = 300; // todo: push into rules, as a weapon

View File

@@ -3,7 +3,7 @@ using OpenRa.Game.Traits.Activities;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class Harvester : IOrder, IPips class Harvester : IIssueOrder, IResolveOrder, IPips
{ {
public int oreCarried = 0; /* sum of these must not exceed capacity */ public int oreCarried = 0; /* sum of these must not exceed capacity */
public int gemsCarried = 0; public int gemsCarried = 0;

View File

@@ -4,7 +4,7 @@ using OpenRa.Game.GameRules;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class Helicopter : IOrder, IMovement class Helicopter : IIssueOrder, IResolveOrder, IMovement
{ {
public IDisposable reservation; public IDisposable reservation;
public Helicopter(Actor self) {} public Helicopter(Actor self) {}

View File

@@ -3,7 +3,7 @@ using OpenRa.Game.Effects;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class IronCurtainable : IOrder, IDamageModifier, ITick class IronCurtainable : IResolveOrder, IDamageModifier, ITick
{ {
int RemainingTicks = 0; int RemainingTicks = 0;
@@ -19,11 +19,6 @@ namespace OpenRa.Game.Traits
return (RemainingTicks > 0) ? 0.0f : 1.0f; return (RemainingTicks > 0) ? 0.0f : 1.0f;
} }
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
return null; // IronCurtain order is issued through Chrome.
}
public void ResolveOrder(Actor self, Order order) public void ResolveOrder(Actor self, Order order)
{ {
if (order.OrderString == "IronCurtain") if (order.OrderString == "IronCurtain")

View File

@@ -3,7 +3,7 @@ using OpenRa.Game.Traits.Activities;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class McvDeploy : IOrder class McvDeploy : IIssueOrder, IResolveOrder
{ {
public McvDeploy(Actor self) { } public McvDeploy(Actor self) { }

View File

@@ -5,7 +5,7 @@ using System.Text;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class Minelayer : IOrder class Minelayer : IIssueOrder, IResolveOrder
{ {
public Minelayer(Actor self) { } public Minelayer(Actor self) { }

View File

@@ -5,7 +5,7 @@ using OpenRa.Game.GameRules;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class Mobile : IOrder, IOccupySpace, IMovement class Mobile : IIssueOrder, IResolveOrder, IOccupySpace, IMovement
{ {
readonly Actor self; readonly Actor self;

View File

@@ -6,7 +6,7 @@ using OpenRa.Game.Traits.Activities;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class Passenger : IOrder class Passenger : IIssueOrder, IResolveOrder
{ {
public Passenger(Actor self) { } public Passenger(Actor self) { }

View File

@@ -6,7 +6,7 @@ using OpenRa.Game.Traits.Activities;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class Plane : IOrder, IMovement class Plane : IIssueOrder, IResolveOrder, IMovement
{ {
public IDisposable reservation; public IDisposable reservation;

View File

@@ -4,7 +4,7 @@ using System.Collections.Generic;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class Production : IOrder, IProducer, ITags class Production : IIssueOrder, IResolveOrder, IProducer, ITags
{ {
bool isPrimary = false; bool isPrimary = false;
public bool IsPrimary { get { return isPrimary; } } public bool IsPrimary { get { return isPrimary; } }
@@ -66,9 +66,7 @@ namespace OpenRa.Game.Traits
public void ResolveOrder(Actor self, Order order) public void ResolveOrder(Actor self, Order order)
{ {
if (order.OrderString == "Deploy") if (order.OrderString == "Deploy")
{
SetPrimaryProducer(self, !isPrimary); SetPrimaryProducer(self, !isPrimary);
}
} }
public void SetPrimaryProducer(Actor self, bool state) public void SetPrimaryProducer(Actor self, bool state)

View File

@@ -6,7 +6,7 @@ using IjwFramework.Collections;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class ProductionQueue : IOrder, ITick class ProductionQueue : IResolveOrder, ITick
{ {
Actor self; Actor self;
@@ -22,12 +22,6 @@ namespace OpenRa.Game.Traits
(p.Value)[0].Tick( self.Owner ); (p.Value)[0].Tick( self.Owner );
} }
public Order IssueOrder( Actor self, int2 xy, MouseInput mi, Actor underCursor )
{
// production isn't done by clicks in the world; the chrome handles it.
return null;
}
public void ResolveOrder( Actor self, Order order ) public void ResolveOrder( Actor self, Order order )
{ {
switch( order.OrderString ) switch( order.OrderString )

View File

@@ -4,7 +4,7 @@ using OpenRa.Game.Orders;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class RallyPoint : IRender, IOrder, ITick class RallyPoint : IRender, IIssueOrder, IResolveOrder, ITick
{ {
public int2 rallyPoint; public int2 rallyPoint;
public Animation anim; public Animation anim;

View File

@@ -6,7 +6,7 @@ using OpenRa.Game.Traits.Activities;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class Repairable : IOrder class Repairable : IIssueOrder, IResolveOrder
{ {
IDisposable reservation; IDisposable reservation;
public Repairable(Actor self) { } public Repairable(Actor self) { }

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
namespace OpenRa.Game.Traits namespace OpenRa.Game.Traits
{ {
class Thief : IOrder class Thief : IIssueOrder, IResolveOrder
{ {
public Thief(Actor self) { } public Thief(Actor self) { }

View File

@@ -18,11 +18,10 @@ namespace OpenRa.Game.Traits
interface INotifyBuildComplete { void BuildingComplete (Actor self); } interface INotifyBuildComplete { void BuildingComplete (Actor self); }
interface INotifyProduction { void UnitProduced(Actor self, Actor other); } interface INotifyProduction { void UnitProduced(Actor self, Actor other); }
interface IAcceptThief { void OnSteal(Actor self, Actor thief); } interface IAcceptThief { void OnSteal(Actor self, Actor thief); }
interface IOrder
{ interface IIssueOrder { Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor); }
Order IssueOrder( Actor self, int2 xy, MouseInput mi, Actor underCursor ); interface IResolveOrder { void ResolveOrder(Actor self, Order order); }
void ResolveOrder( Actor self, Order order );
}
interface IProducer interface IProducer
{ {
bool Produce( Actor self, UnitInfo producee ); bool Produce( Actor self, UnitInfo producee );