changeset 292:4dcb038e4f55

Re #320: WarFoundry.API - GameSystem cannot remove or set categories and stat lines * Update GameSystem * Categories * SetCategory added * RemoveCategory added * SystemStats * SetSystemStats added * RemoveSystemStats added
author Tsudico
date Thu, 16 Dec 2010 23:03:50 +0000
parents 24e7b571f50f
children a1657c6f41a0
files api/Objects/GameSystem.cs
diffstat 1 files changed, 46 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/api/Objects/GameSystem.cs	Tue Dec 14 20:17:07 2010 +0000
+++ b/api/Objects/GameSystem.cs	Thu Dec 16 23:03:50 2010 +0000
@@ -64,6 +64,29 @@
 			RawCategories.TryGetValue(id, out cat);
 			return cat;
 		}
+		
+		public void SetCategory(Category cat)
+		{
+			Category old;
+			RawCategories.TryGetValue(cat.ID, out old);
+			
+			if(old == null)
+			{
+				AddCategory(cat);
+			}
+			else
+			{
+				if(!old.Equals(cat))
+				{
+					RawCategories[old.ID] = cat;
+				}
+			}
+		}
+		
+		public void RemoveCategory(string id)
+		{
+			RawCategories.Remove(id);
+		}
 
 		public Category[] Categories
 		{
@@ -138,6 +161,29 @@
 			return statsForID;
 		}
 		
+		public void SetSystemStats(SystemStats newStats)
+		{
+			SystemStats old;
+			stats.TryGetValue(newStats.ID, out old);
+			
+			if(old == null)
+			{
+				AddSystemStats(newStats);
+			}
+			else
+			{
+				if(!old.Equals(newStats))
+				{
+					stats[old.ID] = newStats;
+				}
+			}
+		}
+		
+		public void RemoveSystemStats(string id)
+		{
+			stats.Remove(id);
+		}
+		
 		public Race SystemDefaultRace
 		{
 			get { return WarFoundryLoader.GetDefault().GetRace(this, Race.SYSTEM_DEFAULT_RACE_ID); }