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 readonly float SpeedUp = 0;
|
||||
public readonly float MaxSpeedUp = 0;
|
||||
public readonly bool SpeedUp = false;
|
||||
public readonly int BuildTimeSpeedUpDivisor = 2;
|
||||
public readonly int MaxBuildTimeReductionSteps = 6;
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
var time = (int) (unit.GetBuildTime() * Info.BuildSpeedModifier);
|
||||
|
||||
if (Info.SpeedUp)
|
||||
{
|
||||
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 selfsameQueue = Rules.Info["player"].Traits.WithInterface<ClassicProductionQueueInfo>()
|
||||
.First(p => selfsameBuildings.First().Trait.Info.Produces.Contains(p.Type));
|
||||
var BuildTimeReductionSteps = Math.Min(selfsameBuildings.Count(), Info.MaxBuildTimeReductionSteps);
|
||||
|
||||
var speedUp = 1 - (selfsameQueue.SpeedUp * (selfsameBuildings.Count() - 1)).Clamp(0, selfsameQueue.MaxSpeedUp);
|
||||
for (int i = 1; i < BuildTimeReductionSteps; i++)
|
||||
time /= Info.BuildTimeSpeedUpDivisor;
|
||||
}
|
||||
|
||||
var time = unit.GetBuildTime() * Info.BuildSpeed * speedUp;
|
||||
|
||||
|
||||
return (int) time;
|
||||
return time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenRA.Mods.RA
|
||||
public readonly string Type = null;
|
||||
public readonly string Group = null;
|
||||
|
||||
public float BuildSpeed = 0.4f;
|
||||
public float BuildSpeedModifier = 0.4f;
|
||||
public readonly int LowPowerSlowdown = 3;
|
||||
|
||||
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)
|
||||
return 0;
|
||||
|
||||
var time = unit.GetBuildTime() * Info.BuildSpeed;
|
||||
var time = unit.GetBuildTime() * Info.BuildSpeedModifier;
|
||||
|
||||
return (int) time;
|
||||
}
|
||||
|
||||
@@ -6,34 +6,39 @@ Player:
|
||||
LowPowerSlowdown: 3
|
||||
QueuedAudio: Building
|
||||
ReadyAudio: ConstructionComplete
|
||||
SpeedUp: 0.25
|
||||
MaxSpeedUp: 0.75
|
||||
SpeedUp: yes
|
||||
BuildTimeSpeedUpDivisor: 2
|
||||
MaxBuildTimeReductionSteps: 6
|
||||
ClassicProductionQueue@Defense:
|
||||
Type: Defense
|
||||
BuildSpeed: .4
|
||||
LowPowerSlowdown: 3
|
||||
QueuedAudio: Building
|
||||
ReadyAudio: ConstructionComplete
|
||||
SpeedUp: 0.25
|
||||
MaxSpeedUp: 0.75
|
||||
SpeedUp: yes
|
||||
BuildTimeSpeedUpDivisor: 2
|
||||
MaxBuildTimeReductionSteps: 6
|
||||
ClassicProductionQueue@Vehicle:
|
||||
Type: Vehicle
|
||||
BuildSpeed: .4
|
||||
LowPowerSlowdown: 3
|
||||
SpeedUp: 0.25
|
||||
MaxSpeedUp: 0.75
|
||||
SpeedUp: yes
|
||||
BuildTimeSpeedUpDivisor: 2
|
||||
MaxBuildTimeReductionSteps: 6
|
||||
ClassicProductionQueue@Infantry:
|
||||
Type: Infantry
|
||||
BuildSpeed: .4
|
||||
LowPowerSlowdown: 3
|
||||
SpeedUp: 0.25
|
||||
MaxSpeedUp: 0.75
|
||||
SpeedUp: yes
|
||||
BuildTimeSpeedUpDivisor: 2
|
||||
MaxBuildTimeReductionSteps: 6
|
||||
ClassicProductionQueue@Aircraft:
|
||||
Type: Aircraft
|
||||
BuildSpeed: .4
|
||||
LowPowerSlowdown: 3
|
||||
SpeedUp: 0.25
|
||||
MaxSpeedUp: 0.75
|
||||
SpeedUp: yes
|
||||
BuildTimeSpeedUpDivisor: 2
|
||||
MaxBuildTimeReductionSteps: 6
|
||||
PlaceBuilding:
|
||||
SupportPowerManager:
|
||||
ConquestVictoryConditions:
|
||||
|
||||
@@ -642,6 +642,10 @@ FACT:
|
||||
Power: 0
|
||||
Footprint: xxx xxx xxx
|
||||
Dimensions: 3,3
|
||||
Buildable:
|
||||
Queue: Building
|
||||
BuildPaletteOrder: 1000
|
||||
Owner: None
|
||||
Health:
|
||||
HP: 1000
|
||||
Armor:
|
||||
@@ -656,6 +660,7 @@ FACT:
|
||||
Cost: 2500
|
||||
Tooltip:
|
||||
Name: Construction Yard
|
||||
Description: Builds base structures.
|
||||
CustomSellValue:
|
||||
Value: 2500
|
||||
BaseBuilding:
|
||||
|
||||
@@ -6,40 +6,46 @@ Player:
|
||||
LowPowerSlowdown: 3
|
||||
QueuedAudio: Building
|
||||
ReadyAudio: ConstructionComplete
|
||||
SpeedUp: 0.25
|
||||
MaxSpeedUp: 0.75
|
||||
SpeedUp: yes
|
||||
BuildTimeSpeedUpDivisor: 2
|
||||
MaxBuildTimeReductionSteps: 6
|
||||
ClassicProductionQueue@Defense:
|
||||
Type: Defense
|
||||
BuildSpeed: .4
|
||||
LowPowerSlowdown: 3
|
||||
QueuedAudio: Building
|
||||
ReadyAudio: ConstructionComplete
|
||||
SpeedUp: 0.25
|
||||
MaxSpeedUp: 0.75
|
||||
SpeedUp: yes
|
||||
BuildTimeSpeedUpDivisor: 2
|
||||
MaxBuildTimeReductionSteps: 6
|
||||
ClassicProductionQueue@Vehicle:
|
||||
Type: Vehicle
|
||||
BuildSpeed: .4
|
||||
LowPowerSlowdown: 3
|
||||
SpeedUp: 0.25
|
||||
MaxSpeedUp: 0.75
|
||||
SpeedUp: yes
|
||||
BuildTimeSpeedUpDivisor: 2
|
||||
MaxBuildTimeReductionSteps: 6
|
||||
ClassicProductionQueue@Infantry:
|
||||
Type: Infantry
|
||||
BuildSpeed: .4
|
||||
LowPowerSlowdown: 3
|
||||
SpeedUp: 0.25
|
||||
MaxSpeedUp: 0.75
|
||||
SpeedUp: yes
|
||||
BuildTimeSpeedUpDivisor: 2
|
||||
MaxBuildTimeReductionSteps: 6
|
||||
ClassicProductionQueue@Ship:
|
||||
Type: Ship
|
||||
BuildSpeed: .4
|
||||
LowPowerSlowdown: 3
|
||||
SpeedUp: 0.25
|
||||
MaxSpeedUp: 0.75
|
||||
SpeedUp: yes
|
||||
BuildTimeSpeedUpDivisor: 2
|
||||
MaxBuildTimeReductionSteps: 6
|
||||
ClassicProductionQueue@Plane:
|
||||
Type: Plane
|
||||
BuildSpeed: .4
|
||||
LowPowerSlowdown: 3
|
||||
SpeedUp: 0.25
|
||||
MaxSpeedUp: 0.75
|
||||
SpeedUp: yes
|
||||
BuildTimeSpeedUpDivisor: 2
|
||||
MaxBuildTimeReductionSteps: 6
|
||||
PlaceBuilding:
|
||||
SupportPowerManager:
|
||||
ConquestVictoryConditions:
|
||||
|
||||
Reference in New Issue
Block a user