From 35ad33e8be09dc7f14608d291f447ce65d6120bf Mon Sep 17 00:00:00 2001 From: Mustafa Alperen Seki Date: Tue, 12 Mar 2019 12:18:43 +0300 Subject: [PATCH] Fix filenames of capture related traits. --- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 4 +-- .../Traits/CapturableProgressBar.cs | 29 ++++++++++--------- ...essBlink.cs => CapturableProgressBlink.cs} | 0 .../Traits/CaptureProgressBar.cs | 29 +++++++++---------- 4 files changed, 31 insertions(+), 31 deletions(-) rename OpenRA.Mods.Common/Traits/{CaptureProgressBlink.cs => CapturableProgressBlink.cs} (100%) diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index 5f9f83b9cf..36bd1e9e8e 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -311,9 +311,9 @@ - - + + diff --git a/OpenRA.Mods.Common/Traits/CapturableProgressBar.cs b/OpenRA.Mods.Common/Traits/CapturableProgressBar.cs index 926ff99e51..b18bdd7aad 100644 --- a/OpenRA.Mods.Common/Traits/CapturableProgressBar.cs +++ b/OpenRA.Mods.Common/Traits/CapturableProgressBar.cs @@ -9,45 +9,48 @@ */ #endregion +using System.Collections.Generic; +using System.Linq; using OpenRA.Primitives; using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - [Desc("Visualize the progress of this actor being captured.")] - class CaptureProgressBarInfo : ITraitInfo, Requires + [Desc("Visualize capture progress.")] + class CapturableProgressBarInfo : ITraitInfo, Requires { public readonly Color Color = Color.Orange; - public object Create(ActorInitializer init) { return new CaptureProgressBar(init.Self, this); } + public object Create(ActorInitializer init) { return new CapturableProgressBar(init.Self, this); } } - class CaptureProgressBar : ISelectionBar, ICaptureProgressWatcher + class CapturableProgressBar : ISelectionBar, ICaptureProgressWatcher { - readonly CaptureProgressBarInfo info; - int current; - int total; + readonly CapturableProgressBarInfo info; + Dictionary> progress = new Dictionary>(); - public CaptureProgressBar(Actor self, CaptureProgressBarInfo info) + public CapturableProgressBar(Actor self, CapturableProgressBarInfo info) { this.info = info; } void ICaptureProgressWatcher.Update(Actor self, Actor captor, Actor target, int current, int total) { - if (self != captor) + if (self != target) return; - this.current = current; - this.total = total; + if (total == 0) + progress.Remove(captor); + else + progress[captor] = Pair.New(current, total); } float ISelectionBar.GetValue() { - if (total == 0) + if (!progress.Any()) return 0f; - return (float)current / total; + return progress.Values.Max(p => (float)p.First / p.Second); } Color ISelectionBar.GetColor() { return info.Color; } diff --git a/OpenRA.Mods.Common/Traits/CaptureProgressBlink.cs b/OpenRA.Mods.Common/Traits/CapturableProgressBlink.cs similarity index 100% rename from OpenRA.Mods.Common/Traits/CaptureProgressBlink.cs rename to OpenRA.Mods.Common/Traits/CapturableProgressBlink.cs diff --git a/OpenRA.Mods.Common/Traits/CaptureProgressBar.cs b/OpenRA.Mods.Common/Traits/CaptureProgressBar.cs index b18bdd7aad..926ff99e51 100644 --- a/OpenRA.Mods.Common/Traits/CaptureProgressBar.cs +++ b/OpenRA.Mods.Common/Traits/CaptureProgressBar.cs @@ -9,48 +9,45 @@ */ #endregion -using System.Collections.Generic; -using System.Linq; using OpenRA.Primitives; using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - [Desc("Visualize capture progress.")] - class CapturableProgressBarInfo : ITraitInfo, Requires + [Desc("Visualize the progress of this actor being captured.")] + class CaptureProgressBarInfo : ITraitInfo, Requires { public readonly Color Color = Color.Orange; - public object Create(ActorInitializer init) { return new CapturableProgressBar(init.Self, this); } + public object Create(ActorInitializer init) { return new CaptureProgressBar(init.Self, this); } } - class CapturableProgressBar : ISelectionBar, ICaptureProgressWatcher + class CaptureProgressBar : ISelectionBar, ICaptureProgressWatcher { - readonly CapturableProgressBarInfo info; - Dictionary> progress = new Dictionary>(); + readonly CaptureProgressBarInfo info; + int current; + int total; - public CapturableProgressBar(Actor self, CapturableProgressBarInfo info) + public CaptureProgressBar(Actor self, CaptureProgressBarInfo info) { this.info = info; } void ICaptureProgressWatcher.Update(Actor self, Actor captor, Actor target, int current, int total) { - if (self != target) + if (self != captor) return; - if (total == 0) - progress.Remove(captor); - else - progress[captor] = Pair.New(current, total); + this.current = current; + this.total = total; } float ISelectionBar.GetValue() { - if (!progress.Any()) + if (total == 0) return 0f; - return progress.Values.Max(p => (float)p.First / p.Second); + return (float)current / total; } Color ISelectionBar.GetColor() { return info.Color; }