Make Capture related traits conditional.
This commit is contained in:
committed by
reaperrr
parent
35ad33e8be
commit
556774804f
@@ -15,23 +15,20 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Visualize the progress of this actor being captured.")]
|
||||
class CaptureProgressBarInfo : ITraitInfo, Requires<CapturesInfo>
|
||||
class CaptureProgressBarInfo : ConditionalTraitInfo, Requires<CapturesInfo>
|
||||
{
|
||||
public readonly Color Color = Color.Orange;
|
||||
|
||||
public object Create(ActorInitializer init) { return new CaptureProgressBar(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new CaptureProgressBar(init.Self, this); }
|
||||
}
|
||||
|
||||
class CaptureProgressBar : ISelectionBar, ICaptureProgressWatcher
|
||||
class CaptureProgressBar : ConditionalTrait<CaptureProgressBarInfo>, ISelectionBar, ICaptureProgressWatcher
|
||||
{
|
||||
readonly CaptureProgressBarInfo info;
|
||||
int current;
|
||||
int total;
|
||||
|
||||
public CaptureProgressBar(Actor self, CaptureProgressBarInfo info)
|
||||
{
|
||||
this.info = info;
|
||||
}
|
||||
: base(info) { }
|
||||
|
||||
void ICaptureProgressWatcher.Update(Actor self, Actor captor, Actor target, int current, int total)
|
||||
{
|
||||
@@ -44,13 +41,13 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
float ISelectionBar.GetValue()
|
||||
{
|
||||
if (total == 0)
|
||||
if (IsTraitDisabled || total == 0)
|
||||
return 0f;
|
||||
|
||||
return (float)current / total;
|
||||
}
|
||||
|
||||
Color ISelectionBar.GetColor() { return info.Color; }
|
||||
Color ISelectionBar.GetColor() { return Info.Color; }
|
||||
bool ISelectionBar.DisplayWhenEmpty { get { return false; } }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user