From bc32d32d54664b89fb8e48251fdca1f3bb4c7578 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Sun, 13 Feb 2011 22:12:46 +1300 Subject: [PATCH] remove FP from RepairableBuilding --- OpenRA.Mods.RA/Buildings/RepairableBuilding.cs | 13 ++++++------- OpenRA.Mods.RA/Effects/RepairIndicator.cs | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/OpenRA.Mods.RA/Buildings/RepairableBuilding.cs b/OpenRA.Mods.RA/Buildings/RepairableBuilding.cs index fae3f0d508..da2412d049 100755 --- a/OpenRA.Mods.RA/Buildings/RepairableBuilding.cs +++ b/OpenRA.Mods.RA/Buildings/RepairableBuilding.cs @@ -16,8 +16,8 @@ namespace OpenRA.Mods.RA.Buildings { public class RepairableBuildingInfo : ITraitInfo, ITraitPrerequisite { - public readonly float RepairPercent = 0.2f; - public readonly float RepairRate = 0.016f; + public readonly int RepairPercent = 20; + public readonly int RepairInterval = 24; public readonly int RepairStep = 7; public object Create(ActorInitializer init) { return new RepairableBuilding(init.self, this); } } @@ -53,11 +53,10 @@ namespace OpenRA.Mods.RA.Buildings if (remainingTicks == 0) { var csv = self.Info.Traits.GetOrDefault(); - var buildingValue = csv != null ? csv.Value : self.Info.Traits.Get().Cost; - - var costPerHp = (Info.RepairPercent * buildingValue) / Health.MaxHP; + var buildingValue = csv != null ? csv.Value : self.Info.Traits.Get().Cost; + var hpToRepair = Math.Min(Info.RepairStep, Health.MaxHP - Health.HP); - var cost = (int)Math.Ceiling(costPerHp * hpToRepair); + var cost = (hpToRepair * Info.RepairPercent * buildingValue) / (Health.MaxHP * 100); if (!self.Owner.PlayerActor.Trait().TakeCash(cost)) { remainingTicks = 1; @@ -71,7 +70,7 @@ namespace OpenRA.Mods.RA.Buildings isRepairing = false; return; } - remainingTicks = (int)(Info.RepairRate * 60 * 25); + remainingTicks = Info.RepairInterval; } else --remainingTicks; diff --git a/OpenRA.Mods.RA/Effects/RepairIndicator.cs b/OpenRA.Mods.RA/Effects/RepairIndicator.cs index df0d73afff..01cff51e83 100755 --- a/OpenRA.Mods.RA/Effects/RepairIndicator.cs +++ b/OpenRA.Mods.RA/Effects/RepairIndicator.cs @@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Effects public RepairIndicator(Actor a) { this.a = a; anim.PlayRepeating("repair"); - framesLeft = (int)(a.Info.Traits.Get().RepairRate * 25 * 60 / 2); + framesLeft = a.Info.Traits.Get().RepairInterval / 2; } public void Tick( World world )