Per-structure queues for cnc
This commit is contained in:
@@ -77,7 +77,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
for (var n = 0; n < order.TargetLocation.X; n++) // repeat count
|
for (var n = 0; n < order.TargetLocation.X; n++) // repeat count
|
||||||
{
|
{
|
||||||
BeginProduction(new ProductionItem(order.TargetString, (int)time, cost,
|
BeginProduction(new ProductionItem(this, order.TargetString, (int)time, cost,
|
||||||
() => self.World.AddFrameEndTask(
|
() => self.World.AddFrameEndTask(
|
||||||
_ =>
|
_ =>
|
||||||
{
|
{
|
||||||
@@ -165,6 +165,15 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
void BuildUnit( string name )
|
void BuildUnit( string name )
|
||||||
{
|
{
|
||||||
|
// If the actor has a production trait, use it.
|
||||||
|
var sp = self.TraitsImplementing<Production>().Where(p => p.Info.Produces.Contains(Info.Type)).FirstOrDefault();
|
||||||
|
if (sp != null)
|
||||||
|
{
|
||||||
|
if (!IsDisabledBuilding(self) && sp.Produce(self, Rules.Info[ name ]))
|
||||||
|
FinishProduction();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var producers = self.World.Queries.OwnedBy[self.Owner]
|
var producers = self.World.Queries.OwnedBy[self.Owner]
|
||||||
.WithTrait<Production>()
|
.WithTrait<Production>()
|
||||||
.Where(x => x.Trait.Info.Produces.Contains(Info.Type))
|
.Where(x => x.Trait.Info.Produces.Contains(Info.Type))
|
||||||
@@ -193,7 +202,7 @@ namespace OpenRA.Traits
|
|||||||
public class ProductionItem
|
public class ProductionItem
|
||||||
{
|
{
|
||||||
public readonly string Item;
|
public readonly string Item;
|
||||||
|
public readonly ProductionQueue Queue;
|
||||||
public readonly int TotalTime;
|
public readonly int TotalTime;
|
||||||
public readonly int TotalCost;
|
public readonly int TotalCost;
|
||||||
public int RemainingTime { get; private set; }
|
public int RemainingTime { get; private set; }
|
||||||
@@ -204,13 +213,14 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
int slowdown = 0;
|
int slowdown = 0;
|
||||||
|
|
||||||
public ProductionItem(string item, int time, int cost, Action onComplete)
|
public ProductionItem(ProductionQueue queue, string item, int time, int cost, Action onComplete)
|
||||||
{
|
{
|
||||||
if (time <= 0) time = 1;
|
if (time <= 0) time = 1;
|
||||||
Item = item;
|
Item = item;
|
||||||
RemainingTime = TotalTime = time;
|
RemainingTime = TotalTime = time;
|
||||||
RemainingCost = TotalCost = cost;
|
RemainingCost = TotalCost = cost;
|
||||||
OnComplete = onComplete;
|
OnComplete = onComplete;
|
||||||
|
Queue = queue;
|
||||||
|
|
||||||
Log.Write("debug", "new ProductionItem: {0} time={1} cost={2}", item, time, cost);
|
Log.Write("debug", "new ProductionItem: {0} time={1} cost={2}", item, time, cost);
|
||||||
}
|
}
|
||||||
@@ -228,7 +238,7 @@ namespace OpenRA.Traits
|
|||||||
if (player.PlayerActor.Trait<PlayerResources>().GetPowerState() != PowerState.Normal)
|
if (player.PlayerActor.Trait<PlayerResources>().GetPowerState() != PowerState.Normal)
|
||||||
{
|
{
|
||||||
if (--slowdown <= 0)
|
if (--slowdown <= 0)
|
||||||
slowdown = player.PlayerActor.Info.Traits.Get<ProductionQueueInfo>().LowPowerSlowdown;
|
slowdown = Queue.Info.LowPowerSlowdown;
|
||||||
else
|
else
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -349,7 +349,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
if (producing.Done)
|
if (producing.Done)
|
||||||
{
|
{
|
||||||
if (unit.Traits.Contains<BuildingInfo>())
|
if (unit.Traits.Contains<BuildingInfo>())
|
||||||
world.OrderGenerator = new PlaceBuildingOrderGenerator(player.PlayerActor, item);
|
world.OrderGenerator = new PlaceBuildingOrderGenerator(CurrentQueue.self, item);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -472,7 +472,7 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
|
|
||||||
var lowpower = resources.GetPowerState() != PowerState.Normal;
|
var lowpower = resources.GetPowerState() != PowerState.Normal;
|
||||||
var time = CurrentQueue.GetBuildTime(info.Name)
|
var time = CurrentQueue.GetBuildTime(info.Name)
|
||||||
* ((lowpower)? pl.PlayerActor.Info.Traits.Get<ProductionQueueInfo>().LowPowerSlowdown : 1);
|
* ((lowpower)? CurrentQueue.Info.LowPowerSlowdown : 1);
|
||||||
DrawRightAligned(WorldUtils.FormatTime(time), pos + new int2(-5, 35), lowpower ? Color.Red: Color.White);
|
DrawRightAligned(WorldUtils.FormatTime(time), pos + new int2(-5, 35), lowpower ? Color.Red: Color.White);
|
||||||
|
|
||||||
var bi = info.Traits.GetOrDefault<BuildingInfo>();
|
var bi = info.Traits.GetOrDefault<BuildingInfo>();
|
||||||
|
|||||||
@@ -24,6 +24,15 @@ FACT:
|
|||||||
IntoActor: mcv
|
IntoActor: mcv
|
||||||
Offset:1,1
|
Offset:1,1
|
||||||
Facing: 108
|
Facing: 108
|
||||||
|
ProductionQueue@Building:
|
||||||
|
Type: Building
|
||||||
|
BuildSpeed: .4
|
||||||
|
LowPowerSlowdown: 3
|
||||||
|
ProductionQueue@Defense:
|
||||||
|
Type: Defense
|
||||||
|
BuildSpeed: .4
|
||||||
|
LowPowerSlowdown: 3
|
||||||
|
|
||||||
NUKE:
|
NUKE:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
Valued:
|
Valued:
|
||||||
@@ -173,7 +182,10 @@ PYLE:
|
|||||||
SpawnOffsets: -10,2, 7,7
|
SpawnOffsets: -10,2, 7,7
|
||||||
ExitCells: 0,1, 1,1
|
ExitCells: 0,1, 1,1
|
||||||
PrimaryBuilding:
|
PrimaryBuilding:
|
||||||
|
ProductionQueue@Vehicle:
|
||||||
|
Type: Infantry
|
||||||
|
BuildSpeed: .4
|
||||||
|
LowPowerSlowdown: 3
|
||||||
HAND:
|
HAND:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
Valued:
|
Valued:
|
||||||
@@ -204,7 +216,10 @@ HAND:
|
|||||||
SpawnOffsets: 12,24
|
SpawnOffsets: 12,24
|
||||||
ExitCells:1,2
|
ExitCells:1,2
|
||||||
PrimaryBuilding:
|
PrimaryBuilding:
|
||||||
|
ProductionQueue@Infantry:
|
||||||
|
Type: Infantry
|
||||||
|
BuildSpeed: .4
|
||||||
|
LowPowerSlowdown: 3
|
||||||
AFLD:
|
AFLD:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
Valued:
|
Valued:
|
||||||
@@ -237,7 +252,11 @@ AFLD:
|
|||||||
SpawnOffsets: -24,0
|
SpawnOffsets: -24,0
|
||||||
ExitCells:3,1
|
ExitCells:3,1
|
||||||
PrimaryBuilding:
|
PrimaryBuilding:
|
||||||
|
ProductionQueue@Vehicle:
|
||||||
|
Type: Vehicle
|
||||||
|
BuildSpeed: .4
|
||||||
|
LowPowerSlowdown: 3
|
||||||
|
|
||||||
WEAP:
|
WEAP:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
Valued:
|
Valued:
|
||||||
@@ -270,7 +289,11 @@ WEAP:
|
|||||||
SpawnOffsets: -8,-8
|
SpawnOffsets: -8,-8
|
||||||
ExitCells: 0,2
|
ExitCells: 0,2
|
||||||
PrimaryBuilding:
|
PrimaryBuilding:
|
||||||
|
ProductionQueue@Vehicle:
|
||||||
|
Type: Vehicle
|
||||||
|
BuildSpeed: .4
|
||||||
|
LowPowerSlowdown: 3
|
||||||
|
|
||||||
HQ:
|
HQ:
|
||||||
RequiresPower:
|
RequiresPower:
|
||||||
CanPowerDown:
|
CanPowerDown:
|
||||||
@@ -383,7 +406,11 @@ HPAD:
|
|||||||
Reservable:
|
Reservable:
|
||||||
RepairsUnits:
|
RepairsUnits:
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
|
ProductionQueue@Plane:
|
||||||
|
Type: Plane
|
||||||
|
BuildSpeed: .4
|
||||||
|
LowPowerSlowdown: 3
|
||||||
|
|
||||||
EYE:
|
EYE:
|
||||||
RequiresPower:
|
RequiresPower:
|
||||||
CanPowerDown:
|
CanPowerDown:
|
||||||
|
|||||||
@@ -1,24 +1,4 @@
|
|||||||
Player:
|
Player:
|
||||||
ProductionQueue@Building:
|
|
||||||
Type: Building
|
|
||||||
BuildSpeed: .4
|
|
||||||
LowPowerSlowdown: 3
|
|
||||||
ProductionQueue@Defense:
|
|
||||||
Type: Defense
|
|
||||||
BuildSpeed: .4
|
|
||||||
LowPowerSlowdown: 3
|
|
||||||
ProductionQueue@Infantry:
|
|
||||||
Type: Infantry
|
|
||||||
BuildSpeed: .4
|
|
||||||
LowPowerSlowdown: 3
|
|
||||||
ProductionQueue@Vehicle:
|
|
||||||
Type: Vehicle
|
|
||||||
BuildSpeed: .4
|
|
||||||
LowPowerSlowdown: 3
|
|
||||||
ProductionQueue@Plane:
|
|
||||||
Type: Plane
|
|
||||||
BuildSpeed: .4
|
|
||||||
LowPowerSlowdown: 3
|
|
||||||
PlaceBuilding:
|
PlaceBuilding:
|
||||||
TechTreeCache:
|
TechTreeCache:
|
||||||
NukePower:
|
NukePower:
|
||||||
|
|||||||
Reference in New Issue
Block a user