diff api/Factories/AbstractNativeWarFoundryFactory.cs @ 313:f00a57369aaa

Re #253: Allow multiple data files in a single zip * Add event-based mechanism to allow GameSystem to be registered before Race is loaded from a single zip
author IBBoard <dev@ibboard.co.uk>
date Sun, 27 Feb 2011 15:54:13 +0000
parents 3854c26073c4
children
line wrap: on
line diff
--- a/api/Factories/AbstractNativeWarFoundryFactory.cs	Sat Feb 26 20:15:12 2011 +0000
+++ b/api/Factories/AbstractNativeWarFoundryFactory.cs	Sun Feb 27 15:54:13 2011 +0000
@@ -82,15 +82,29 @@
 			{
 				if (CheckCanFindSystemFileContent(file))
 				{
-					AddAll(objects, CreateGameSystemsFromFile(file));
+					foreach (GameSystem system in CreateGameSystemsFromFile(file))
+					{
+						OnGameSystemLoaded(system);
+						objects.Add(system);
+					}
 				}
+				
 				if (CheckCanFindRaceFileContent(file))
 				{
-					AddAll(objects, CreateRacesFromFile(file));
+					foreach(Race race in CreateRacesFromFile(file))
+					{
+						OnRaceLoaded(race);
+						objects.Add(race);
+					}
 				}
+				
 				if (CheckCanFindArmyFileContent(file))
 				{
-					AddAll(objects, CreateArmiesFromFile(file));
+					foreach (Army army in CreateArmiesFromFile(file))
+					{
+						OnArmyLoaded(army);
+						objects.Add(army);
+					}
 				}
 			}
 			finally
@@ -101,14 +115,6 @@
 			return objects;
 		}
 		
-		private void AddAll <NEW_ITEM_TYPE>(ICollection<IWarFoundryObject> collection, ICollection<NEW_ITEM_TYPE> newItems) where NEW_ITEM_TYPE : IWarFoundryObject
-		{
-			foreach (IWarFoundryObject obj in newItems)
-			{
-				collection.Add(obj);
-			}
-		}
-		
 		protected ICollection<Army> CreateArmiesFromFile(ZipFile file)
 		{
 			ICollection<ZipEntry> dataStreams = GetArmyZipEntries(file);