fix #2709 CustomBuildTimeValue should not desync
remove redundant code by outsourcing raw build time calculation
This commit is contained in:
@@ -16,8 +16,25 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
|
|
||||||
public class CustomBuildTimeValueInfo : TraitInfo<CustomBuildTimeValue>
|
public class CustomBuildTimeValueInfo : TraitInfo<CustomBuildTimeValue>
|
||||||
{
|
{
|
||||||
public readonly int Value = 0; //in milisecons
|
public readonly int Value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CustomBuildTimeValue { }
|
public class CustomBuildTimeValue { }
|
||||||
|
|
||||||
|
public static class CustomBuildTimeValueExts
|
||||||
|
{
|
||||||
|
public static int GetBuildTime(this ActorInfo a)
|
||||||
|
{
|
||||||
|
var csv = a.Traits.GetOrDefault<CustomBuildTimeValueInfo>();
|
||||||
|
if (csv != null)
|
||||||
|
return csv.Value;
|
||||||
|
|
||||||
|
var cost = a.Traits.Contains<ValuedInfo>() ? a.Traits.Get<ValuedInfo>().Cost : 0;
|
||||||
|
var time = cost
|
||||||
|
* (25 * 60) /* frames per min */
|
||||||
|
/ 1000;
|
||||||
|
return
|
||||||
|
time;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,8 +87,8 @@ namespace OpenRA.Mods.RA
|
|||||||
if (unit == null || ! unit.Traits.Contains<BuildableInfo>())
|
if (unit == null || ! unit.Traits.Contains<BuildableInfo>())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (self.World.LobbyInfo.GlobalSettings.AllowCheats && self.Owner.PlayerActor.Trait<DeveloperMode>().FastBuild) return 0;
|
if (self.World.LobbyInfo.GlobalSettings.AllowCheats && self.Owner.PlayerActor.Trait<DeveloperMode>().FastBuild)
|
||||||
var cost = unit.Traits.Contains<ValuedInfo>() ? unit.Traits.Get<ValuedInfo>().Cost : 0;
|
return 0;
|
||||||
|
|
||||||
var selfsameBuildings = self.World.ActorsWithTrait<Production>()
|
var selfsameBuildings = self.World.ActorsWithTrait<Production>()
|
||||||
.Where(p => p.Trait.Info.Produces.Contains(unit.Traits.Get<BuildableInfo>().Queue))
|
.Where(p => p.Trait.Info.Produces.Contains(unit.Traits.Get<BuildableInfo>().Queue))
|
||||||
@@ -99,11 +99,8 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
var speedUp = 1 - (selfsameQueue.SpeedUp * (selfsameBuildings.Count() - 1)).Clamp(0, selfsameQueue.MaxSpeedUp);
|
var speedUp = 1 - (selfsameQueue.SpeedUp * (selfsameBuildings.Count() - 1)).Clamp(0, selfsameQueue.MaxSpeedUp);
|
||||||
|
|
||||||
var time = cost
|
var time = unit.GetBuildTime() * Info.BuildSpeed * speedUp;
|
||||||
* Info.BuildSpeed
|
|
||||||
* (25 * 60) /* frames per min */
|
|
||||||
* speedUp
|
|
||||||
/ 1000;
|
|
||||||
|
|
||||||
return (int) time;
|
return (int) time;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -259,15 +259,10 @@ namespace OpenRA.Mods.RA
|
|||||||
if (unit == null || ! unit.Traits.Contains<BuildableInfo>())
|
if (unit == null || ! unit.Traits.Contains<BuildableInfo>())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (self.World.LobbyInfo.GlobalSettings.AllowCheats && self.Owner.PlayerActor.Trait<DeveloperMode>().FastBuild) return 0;
|
if (self.World.LobbyInfo.GlobalSettings.AllowCheats && self.Owner.PlayerActor.Trait<DeveloperMode>().FastBuild)
|
||||||
var cost = unit.Traits.Contains<ValuedInfo>() ? unit.Traits.Get<ValuedInfo>().Cost : 0;
|
return 0;
|
||||||
var time = cost
|
|
||||||
* Info.BuildSpeed
|
|
||||||
* (25 * 60) /* frames per min */
|
|
||||||
/ 1000;
|
|
||||||
|
|
||||||
if (unit.Traits.Contains<CustomBuildTimeValueInfo>())
|
var time = unit.GetBuildTime() * Info.BuildSpeed;
|
||||||
time = unit.Traits.Get<CustomBuildTimeValueInfo>().Value * (1 / Info.BuildSpeed);
|
|
||||||
|
|
||||||
return (int) time;
|
return (int) time;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ PROC:
|
|||||||
Tooltip:
|
Tooltip:
|
||||||
Name: Tiberium Refinery
|
Name: Tiberium Refinery
|
||||||
Icon: procicnh
|
Icon: procicnh
|
||||||
Description: Processes raw Tiberium into useable resources
|
Description: Processes raw Tiberium to sell it for cash.
|
||||||
Buildable:
|
Buildable:
|
||||||
BuildPaletteOrder: 20
|
BuildPaletteOrder: 20
|
||||||
Prerequisites: anypower
|
Prerequisites: anypower
|
||||||
@@ -89,7 +89,7 @@ PROC:
|
|||||||
CustomSellValue:
|
CustomSellValue:
|
||||||
Value: 600
|
Value: 600
|
||||||
CustomBuildTimeValue:
|
CustomBuildTimeValue:
|
||||||
Value: 80
|
Value: 900
|
||||||
FreeActor:
|
FreeActor:
|
||||||
Actor: HARV
|
Actor: HARV
|
||||||
InitialActivity: FindResources
|
InitialActivity: FindResources
|
||||||
|
|||||||
Reference in New Issue
Block a user