low power slowdown
This commit is contained in:
@@ -121,5 +121,6 @@ namespace OpenRa.Game.GameRules
|
|||||||
/* OpenRA-specific */
|
/* OpenRA-specific */
|
||||||
public readonly float OreChance; /* chance of spreading to a
|
public readonly float OreChance; /* chance of spreading to a
|
||||||
* particular eligible cell */
|
* particular eligible cell */
|
||||||
|
public readonly int LowPowerSlowdown; /* build time multiplier */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ using OpenRa.Game.Traits;
|
|||||||
|
|
||||||
namespace OpenRa.Game
|
namespace OpenRa.Game
|
||||||
{
|
{
|
||||||
|
enum PowerState { Normal, Low, Critical };
|
||||||
|
|
||||||
class Player
|
class Player
|
||||||
{
|
{
|
||||||
public int Palette;
|
public int Palette;
|
||||||
@@ -65,6 +67,13 @@ namespace OpenRa.Game
|
|||||||
return (float)Ore / GetOreCapacity();
|
return (float)Ore / GetOreCapacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PowerState GetPowerState()
|
||||||
|
{
|
||||||
|
if (powerProvided >= powerDrained) return PowerState.Normal;
|
||||||
|
if (powerProvided > powerDrained / 2) return PowerState.Low;
|
||||||
|
return PowerState.Critical;
|
||||||
|
}
|
||||||
|
|
||||||
public int GetOreCapacity()
|
public int GetOreCapacity()
|
||||||
{
|
{
|
||||||
return Game.world.Actors
|
return Game.world.Actors
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ namespace OpenRa.Game
|
|||||||
public bool Paused = false, Done = false;
|
public bool Paused = false, Done = false;
|
||||||
public Action OnComplete;
|
public Action OnComplete;
|
||||||
|
|
||||||
|
int slowdown = 0;
|
||||||
|
|
||||||
public ProductionItem(string item, int time, int cost, Action onComplete)
|
public ProductionItem(string item, int time, int cost, Action onComplete)
|
||||||
{
|
{
|
||||||
Item = item;
|
Item = item;
|
||||||
@@ -32,6 +34,14 @@ namespace OpenRa.Game
|
|||||||
|
|
||||||
if (Paused) return;
|
if (Paused) return;
|
||||||
|
|
||||||
|
if (player.GetPowerState() != PowerState.Normal)
|
||||||
|
{
|
||||||
|
if (--slowdown <= 0)
|
||||||
|
slowdown = Rules.General.LowPowerSlowdown;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var costThisFrame = RemainingCost / RemainingTime;
|
var costThisFrame = RemainingCost / RemainingTime;
|
||||||
if (costThisFrame != 0 && !player.TakeCash(costThisFrame)) return;
|
if (costThisFrame != 0 && !player.TakeCash(costThisFrame)) return;
|
||||||
|
|
||||||
|
|||||||
@@ -56,9 +56,9 @@ namespace OpenRa.Game
|
|||||||
string group = Rules.UnitCategory[ order.TargetString ];
|
string group = Rules.UnitCategory[ order.TargetString ];
|
||||||
var ui = Rules.UnitInfo[ order.TargetString ];
|
var ui = Rules.UnitInfo[ order.TargetString ];
|
||||||
var time = ui.Cost
|
var time = ui.Cost
|
||||||
* .8f /* Game.BuildSpeed */ /* todo: country-specific build speed bonus */
|
* Rules.General.BuildSpeed /* todo: country-specific build speed bonus */
|
||||||
* ( 25 * 60 ) /* frames per min */ /* todo: build acceleration, if we do that */
|
* (25 * 60) /* frames per min */ /* todo: build acceleration, if we do that */
|
||||||
/ 1000;
|
/ 1000;
|
||||||
|
|
||||||
time = .08f * time; /* temporary hax so we can build stuff fast for test */
|
time = .08f * time; /* temporary hax so we can build stuff fast for test */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user