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;

View File

@@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
displayResources += move;
if (Game.Settings.Sound.CashTicks)
Game.Sound.PlayNotification(world.Map.Rules, player, "Sounds", "CashTickUp", player.Faction.InternalName);
Game.Sound.PlayNotification(world.Map.Rules, player, "Sounds", playerResources.Info.CashTickUpNotification, player.Faction.InternalName);
}
else if (displayResources > actual)
{
@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
if (Game.Settings.Sound.CashTicks && nextCashTickTime == 0)
{
Game.Sound.PlayNotification(world.Map.Rules, player, "Sounds", "CashTickDown", player.Faction.InternalName);
Game.Sound.PlayNotification(world.Map.Rules, player, "Sounds", playerResources.Info.CashTickDownNotification, player.Faction.InternalName);
nextCashTickTime = 2;
}
}

View File

@@ -16,6 +16,8 @@ Player:
PowerManager:
AllyRepair:
PlayerResources:
CashTickUpNotification: CashTickUp
CashTickDownNotification: CashTickDown
DeveloperMode:
CheckboxDisplayOrder: 8
BaseAttackNotifier:

View File

@@ -68,6 +68,8 @@ Player:
PlayerResources:
SelectableCash: 2500, 5000, 7000, 10000, 20000
InsufficientFundsNotification: InsufficientFunds
CashTickUpNotification: CashTickUp
CashTickDownNotification: CashTickDown
DeveloperMode:
CheckboxDisplayOrder: 7
BaseAttackNotifier:

View File

@@ -55,6 +55,8 @@ Player:
AllyRepair:
PlayerResources:
InsufficientFundsNotification: InsufficientFunds
CashTickUpNotification: CashTickUp
CashTickDownNotification: CashTickDown
DeveloperMode:
CheckboxDisplayOrder: 9
GpsWatcher:

View File

@@ -59,6 +59,8 @@ Player:
AllyRepair:
PlayerResources:
InsufficientFundsNotification: InsufficientFunds
CashTickUpNotification: CashTickUp
CashTickDownNotification: CashTickDown
DeveloperMode:
CheckboxEnabled: true
CheckboxDisplayOrder: 8