Merge pull request #11951 from pchote/hack-production-locking
Rework external capture -> production interaction
This commit is contained in:
@@ -27,12 +27,14 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public object Create(ActorInitializer init) { return new BaseProvider(init.Self, this); }
|
public object Create(ActorInitializer init) { return new BaseProvider(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BaseProvider : ITick, IRenderAboveShroudWhenSelected, ISelectionBar
|
public class BaseProvider : ITick, INotifyCreated, IRenderAboveShroudWhenSelected, ISelectionBar
|
||||||
{
|
{
|
||||||
public readonly BaseProviderInfo Info;
|
public readonly BaseProviderInfo Info;
|
||||||
readonly DeveloperMode devMode;
|
readonly DeveloperMode devMode;
|
||||||
readonly Actor self;
|
readonly Actor self;
|
||||||
|
|
||||||
|
Building building;
|
||||||
|
|
||||||
int total;
|
int total;
|
||||||
int progress;
|
int progress;
|
||||||
bool allyBuildEnabled;
|
bool allyBuildEnabled;
|
||||||
@@ -46,6 +48,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
allyBuildEnabled = self.World.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled;
|
allyBuildEnabled = self.World.WorldActor.Trait<MapBuildRadius>().AllyBuildRadiusEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void INotifyCreated.Created(Actor self)
|
||||||
|
{
|
||||||
|
building = self.TraitOrDefault<Building>();
|
||||||
|
}
|
||||||
|
|
||||||
void ITick.Tick(Actor self)
|
void ITick.Tick(Actor self)
|
||||||
{
|
{
|
||||||
if (progress > 0)
|
if (progress > 0)
|
||||||
@@ -59,6 +66,9 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public bool Ready()
|
public bool Ready()
|
||||||
{
|
{
|
||||||
|
if (building != null && building.Locked)
|
||||||
|
return false;
|
||||||
|
|
||||||
return devMode.FastBuild || progress == 0;
|
return devMode.FastBuild || progress == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,9 +55,6 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
{
|
{
|
||||||
if (x.Actor.Owner == self.Owner && x.Trait.Info.Produces.Contains(Info.Type))
|
if (x.Actor.Owner == self.Owner && x.Trait.Info.Produces.Contains(Info.Type))
|
||||||
{
|
{
|
||||||
var b = x.Actor.TraitOrDefault<Building>();
|
|
||||||
if (b != null && b.Locked)
|
|
||||||
continue;
|
|
||||||
isActive = true;
|
isActive = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,13 +28,15 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
public virtual object Create(ActorInitializer init) { return new Production(init, this); }
|
public virtual object Create(ActorInitializer init) { return new Production(init, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Production
|
public class Production : INotifyCreated
|
||||||
{
|
{
|
||||||
readonly Lazy<RallyPoint> rp;
|
readonly Lazy<RallyPoint> rp;
|
||||||
|
|
||||||
public readonly ProductionInfo Info;
|
public readonly ProductionInfo Info;
|
||||||
public string Faction { get; private set; }
|
public string Faction { get; private set; }
|
||||||
|
|
||||||
|
Building building;
|
||||||
|
|
||||||
public Production(ActorInitializer init, ProductionInfo info)
|
public Production(ActorInitializer init, ProductionInfo info)
|
||||||
{
|
{
|
||||||
Info = info;
|
Info = info;
|
||||||
@@ -42,6 +44,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
Faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
|
Faction = init.Contains<FactionInit>() ? init.Get<FactionInit, string>() : init.Self.Owner.Faction.InternalName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void INotifyCreated.Created(Actor self)
|
||||||
|
{
|
||||||
|
building = self.TraitOrDefault<Building>();
|
||||||
|
}
|
||||||
|
|
||||||
public virtual void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo, string factionVariant)
|
public virtual void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo, string factionVariant)
|
||||||
{
|
{
|
||||||
var exit = CPos.Zero;
|
var exit = CPos.Zero;
|
||||||
@@ -122,7 +129,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
|
|
||||||
public virtual bool Produce(Actor self, ActorInfo producee, string factionVariant)
|
public virtual bool Produce(Actor self, ActorInfo producee, string factionVariant)
|
||||||
{
|
{
|
||||||
if (Reservable.IsReserved(self))
|
if (Reservable.IsReserved(self) || (building != null && building.Locked))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Pick a spawn/exit point pair
|
// Pick a spawn/exit point pair
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
public object Create(ActorInitializer init) { return new WithBuildingPlacedAnimation(init.Self, this); }
|
public object Create(ActorInitializer init) { return new WithBuildingPlacedAnimation(init.Self, this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class WithBuildingPlacedAnimation : INotifyBuildingPlaced, INotifyBuildComplete
|
public class WithBuildingPlacedAnimation : INotifyBuildingPlaced, INotifyBuildComplete, INotifySold, INotifyTransform
|
||||||
{
|
{
|
||||||
readonly WithBuildingPlacedAnimationInfo info;
|
readonly WithBuildingPlacedAnimationInfo info;
|
||||||
readonly WithSpriteBody wsb;
|
readonly WithSpriteBody wsb;
|
||||||
@@ -35,12 +35,26 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
buildComplete = !self.Info.HasTraitInfo<BuildingInfo>();
|
buildComplete = !self.Info.HasTraitInfo<BuildingInfo>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BuildingComplete(Actor self)
|
void INotifyBuildComplete.BuildingComplete(Actor self)
|
||||||
{
|
{
|
||||||
buildComplete = true;
|
buildComplete = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BuildingPlaced(Actor self)
|
void INotifySold.Sold(Actor self) { }
|
||||||
|
void INotifySold.Selling(Actor self)
|
||||||
|
{
|
||||||
|
buildComplete = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void INotifyTransform.BeforeTransform(Actor self)
|
||||||
|
{
|
||||||
|
buildComplete = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void INotifyTransform.OnTransform(Actor self) { }
|
||||||
|
void INotifyTransform.AfterTransform(Actor self) { }
|
||||||
|
|
||||||
|
void INotifyBuildingPlaced.BuildingPlaced(Actor self)
|
||||||
{
|
{
|
||||||
if (buildComplete)
|
if (buildComplete)
|
||||||
wsb.PlayCustomAnimation(self, info.Sequence, () => wsb.CancelCustomAnimation(self));
|
wsb.PlayCustomAnimation(self, info.Sequence, () => wsb.CancelCustomAnimation(self));
|
||||||
|
|||||||
@@ -55,32 +55,32 @@ namespace OpenRA.Mods.Common.Traits.Render
|
|||||||
rs.Add(anim, info.Palette, info.IsPlayerPalette);
|
rs.Add(anim, info.Palette, info.IsPlayerPalette);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BuildingComplete(Actor self)
|
void INotifyBuildComplete.BuildingComplete(Actor self)
|
||||||
{
|
{
|
||||||
buildComplete = true;
|
buildComplete = true;
|
||||||
visible = false;
|
visible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Sold(Actor self) { }
|
void INotifySold.Sold(Actor self) { }
|
||||||
public void Selling(Actor self)
|
void INotifySold.Selling(Actor self)
|
||||||
{
|
{
|
||||||
buildComplete = false;
|
buildComplete = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BeforeTransform(Actor self)
|
void INotifyTransform.BeforeTransform(Actor self)
|
||||||
{
|
{
|
||||||
buildComplete = false;
|
buildComplete = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnTransform(Actor self) { }
|
void INotifyTransform.OnTransform(Actor self) { }
|
||||||
public void AfterTransform(Actor self) { }
|
void INotifyTransform.AfterTransform(Actor self) { }
|
||||||
|
|
||||||
public void DamageStateChanged(Actor self, AttackInfo e)
|
void INotifyDamageStateChanged.DamageStateChanged(Actor self, AttackInfo e)
|
||||||
{
|
{
|
||||||
overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, overlay.CurrentSequence.Name));
|
overlay.ReplaceAnim(RenderSprites.NormalizeSequence(overlay, e.DamageState, overlay.CurrentSequence.Name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BuildingPlaced(Actor self)
|
void INotifyBuildingPlaced.BuildingPlaced(Actor self)
|
||||||
{
|
{
|
||||||
visible = true;
|
visible = true;
|
||||||
overlay.PlayThen(overlay.CurrentSequence.Name, () => visible = false);
|
overlay.PlayThen(overlay.CurrentSequence.Name, () => visible = false);
|
||||||
|
|||||||
Reference in New Issue
Block a user