fix #2709 CustomBuildTimeValue should not desync

remove redundant code by outsourcing raw build time calculation
This commit is contained in:
Matthias Mailänder
2013-03-07 21:48:54 +01:00
parent e3fbd40278
commit f3e0ff8758
4 changed files with 27 additions and 18 deletions

View File

@@ -259,15 +259,10 @@ namespace OpenRA.Mods.RA
if (unit == null || ! unit.Traits.Contains<BuildableInfo>())
return 0;
if (self.World.LobbyInfo.GlobalSettings.AllowCheats && self.Owner.PlayerActor.Trait<DeveloperMode>().FastBuild) return 0;
var cost = unit.Traits.Contains<ValuedInfo>() ? unit.Traits.Get<ValuedInfo>().Cost : 0;
var time = cost
* Info.BuildSpeed
* (25 * 60) /* frames per min */
/ 1000;
if (self.World.LobbyInfo.GlobalSettings.AllowCheats && self.Owner.PlayerActor.Trait<DeveloperMode>().FastBuild)
return 0;
if (unit.Traits.Contains<CustomBuildTimeValueInfo>())
time = unit.Traits.Get<CustomBuildTimeValueInfo>().Value * (1 / Info.BuildSpeed);
var time = unit.GetBuildTime() * Info.BuildSpeed;
return (int) time;
}