#186 unlimited power devhack
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace OpenRA.Traits
|
namespace OpenRA.Traits
|
||||||
{
|
{
|
||||||
public class DeveloperModeInfo : ITraitInfo
|
public class DeveloperModeInfo : ITraitInfo
|
||||||
@@ -19,6 +20,7 @@ namespace OpenRA.Traits
|
|||||||
public bool DisableShroud = false;
|
public bool DisableShroud = false;
|
||||||
public bool PathDebug = false;
|
public bool PathDebug = false;
|
||||||
public bool UnitInfluenceDebug = false;
|
public bool UnitInfluenceDebug = false;
|
||||||
|
public bool UnlimitedPower;
|
||||||
|
|
||||||
public object Create (ActorInitializer init) { return new DeveloperMode(this); }
|
public object Create (ActorInitializer init) { return new DeveloperMode(this); }
|
||||||
}
|
}
|
||||||
@@ -31,7 +33,8 @@ namespace OpenRA.Traits
|
|||||||
[Sync] public bool FastBuild;
|
[Sync] public bool FastBuild;
|
||||||
[Sync] public bool DisableShroud;
|
[Sync] public bool DisableShroud;
|
||||||
[Sync] public bool PathDebug;
|
[Sync] public bool PathDebug;
|
||||||
[Sync] public bool UnitInfluenceDebug;
|
[Sync] public bool UnitInfluenceDebug;
|
||||||
|
[Sync] public bool UnlimitedPower;
|
||||||
|
|
||||||
public DeveloperMode(DeveloperModeInfo info)
|
public DeveloperMode(DeveloperModeInfo info)
|
||||||
{
|
{
|
||||||
@@ -40,7 +43,8 @@ namespace OpenRA.Traits
|
|||||||
FastCharge = Info.FastCharge;
|
FastCharge = Info.FastCharge;
|
||||||
DisableShroud = Info.DisableShroud;
|
DisableShroud = Info.DisableShroud;
|
||||||
PathDebug = Info.PathDebug;
|
PathDebug = Info.PathDebug;
|
||||||
UnitInfluenceDebug = info.UnitInfluenceDebug;
|
UnitInfluenceDebug = info.UnitInfluenceDebug;
|
||||||
|
UnlimitedPower = info.UnlimitedPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResolveOrder (Actor self, Order order)
|
public void ResolveOrder (Actor self, Order order)
|
||||||
@@ -91,6 +95,11 @@ namespace OpenRA.Traits
|
|||||||
if (self.World.LocalPlayer == self.Owner)
|
if (self.World.LocalPlayer == self.Owner)
|
||||||
self.World.WorldActor.Trait<Shroud>().ExploreAll(self.World);
|
self.World.WorldActor.Trait<Shroud>().ExploreAll(self.World);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
case "DevUnlimitedPower":
|
||||||
|
{
|
||||||
|
UnlimitedPower ^= true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -93,6 +93,14 @@ namespace OpenRA.Widgets.Delegates
|
|||||||
return true;
|
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 =>
|
devmodeBG.GetWidget<ButtonWidget>("GIVE_EXPLORATION").OnMouseUp = mi =>
|
||||||
{
|
{
|
||||||
world.IssueOrder(new Order("DevGiveExploration", world.LocalPlayer.PlayerActor, false));
|
world.IssueOrder(new Order("DevGiveExploration", world.LocalPlayer.PlayerActor, false));
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA.Buildings
|
namespace OpenRA.Mods.RA.Buildings
|
||||||
{
|
{
|
||||||
public class PowerManagerInfo : ITraitInfo
|
public class PowerManagerInfo : ITraitInfo, ITraitPrerequisite<DeveloperModeInfo>
|
||||||
{
|
{
|
||||||
public readonly int AdviceInterval = 250;
|
public readonly int AdviceInterval = 250;
|
||||||
public object Create(ActorInitializer init) { return new PowerManager(init, this); }
|
public object Create(ActorInitializer init) { return new PowerManager(init, this); }
|
||||||
@@ -22,7 +22,8 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
public class PowerManager : ITick
|
public class PowerManager : ITick
|
||||||
{
|
{
|
||||||
PowerManagerInfo Info;
|
PowerManagerInfo Info;
|
||||||
Player Player;
|
Player Player;
|
||||||
|
DeveloperMode devMode;
|
||||||
|
|
||||||
Dictionary<Actor, int> PowerDrain = new Dictionary<Actor, int>();
|
Dictionary<Actor, int> PowerDrain = new Dictionary<Actor, int>();
|
||||||
[Sync] int totalProvided;
|
[Sync] int totalProvided;
|
||||||
@@ -37,7 +38,10 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
Player = init.self.Owner;
|
Player = init.self.Owner;
|
||||||
|
|
||||||
init.world.ActorAdded += ActorAdded;
|
init.world.ActorAdded += ActorAdded;
|
||||||
init.world.ActorRemoved += ActorRemoved;
|
init.world.ActorRemoved += ActorRemoved;
|
||||||
|
|
||||||
|
devMode = init.self.Trait<DeveloperMode>();
|
||||||
|
wasHackEnabled = devMode.UnlimitedPower;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActorAdded(Actor a)
|
void ActorAdded(Actor a)
|
||||||
@@ -67,7 +71,10 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
totalProvided += p;
|
totalProvided += p;
|
||||||
else
|
else
|
||||||
totalDrained -= p;
|
totalDrained -= p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (devMode.UnlimitedPower)
|
||||||
|
totalProvided = 1000000;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateActor(Actor a, int newPower)
|
public void UpdateActor(Actor a, int newPower)
|
||||||
@@ -80,9 +87,17 @@ namespace OpenRA.Mods.RA.Buildings
|
|||||||
}
|
}
|
||||||
|
|
||||||
int nextPowerAdviceTime = 0;
|
int nextPowerAdviceTime = 0;
|
||||||
bool wasLowPower = false;
|
bool wasLowPower = false;
|
||||||
|
bool wasHackEnabled;
|
||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
|
if (wasHackEnabled != devMode.UnlimitedPower)
|
||||||
|
{
|
||||||
|
UpdateTotals();
|
||||||
|
wasHackEnabled = devMode.UnlimitedPower;
|
||||||
|
}
|
||||||
|
|
||||||
var lowPower = totalProvided < totalDrained;
|
var lowPower = totalProvided < totalDrained;
|
||||||
if (lowPower && !wasLowPower)
|
if (lowPower && !wasLowPower)
|
||||||
nextPowerAdviceTime = 0;
|
nextPowerAdviceTime = 0;
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ Container@INGAME_ROOT:
|
|||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||||
Width:350
|
Width:350
|
||||||
Height:330
|
Height:360
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
Label@LABEL_TITLE:
|
Label@LABEL_TITLE:
|
||||||
@@ -278,10 +278,17 @@ Container@INGAME_ROOT:
|
|||||||
Width:PARENT_RIGHT - 30
|
Width:PARENT_RIGHT - 30
|
||||||
Height:20
|
Height:20
|
||||||
Text:Build Everything
|
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
|
Button@GIVE_EXPLORATION
|
||||||
Id:GIVE_EXPLORATION
|
Id:GIVE_EXPLORATION
|
||||||
X:30
|
X:30
|
||||||
Y:260
|
Y:290
|
||||||
Width:200
|
Width:200
|
||||||
Height:20
|
Height:20
|
||||||
Text: Give Exploration
|
Text: Give Exploration
|
||||||
|
|||||||
@@ -226,7 +226,7 @@ Container@INGAME_ROOT:
|
|||||||
X:(WINDOW_RIGHT - WIDTH)/2
|
X:(WINDOW_RIGHT - WIDTH)/2
|
||||||
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
Y:(WINDOW_BOTTOM - HEIGHT)/2
|
||||||
Width:350
|
Width:350
|
||||||
Height:330
|
Height:360
|
||||||
Visible:false
|
Visible:false
|
||||||
Children:
|
Children:
|
||||||
Label@LABEL_TITLE:
|
Label@LABEL_TITLE:
|
||||||
@@ -286,10 +286,17 @@ Container@INGAME_ROOT:
|
|||||||
Width:PARENT_RIGHT - 30
|
Width:PARENT_RIGHT - 30
|
||||||
Height:20
|
Height:20
|
||||||
Text:Build Everything
|
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
|
Button@GIVE_EXPLORATION
|
||||||
Id:GIVE_EXPLORATION
|
Id:GIVE_EXPLORATION
|
||||||
X:30
|
X:30
|
||||||
Y:260
|
Y:290
|
||||||
Width:200
|
Width:200
|
||||||
Height:20
|
Height:20
|
||||||
Text: Give Exploration
|
Text: Give Exploration
|
||||||
|
|||||||
Reference in New Issue
Block a user