make classic production queue speedup less error prone
- avoid float modifiers because of rounding errors and desync - try not to crash when the last production building is gone - don't do LINQ queries on selfsame buildings if not required
This commit is contained in:
@@ -18,8 +18,9 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
public class ClassicProductionQueueInfo : ProductionQueueInfo, Requires<TechTreeInfo>, Requires<PowerManagerInfo>, Requires<PlayerResourcesInfo>
|
public class ClassicProductionQueueInfo : ProductionQueueInfo, Requires<TechTreeInfo>, Requires<PowerManagerInfo>, Requires<PlayerResourcesInfo>
|
||||||
{
|
{
|
||||||
public readonly float SpeedUp = 0;
|
public readonly bool SpeedUp = false;
|
||||||
public readonly float MaxSpeedUp = 0;
|
public readonly int BuildTimeSpeedUpDivisor = 2;
|
||||||
|
public readonly int MaxBuildTimeReductionSteps = 6;
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new ClassicProductionQueue(init.self, this); }
|
public override object Create(ActorInitializer init) { return new ClassicProductionQueue(init.self, this); }
|
||||||
}
|
}
|
||||||
@@ -90,19 +91,21 @@ namespace OpenRA.Mods.RA
|
|||||||
if (self.World.LobbyInfo.GlobalSettings.AllowCheats && self.Owner.PlayerActor.Trait<DeveloperMode>().FastBuild)
|
if (self.World.LobbyInfo.GlobalSettings.AllowCheats && self.Owner.PlayerActor.Trait<DeveloperMode>().FastBuild)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
var selfsameBuildings = self.World.ActorsWithTrait<Production>()
|
var time = (int) (unit.GetBuildTime() * Info.BuildSpeedModifier);
|
||||||
.Where(p => p.Trait.Info.Produces.Contains(unit.Traits.Get<BuildableInfo>().Queue))
|
|
||||||
.Where(p => p.Actor.Owner == self.Owner).ToArray();
|
|
||||||
|
|
||||||
var selfsameQueue = Rules.Info["player"].Traits.WithInterface<ClassicProductionQueueInfo>()
|
if (Info.SpeedUp)
|
||||||
.First(p => selfsameBuildings.First().Trait.Info.Produces.Contains(p.Type));
|
{
|
||||||
|
var selfsameBuildings = self.World.ActorsWithTrait<Production>()
|
||||||
|
.Where(p => p.Trait.Info.Produces.Contains(unit.Traits.Get<BuildableInfo>().Queue))
|
||||||
|
.Where(p => p.Actor.Owner == self.Owner).ToArray();
|
||||||
|
|
||||||
var speedUp = 1 - (selfsameQueue.SpeedUp * (selfsameBuildings.Count() - 1)).Clamp(0, selfsameQueue.MaxSpeedUp);
|
var BuildTimeReductionSteps = Math.Min(selfsameBuildings.Count(), Info.MaxBuildTimeReductionSteps);
|
||||||
|
|
||||||
var time = unit.GetBuildTime() * Info.BuildSpeed * speedUp;
|
for (int i = 1; i < BuildTimeReductionSteps; i++)
|
||||||
|
time /= Info.BuildTimeSpeedUpDivisor;
|
||||||
|
}
|
||||||
|
|
||||||
|
return time;
|
||||||
return (int) time;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly string Type = null;
|
public readonly string Type = null;
|
||||||
public readonly string Group = null;
|
public readonly string Group = null;
|
||||||
|
|
||||||
public float BuildSpeed = 0.4f;
|
public float BuildSpeedModifier = 0.4f;
|
||||||
public readonly int LowPowerSlowdown = 3;
|
public readonly int LowPowerSlowdown = 3;
|
||||||
|
|
||||||
public readonly string ReadyAudio = "UnitReady";
|
public readonly string ReadyAudio = "UnitReady";
|
||||||
@@ -262,7 +262,7 @@ namespace OpenRA.Mods.RA
|
|||||||
if (self.World.LobbyInfo.GlobalSettings.AllowCheats && self.Owner.PlayerActor.Trait<DeveloperMode>().FastBuild)
|
if (self.World.LobbyInfo.GlobalSettings.AllowCheats && self.Owner.PlayerActor.Trait<DeveloperMode>().FastBuild)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
var time = unit.GetBuildTime() * Info.BuildSpeed;
|
var time = unit.GetBuildTime() * Info.BuildSpeedModifier;
|
||||||
|
|
||||||
return (int) time;
|
return (int) time;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,34 +6,39 @@ Player:
|
|||||||
LowPowerSlowdown: 3
|
LowPowerSlowdown: 3
|
||||||
QueuedAudio: Building
|
QueuedAudio: Building
|
||||||
ReadyAudio: ConstructionComplete
|
ReadyAudio: ConstructionComplete
|
||||||
SpeedUp: 0.25
|
SpeedUp: yes
|
||||||
MaxSpeedUp: 0.75
|
BuildTimeSpeedUpDivisor: 2
|
||||||
|
MaxBuildTimeReductionSteps: 6
|
||||||
ClassicProductionQueue@Defense:
|
ClassicProductionQueue@Defense:
|
||||||
Type: Defense
|
Type: Defense
|
||||||
BuildSpeed: .4
|
BuildSpeed: .4
|
||||||
LowPowerSlowdown: 3
|
LowPowerSlowdown: 3
|
||||||
QueuedAudio: Building
|
QueuedAudio: Building
|
||||||
ReadyAudio: ConstructionComplete
|
ReadyAudio: ConstructionComplete
|
||||||
SpeedUp: 0.25
|
SpeedUp: yes
|
||||||
MaxSpeedUp: 0.75
|
BuildTimeSpeedUpDivisor: 2
|
||||||
|
MaxBuildTimeReductionSteps: 6
|
||||||
ClassicProductionQueue@Vehicle:
|
ClassicProductionQueue@Vehicle:
|
||||||
Type: Vehicle
|
Type: Vehicle
|
||||||
BuildSpeed: .4
|
BuildSpeed: .4
|
||||||
LowPowerSlowdown: 3
|
LowPowerSlowdown: 3
|
||||||
SpeedUp: 0.25
|
SpeedUp: yes
|
||||||
MaxSpeedUp: 0.75
|
BuildTimeSpeedUpDivisor: 2
|
||||||
|
MaxBuildTimeReductionSteps: 6
|
||||||
ClassicProductionQueue@Infantry:
|
ClassicProductionQueue@Infantry:
|
||||||
Type: Infantry
|
Type: Infantry
|
||||||
BuildSpeed: .4
|
BuildSpeed: .4
|
||||||
LowPowerSlowdown: 3
|
LowPowerSlowdown: 3
|
||||||
SpeedUp: 0.25
|
SpeedUp: yes
|
||||||
MaxSpeedUp: 0.75
|
BuildTimeSpeedUpDivisor: 2
|
||||||
|
MaxBuildTimeReductionSteps: 6
|
||||||
ClassicProductionQueue@Aircraft:
|
ClassicProductionQueue@Aircraft:
|
||||||
Type: Aircraft
|
Type: Aircraft
|
||||||
BuildSpeed: .4
|
BuildSpeed: .4
|
||||||
LowPowerSlowdown: 3
|
LowPowerSlowdown: 3
|
||||||
SpeedUp: 0.25
|
SpeedUp: yes
|
||||||
MaxSpeedUp: 0.75
|
BuildTimeSpeedUpDivisor: 2
|
||||||
|
MaxBuildTimeReductionSteps: 6
|
||||||
PlaceBuilding:
|
PlaceBuilding:
|
||||||
SupportPowerManager:
|
SupportPowerManager:
|
||||||
ConquestVictoryConditions:
|
ConquestVictoryConditions:
|
||||||
|
|||||||
@@ -642,6 +642,10 @@ FACT:
|
|||||||
Power: 0
|
Power: 0
|
||||||
Footprint: xxx xxx xxx
|
Footprint: xxx xxx xxx
|
||||||
Dimensions: 3,3
|
Dimensions: 3,3
|
||||||
|
Buildable:
|
||||||
|
Queue: Building
|
||||||
|
BuildPaletteOrder: 1000
|
||||||
|
Owner: None
|
||||||
Health:
|
Health:
|
||||||
HP: 1000
|
HP: 1000
|
||||||
Armor:
|
Armor:
|
||||||
@@ -651,11 +655,12 @@ FACT:
|
|||||||
Bib:
|
Bib:
|
||||||
Production:
|
Production:
|
||||||
Produces: Building,Defense
|
Produces: Building,Defense
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
Valued:
|
Valued:
|
||||||
Cost: 2500
|
Cost: 2500
|
||||||
Tooltip:
|
Tooltip:
|
||||||
Name: Construction Yard
|
Name: Construction Yard
|
||||||
|
Description: Builds base structures.
|
||||||
CustomSellValue:
|
CustomSellValue:
|
||||||
Value: 2500
|
Value: 2500
|
||||||
BaseBuilding:
|
BaseBuilding:
|
||||||
|
|||||||
@@ -6,40 +6,46 @@ Player:
|
|||||||
LowPowerSlowdown: 3
|
LowPowerSlowdown: 3
|
||||||
QueuedAudio: Building
|
QueuedAudio: Building
|
||||||
ReadyAudio: ConstructionComplete
|
ReadyAudio: ConstructionComplete
|
||||||
SpeedUp: 0.25
|
SpeedUp: yes
|
||||||
MaxSpeedUp: 0.75
|
BuildTimeSpeedUpDivisor: 2
|
||||||
|
MaxBuildTimeReductionSteps: 6
|
||||||
ClassicProductionQueue@Defense:
|
ClassicProductionQueue@Defense:
|
||||||
Type: Defense
|
Type: Defense
|
||||||
BuildSpeed: .4
|
BuildSpeed: .4
|
||||||
LowPowerSlowdown: 3
|
LowPowerSlowdown: 3
|
||||||
QueuedAudio: Building
|
QueuedAudio: Building
|
||||||
ReadyAudio: ConstructionComplete
|
ReadyAudio: ConstructionComplete
|
||||||
SpeedUp: 0.25
|
SpeedUp: yes
|
||||||
MaxSpeedUp: 0.75
|
BuildTimeSpeedUpDivisor: 2
|
||||||
|
MaxBuildTimeReductionSteps: 6
|
||||||
ClassicProductionQueue@Vehicle:
|
ClassicProductionQueue@Vehicle:
|
||||||
Type: Vehicle
|
Type: Vehicle
|
||||||
BuildSpeed: .4
|
BuildSpeed: .4
|
||||||
LowPowerSlowdown: 3
|
LowPowerSlowdown: 3
|
||||||
SpeedUp: 0.25
|
SpeedUp: yes
|
||||||
MaxSpeedUp: 0.75
|
BuildTimeSpeedUpDivisor: 2
|
||||||
|
MaxBuildTimeReductionSteps: 6
|
||||||
ClassicProductionQueue@Infantry:
|
ClassicProductionQueue@Infantry:
|
||||||
Type: Infantry
|
Type: Infantry
|
||||||
BuildSpeed: .4
|
BuildSpeed: .4
|
||||||
LowPowerSlowdown: 3
|
LowPowerSlowdown: 3
|
||||||
SpeedUp: 0.25
|
SpeedUp: yes
|
||||||
MaxSpeedUp: 0.75
|
BuildTimeSpeedUpDivisor: 2
|
||||||
|
MaxBuildTimeReductionSteps: 6
|
||||||
ClassicProductionQueue@Ship:
|
ClassicProductionQueue@Ship:
|
||||||
Type: Ship
|
Type: Ship
|
||||||
BuildSpeed: .4
|
BuildSpeed: .4
|
||||||
LowPowerSlowdown: 3
|
LowPowerSlowdown: 3
|
||||||
SpeedUp: 0.25
|
SpeedUp: yes
|
||||||
MaxSpeedUp: 0.75
|
BuildTimeSpeedUpDivisor: 2
|
||||||
|
MaxBuildTimeReductionSteps: 6
|
||||||
ClassicProductionQueue@Plane:
|
ClassicProductionQueue@Plane:
|
||||||
Type: Plane
|
Type: Plane
|
||||||
BuildSpeed: .4
|
BuildSpeed: .4
|
||||||
LowPowerSlowdown: 3
|
LowPowerSlowdown: 3
|
||||||
SpeedUp: 0.25
|
SpeedUp: yes
|
||||||
MaxSpeedUp: 0.75
|
BuildTimeSpeedUpDivisor: 2
|
||||||
|
MaxBuildTimeReductionSteps: 6
|
||||||
PlaceBuilding:
|
PlaceBuilding:
|
||||||
SupportPowerManager:
|
SupportPowerManager:
|
||||||
ConquestVictoryConditions:
|
ConquestVictoryConditions:
|
||||||
|
|||||||
Reference in New Issue
Block a user