diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj
index 371356b305..865fb10c03 100755
--- a/OpenRA.Game/OpenRA.Game.csproj
+++ b/OpenRA.Game/OpenRA.Game.csproj
@@ -81,7 +81,7 @@
-
+
@@ -184,7 +184,6 @@
-
diff --git a/OpenRA.Game/Traits/BaseBuilding.cs b/OpenRA.Game/Traits/BaseBuilding.cs
new file mode 100755
index 0000000000..ee19ae0fc2
--- /dev/null
+++ b/OpenRA.Game/Traits/BaseBuilding.cs
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace OpenRA.Traits
+{
+ /* tag trait for "bases": mcv/fact */
+ class BaseBuildingInfo : TraitInfo { }
+ class BaseBuilding { }
+}
diff --git a/OpenRA.Game/Traits/Player/PlaceBuilding.cs b/OpenRA.Game/Traits/Player/PlaceBuilding.cs
index 35a08353e8..3222b53488 100644
--- a/OpenRA.Game/Traits/Player/PlaceBuilding.cs
+++ b/OpenRA.Game/Traits/Player/PlaceBuilding.cs
@@ -20,6 +20,7 @@
using System.Linq;
using OpenRA.Effects;
+using OpenRA.GameRules;
namespace OpenRA.Traits
{
@@ -63,16 +64,7 @@ namespace OpenRA.Traits
Sound.PlayToPlayer(order.Player, s, building.CenterLocation);
}
- /* todo: reimpl this properly */
-
- var facts = w.Queries.OwnedBy[self.Owner]
- .WithTrait().Select(x => x.Actor);
-
- var primaryFact = facts.Where(y => y.traits.Get().IsPrimary);
- var fact = (primaryFact.Count() > 0) ? primaryFact.FirstOrDefault() : facts.FirstOrDefault();
-
- if (fact != null)
- fact.traits.Get().PlayCustomAnim(fact, "build");
+ PlayBuildAnim( self, unit );
queue.FinishProduction(unit.Category);
@@ -84,6 +76,20 @@ namespace OpenRA.Traits
}
}
+ // finds a construction yard (or equivalent) and runs its "build" animation.
+ static void PlayBuildAnim( Actor self, ActorInfo unit )
+ {
+ var producers = self.World.Queries.OwnedBy[ self.Owner ].WithTrait()
+ .Where( x => x.Actor.Info.Traits.Get().Produces.Contains( unit.Category ) )
+ .ToList();
+ var producer = producers.Where( x => x.Trait.IsPrimary ).Concat( producers )
+ .Select( x => x.Actor )
+ .FirstOrDefault();
+
+ if( producer != null )
+ producer.traits.Get().PlayCustomAnim( producer, "build" );
+ }
+
static int GetNumBuildables(Player p)
{
if (p != p.World.LocalPlayer) return 0; // this only matters for local players.
diff --git a/OpenRA.Game/Traits/Activities/UndeployMcv.cs b/OpenRA.Mods.RA/Activities/UndeployMcv.cs
old mode 100644
new mode 100755
similarity index 91%
rename from OpenRA.Game/Traits/Activities/UndeployMcv.cs
rename to OpenRA.Mods.RA/Activities/UndeployMcv.cs
index 3a5a86210e..7a2cfdd7f9
--- a/OpenRA.Game/Traits/Activities/UndeployMcv.cs
+++ b/OpenRA.Mods.RA/Activities/UndeployMcv.cs
@@ -18,9 +18,11 @@
*/
#endregion
-namespace OpenRA.Traits.Activities
+using OpenRA.Traits;
+
+namespace OpenRA.Mods.RA.Activities
{
- class UndeployMcv : IActivity
+ public class UndeployMcv : IActivity
{
public IActivity NextActivity { get; set; }
bool started;
diff --git a/OpenRA.Mods.RA/Chrome/PowerDownButton.cs b/OpenRA.Mods.RA/Chrome/PowerDownButton.cs
index 993e48fc44..d251799469 100755
--- a/OpenRA.Mods.RA/Chrome/PowerDownButton.cs
+++ b/OpenRA.Mods.RA/Chrome/PowerDownButton.cs
@@ -46,9 +46,8 @@ namespace OpenRA.Mods.RA
{
get
{
- return !info.RequiresConstructionYard ||
- Game.world.Queries.OwnedBy[Game.world.LocalPlayer]
- .WithTrait().Any();
+ // WTF: why are these buttons even traits?
+ return RepairOrderGenerator.PlayerIsAllowedToRepair( Game.world );
}
}
diff --git a/OpenRA.Game/Traits/ConstructionYard.cs b/OpenRA.Mods.RA/ConstructionYard.cs
old mode 100644
new mode 100755
similarity index 85%
rename from OpenRA.Game/Traits/ConstructionYard.cs
rename to OpenRA.Mods.RA/ConstructionYard.cs
index 910df032df..49116e0307
--- a/OpenRA.Game/Traits/ConstructionYard.cs
+++ b/OpenRA.Mods.RA/ConstructionYard.cs
@@ -18,9 +18,10 @@
*/
#endregion
-using OpenRA.Traits.Activities;
+using OpenRA.Mods.RA.Activities;
+using OpenRA.Traits;
-namespace OpenRA.Traits
+namespace OpenRA.Mods.RA
{
class ConstructionYardInfo : TraitInfo { }
@@ -45,9 +46,4 @@ namespace OpenRA.Traits
}
}
}
-
- /* tag trait for "bases": mcv/fact */
-
- class BaseBuildingInfo : TraitInfo { }
- class BaseBuilding { }
}
diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
index 2e7bbe53bf..2becaaada1 100644
--- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
+++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj
@@ -67,8 +67,10 @@
+
+
diff --git a/OpenRA.Mods.RA/Orders/RepairOrderGenerator.cs b/OpenRA.Mods.RA/Orders/RepairOrderGenerator.cs
index 1f85532de6..056f616798 100755
--- a/OpenRA.Mods.RA/Orders/RepairOrderGenerator.cs
+++ b/OpenRA.Mods.RA/Orders/RepairOrderGenerator.cs
@@ -52,14 +52,20 @@ namespace OpenRA.Mods.RA.Orders
public void Tick( World world )
{
- var hasFact = world.Queries.OwnedBy[world.LocalPlayer]
- .WithTrait()
- .Any();
-
- if (!hasFact)
+ if( PlayerIsAllowedToRepair( world ) )
Game.controller.CancelInputMode();
}
+ public static bool PlayerIsAllowedToRepair( World world )
+ {
+ if( !world.WorldActor.Info.Traits.Get().RequiresConstructionYard )
+ return true;
+
+ return Game.world.Queries.OwnedBy[ Game.world.LocalPlayer ]
+ .WithTrait().Where( x => x.Actor.Info.Traits.Get().Produces.Contains( "Building" ) )
+ .Any();
+ }
+
public void Render( World world ) {}
public string GetCursor(World world, int2 xy, MouseInput mi)
diff --git a/OpenRA.Mods.RA/Player/ActorGroupProxy.cs b/OpenRA.Mods.RA/Player/ActorGroupProxy.cs
index 9318207f92..de7d52c01e 100755
--- a/OpenRA.Mods.RA/Player/ActorGroupProxy.cs
+++ b/OpenRA.Mods.RA/Player/ActorGroupProxy.cs
@@ -1,9 +1,7 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
+using System.Linq;
+using OpenRA.Traits;
-namespace OpenRA.Traits
+namespace OpenRA.Mods.RA
{
class ActorGroupProxyInfo : TraitInfo { }