Add WithProductionOverlay>Queues
This commit is contained in:
committed by
Paul Chote
parent
e64a966b4f
commit
f05fc0cae8
@@ -10,6 +10,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Traits;
|
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.")]
|
"Works both with per player ClassicProductionQueue and per building ProductionQueue, but needs any of these.")]
|
||||||
public class WithProductionOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>, Requires<ProductionInfo>
|
public class WithProductionOverlayInfo : ITraitInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>, Requires<ProductionInfo>
|
||||||
{
|
{
|
||||||
|
[Desc("Queues that should be producing for this overlay to render.")]
|
||||||
|
public readonly HashSet<string> Queues = new HashSet<string>();
|
||||||
|
|
||||||
[Desc("Sequence name to use")]
|
[Desc("Sequence name to use")]
|
||||||
[SequenceReference] public readonly string Sequence = "production-overlay";
|
[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
|
public class WithProductionOverlay : INotifyDamageStateChanged, INotifyCreated, INotifyBuildComplete, INotifySold, INotifyOwnerChanged
|
||||||
{
|
{
|
||||||
|
readonly WithProductionOverlayInfo info;
|
||||||
readonly Animation overlay;
|
readonly Animation overlay;
|
||||||
readonly ProductionInfo production;
|
readonly ProductionInfo production;
|
||||||
ProductionQueue[] queues;
|
ProductionQueue[] queues;
|
||||||
@@ -49,6 +54,8 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
|
|
||||||
public WithProductionOverlay(Actor self, WithProductionOverlayInfo info)
|
public WithProductionOverlay(Actor self, WithProductionOverlayInfo info)
|
||||||
{
|
{
|
||||||
|
this.info = info;
|
||||||
|
|
||||||
var rs = self.Trait<RenderSprites>();
|
var rs = self.Trait<RenderSprites>();
|
||||||
var body = self.Trait<BodyOrientation>();
|
var body = self.Trait<BodyOrientation>();
|
||||||
|
|
||||||
@@ -70,6 +77,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
// Per-actor production
|
// Per-actor production
|
||||||
queues = self.TraitsImplementing<ProductionQueue>()
|
queues = self.TraitsImplementing<ProductionQueue>()
|
||||||
.Where(q => production.Produces.Contains(q.Info.Type))
|
.Where(q => production.Produces.Contains(q.Info.Type))
|
||||||
|
.Where(q => !info.Queues.Any() || info.Queues.Contains(q.Info.Type))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
if (!queues.Any())
|
if (!queues.Any())
|
||||||
@@ -77,6 +85,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
// Player-wide production
|
// Player-wide production
|
||||||
queues = self.Owner.PlayerActor.TraitsImplementing<ProductionQueue>()
|
queues = self.Owner.PlayerActor.TraitsImplementing<ProductionQueue>()
|
||||||
.Where(q => production.Produces.Contains(q.Info.Type))
|
.Where(q => production.Produces.Contains(q.Info.Type))
|
||||||
|
.Where(q => !info.Queues.Any() || info.Queues.Contains(q.Info.Type))
|
||||||
.ToArray();
|
.ToArray();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user