From f05fc0cae8d5f59ba6b163f07ce2aa67afd4e132 Mon Sep 17 00:00:00 2001 From: Mustafa Alperen Seki Date: Thu, 26 Jul 2018 18:21:40 +0300 Subject: [PATCH] Add WithProductionOverlay>Queues --- .../Traits/Render/WithProductionOverlay.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs b/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs index c268321e06..d8558561c5 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithProductionOverlay.cs @@ -10,6 +10,7 @@ #endregion using System; +using System.Collections.Generic; using System.Linq; using OpenRA.Graphics; using OpenRA.Traits; @@ -20,6 +21,9 @@ namespace OpenRA.Mods.Common.Traits.Render "Works both with per player ClassicProductionQueue and per building ProductionQueue, but needs any of these.")] public class WithProductionOverlayInfo : ITraitInfo, Requires, Requires, Requires { + [Desc("Queues that should be producing for this overlay to render.")] + public readonly HashSet Queues = new HashSet(); + [Desc("Sequence name to use")] [SequenceReference] public readonly string Sequence = "production-overlay"; @@ -37,6 +41,7 @@ namespace OpenRA.Mods.Common.Traits.Render public class WithProductionOverlay : INotifyDamageStateChanged, INotifyCreated, INotifyBuildComplete, INotifySold, INotifyOwnerChanged { + readonly WithProductionOverlayInfo info; readonly Animation overlay; readonly ProductionInfo production; ProductionQueue[] queues; @@ -49,6 +54,8 @@ namespace OpenRA.Mods.Common.Traits.Render public WithProductionOverlay(Actor self, WithProductionOverlayInfo info) { + this.info = info; + var rs = self.Trait(); var body = self.Trait(); @@ -70,6 +77,7 @@ namespace OpenRA.Mods.Common.Traits.Render // Per-actor production queues = self.TraitsImplementing() .Where(q => production.Produces.Contains(q.Info.Type)) + .Where(q => !info.Queues.Any() || info.Queues.Contains(q.Info.Type)) .ToArray(); if (!queues.Any()) @@ -77,6 +85,7 @@ namespace OpenRA.Mods.Common.Traits.Render // Player-wide production queues = self.Owner.PlayerActor.TraitsImplementing() .Where(q => production.Produces.Contains(q.Info.Type)) + .Where(q => !info.Queues.Any() || info.Queues.Contains(q.Info.Type)) .ToArray(); } }