diff --git a/OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj b/OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj
index 3fa3718043..1cd3725cac 100644
--- a/OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj
+++ b/OpenRA.Mods.D2k/OpenRA.Mods.D2k.csproj
@@ -83,6 +83,7 @@
+
diff --git a/OpenRA.Mods.D2k/Render/WithProductionOverlay.cs b/OpenRA.Mods.D2k/Render/WithProductionOverlay.cs
new file mode 100644
index 0000000000..8d4351e172
--- /dev/null
+++ b/OpenRA.Mods.D2k/Render/WithProductionOverlay.cs
@@ -0,0 +1,95 @@
+#region Copyright & License Information
+/*
+ * Copyright 2007-2014 The OpenRA Developers (see AUTHORS)
+ * This file is part of OpenRA, which is free software. It is made
+ * available to you under the terms of the GNU General Public License
+ * as published by the Free Software Foundation. For more information,
+ * see COPYING.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using OpenRA.FileFormats;
+using OpenRA.Graphics;
+using OpenRA.Mods.RA.Buildings;
+using OpenRA.Traits;
+
+namespace OpenRA.Mods.RA.Render
+{
+ public class WithProductionOverlayInfo : ITraitInfo, Requires, Requires
+ {
+ [Desc("Sequence name to use")]
+ public readonly string Sequence = "production-overlay";
+
+ [Desc("Position relative to body")]
+ public readonly WVec Offset = WVec.Zero;
+
+ public object Create(ActorInitializer init) { return new WithProductionOverlay(init.self, this); }
+ }
+
+ public class WithProductionOverlay : INotifyDamageStateChanged, ITick, INotifyBuildComplete, INotifySold
+ {
+ Animation overlay;
+ ProductionQueue queue;
+ bool buildComplete;
+
+ bool IsProducing
+ {
+ get { return queue != null && queue.CurrentItem() != null && !queue.CurrentPaused; }
+ }
+
+ public WithProductionOverlay(Actor self, WithProductionOverlayInfo info)
+ {
+ var rs = self.Trait();
+ var body = self.Trait();
+
+ buildComplete = !self.HasTrait(); // always render instantly for units
+
+ overlay = new Animation(rs.GetImage(self));
+ overlay.PlayRepeating(info.Sequence);
+ rs.anims.Add("production_overlay_{0}".F(info.Sequence),
+ new AnimationWithOffset(overlay,
+ () => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation))),
+ () => !IsProducing || !buildComplete));
+ }
+
+ public void Tick(Actor self)
+ {
+ // search for the queue here once so we don't rely on order of trait initialization
+ if (queue == null)
+ {
+ var production = self.TraitOrDefault();
+
+ var perBuildingQueues = self.TraitsImplementing();
+ queue = perBuildingQueues.FirstOrDefault(q => production.Info.Produces.Contains(q.Info.Type));
+
+ if (queue == null)
+ {
+ var perPlayerQueues = self.Owner.PlayerActor.TraitsImplementing();
+ queue = perPlayerQueues.FirstOrDefault(q => production.Info.Produces.Contains(q.Info.Type));
+ }
+
+ if (queue == null)
+ throw new InvalidOperationException("Can't find production queues.");
+ }
+ }
+
+ public void BuildingComplete(Actor self)
+ {
+ buildComplete = true;
+ }
+
+ public void Sold(Actor self) { }
+ public void Selling(Actor self)
+ {
+ buildComplete = false;
+ }
+
+ public void DamageStateChanged(Actor self, AttackInfo e)
+ {
+ overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, overlay.CurrentSequence.Name));
+ }
+ }
+}
\ No newline at end of file
diff --git a/OpenRA.Mods.RA/Player/ProductionQueue.cs b/OpenRA.Mods.RA/Player/ProductionQueue.cs
index 02336b1396..554032ab26 100755
--- a/OpenRA.Mods.RA/Player/ProductionQueue.cs
+++ b/OpenRA.Mods.RA/Player/ProductionQueue.cs
@@ -203,9 +203,9 @@ namespace OpenRA.Mods.RA
Queue[ 0 ].Tick(playerResources);
}
- public void ResolveOrder( Actor self, Order order )
+ public void ResolveOrder(Actor self, Order order)
{
- switch( order.OrderString )
+ switch(order.OrderString)
{
case "StartProduction":
{
@@ -225,45 +225,43 @@ namespace OpenRA.Mods.RA
{
var inQueue = Queue.Count(pi => pi.Item == order.TargetString);
var owned = self.Owner.World.ActorsWithTrait().Count(a => a.Actor.Info.Name == order.TargetString && a.Actor.Owner == self.Owner);
- if (inQueue + owned >= bi.BuildLimit)
- return;
+ if (inQueue + owned >= bi.BuildLimit)
+ return;
}
- for (var n = 0; n < order.TargetLocation.X; n++) // repeat count
+ for (var n = 0; n < order.TargetLocation.X; n++) // repeat count
{
bool hasPlayedSound = false;
BeginProduction(new ProductionItem(this, order.TargetString, cost, PlayerPower,
- () => self.World.AddFrameEndTask(
- _ =>
+ () => self.World.AddFrameEndTask(_ =>
+ {
+ var isBuilding = unit.Traits.Contains();
+ if (isBuilding && !hasPlayedSound)
{
- var isBuilding = unit.Traits.Contains();
-
- if (isBuilding && !hasPlayedSound)
+ hasPlayedSound = Sound.PlayNotification(self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race);
+ }
+ else if (!isBuilding)
+ {
+ if (BuildUnit(order.TargetString))
+ Sound.PlayNotification(self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race);
+ else if (!hasPlayedSound && time > 0)
{
- hasPlayedSound = Sound.PlayNotification(self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race);
+ hasPlayedSound = Sound.PlayNotification(self.Owner, "Speech", Info.BlockedAudio, self.Owner.Country.Race);
}
- else if (!isBuilding)
- {
- if (BuildUnit(order.TargetString))
- Sound.PlayNotification(self.Owner, "Speech", Info.ReadyAudio, self.Owner.Country.Race);
- else if (!hasPlayedSound && time > 0)
- {
- hasPlayedSound = Sound.PlayNotification(self.Owner, "Speech", Info.BlockedAudio, self.Owner.Country.Race);
- }
- }
- })));
+ }
+ })));
}
break;
}
case "PauseProduction":
{
- if( Queue.Count > 0 && Queue[0].Item == order.TargetString )
+ if (Queue.Count > 0 && Queue[0].Item == order.TargetString)
Queue[0].Paused = ( order.TargetLocation.X != 0 );
break;
}
case "CancelProduction":
{
- CancelProduction(order.TargetString,order.TargetLocation.X);
+ CancelProduction(order.TargetString, order.TargetLocation.X);
break;
}
}
@@ -309,14 +307,14 @@ namespace OpenRA.Mods.RA
Queue.RemoveAt(0);
}
- protected void BeginProduction( ProductionItem item )
+ protected void BeginProduction(ProductionItem item)
{
Queue.Add(item);
}
// Builds a unit from the actor that holds this queue (1 queue per building)
// Returns false if the unit can't be built
- protected virtual bool BuildUnit( string name )
+ protected virtual bool BuildUnit(string name)
{
// Cannot produce if i'm dead
if (!self.IsInWorld || self.IsDead())
@@ -326,7 +324,7 @@ namespace OpenRA.Mods.RA
}
var sp = self.TraitsImplementing().FirstOrDefault(p => p.Info.Produces.Contains(Info.Type));
- if (sp != null && !self.IsDisabled() && sp.Produce(self, Rules.Info[ name ]))
+ if (sp != null && !self.IsDisabled() && sp.Produce(self, Rules.Info[name]))
{
FinishProduction();
return true;
diff --git a/mods/d2k/rules/structures.yaml b/mods/d2k/rules/structures.yaml
index b32e2388a1..6e9ef558e9 100644
--- a/mods/d2k/rules/structures.yaml
+++ b/mods/d2k/rules/structures.yaml
@@ -260,8 +260,8 @@ CONCRETEB:
ProductionBar:
ProvidesCustomPrerequisite:
Prerequisite: Light
- WithIdleOverlay@WELDING:
- Sequence: idle-welding
+ WithProductionOverlay@WELDING:
+ Sequence: production-welding
^HEAVY:
Inherits: ^Building
@@ -300,8 +300,8 @@ CONCRETEB:
ProductionBar:
ProvidesCustomPrerequisite:
Prerequisite: Heavy
- WithIdleOverlay@WELDING:
- Sequence: idle-welding
+ WithProductionOverlay@WELDING:
+ Sequence: production-welding
^RADAR:
Inherits: ^Building
@@ -603,8 +603,8 @@ WALL:
Range: 4c0
ProvidesCustomPrerequisite:
Prerequisite: Hitech
- WithIdleOverlay@WELDING:
- Sequence: idle-welding
+# WithProductionOverlay@WELDING:
+# Sequence: production-welding
^RESEARCH:
Inherits: ^Building
diff --git a/mods/d2k/sequences/structures.yaml b/mods/d2k/sequences/structures.yaml
index f92d6b34a7..b6674bdce2 100644
--- a/mods/d2k/sequences/structures.yaml
+++ b/mods/d2k/sequences/structures.yaml
@@ -514,7 +514,7 @@ hightecha:
damaged-idle: DATA
Start: 2565
Offset: -48,80
- idle-welding: DATA
+ production-welding: DATA
Start: 4614
Length: 30
Offset: -48,80
@@ -690,7 +690,7 @@ lighta:
damaged-idle-top: DATA
Start: 2675
Offset: -48,64
- idle-welding: DATA
+ production-welding: DATA
Start: 4644
Length: 30
Offset: -48,64
@@ -739,7 +739,7 @@ heavya:
damaged-idle-top: DATA
Start: 2520
Offset: -48,80
- idle-welding: DATA
+ production-welding: DATA
Start: 4674
Length: 47
Offset: -48,80
@@ -1005,7 +1005,7 @@ hightechh:
damaged-idle: DATA
Start: 2725
Offset: -48,80
- idle-welding: DATA
+ production-welding: DATA
Start: 4614
Length: 30
Offset: -48,80
@@ -1090,7 +1090,7 @@ lighth:
damaged-idle-top: DATA
Start: 2835
Offset: -48,64
- idle-welding: DATA
+ production-welding: DATA
Start: 4644
Length: 30
Offset: -48,64
@@ -1139,7 +1139,7 @@ heavyh:
damaged-idle-top: DATA
Start: 2680
Offset: -48,80
- idle-welding: DATA
+ production-welding: DATA
Start: 4674
Length: 47
Offset: -48,80
@@ -1406,7 +1406,7 @@ hightecho:
damaged-idle: DATA
Start: 2885
Offset: -48,80
- idle-welding: DATA
+ production-welding: DATA
Start: 4614
Length: 30
Offset: -48,80
@@ -1483,7 +1483,7 @@ lighto:
damaged-idle-top: DATA
Start: 2995
Offset: -48,64
- idle-welding: DATA
+ production-welding: DATA
Start: 4644
Length: 30
Offset: -48,64
@@ -1532,7 +1532,7 @@ heavyo:
damaged-idle-top: DATA
Start: 2840
Offset: -48,80
- idle-welding: DATA
+ production-welding: DATA
Start: 4674
Length: 47
Offset: -48,80
@@ -1647,7 +1647,7 @@ heavyc: # TODO: unused
damaged-idle-top: DATA
Start: 3003
Offset: -48,64
- idle-welding: DATA
+ production-welding: DATA
Start: 4674
Length: 47
Offset: -48,80
diff --git a/mods/ts/mod.yaml b/mods/ts/mod.yaml
index d87b20f569..60125cb8fc 100644
--- a/mods/ts/mod.yaml
+++ b/mods/ts/mod.yaml
@@ -90,8 +90,8 @@ Chrome:
mods/ts/chrome.yaml
Assemblies:
- mods/ra/OpenRA.Mods.RA.dll
mods/d2k/OpenRA.Mods.D2k.dll
+ mods/ra/OpenRA.Mods.RA.dll
mods/ts/OpenRA.Mods.TS.dll
ChromeLayout:
diff --git a/mods/ts/rules/structures.yaml b/mods/ts/rules/structures.yaml
index 6614b9edf8..5ea2d05bff 100644
--- a/mods/ts/rules/structures.yaml
+++ b/mods/ts/rules/structures.yaml
@@ -104,8 +104,8 @@ GAPILE:
PrimaryBuilding:
IronCurtainable:
ProductionBar:
- WithIdleOverlay@LIGHTS:
- Sequence: idle-lights
+ WithProductionOverlay@LIGHTS:
+ Sequence: production-lights
WithIdleOverlay@LIGHT:
Sequence: idle-light
WithIdleOverlay@FLAG:
@@ -142,10 +142,10 @@ GAWEAP:
Production:
Produces: Vehicle
ProductionBar:
- WithIdleOverlay@LIGHTS1:
- Sequence: idle-lights1
- WithIdleOverlay@LIGHTS2:
- Sequence: idle-lights2
+ WithProductionOverlay@WHITELIGHTS:
+ Sequence: production-lights-white
+ WithProductionOverlay@REDLIGHTS:
+ Sequence: production-lights-red
WithIdleOverlay@TURBINES:
Sequence: idle-turbines
@@ -211,8 +211,8 @@ NAHAND:
ProductionBar:
WithIdleOverlay@LIGHTS:
Sequence: idle-lights
- WithIdleOverlay@LIGHT:
- Sequence: idle-light
+ WithProductionOverlay@LIGHT:
+ Sequence: production-light
NAWEAP:
Inherits: ^Building
@@ -245,8 +245,8 @@ NAWEAP:
Production:
Produces: Vehicle
ProductionBar:
- WithIdleOverlay@LIGHTS:
- Sequence: idle-lights
+ WithProductionOverlay@LIGHTS:
+ Sequence: production-lights
GASAND:
Inherits: ^Wall
diff --git a/mods/ts/sequences/structures.yaml b/mods/ts/sequences/structures.yaml
index c7d9f00f60..1dc543c348 100644
--- a/mods/ts/sequences/structures.yaml
+++ b/mods/ts/sequences/structures.yaml
@@ -103,11 +103,11 @@ gapile:
critical-idle: gtpile
Start: 2
ShadowStart: 5
- idle-lights: gtpile_a
+ production-lights: gtpile_a
Start: 0
Length: 7
Tick: 200
- damaged-idle-lights: gtpile_a
+ damaged-production-lights: gtpile_a
Start:7
Length: 7
Tick: 200
@@ -142,22 +142,22 @@ gaweap:
dead: gtweap
Start: 2
ShadowStart: 5
- idle-lights1: gtweap_a
+ production-lights-white: gtweap_a
Start: 0
Length: 8
Tick: 100
ZOffset: 2048
- damaged-idle-lights1: gtweap_a
+ damaged-production-lights-white: gtweap_a
Start: 8
Length: 8
Tick: 100
ZOffset: 2048
- idle-lights2: gtweap_b
+ production-lights-red: gtweap_b
Start: 0
Length: 4
Tick: 120
ZOffset: 2048
- damaged-idle-lights2: gtweap_b
+ damaged-production-lights-red: gtweap_b
Start: 4
Length: 4
Tick: 120
@@ -232,11 +232,11 @@ nahand:
critical-idle: nthand
Start: 2
ShadowStart: 5
- idle-light: nthand_a
+ production-light: nthand_a
Start: 0
Length: 5
Tick: 100
- damaged-idle-light: nthand_a
+ damaged-production-light: nthand_a
Start: 5
Length: 5
Tick: 100
@@ -265,12 +265,12 @@ naweap:
dead: ntweap
Start: 2
ShadowStart: 5
- idle-lights: ntweap_a
+ production-lights: ntweap_a
Start: 0
Length: 16
Tick: 100
ZOffset: 2048
- damaged-idle-lights: ntweap_a
+ damaged-production-lights: ntweap_a
Start: 16
Length: 16
Tick: 100