Migrate BuildSpeed from float to int
This commit is contained in:
@@ -128,7 +128,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (self.World.AllowDevCommands && self.Owner.PlayerActor.Trait<DeveloperMode>().FastBuild)
|
||||
return 0;
|
||||
|
||||
var time = (int)(unit.GetBuildTime() * Info.BuildSpeed);
|
||||
var time = unit.GetBuildTime() * Info.BuildSpeed / 100;
|
||||
|
||||
if (info.SpeedUp)
|
||||
{
|
||||
|
||||
@@ -34,8 +34,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Should the prerequisite remain enabled if the owner changes?")]
|
||||
public readonly bool Sticky = true;
|
||||
|
||||
[Desc("This value is used to translate the unit cost into build time.")]
|
||||
public readonly float BuildSpeed = 0.4f;
|
||||
[Desc("This percentage value is multiplied with actor cost to translate into build time (lower means faster).")]
|
||||
public readonly int BuildSpeed = 40;
|
||||
|
||||
[Desc("The build time is multiplied with this value on low power.")]
|
||||
public readonly int LowPowerSlowdown = 3;
|
||||
@@ -319,8 +319,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (self.World.AllowDevCommands && self.Owner.PlayerActor.Trait<DeveloperMode>().FastBuild)
|
||||
return 0;
|
||||
|
||||
var time = unit.GetBuildTime() * Info.BuildSpeed;
|
||||
return (int)time;
|
||||
var time = unit.GetBuildTime() * Info.BuildSpeed / 100;
|
||||
return time;
|
||||
}
|
||||
|
||||
protected void CancelProduction(string itemName, uint numberToCancel)
|
||||
|
||||
@@ -644,6 +644,22 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
node.Key = "ReloadDelay";
|
||||
}
|
||||
|
||||
// Migrated ProductionQueue BuildSpeed to use int percentage instead of float
|
||||
if (engineVersion < 20160325)
|
||||
{
|
||||
if (node.Key.StartsWith("ProductionQueue") || node.Key.StartsWith("ClassicProductionQueue"))
|
||||
{
|
||||
var buildSpeedNode = node.Value.Nodes.FirstOrDefault(x => x.Key == "BuildSpeed");
|
||||
if (buildSpeedNode != null)
|
||||
{
|
||||
// The BuildSpeed value is now an int percentage, so multiply the float with 100.
|
||||
var oldValue = FieldLoader.GetValue<float>("BuildSpeed", buildSpeedNode.Value.Value);
|
||||
var newValue = (int)(oldValue * 100);
|
||||
buildSpeedNode.Value.Value = newValue.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user