All pastes #49462 Raw Edit

tobz

public text v1 · immutable
#49462 ·published 2006-04-16 03:03 UTC
rendered paste body
using System;
using System.Collections.Generic;
using System.Text;
using Cell.Core;
using System.Collections;

namespace DOLC.ConfigReaders
{
	[Serializable]
	public class RaceInfo
	{
		private string m_raceName;
		private int m_raceID;
		private RaceStat m_stats;

		public string RaceName
		{
			get
			{
				return m_raceName;
			}
			set
			{
				m_raceName = value;
			}
		}

		public int RaceID
		{
			get
			{
				return m_raceID;
			}
			set
			{
				m_raceID = value;
			}
		}

		public RaceStat Stats
		{
			get
			{
				return m_stats;
			}
			set
			{
				m_stats = value;
			}
		}
	}

	[Serializable]
	public class RaceStat
	{
		private int m_str = 0;
		private int m_con = 0;
		private int m_dex = 0;
		private int m_qui = 0;
		private int m_int = 0;
		private int m_pie = 0;
		private int m_emp = 0;
		private int m_cha = 0;

		public int Strength
		{
			get
			{
				return m_str;
			}
			set
			{
				m_str = value;
			}
		}

		public int Constitution
		{
			get
			{
				return m_con;
			}
			set
			{
				m_con = value;
			}
		}

		public int Dexterity
		{
			get
			{
				return m_dex;
			}
			set
			{
				m_dex = value;
			}
		}

		public int Quickness
		{
			get
			{
				return m_qui;
			}
			set
			{
				m_qui = value;
			}
		}

		public int Intelligence
		{
			get
			{
				return m_int;
			}
			set
			{
				m_int = value;
			}
		}

		public int Piety
		{
			get
			{
				return m_pie;
			}
			set
			{
				m_pie = value;
			}
		}

		public int Empathy
		{
			get
			{
				return m_emp;
			}
			set
			{
				m_emp = value;
			}
		}

		public int Charisma
		{
			get
			{
				return m_cha;
			}
			set
			{
				m_cha = value;
			}
		}
	}

	public class RaceConfig : XmlConfig, IEnumerable
	{
		private Dictionary<int, RaceInfo> m_races = new Dictionary<int,RaceInfo>();

		public Dictionary<int,RaceInfo> Races
		{
			get
			{
				return m_raceName;
			}
			set
			{
				m_raceName = value;
			}
		}

		[NonSerialized]
		public RaceInfo this[int raceID]
		{
			get
			{
				return (m_races.ContainsKey(raceID) ? m_races[raceID] : null);
			}
		}

		[NonSerialized]
		public Dictionary<int,RaceInfo>.Enumerator GetEnumerator()
		{
			return m_races.GetEnumerator();
		}

		/// <summary>
		/// Copies one <see cref="XmlConfig"/> derived class into another.
		/// </summary>
		/// <param name="cfg">The <see cref="XmlConfig"/> derived class to copy from.</param>
		public override void Assign(XmlConfig cfg)
		{
			base.Assign(cfg);

			RaceConfig rcfg;
			if ((rcfg = cfg as RaceConfig) != null)
			{
				this.Races = rcfg.Races;
			}
		}
	}
}