/// <summary> /// Starts filling the previous data of the villages, players and tribes /// </summary> /// <param name="wrapper">Wrapper object with path and current data</param> private void BeginDictionaryAsync(DictionaryLoaderWrapper wrapper) { // Load the data WorldVillagesCollection villages; Dictionary <string, Player> players; Dictionary <string, Tribe> tribes; LoadTwSnapshot(wrapper.Path, out villages, out players, out tribes); foreach (Village village in villages.Values) { if (wrapper.Villages.ContainsKey(village.Location)) { wrapper.Villages[village.Location].SetPreviousDetails(village); } } foreach (KeyValuePair <string, Player> pair in players) { if (wrapper.Players.ContainsKey(pair.Key)) { wrapper.Players[pair.Key].SetPreviousDetails(pair.Value); } } foreach (KeyValuePair <string, Tribe> pair in tribes) { if (wrapper.Tribes.ContainsKey(pair.Key)) { wrapper.Tribes[pair.Key].SetPreviousDetails(pair.Value); } } }
/// <summary> /// Load previous data async /// </summary> public void LoadPreviousTwSnapshot(string previousPath, WorldVillagesCollection villages, Dictionary <string, Player> players, Dictionary <string, Tribe> tribes) { bool load = true; if (previousPath != null) { string currentPath = PreviousWorldDataDateDirectory; _previousData = previousPath; if (currentPath == PreviousWorldDataDateDirectory) { load = false; } } if (load && PreviousWorldDataDateDirectory != null) { var wrapper = new DictionaryLoaderWrapper(); wrapper.Villages = villages; wrapper.Tribes = tribes; wrapper.Players = players; wrapper.Path = PreviousWorldDataDateDirectory; DictionaryLoader invoker = BeginDictionaryAsync; invoker.BeginInvoke(wrapper, EndDictionaryAsync, null); } }
/// <summary> /// Starts filling the previous data of the villages, players and tribes /// </summary> /// <param name="wrapper">Wrapper object with path and current data</param> private void BeginDictionaryAsync(DictionaryLoaderWrapper wrapper) { // Load the data WorldVillagesCollection villages; Dictionary<string, Player> players; Dictionary<string, Tribe> tribes; LoadTwSnapshot(wrapper.Path, out villages, out players, out tribes); foreach (Village village in villages.Values) { if (wrapper.Villages.ContainsKey(village.Location)) { wrapper.Villages[village.Location].SetPreviousDetails(village); } } foreach (KeyValuePair<string, Player> pair in players) { if (wrapper.Players.ContainsKey(pair.Key)) { wrapper.Players[pair.Key].SetPreviousDetails(pair.Value); } } foreach (KeyValuePair<string, Tribe> pair in tribes) { if (wrapper.Tribes.ContainsKey(pair.Key)) { wrapper.Tribes[pair.Key].SetPreviousDetails(pair.Value); } } }
/// <summary> /// Load previous data async /// </summary> public void LoadPreviousTwSnapshot(string previousPath, WorldVillagesCollection villages, Dictionary<string, Player> players, Dictionary<string, Tribe> tribes) { bool load = true; if (previousPath != null) { string currentPath = PreviousWorldDataDateDirectory; _previousData = previousPath; if (currentPath == PreviousWorldDataDateDirectory) load = false; } if (load && PreviousWorldDataDateDirectory != null) { var wrapper = new DictionaryLoaderWrapper(); wrapper.Villages = villages; wrapper.Tribes = tribes; wrapper.Players = players; wrapper.Path = PreviousWorldDataDateDirectory; DictionaryLoader invoker = BeginDictionaryAsync; invoker.BeginInvoke(wrapper, EndDictionaryAsync, null); } }