Add total earned/spent tracking
This commit is contained in:
@@ -87,9 +87,13 @@ namespace OpenRA.Traits
|
|||||||
public int DisplayOre;
|
public int DisplayOre;
|
||||||
|
|
||||||
public int IncomePerMin;
|
public int IncomePerMin;
|
||||||
public double IncomeChange;
|
|
||||||
int incomeCounter;
|
int incomeCounter;
|
||||||
|
|
||||||
|
public double IncomeChange;
|
||||||
|
|
||||||
|
public int TotalEarned;
|
||||||
|
public int TotalSpent;
|
||||||
|
|
||||||
public bool CanGiveOre(int amount)
|
public bool CanGiveOre(int amount)
|
||||||
{
|
{
|
||||||
return Ore + amount <= OreCapacity;
|
return Ore + amount <= OreCapacity;
|
||||||
@@ -98,20 +102,25 @@ namespace OpenRA.Traits
|
|||||||
public void GiveOre(int num)
|
public void GiveOre(int num)
|
||||||
{
|
{
|
||||||
Ore += num;
|
Ore += num;
|
||||||
|
incomeCounter += num;
|
||||||
|
TotalEarned += num;
|
||||||
|
|
||||||
if (Ore > OreCapacity)
|
if (Ore > OreCapacity)
|
||||||
{
|
{
|
||||||
nextSiloAdviceTime = 0;
|
nextSiloAdviceTime = 0;
|
||||||
|
|
||||||
|
incomeCounter -= Ore - OreCapacity;
|
||||||
|
TotalEarned -= Ore - OreCapacity;
|
||||||
|
|
||||||
Ore = OreCapacity;
|
Ore = OreCapacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
incomeCounter += num;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TakeOre(int num)
|
public bool TakeOre(int num)
|
||||||
{
|
{
|
||||||
if (Ore < num) return false;
|
if (Ore < num) return false;
|
||||||
Ore -= num;
|
Ore -= num;
|
||||||
|
TotalSpent += num;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -120,6 +129,7 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
Cash += num;
|
Cash += num;
|
||||||
incomeCounter += num;
|
incomeCounter += num;
|
||||||
|
TotalEarned += num;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool TakeCash(int num)
|
public bool TakeCash(int num)
|
||||||
@@ -128,6 +138,7 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
// Spend ore before cash
|
// Spend ore before cash
|
||||||
Ore -= num;
|
Ore -= num;
|
||||||
|
TotalSpent += num;
|
||||||
if (Ore < 0)
|
if (Ore < 0)
|
||||||
{
|
{
|
||||||
Cash += Ore;
|
Cash += Ore;
|
||||||
|
|||||||
@@ -175,6 +175,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
.Where(a => a.Owner == player && !a.IsDead() && a.Info.Traits.WithInterface<ValuedInfo>().Any())
|
.Where(a => a.Owner == player && !a.IsDead() && a.Info.Traits.WithInterface<ValuedInfo>().Any())
|
||||||
.Sum(a => a.Info.Traits.WithInterface<ValuedInfo>().First().Cost);
|
.Sum(a => a.Info.Traits.WithInterface<ValuedInfo>().First().Cost);
|
||||||
|
|
||||||
|
template.Get<LabelWidget>("TOTAL_EARNED").GetText = () => "$" + res.TotalEarned;
|
||||||
|
template.Get<LabelWidget>("TOTAL_SPENT").GetText = () => "$" + res.TotalSpent;
|
||||||
|
|
||||||
var numHarvesters = template.Get<LabelWidget>("NUMBER_HARVESTERS");
|
var numHarvesters = template.Get<LabelWidget>("NUMBER_HARVESTERS");
|
||||||
numHarvesters.GetText = () => world.Actors.Count(a => a.Owner == player && !a.IsDead() && a.HasTrait<Harvester>()).ToString();
|
numHarvesters.GetText = () => world.Actors.Count(a => a.Owner == player && !a.IsDead() && a.HasTrait<Harvester>()).ToString();
|
||||||
|
|
||||||
|
|||||||
@@ -510,8 +510,22 @@ Container@OBSERVER_ROOT:
|
|||||||
Height:25
|
Height:25
|
||||||
Font:Bold
|
Font:Bold
|
||||||
Text:Assets
|
Text:Assets
|
||||||
|
Label@TOTAL_EARNED_HEADER
|
||||||
|
X:505
|
||||||
|
Y:40
|
||||||
|
Width:60
|
||||||
|
Height:25
|
||||||
|
Font:Bold
|
||||||
|
Text:Earned
|
||||||
|
Label@TOTAL_SPENT_HEADER
|
||||||
|
X:565
|
||||||
|
Y:40
|
||||||
|
Width:60
|
||||||
|
Height:25
|
||||||
|
Font:Bold
|
||||||
|
Text:Spent
|
||||||
Label@NUMBER_HARVESTERS_HEADER
|
Label@NUMBER_HARVESTERS_HEADER
|
||||||
X:525
|
X:645
|
||||||
Y:40
|
Y:40
|
||||||
Width:60
|
Width:60
|
||||||
Height:25
|
Height:25
|
||||||
@@ -648,8 +662,18 @@ Container@OBSERVER_ROOT:
|
|||||||
Y:0
|
Y:0
|
||||||
Width:60
|
Width:60
|
||||||
Height:PARENT_BOTTOM
|
Height:PARENT_BOTTOM
|
||||||
|
Label@TOTAL_EARNED:
|
||||||
|
X:475
|
||||||
|
Y:0
|
||||||
|
Width:60
|
||||||
|
Height:PARENT_BOTTOM
|
||||||
|
Label@TOTAL_SPENT:
|
||||||
|
X:535
|
||||||
|
Y:0
|
||||||
|
Width:60
|
||||||
|
Height:PARENT_BOTTOM
|
||||||
Label@NUMBER_HARVESTERS:
|
Label@NUMBER_HARVESTERS:
|
||||||
X:495
|
X:615
|
||||||
Y:0
|
Y:0
|
||||||
Width:60
|
Width:60
|
||||||
Height:PARENT_BOTTOM
|
Height:PARENT_BOTTOM
|
||||||
|
|||||||
Reference in New Issue
Block a user