Cache production queue on PBOG.
This commit is contained in:
@@ -23,7 +23,7 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
{
|
{
|
||||||
public class PlaceBuildingOrderGenerator : IOrderGenerator
|
public class PlaceBuildingOrderGenerator : IOrderGenerator
|
||||||
{
|
{
|
||||||
readonly Actor producer;
|
readonly ProductionQueue queue;
|
||||||
readonly string building;
|
readonly string building;
|
||||||
readonly BuildingInfo buildingInfo;
|
readonly BuildingInfo buildingInfo;
|
||||||
readonly PlaceBuildingInfo placeBuildingInfo;
|
readonly PlaceBuildingInfo placeBuildingInfo;
|
||||||
@@ -37,16 +37,17 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
|
|
||||||
public PlaceBuildingOrderGenerator(ProductionQueue queue, string name)
|
public PlaceBuildingOrderGenerator(ProductionQueue queue, string name)
|
||||||
{
|
{
|
||||||
producer = queue.Actor;
|
var world = queue.Actor.World;
|
||||||
placeBuildingInfo = producer.Owner.PlayerActor.Info.TraitInfo<PlaceBuildingInfo>();
|
this.queue = queue;
|
||||||
|
placeBuildingInfo = queue.Actor.Owner.PlayerActor.Info.TraitInfo<PlaceBuildingInfo>();
|
||||||
building = name;
|
building = name;
|
||||||
|
|
||||||
// Clear selection if using Left-Click Orders
|
// Clear selection if using Left-Click Orders
|
||||||
if (Game.Settings.Game.UseClassicMouseStyle)
|
if (Game.Settings.Game.UseClassicMouseStyle)
|
||||||
producer.World.Selection.Clear();
|
world.Selection.Clear();
|
||||||
|
|
||||||
var map = producer.World.Map;
|
var map = world.Map;
|
||||||
var tileset = producer.World.TileSet.Id.ToLowerInvariant();
|
var tileset = world.TileSet.Id.ToLowerInvariant();
|
||||||
|
|
||||||
var info = map.Rules.Actors[building];
|
var info = map.Rules.Actors[building];
|
||||||
buildingInfo = info.TraitInfo<BuildingInfo>();
|
buildingInfo = info.TraitInfo<BuildingInfo>();
|
||||||
@@ -54,12 +55,12 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
var buildableInfo = info.TraitInfo<BuildableInfo>();
|
var buildableInfo = info.TraitInfo<BuildableInfo>();
|
||||||
var mostLikelyProducer = queue.MostLikelyProducer();
|
var mostLikelyProducer = queue.MostLikelyProducer();
|
||||||
faction = buildableInfo.ForceFaction
|
faction = buildableInfo.ForceFaction
|
||||||
?? (mostLikelyProducer.Trait != null ? mostLikelyProducer.Trait.Faction : producer.Owner.Faction.InternalName);
|
?? (mostLikelyProducer.Trait != null ? mostLikelyProducer.Trait.Faction : queue.Actor.Owner.Faction.InternalName);
|
||||||
|
|
||||||
buildOk = map.SequenceProvider.GetSequence("overlay", "build-valid-{0}".F(tileset)).GetSprite(0);
|
buildOk = map.SequenceProvider.GetSequence("overlay", "build-valid-{0}".F(tileset)).GetSprite(0);
|
||||||
buildBlocked = map.SequenceProvider.GetSequence("overlay", "build-invalid").GetSprite(0);
|
buildBlocked = map.SequenceProvider.GetSequence("overlay", "build-invalid").GetSprite(0);
|
||||||
|
|
||||||
buildingInfluence = producer.World.WorldActor.Trait<BuildingInfluence>();
|
buildingInfluence = world.WorldActor.Trait<BuildingInfluence>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Order> Order(World world, CPos cell, int2 worldPixel, MouseInput mi)
|
public IEnumerable<Order> Order(World world, CPos cell, int2 worldPixel, MouseInput mi)
|
||||||
@@ -83,6 +84,7 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
if (world.Paused)
|
if (world.Paused)
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
|
var owner = queue.Actor.Owner;
|
||||||
if (mi.Button == MouseButton.Left)
|
if (mi.Button == MouseButton.Left)
|
||||||
{
|
{
|
||||||
var orderType = "PlaceBuilding";
|
var orderType = "PlaceBuilding";
|
||||||
@@ -94,19 +96,19 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
orderType = "PlacePlug";
|
orderType = "PlacePlug";
|
||||||
if (!AcceptsPlug(topLeft, plugInfo))
|
if (!AcceptsPlug(topLeft, plugInfo))
|
||||||
{
|
{
|
||||||
Game.Sound.PlayNotification(world.Map.Rules, producer.Owner, "Speech", "BuildingCannotPlaceAudio", producer.Owner.Faction.InternalName);
|
Game.Sound.PlayNotification(world.Map.Rules, owner, "Speech", "BuildingCannotPlaceAudio", owner.Faction.InternalName);
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!world.CanPlaceBuilding(building, buildingInfo, topLeft, null)
|
if (!world.CanPlaceBuilding(building, buildingInfo, topLeft, null)
|
||||||
|| !buildingInfo.IsCloseEnoughToBase(world, producer.Owner, building, topLeft))
|
|| !buildingInfo.IsCloseEnoughToBase(world, owner, building, topLeft))
|
||||||
{
|
{
|
||||||
foreach (var order in ClearBlockersOrders(world, topLeft))
|
foreach (var order in ClearBlockersOrders(world, topLeft))
|
||||||
yield return order;
|
yield return order;
|
||||||
|
|
||||||
Game.Sound.PlayNotification(world.Map.Rules, producer.Owner, "Speech", "BuildingCannotPlaceAudio", producer.Owner.Faction.InternalName);
|
Game.Sound.PlayNotification(world.Map.Rules, owner, "Speech", "BuildingCannotPlaceAudio", owner.Faction.InternalName);
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,10 +116,10 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
orderType = "LineBuild";
|
orderType = "LineBuild";
|
||||||
}
|
}
|
||||||
|
|
||||||
yield return new Order(orderType, producer.Owner.PlayerActor, false)
|
yield return new Order(orderType, owner.PlayerActor, false)
|
||||||
{
|
{
|
||||||
TargetLocation = topLeft,
|
TargetLocation = topLeft,
|
||||||
TargetActor = producer,
|
TargetActor = queue.Actor,
|
||||||
TargetString = building,
|
TargetString = building,
|
||||||
SuppressVisualFeedback = true
|
SuppressVisualFeedback = true
|
||||||
};
|
};
|
||||||
@@ -185,7 +187,7 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
var td = new TypeDictionary()
|
var td = new TypeDictionary()
|
||||||
{
|
{
|
||||||
new FactionInit(faction),
|
new FactionInit(faction),
|
||||||
new OwnerInit(producer.Owner),
|
new OwnerInit(queue.Actor.Owner),
|
||||||
new HideBibPreviewInit()
|
new HideBibPreviewInit()
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -230,7 +232,7 @@ namespace OpenRA.Mods.Common.Orders
|
|||||||
.Where(world.Map.Contains).ToList();
|
.Where(world.Map.Contains).ToList();
|
||||||
|
|
||||||
var blockers = allTiles.SelectMany(world.ActorMap.GetActorsAt)
|
var blockers = allTiles.SelectMany(world.ActorMap.GetActorsAt)
|
||||||
.Where(a => a.Owner == producer.Owner && a.IsIdle)
|
.Where(a => a.Owner == queue.Actor.Owner && a.IsIdle)
|
||||||
.Select(a => new TraitPair<Mobile> { Actor = a, Trait = a.TraitOrDefault<Mobile>() });
|
.Select(a => new TraitPair<Mobile> { Actor = a, Trait = a.TraitOrDefault<Mobile>() });
|
||||||
|
|
||||||
foreach (var blocker in blockers.Where(x => x.Trait != null))
|
foreach (var blocker in blockers.Where(x => x.Trait != null))
|
||||||
|
|||||||
Reference in New Issue
Block a user