#186 unlimited power devhack

This commit is contained in:
Chris Forbes
2010-11-21 12:36:18 +13:00
parent 1db3ce4b59
commit 5292272902
5 changed files with 58 additions and 12 deletions

View File

@@ -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); }
}
@@ -32,6 +34,7 @@ namespace OpenRA.Traits
[Sync] public bool DisableShroud;
[Sync] public bool PathDebug;
[Sync] public bool UnitInfluenceDebug;
[Sync] public bool UnlimitedPower;
public DeveloperMode(DeveloperModeInfo info)
{
@@ -41,6 +44,7 @@ namespace OpenRA.Traits
DisableShroud = Info.DisableShroud;
PathDebug = Info.PathDebug;
UnitInfluenceDebug = info.UnitInfluenceDebug;
UnlimitedPower = info.UnlimitedPower;
}
public void ResolveOrder (Actor self, Order order)
@@ -92,6 +96,11 @@ namespace OpenRA.Traits
self.World.WorldActor.Trait<Shroud>().ExploreAll(self.World);
break;
}
case "DevUnlimitedPower":
{
UnlimitedPower ^= true;
break;
}
default:
return;
}

View File

@@ -93,6 +93,14 @@ namespace OpenRA.Widgets.Delegates
return true;
};
devmodeBG.GetWidget<CheckboxWidget>("UNLIMITED_POWER").Checked =
() => world.LocalPlayer.PlayerActor.Trait<DeveloperMode>().UnlimitedPower;
devmodeBG.GetWidget<CheckboxWidget>("UNLIMITED_POWER").OnMouseDown = mi =>
{
world.IssueOrder(new Order("DevUnlimitedPower", world.LocalPlayer.PlayerActor, false));
return true;
};
devmodeBG.GetWidget<ButtonWidget>("GIVE_EXPLORATION").OnMouseUp = mi =>
{
world.IssueOrder(new Order("DevGiveExploration", world.LocalPlayer.PlayerActor, false));

View File

@@ -13,7 +13,7 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA.Buildings
{
public class PowerManagerInfo : ITraitInfo
public class PowerManagerInfo : ITraitInfo, ITraitPrerequisite<DeveloperModeInfo>
{
public readonly int AdviceInterval = 250;
public object Create(ActorInitializer init) { return new PowerManager(init, this); }
@@ -23,6 +23,7 @@ namespace OpenRA.Mods.RA.Buildings
{
PowerManagerInfo Info;
Player Player;
DeveloperMode devMode;
Dictionary<Actor, int> PowerDrain = new Dictionary<Actor, int>();
[Sync] int totalProvided;
@@ -38,6 +39,9 @@ namespace OpenRA.Mods.RA.Buildings
init.world.ActorAdded += ActorAdded;
init.world.ActorRemoved += ActorRemoved;
devMode = init.self.Trait<DeveloperMode>();
wasHackEnabled = devMode.UnlimitedPower;
}
void ActorAdded(Actor a)
@@ -68,6 +72,9 @@ namespace OpenRA.Mods.RA.Buildings
else
totalDrained -= p;
}
if (devMode.UnlimitedPower)
totalProvided = 1000000;
}
public void UpdateActor(Actor a, int newPower)
@@ -81,8 +88,16 @@ namespace OpenRA.Mods.RA.Buildings
int nextPowerAdviceTime = 0;
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;

View File

@@ -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

View File

@@ -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