Mercurial > repos > snowblizz-super-API-ideas
diff api/Objects/StagedLoadingRace.cs @ 0:520818033bb6
Initial commit of WarFoundry code
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 19 Dec 2008 15:57:51 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/api/Objects/StagedLoadingRace.cs Fri Dec 19 15:57:51 2008 +0000 @@ -0,0 +1,150 @@ +// StagedLoadingRace.cs +// +// Copyright (C) 2008 IBBoard +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// + +using System; +using System.Collections.Generic; +using IBBoard.WarFoundry.API.Factories; + +namespace IBBoard.WarFoundry.API.Objects +{ + /// <summary> + /// Summary description for StagedLoadingRace. + /// </summary> + public class StagedLoadingRace : Race, IWarFoundryStagedLoadObject + { + private AbstractNativeWarFoundryFactory creatingFactory; + + public StagedLoadingRace(string raceID, string raceName, string gameSystemID, AbstractNativeWarFoundryFactory factory) : this(raceID, "", raceName, gameSystemID, factory) + { + } + + public StagedLoadingRace(string raceID, string raceSubID, string raceName, string gameSystemID, AbstractNativeWarFoundryFactory factory) : base(raceID, raceName, gameSystemID) + { + creatingFactory = factory; + } + + public AbstractNativeWarFoundryFactory Factory + { + get { return creatingFactory; } + } + + public void EnsureFullyLoaded () + { + if (!IsFullyLoaded) + { + Factory.CompleteLoading(this); + } + } + + public bool IsFullyLoaded + { + get { return RaceRawOverrideCategories != null && RaceRawUnitTypes != null && RaceRawEquipment != null && RaceRawAbilities != null; } + } + + protected override Category[] RaceOverrideCategories + { + get + { + EnsureFullyLoaded(); + return base.RaceOverrideCategories; + } + } + + protected override Dictionary<string, Ability> RaceAbilities + { + get + { + EnsureFullyLoaded(); + return base.RaceAbilities; + } + set + { + base.RaceAbilities = value; + } + } + + protected override Dictionary<string, EquipmentItem> RaceEquipment + { + get + { + EnsureFullyLoaded(); + return base.RaceEquipment; + } + set + { + base.RaceEquipment = value; + } + } + + protected override Dictionary<string, UnitType> RaceUnitTypes + { + get + { + EnsureFullyLoaded(); + return base.RaceUnitTypes; + } + set + { + base.RaceUnitTypes = value; + } + } + + + + + + + /*public void CompleteLoading(List<Category> categoriesList, Dictionary<string,UnitType> unitTypesList, Dictionary<string,EquipmentItem> equipmentList, Dictionary<string, Ability> abilityList) + { + logger.Debug("Preparing dictionaries"); + + if (categoriesList != null && categoriesList.Count > 0) + { + cats = categoriesList.ToArray(); + } + + logger.Debug("Loading equipment"); + equipment = new Dictionary<string,EquipmentItem>(); + + foreach (string equipID in equipmentList.Keys) + { + equipment.Add(equipID, equipmentList[equipID]); + } + + logger.Debug("Loading abilities"); + abilities = new Dictionary<string,Ability>(); + + foreach (string abilityID in abilityList.Keys) + { + abilities.Add(abilityID, abilityList[abilityID]); + } + + logger.Debug("Loading units"); + unitTypes = new Dictionary<string,UnitType>(); + + foreach (string unitID in unitTypesList.Keys) + { + unitTypes.Add(unitID, unitTypesList[unitID]); + } + + base.CompleteLoading(); + }*/ + } +} \ No newline at end of file