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 diff
     1.1 --- a/api/Objects/GameSystem.cs	Tue Dec 14 20:17:07 2010 +0000
     1.2 +++ b/api/Objects/GameSystem.cs	Thu Dec 16 23:03:50 2010 +0000
     1.3 @@ -64,6 +64,29 @@
     1.4  			RawCategories.TryGetValue(id, out cat);
     1.5  			return cat;
     1.6  		}
     1.7 +		
     1.8 +		public void SetCategory(Category cat)
     1.9 +		{
    1.10 +			Category old;
    1.11 +			RawCategories.TryGetValue(cat.ID, out old);
    1.12 +			
    1.13 +			if(old == null)
    1.14 +			{
    1.15 +				AddCategory(cat);
    1.16 +			}
    1.17 +			else
    1.18 +			{
    1.19 +				if(!old.Equals(cat))
    1.20 +				{
    1.21 +					RawCategories[old.ID] = cat;
    1.22 +				}
    1.23 +			}
    1.24 +		}
    1.25 +		
    1.26 +		public void RemoveCategory(string id)
    1.27 +		{
    1.28 +			RawCategories.Remove(id);
    1.29 +		}
    1.30  
    1.31  		public Category[] Categories
    1.32  		{
    1.33 @@ -138,6 +161,29 @@
    1.34  			return statsForID;
    1.35  		}
    1.36  		
    1.37 +		public void SetSystemStats(SystemStats newStats)
    1.38 +		{
    1.39 +			SystemStats old;
    1.40 +			stats.TryGetValue(newStats.ID, out old);
    1.41 +			
    1.42 +			if(old == null)
    1.43 +			{
    1.44 +				AddSystemStats(newStats);
    1.45 +			}
    1.46 +			else
    1.47 +			{
    1.48 +				if(!old.Equals(newStats))
    1.49 +				{
    1.50 +					stats[old.ID] = newStats;
    1.51 +				}
    1.52 +			}
    1.53 +		}
    1.54 +		
    1.55 +		public void RemoveSystemStats(string id)
    1.56 +		{
    1.57 +			stats.Remove(id);
    1.58 +		}
    1.59 +		
    1.60  		public Race SystemDefaultRace
    1.61  		{
    1.62  			get { return WarFoundryLoader.GetDefault().GetRace(this, Race.SYSTEM_DEFAULT_RACE_ID); }