Mercurial > repos > IBDev-IBBoard.WarFoundry.API
view api/Objects/WarFoundryObject.cs @ 6:150a5669cd7b
Re #9 - more granular loading
* Remove SystemStatsSet class so that other classes don't know the internals of how GameSystem stores its stats (cleaner code principle)
* Make XML loader each stats set and add to the game system
* Add methods to GameSystem to remove use of SystemStatsSet and hide internal handling
* Add methods to add SystemStats to GameSystem
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sun, 04 Jan 2009 12:13:59 +0000 |
parents | 520818033bb6 |
children | 613bc5eaac59 |
line wrap: on
line source
using System; namespace IBBoard.WarFoundry.API.Objects { /// <summary> /// Summary description for WarFoundryObject. /// </summary> public abstract class WarFoundryObject : IWarFoundryObject { protected string name, id; public event StringValChangedDelegate NameChanged; protected WarFoundryObject(){} protected WarFoundryObject(string objName) : this() { Name = objName; } protected WarFoundryObject(string objId, string objName) : this(objName) { ID = objId; } public virtual string ID { get { if (id == null) { id = GenerateID(); } return id; } set { id = (value == null ? GenerateID() : value.Trim()); } } public virtual string Name { get { if (HasDefaultName()) { return DefaultName(); } else { return name; } } set { string oldValue = name; name = value; if (name!=oldValue) { OnNameChanged(oldValue, name); } } } protected bool HasDefaultName() { return (name == null || name == ""); } protected void OnNameChanged(string oldValue, string newValue) { if (NameChanged!=null) { NameChanged(this, oldValue, newValue); } } protected virtual string DefaultName() { return "-"; } protected string GenerateID() { return "ID" + UnixTimestamp.GetTimestamp(DateTime.Now) + "." + DateTime.Now.Millisecond; } } }