Selectively power-up/down buildings via chrome

This commit is contained in:
Paul Chote
2010-01-04 21:04:57 +13:00
parent 3b0fd0e22c
commit 88c3e21ed0
10 changed files with 115 additions and 13 deletions

View File

@@ -10,15 +10,34 @@ namespace OpenRa.Game.Traits
{
class Building : INotifyDamage, IOrder, ITick
{
readonly Actor self;
public readonly BuildingInfo unitInfo;
bool isRepairing = false;
bool isPoweredDown = false;
public Building(Actor self)
{
this.self = self;
unitInfo = (BuildingInfo)self.Info;
self.CenterLocation = Game.CellSize
* ((float2)self.Location + .5f * (float2)unitInfo.Dimensions);
}
public bool IsActive()
{
return !(isPoweredDown || (unitInfo.Powered && self.Owner.GetPowerState() != PowerState.Normal));
}
public int GetPowerUsage()
{
if (isPoweredDown)
return 0;
if (unitInfo.Power > 0) /* todo: is this how real-ra scales it? */
return (self.Health * unitInfo.Power) / unitInfo.Strength;
else
return unitInfo.Power;
}
public void Damaged(Actor self, AttackInfo e)
{
@@ -43,6 +62,11 @@ namespace OpenRa.Game.Traits
{
isRepairing = !isRepairing;
}
if (order.OrderString == "PowerDown")
{
isPoweredDown = !isPoweredDown;
}
}
int remainingTicks;