diff --git a/OpenRa.Game/Controller.cs b/OpenRa.Game/Controller.cs index c51f7f6499..18394e168d 100644 --- a/OpenRa.Game/Controller.cs +++ b/OpenRa.Game/Controller.cs @@ -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 diff --git a/OpenRa.Game/Order.cs b/OpenRa.Game/Order.cs index 2e04a43540..c2d25713bc 100644 --- a/OpenRa.Game/Order.cs +++ b/OpenRa.Game/Order.cs @@ -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 ); - } } } diff --git a/OpenRa.Game/PlaceBuilding.cs b/OpenRa.Game/PlaceBuilding.cs index 3497a423f9..b8306e26f7 100644 --- a/OpenRa.Game/PlaceBuilding.cs +++ b/OpenRa.Game/PlaceBuilding.cs @@ -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 { diff --git a/OpenRa.Game/Traits/AttackBase.cs b/OpenRa.Game/Traits/AttackBase.cs index 44b0763a5c..2253655437 100644 --- a/OpenRa.Game/Traits/AttackBase.cs +++ b/OpenRa.Game/Traits/AttackBase.cs @@ -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) diff --git a/OpenRa.Game/Traits/ChronoshiftDeploy.cs b/OpenRa.Game/Traits/ChronoshiftDeploy.cs index d88dc9da6a..381ea0fef5 100644 --- a/OpenRa.Game/Traits/ChronoshiftDeploy.cs +++ b/OpenRa.Game/Traits/ChronoshiftDeploy.cs @@ -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().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)); diff --git a/OpenRa.Game/Traits/Harvester.cs b/OpenRa.Game/Traits/Harvester.cs index b3e6bee845..8fa52e88ce 100644 --- a/OpenRa.Game/Traits/Harvester.cs +++ b/OpenRa.Game/Traits/Harvester.cs @@ -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() && !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)); } } diff --git a/OpenRa.Game/Traits/Helicopter.cs b/OpenRa.Game/Traits/Helicopter.cs index 9f21b16f75..400456f832 100644 --- a/OpenRa.Game/Traits/Helicopter.cs +++ b/OpenRa.Game/Traits/Helicopter.cs @@ -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; } diff --git a/OpenRa.Game/Traits/McvDeploy.cs b/OpenRa.Game/Traits/McvDeploy.cs index dfef831c25..ab72c362fb 100644 --- a/OpenRa.Game/Traits/McvDeploy.cs +++ b/OpenRa.Game/Traits/McvDeploy.cs @@ -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() ); } } } diff --git a/OpenRa.Game/Traits/Mobile.cs b/OpenRa.Game/Traits/Mobile.cs index e1fd485391..88d5a3123d 100644 --- a/OpenRa.Game/Traits/Mobile.cs +++ b/OpenRa.Game/Traits/Mobile.cs @@ -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) diff --git a/OpenRa.Game/Traits/Plane.cs b/OpenRa.Game/Traits/Plane.cs index 6fb4693946..064662ee06 100644 --- a/OpenRa.Game/Traits/Plane.cs +++ b/OpenRa.Game/Traits/Plane.cs @@ -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; } diff --git a/OpenRa.Game/Traits/RallyPoint.cs b/OpenRa.Game/Traits/RallyPoint.cs index e4a3fc7d99..acb2b8b63a 100644 --- a/OpenRa.Game/Traits/RallyPoint.cs +++ b/OpenRa.Game/Traits/RallyPoint.cs @@ -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 ) diff --git a/OpenRa.Game/UnitOrders.cs b/OpenRa.Game/UnitOrders.cs index 459a833627..fa9b2b858f 100755 --- a/OpenRa.Game/UnitOrders.cs +++ b/OpenRa.Game/UnitOrders.cs @@ -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() ) - 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()) + t.ResolveOrder(order.Subject, order); + break; + } } } }