Move FrozenActor creation to Created in FrozenUnderFog

This commit is contained in:
atlimit8
2015-09-26 15:26:45 -05:00
parent f7c6938e27
commit 4744f436d3
2 changed files with 46 additions and 53 deletions

View File

@@ -11,7 +11,7 @@ namespace OpenRA.Primitives
readonly T[] valueByPlayerIndex;
readonly Dictionary<Player, T> valueByPlayer;
public PlayerDictionary(World world, Func<Player, T> valueFactory)
public PlayerDictionary(World world, Func<Player, int, T> valueFactory)
{
var players = world.Players;
if (players.Length == 0)
@@ -24,12 +24,16 @@ namespace OpenRA.Primitives
for (var i = 0; i < players.Length; i++)
{
var player = players[i];
var state = valueFactory(player);
var state = valueFactory(player, i);
valueByPlayerIndex[i] = state;
valueByPlayer[player] = state;
}
}
public PlayerDictionary(World world, Func<Player, T> valueFactory)
: this(world, (player, _) => valueFactory(player))
{ }
/// <summary>Gets the value for the specified player. This is slower than specifying a player index.</summary>
public T this[Player player] { get { return valueByPlayer[player]; } }