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