Extracted CashTickUp and CashTickDown to PlayerResources.

This commit is contained in:
Andre Mohren
2018-07-22 13:30:01 +02:00
committed by abcdefg30
parent bb7c19ad02
commit e353ff326e
6 changed files with 18 additions and 7 deletions

View File

@@ -47,6 +47,9 @@ namespace OpenRA.Mods.Common.Traits
[Desc("Delay (in ticks) during which warnings will be muted.")]
public readonly int InsufficientFundsNotificationDelay = 750;
public readonly string CashTickUpNotification = null;
public readonly string CashTickDownNotification = null;
IEnumerable<LobbyOption> ILobbyOptions.LobbyOptions(Ruleset rules)
{
var startingCash = SelectableCash.ToDictionary(c => c.ToString(), c => "$" + c.ToString());
@@ -61,12 +64,12 @@ namespace OpenRA.Mods.Common.Traits
public class PlayerResources : ITick, ISync
{
readonly PlayerResourcesInfo info;
public readonly PlayerResourcesInfo Info;
readonly Player owner;
public PlayerResources(Actor self, PlayerResourcesInfo info)
{
this.info = info;
Info = info;
owner = self.Owner;
var startingCash = self.World.LobbyInfo.GlobalSettings
@@ -164,11 +167,11 @@ namespace OpenRA.Mods.Common.Traits
{
if (Cash + Resources < num)
{
if (notifyLowFunds && !string.IsNullOrEmpty(info.InsufficientFundsNotification) &&
owner.World.WorldTick - lastNotificationTick >= info.InsufficientFundsNotificationDelay)
if (notifyLowFunds && !string.IsNullOrEmpty(Info.InsufficientFundsNotification) &&
owner.World.WorldTick - lastNotificationTick >= Info.InsufficientFundsNotificationDelay)
{
lastNotificationTick = owner.World.WorldTick;
Game.Sound.PlayNotification(owner.World.Map.Rules, owner, "Speech", info.InsufficientFundsNotification, owner.Faction.InternalName);
Game.Sound.PlayNotification(owner.World.Map.Rules, owner, "Speech", Info.InsufficientFundsNotification, owner.Faction.InternalName);
}
return false;