Extracted CashTickUp and CashTickDown to PlayerResources.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user