diff --git a/OpenRA.Game/Traits/Player/DeveloperMode.cs b/OpenRA.Game/Traits/Player/DeveloperMode.cs index 0bd3c0ac1e..90dcb10825 100644 --- a/OpenRA.Game/Traits/Player/DeveloperMode.cs +++ b/OpenRA.Game/Traits/Player/DeveloperMode.cs @@ -9,6 +9,7 @@ #endregion using System; + namespace OpenRA.Traits { public class DeveloperModeInfo : ITraitInfo @@ -19,6 +20,7 @@ namespace OpenRA.Traits public bool DisableShroud = false; public bool PathDebug = false; public bool UnitInfluenceDebug = false; + public bool UnlimitedPower; public object Create (ActorInitializer init) { return new DeveloperMode(this); } } @@ -31,7 +33,8 @@ namespace OpenRA.Traits [Sync] public bool FastBuild; [Sync] public bool DisableShroud; [Sync] public bool PathDebug; - [Sync] public bool UnitInfluenceDebug; + [Sync] public bool UnitInfluenceDebug; + [Sync] public bool UnlimitedPower; public DeveloperMode(DeveloperModeInfo info) { @@ -40,7 +43,8 @@ namespace OpenRA.Traits FastCharge = Info.FastCharge; DisableShroud = Info.DisableShroud; PathDebug = Info.PathDebug; - UnitInfluenceDebug = info.UnitInfluenceDebug; + UnitInfluenceDebug = info.UnitInfluenceDebug; + UnlimitedPower = info.UnlimitedPower; } public void ResolveOrder (Actor self, Order order) @@ -91,6 +95,11 @@ namespace OpenRA.Traits if (self.World.LocalPlayer == self.Owner) self.World.WorldActor.Trait().ExploreAll(self.World); break; + } + case "DevUnlimitedPower": + { + UnlimitedPower ^= true; + break; } default: return; diff --git a/OpenRA.Game/Widgets/Delegates/DeveloperModeDelegate.cs b/OpenRA.Game/Widgets/Delegates/DeveloperModeDelegate.cs index 05ee0f3bc3..d4d8908f9c 100644 --- a/OpenRA.Game/Widgets/Delegates/DeveloperModeDelegate.cs +++ b/OpenRA.Game/Widgets/Delegates/DeveloperModeDelegate.cs @@ -93,6 +93,14 @@ namespace OpenRA.Widgets.Delegates return true; }; + devmodeBG.GetWidget("UNLIMITED_POWER").Checked = + () => world.LocalPlayer.PlayerActor.Trait().UnlimitedPower; + devmodeBG.GetWidget("UNLIMITED_POWER").OnMouseDown = mi => + { + world.IssueOrder(new Order("DevUnlimitedPower", world.LocalPlayer.PlayerActor, false)); + return true; + }; + devmodeBG.GetWidget("GIVE_EXPLORATION").OnMouseUp = mi => { world.IssueOrder(new Order("DevGiveExploration", world.LocalPlayer.PlayerActor, false)); diff --git a/OpenRA.Mods.RA/Buildings/PowerManager.cs b/OpenRA.Mods.RA/Buildings/PowerManager.cs index 4a7d477c80..d26ed43232 100755 --- a/OpenRA.Mods.RA/Buildings/PowerManager.cs +++ b/OpenRA.Mods.RA/Buildings/PowerManager.cs @@ -13,7 +13,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA.Buildings { - public class PowerManagerInfo : ITraitInfo + public class PowerManagerInfo : ITraitInfo, ITraitPrerequisite { public readonly int AdviceInterval = 250; public object Create(ActorInitializer init) { return new PowerManager(init, this); } @@ -22,7 +22,8 @@ namespace OpenRA.Mods.RA.Buildings public class PowerManager : ITick { PowerManagerInfo Info; - Player Player; + Player Player; + DeveloperMode devMode; Dictionary PowerDrain = new Dictionary(); [Sync] int totalProvided; @@ -37,7 +38,10 @@ namespace OpenRA.Mods.RA.Buildings Player = init.self.Owner; init.world.ActorAdded += ActorAdded; - init.world.ActorRemoved += ActorRemoved; + init.world.ActorRemoved += ActorRemoved; + + devMode = init.self.Trait(); + wasHackEnabled = devMode.UnlimitedPower; } void ActorAdded(Actor a) @@ -67,7 +71,10 @@ namespace OpenRA.Mods.RA.Buildings totalProvided += p; else totalDrained -= p; - } + } + + if (devMode.UnlimitedPower) + totalProvided = 1000000; } public void UpdateActor(Actor a, int newPower) @@ -80,9 +87,17 @@ namespace OpenRA.Mods.RA.Buildings } int nextPowerAdviceTime = 0; - bool wasLowPower = false; + bool wasLowPower = false; + bool wasHackEnabled; + public void Tick(Actor self) - { + { + if (wasHackEnabled != devMode.UnlimitedPower) + { + UpdateTotals(); + wasHackEnabled = devMode.UnlimitedPower; + } + var lowPower = totalProvided < totalDrained; if (lowPower && !wasLowPower) nextPowerAdviceTime = 0; diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml index 5d10e5ab08..53c76dbbbd 100644 --- a/mods/cnc/chrome/ingame.yaml +++ b/mods/cnc/chrome/ingame.yaml @@ -218,7 +218,7 @@ Container@INGAME_ROOT: X:(WINDOW_RIGHT - WIDTH)/2 Y:(WINDOW_BOTTOM - HEIGHT)/2 Width:350 - Height:330 + Height:360 Visible:false Children: Label@LABEL_TITLE: @@ -278,10 +278,17 @@ Container@INGAME_ROOT: Width:PARENT_RIGHT - 30 Height:20 Text:Build Everything + Checkbox@UNLIMITED_POWER + Id:UNLIMITED_POWER + X:30 + Y:260 + Width:PARENT_RIGHT - 30 + Height:20 + Text:Unlimited Power Button@GIVE_EXPLORATION Id:GIVE_EXPLORATION X:30 - Y:260 + Y:290 Width:200 Height:20 Text: Give Exploration diff --git a/mods/ra/chrome/ingame.yaml b/mods/ra/chrome/ingame.yaml index 7062c727d2..6456fe1767 100644 --- a/mods/ra/chrome/ingame.yaml +++ b/mods/ra/chrome/ingame.yaml @@ -226,7 +226,7 @@ Container@INGAME_ROOT: X:(WINDOW_RIGHT - WIDTH)/2 Y:(WINDOW_BOTTOM - HEIGHT)/2 Width:350 - Height:330 + Height:360 Visible:false Children: Label@LABEL_TITLE: @@ -286,10 +286,17 @@ Container@INGAME_ROOT: Width:PARENT_RIGHT - 30 Height:20 Text:Build Everything + Checkbox@UNLIMITED_POWER + Id:UNLIMITED_POWER + X:30 + Y:260 + Width:PARENT_RIGHT - 30 + Height:20 + Text:Unlimited Power Button@GIVE_EXPLORATION Id:GIVE_EXPLORATION X:30 - Y:260 + Y:290 Width:200 Height:20 Text: Give Exploration