Add UseResourceStorage trait to CashTrickler

This commit is contained in:
blackhand1001
2019-10-16 14:31:49 -04:00
committed by teinarss
parent 1599eac66c
commit 9a9bf441ba

View File

@@ -33,6 +33,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("How long to show the cash tick indicator when enabled.")]
public readonly int DisplayDuration = 30;
[Desc("Use resource storage for cash granted.")]
public readonly bool UseResourceStorage = false;
public override object Create(ActorInitializer init) { return new CashTrickler(this); }
}
@@ -87,7 +90,14 @@ namespace OpenRA.Mods.Common.Traits
void ModifyCash(Actor self, Player newOwner, int amount)
{
amount = resources.ChangeCash(amount);
if (info.UseResourceStorage)
{
var initialAmount = resources.Resources;
resources.GiveResources(amount);
amount = resources.Resources - initialAmount;
}
else
amount = resources.ChangeCash(amount);
if (info.ShowTicks && amount != 0)
AddCashTick(self, amount);