using System; using System.Collections.Generic; using System.IO; using MaidStatus.CsvData; using wf; namespace MaidStatus { public abstract class IClassSystem where T : AbstractClassData { public abstract ReadOnlySortedDictionary> datas { get; protected set; } public abstract ReadOnlySortedDictionary> oldDatas { get; protected set; } public abstract Status status { get; protected set; } public abstract ClassData Add(T data, bool setOpenFlag, bool updateBonusStatus = true); public abstract void Remove(T data, bool updateBonusStatus = true); public abstract T IdToClass(int id); public abstract void Serialize(BinaryWriter binary); public abstract void Deserialize(BinaryReader binary, int version); protected abstract List GetAllBaseClassData(); public virtual SortedDictionary> GetAllDatas() { SortedDictionary> sortedDictionary = new SortedDictionary>(); foreach (ClassData classData in this.datas.GetValueArray()) { if (!sortedDictionary.ContainsKey(classData.data.id)) { sortedDictionary.Add(classData.data.id, classData); } } if (this.oldDatas != null) { foreach (ClassData classData2 in this.oldDatas.GetValueArray()) { if (!sortedDictionary.ContainsKey(classData2.data.id)) { sortedDictionary.Add(classData2.data.id, classData2); } } } return sortedDictionary; } public virtual ClassData Add(int id, bool setOpenFlag, bool updateBonusStatus = true) { return this.Add(this.IdToClass(id), setOpenFlag, updateBonusStatus); } public virtual void Remove(int id, bool updateBonusStatus = true) { this.Remove(this.IdToClass(id), updateBonusStatus); } public virtual bool Contains(int id) { return this.Contains(this.IdToClass(id)); } public virtual bool Contains(T data) { return data != null && (this.datas.ContainsKey(data.id) || (this.oldDatas != null && this.oldDatas.ContainsKey(data.id))); } public virtual ClassData Get(T data) { return this.Contains(data) ? ((!this.datas.ContainsKey(data.id)) ? this.oldDatas[data.id] : this.datas[data.id]) : null; } public virtual ClassData Get(int id) { return this.Get(this.IdToClass(id)); } public virtual List GetLearnPossibleClassDatas(bool unlearnedOnly, AbstractClassData.ClassType classTypeFlags) { List list = new List(); CharacterMgr characterMgr = GameMain.Instance.CharacterMgr; List allBaseClassData = this.GetAllBaseClassData(); foreach (T t in allBaseClassData) { if (!unlearnedOnly || !this.Contains(t.id)) { if ((classTypeFlags & t.classType) != (AbstractClassData.ClassType)0 && t.learnConditions.isLearnPossibleStatus(this.status)) { list.Add(t); } } } return list; } protected SortedDictionary> classDatas_; protected SortedDictionary> oldClassDatas_; } }