Make BaseProvider PausableConditional
This commit is contained in:
committed by
reaperrr
parent
12054506e1
commit
c976bb1d7b
@@ -18,18 +18,17 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Limits the zone where buildings can be constructed to a radius around this actor.")]
|
||||
public class BaseProviderInfo : ITraitInfo
|
||||
public class BaseProviderInfo : PausableConditionalTraitInfo
|
||||
{
|
||||
public readonly WDist Range = WDist.FromCells(10);
|
||||
public readonly int Cooldown = 0;
|
||||
public readonly int InitialDelay = 0;
|
||||
|
||||
public object Create(ActorInitializer init) { return new BaseProvider(init.Self, this); }
|
||||
public override object Create(ActorInitializer init) { return new BaseProvider(init.Self, this); }
|
||||
}
|
||||
|
||||
public class BaseProvider : ITick, INotifyCreated, IRenderAboveShroudWhenSelected, ISelectionBar
|
||||
public class BaseProvider : PausableConditionalTrait<BaseProviderInfo>, ITick, INotifyCreated, IRenderAboveShroudWhenSelected, ISelectionBar
|
||||
{
|
||||
public readonly BaseProviderInfo Info;
|
||||
readonly DeveloperMode devMode;
|
||||
readonly Actor self;
|
||||
readonly bool allyBuildEnabled;
|
||||
@@ -41,8 +40,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
int progress;
|
||||
|
||||
public BaseProvider(Actor self, BaseProviderInfo info)
|
||||
: base(info)
|
||||
{
|
||||
Info = info;
|
||||
this.self = self;
|
||||
devMode = self.Owner.PlayerActor.Trait<DeveloperMode>();
|
||||
progress = total = info.InitialDelay;
|
||||
@@ -69,7 +68,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public bool Ready()
|
||||
{
|
||||
if (building != null && building.Locked)
|
||||
if (IsTraitDisabled || IsTraitPaused || (building != null && building.Locked))
|
||||
return false;
|
||||
|
||||
return devMode.FastBuild || progress == 0;
|
||||
@@ -82,6 +81,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public IEnumerable<IRenderable> RangeCircleRenderables(WorldRenderer wr)
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
yield break;
|
||||
|
||||
// Visible to player and allies
|
||||
if (!ValidRenderPlayer())
|
||||
yield break;
|
||||
@@ -103,6 +105,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
float ISelectionBar.GetValue()
|
||||
{
|
||||
if (IsTraitDisabled)
|
||||
return 0f;
|
||||
|
||||
// Visible to player and allies
|
||||
if (!ValidRenderPlayer())
|
||||
return 0f;
|
||||
|
||||
@@ -143,7 +143,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return (off - new WVec(0, 0, off.Z)) + LocalCenterOffset;
|
||||
}
|
||||
|
||||
public Actor FindBaseProvider(World world, Player p, CPos topLeft)
|
||||
public BaseProvider FindBaseProvider(World world, Player p, CPos topLeft)
|
||||
{
|
||||
var center = world.Map.CenterOfCell(topLeft) + CenterOffset(world);
|
||||
var mapBuildRadius = world.WorldActor.Trait<MapBuildRadius>();
|
||||
@@ -161,7 +161,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// Range is counted from the center of the actor, not from each cell.
|
||||
var target = Target.FromPos(bp.Actor.CenterPosition);
|
||||
if (target.IsInRange(center, bp.Trait.Info.Range))
|
||||
return bp.Actor;
|
||||
return bp.Trait;
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
@@ -159,7 +159,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
// BuildingInfo.IsCloseEnoughToBase has already verified that this is a valid build location
|
||||
var provider = buildingInfo.FindBaseProvider(w, self.Owner, order.TargetLocation);
|
||||
if (provider != null)
|
||||
provider.Trait<BaseProvider>().BeginCooldown();
|
||||
provider.BeginCooldown();
|
||||
}
|
||||
|
||||
if (GetNumBuildables(self.Owner) > prevItems)
|
||||
|
||||
Reference in New Issue
Block a user