#186 unlimited power devhack
This commit is contained in:
@@ -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<Shroud>().ExploreAll(self.World);
|
||||
break;
|
||||
}
|
||||
case "DevUnlimitedPower":
|
||||
{
|
||||
UnlimitedPower ^= true;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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); }
|
||||
@@ -22,7 +22,8 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
public class PowerManager : ITick
|
||||
{
|
||||
PowerManagerInfo Info;
|
||||
Player Player;
|
||||
Player Player;
|
||||
DeveloperMode devMode;
|
||||
|
||||
Dictionary<Actor, int> PowerDrain = new Dictionary<Actor, int>();
|
||||
[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<DeveloperMode>();
|
||||
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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user