Fix filenames of capture related traits.
This commit is contained in:
committed by
reaperrr
parent
00b8576edf
commit
35ad33e8be
@@ -311,9 +311,9 @@
|
||||
<Compile Include="Traits\Buildings\RepairableBuilding.cs" />
|
||||
<Compile Include="Traits\Buildings\RequiresBuildableArea.cs" />
|
||||
<Compile Include="Traits\Buildings\Reservable.cs" />
|
||||
<Compile Include="Traits\CapturableProgressBar.cs" />
|
||||
<Compile Include="Traits\CaptureProgressBar.cs" />
|
||||
<Compile Include="Traits\CaptureProgressBlink.cs" />
|
||||
<Compile Include="Traits\CapturableProgressBar.cs" />
|
||||
<Compile Include="Traits\CapturableProgressBlink.cs" />
|
||||
<Compile Include="Traits\Conditions\GrantConditionOnPlayerResources.cs" />
|
||||
<Compile Include="Traits\GrantExternalConditionToProduced.cs" />
|
||||
<Compile Include="Traits\Multipliers\CreatesShroudMultiplier.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<CapturesInfo>
|
||||
[Desc("Visualize capture progress.")]
|
||||
class CapturableProgressBarInfo : ITraitInfo, Requires<CapturableInfo>
|
||||
{
|
||||
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<Actor, Pair<int, int>> progress = new Dictionary<Actor, Pair<int, int>>();
|
||||
|
||||
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; }
|
||||
|
||||
@@ -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<CapturableInfo>
|
||||
[Desc("Visualize the progress of this actor being captured.")]
|
||||
class CaptureProgressBarInfo : ITraitInfo, Requires<CapturesInfo>
|
||||
{
|
||||
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<Actor, Pair<int, int>> progress = new Dictionary<Actor, Pair<int, int>>();
|
||||
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; }
|
||||
|
||||
Reference in New Issue
Block a user