public static RawItems LoadFrom(string directory) { var items = new RawItems(); foreach (var file in Directory.EnumerateFiles(directory, "Raw_*.json")) { items.Load(file); } items.Initialize(); return(items); }
static Mappings() { UntypedFactories = new Dictionary <Type, Func <ModelDataAccessor, object> >(); Factories = new Dictionary <Type, object>(); RegisterFactory(m => new PartyModel(m)); RegisterFactory(m => new UnitEntityModel(m)); RegisterFactory(m => new CharacterModel(m)); RegisterFactory(m => new VectorModel(m)); RegisterFactory(m => new CharacterAttributeModel(m)); RegisterFactory(m => new ClassSkillModel(m)); RegisterFactory(m => new PlayerModel(m)); RegisterFactory(m => new PersistentModifierModel(m)); RegisterFactory(m => new InventoryModel(m)); RegisterFactory(ItemModel.Create); RegisterFactory(m => new HoldingSlotModel(m)); RegisterFactory(m => new HandsEquipmentSetModel(m)); RegisterFactory(m => new PlayerKingdomLeaderModel(m)); RegisterFactory(m => new PlayerKingdomTaskModel(m)); RegisterFactory(m => new PlayerKingdomChangeModel(m)); RegisterFactory(m => new PlayerKingdomEventHistoryModel(m)); RegisterFactory(m => new PlayerKingdomEventModel(m)); RegisterFactory(m => new PlayerKingdomRegionModel(m)); RegisterFactory(m => new PlayerKingdomLeaderSpecificBonusModel(m)); var dataMappings = DataMappings.LoadFromDefault(); Classes = dataMappings.Classes .Concat(dataMappings.Classes.Where(c => c.Archetypes != null).SelectMany(c => c.Archetypes)) .Where(a => !string.IsNullOrEmpty(a.Id)) .ToDictionary(x => x.Id, StringComparer.Ordinal); Races = dataMappings.Races .ToDictionary(x => x.Id, StringComparer.Ordinal); Characters = dataMappings.Characters .ToDictionary(x => x.Id, StringComparer.Ordinal); Leaders = dataMappings.Leaders .ToDictionary(x => x.Id, StringComparer.Ordinal); BlueprintTypes = dataMappings.Characters.ToDictionary(x => new BlueprintIdentifier(x.Id), x => typeof(CharacterModel)); TypeToBlueprint = BlueprintTypes .GroupBy(kv => kv.Value) .ToDictionary(g => g.Key, g => g.Select(kv => kv.Key).ToList()); RawItems = RawItems.LoadFromDefault(); DescriptiveItems = DescriptiveItems.LoadFromDefault(); }