diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index 1ae7e77370..3407537aa4 100755 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -157,7 +157,7 @@ namespace OpenRA if (Health <= 0) return DamageState.Dead; - if (Health < this.GetMaxHP() * Rules.General.ConditionYellow) + if (Health < this.GetMaxHP() * World.Defaults.ConditionYellow) return DamageState.Half; return DamageState.Normal; diff --git a/OpenRA.Game/Effects/RepairIndicator.cs b/OpenRA.Game/Effects/RepairIndicator.cs index 93bcb0dcda..d9ae3d5e2a 100755 --- a/OpenRA.Game/Effects/RepairIndicator.cs +++ b/OpenRA.Game/Effects/RepairIndicator.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. * This file is part of OpenRA. @@ -26,11 +26,15 @@ namespace OpenRA.Effects { class RepairIndicator : IEffect { - int framesLeft = (int)(Rules.General.RepairRate * 25 * 60 / 2); + int framesLeft; Actor a; Animation anim = new Animation("select"); - public RepairIndicator(Actor a) { this.a = a; anim.PlayRepeating("repair"); } + public RepairIndicator(Actor a) + { + this.a = a; anim.PlayRepeating("repair"); + framesLeft = (int)(a.World.Defaults.RepairRate * 25 * 60 / 2); + } public void Tick( World world ) { diff --git a/OpenRA.Game/GameRules/Rules.cs b/OpenRA.Game/GameRules/Rules.cs index df87408ffa..61b16f06d3 100755 --- a/OpenRA.Game/GameRules/Rules.cs +++ b/OpenRA.Game/GameRules/Rules.cs @@ -34,7 +34,6 @@ namespace OpenRA public static InfoLoader WarheadInfo; public static InfoLoader ProjectileInfo; public static InfoLoader VoiceInfo; - public static GeneralInfo General; public static TechTree TechTree; public static Dictionary Info; @@ -45,9 +44,6 @@ namespace OpenRA legacyRules.Insert(0, map); AllRules = new IniFile(legacyRules.Select(a => FileSystem.Open(a)).ToArray()); - General = new GeneralInfo(); - FieldLoader.Load(General, AllRules.GetSection("General")); - LoadCategories( "Weapon", "Warhead", diff --git a/OpenRA.Game/Graphics/WorldRenderer.cs b/OpenRA.Game/Graphics/WorldRenderer.cs index d9b4f9f6cf..af418b34ab 100644 --- a/OpenRA.Game/Graphics/WorldRenderer.cs +++ b/OpenRA.Game/Graphics/WorldRenderer.cs @@ -255,8 +255,8 @@ namespace OpenRA.Graphics lineRenderer.DrawLine(Xy + new float2(0, -2), Xy + new float2(0, -4), c, c); var healthAmount = (float)selectedUnit.Health / selectedUnit.Info.Traits.Get().HP; - var healthColor = (healthAmount < Rules.General.ConditionRed) ? Color.Red - : (healthAmount < Rules.General.ConditionYellow) ? Color.Yellow + var healthColor = (healthAmount < selectedUnit.World.Defaults.ConditionRed) ? Color.Red + : (healthAmount < selectedUnit.World.Defaults.ConditionYellow) ? Color.Yellow : Color.LimeGreen; var healthColor2 = Color.FromArgb( diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index b75ec87060..c9ce38357a 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -302,7 +302,7 @@ - + @@ -338,7 +338,4 @@ --> - - - \ No newline at end of file diff --git a/OpenRA.Game/Player.cs b/OpenRA.Game/Player.cs index c37f5a72fc..c01cf28fb4 100644 --- a/OpenRA.Game/Player.cs +++ b/OpenRA.Game/Player.cs @@ -138,7 +138,7 @@ namespace OpenRA void GiveAdvice(string advice) { // todo: store the condition or something. - // repeat after Rules.General.SpeakDelay, as long as the condition holds. + // repeat after World.Defaults.SpeakDelay, as long as the condition holds. Sound.PlayToPlayer(this, advice); } diff --git a/OpenRA.Game/Traits/Activities/Repair.cs b/OpenRA.Game/Traits/Activities/Repair.cs index 1231240046..6202f0f50b 100644 --- a/OpenRA.Game/Traits/Activities/Repair.cs +++ b/OpenRA.Game/Traits/Activities/Repair.cs @@ -1,4 +1,4 @@ -#region Copyright & License Information +#region Copyright & License Information /* * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. * This file is part of OpenRA. @@ -39,8 +39,8 @@ namespace OpenRA.Traits.Activities var unitCost = self.Info.Traits.Get().Cost; var hp = self.Info.Traits.Get().HP; - var costPerHp = (Rules.General.URepairPercent * unitCost) / hp; - var hpToRepair = Math.Min(Rules.General.URepairStep, hp - self.Health); + var costPerHp = (self.World.Defaults.URepairPercent * unitCost) / hp; + var hpToRepair = Math.Min(self.World.Defaults.URepairStep, hp - self.Health); var cost = (int)Math.Ceiling(costPerHp * hpToRepair); if (!self.Owner.TakeCash(cost)) { @@ -59,7 +59,7 @@ namespace OpenRA.Traits.Activities hostBuilding.traits.Get() .PlayCustomAnim(hostBuilding, "active"); - remainingTicks = (int)(Rules.General.RepairRate * 60 * 25); + remainingTicks = (int)(self.World.Defaults.RepairRate * 60 * 25); } else --remainingTicks; diff --git a/OpenRA.Game/Traits/Activities/Sell.cs b/OpenRA.Game/Traits/Activities/Sell.cs index 159074ce19..3dccb60157 100644 --- a/OpenRA.Game/Traits/Activities/Sell.cs +++ b/OpenRA.Game/Traits/Activities/Sell.cs @@ -33,7 +33,7 @@ namespace OpenRA.Traits.Activities var csv = self.Info.Traits.GetOrDefault(); var cost = csv != null ? csv.Value : self.Info.Traits.Get().Cost; var hp = self.Info.Traits.Get().HP; - var refund = Rules.General.RefundPercent * self.Health * cost / hp; + var refund = self.World.Defaults.RefundPercent * self.Health * cost / hp; self.Owner.GiveCash((int)refund); self.Health = 0; diff --git a/OpenRA.Game/Traits/Building.cs b/OpenRA.Game/Traits/Building.cs index 2e1aa3836a..d60f228f6f 100644 --- a/OpenRA.Game/Traits/Building.cs +++ b/OpenRA.Game/Traits/Building.cs @@ -125,8 +125,8 @@ namespace OpenRA.Traits var csv = self.Info.Traits.GetOrDefault(); var buildingValue = csv != null ? csv.Value : self.Info.Traits.Get().Cost; var maxHP = self.Info.Traits.Get().HP; - var costPerHp = (Rules.General.URepairPercent * buildingValue) / maxHP; - var hpToRepair = Math.Min(Rules.General.URepairStep, maxHP - self.Health); + var costPerHp = (self.World.Defaults.URepairPercent * buildingValue) / maxHP; + var hpToRepair = Math.Min(self.World.Defaults.URepairStep, maxHP - self.Health); var cost = (int)Math.Ceiling(costPerHp * hpToRepair); if (!self.Owner.TakeCash(cost)) { @@ -141,7 +141,7 @@ namespace OpenRA.Traits isRepairing = false; return; } - remainingTicks = (int)(Rules.General.RepairRate * 60 * 25); + remainingTicks = (int)(self.World.Defaults.RepairRate * 60 * 25); } else --remainingTicks; diff --git a/OpenRA.Game/Traits/Player/ProductionQueue.cs b/OpenRA.Game/Traits/Player/ProductionQueue.cs index 29f7175393..6c027c0e2c 100644 --- a/OpenRA.Game/Traits/Player/ProductionQueue.cs +++ b/OpenRA.Game/Traits/Player/ProductionQueue.cs @@ -57,7 +57,7 @@ namespace OpenRA.Traits var unit = Rules.Info[order.TargetString]; var ui = unit.Traits.Get(); var time = ui.Cost - * Rules.General.BuildSpeed /* todo: country-specific build speed bonus */ + * self.World.Defaults.BuildSpeed /* todo: country-specific build speed bonus */ * (25 * 60) /* frames per min */ /* todo: build acceleration, if we do that */ / 1000; @@ -226,7 +226,7 @@ namespace OpenRA.Traits if (player.GetPowerState() != PowerState.Normal) { if (--slowdown <= 0) - slowdown = Rules.General.LowPowerSlowdown; + slowdown = player.World.Defaults.LowPowerSlowdown; else return; } diff --git a/OpenRA.Game/Traits/Render/RenderBuildingWall.cs b/OpenRA.Game/Traits/Render/RenderBuildingWall.cs index 8084c8c3ae..a55bd846a0 100644 --- a/OpenRA.Game/Traits/Render/RenderBuildingWall.cs +++ b/OpenRA.Game/Traits/Render/RenderBuildingWall.cs @@ -51,10 +51,10 @@ namespace OpenRA.Traits if (effectiveHealth <= 0) return ExtendedDamageState.Dead; - if (effectiveHealth < self.GetMaxHP() * Rules.General.ConditionRed) + if (effectiveHealth < self.GetMaxHP() * self.World.Defaults.ConditionRed) return ExtendedDamageState.Quarter; - if (effectiveHealth < self.GetMaxHP() * Rules.General.ConditionYellow) + if (effectiveHealth < self.GetMaxHP() * self.World.Defaults.ConditionYellow) return ExtendedDamageState.Half; if (effectiveHealth < self.GetMaxHP() * 0.75) diff --git a/OpenRA.Game/Traits/Defaults/GlobalDefaults.cs b/OpenRA.Game/Traits/World/GlobalDefaults.cs similarity index 91% rename from OpenRA.Game/Traits/Defaults/GlobalDefaults.cs rename to OpenRA.Game/Traits/World/GlobalDefaults.cs index 5fbb29987e..d2c72235a7 100644 --- a/OpenRA.Game/Traits/Defaults/GlobalDefaults.cs +++ b/OpenRA.Game/Traits/World/GlobalDefaults.cs @@ -1,9 +1,9 @@ using System; -namespace OpenRA.Traits.Defaults +namespace OpenRA.Traits { - class GlobalDefaultsInfo : ITraitInfo + public class GlobalDefaultsInfo : StatelessTraitInfo { /* Special Weapons */ public readonly float GapRegenInterval =0; @@ -80,15 +80,8 @@ namespace OpenRA.Traits.Defaults public readonly int SuspendPriority = 0; public readonly float TeamDelay = 0; - public object Create(Actor self) { return new GlobalDefaults(self); } + public readonly int LowPowerSlowdown = 3; } - public class GlobalDefaults - { - Actor self; - public GlobalDefaults (Actor self) - { - this.self = self; - } - } + public class GlobalDefaults {} } diff --git a/OpenRA.Game/World.cs b/OpenRA.Game/World.cs index acbf3261d8..104e45dbdd 100644 --- a/OpenRA.Game/World.cs +++ b/OpenRA.Game/World.cs @@ -66,6 +66,7 @@ namespace OpenRA public readonly Map Map; public readonly TileSet TileSet; + public GlobalDefaultsInfo Defaults { get {return WorldActor.Info.Traits.Get();}} // for tricky things like bridges. public readonly ICustomTerrain[,] customTerrain; @@ -114,7 +115,7 @@ namespace OpenRA Add( a ); return a; } - + public void Add(Actor a) { a.IsInWorld = true; diff --git a/mods/ra/rules.yaml b/mods/ra/rules.yaml index 57f4ff5385..415deae771 100755 --- a/mods/ra/rules.yaml +++ b/mods/ra/rules.yaml @@ -63,7 +63,7 @@ Player: GivenAuto: no OneShot: yes -Defaults: +World: GlobalDefaults: GapRegenInterval: .1 BadgerBombCount: 1 @@ -125,8 +125,7 @@ Defaults: SuspendDelay: 2 SuspendPriority: 20 TeamDelay: .6 - -World: + LowPowerSlowdown: 3 ScreenShaker: WaterPaletteRotation: ChronoshiftPaletteEffect: