private static CustomizationDefinition CreateCustomization( InfoDictionary <DownloadableContentDefinition> downloadableContents, KeyValuePair <string, Raw.CustomizationDefinition> kv) { var raw = kv.Value; DownloadableContentDefinition content = null; if (string.IsNullOrEmpty(raw.DLC) == false) { if (downloadableContents.TryGetValue(raw.DLC, out content) == false) { throw ResourceNotFoundException.Create("downloadable content", kv.Value.DLC); } } return(new CustomizationDefinition() { ResourcePath = kv.Key, Name = raw.Name, Type = raw.Type, Usage = raw.Usage, DataName = raw.DataName, PrimarySort = raw.PrimarySort, SecondarySort = raw.SecondarySort, DLC = content, }); }
private void AddToInfoDictionary(string key, InfoHelper helper) { if (helper == null) { return; } lock (AccessLock) { InfoHelper testValue; int suffix = 1; bool trying = true; string alternativeKey = key; while (trying) { trying = InfoDictionary.TryGetValue(alternativeKey, out testValue); if (trying) { alternativeKey = key + (suffix++).ToString(); } } Dictionary <string, InfoHelper> _tempInfo = new Dictionary <string, InfoHelper>(); foreach (var item in InfoDictionary) { _tempInfo.Add(item.Key, item.Value); } _tempInfo.Add(alternativeKey, helper); InfoDictionary = _tempInfo; } }
private static PlayerClassDefinition CreatePlayerClass( InfoDictionary <DownloadableContentDefinition> downloadableContents, KeyValuePair <string, Raw.PlayerClassDefinition> kv) { var raw = kv.Value; DownloadableContentDefinition downloadableContent = null; if (string.IsNullOrEmpty(raw.DLC) == false) { if (downloadableContents.TryGetValue(kv.Value.DLC, out downloadableContent) == false) { throw ResourceNotFoundException.Create("downloadable content", raw.DLC); } } return(new PlayerClassDefinition() { ResourcePath = kv.Key, Name = raw.Name, Class = raw.Class, SortOrder = raw.SortOrder, DLC = downloadableContent, }); }
private static WeaponBalancePartCollection CreateWeaponBalancePartCollection( InfoDictionary <WeaponTypeDefinition> weaponTypes, KeyValuePair <string, Raw.WeaponBalancePartCollection> kv) { var raw = kv.Value; WeaponTypeDefinition type = null; if (string.IsNullOrEmpty(raw.WeaponType) == false) { if (weaponTypes.TryGetValue(raw.WeaponType, out type) == false) { throw ResourceNotFoundException.Create("weapon type", raw.WeaponType); } } return(new WeaponBalancePartCollection() { WeaponType = type, Mode = raw.Mode, BodyParts = raw.BodyParts, GripParts = raw.GripParts, BarrelParts = raw.BarrelParts, SightParts = raw.SightParts, StockParts = raw.StockParts, ElementalParts = raw.ElementalParts, Accessory1Parts = raw.Accessory1Parts, Accessory2Parts = raw.Accessory2Parts, MaterialParts = raw.MaterialParts, }); }
private static TravelStationDefinition CreateFastTravelStation( InfoDictionary <DownloadableContentDefinition> downloadableContents, string path, Raw.FastTravelStationDefinition raw) { DownloadableContentDefinition dlcExpansion = null; if (string.IsNullOrEmpty(raw.DLCExpansion) == false) { if (downloadableContents.TryGetValue(raw.DLCExpansion, out dlcExpansion) == false) { throw ResourceNotFoundException.Create("downloadable content", raw.DLCExpansion); } } return(new FastTravelStationDefinition() { ResourcePath = path, ResourceName = raw.ResourceName, LevelName = raw.LevelName, DLCExpansion = dlcExpansion, StationDisplayName = raw.StationDisplayName, MissionDependencies = CreateMissionStatusData(raw.MissionDependencies), InitiallyActive = raw.InitiallyActive, SendOnly = raw.SendOnly, Description = raw.Description, Sign = raw.Sign, InaccessibleObjective = raw.InaccessibleObjective, AccessibleObjective = raw.AccessibleObjective, }); }
public static InfoDictionary <WeaponBalanceDefinition> Load(InfoDictionary <WeaponTypeDefinition> weaponTypes) { try { var rawPartLists = LoaderHelper.DeserializeDump <Dictionary <string, Raw.WeaponBalancePartCollection> >( "Weapon Balance Part Lists"); var partLists = new InfoDictionary <WeaponBalancePartCollection>( rawPartLists.ToDictionary( kv => kv.Key, kv => CreateWeaponBalancePartCollection(weaponTypes, kv))); var raws = LoaderHelper.DeserializeDump <Dictionary <string, Raw.WeaponBalanceDefinition> >( "Weapon Balance"); var balances = new InfoDictionary <WeaponBalanceDefinition>( raws.ToDictionary( kv => kv.Key, kv => CreateWeaponBalance(weaponTypes, kv, partLists))); foreach (var kv in raws.Where(kv => string.IsNullOrEmpty(kv.Value.Base) == false)) { if (balances.TryGetValue(kv.Value.Base, out var baseBalance) == false) { throw ResourceNotFoundException.Create("weapon balance", kv.Value.Base); } balances[kv.Key].Base = baseBalance; } return(balances); } catch (Exception e) { throw new InfoLoadException("failed to load weapon balance", e); } }
private static DownloadableContentDefinition CreateDownloadableContent( InfoDictionary <DownloadablePackageDefinition> packages, KeyValuePair <string, Raw.DownloadableContentDefinition> kv) { var raw = kv.Value; DownloadablePackageDefinition package = null; if (string.IsNullOrEmpty(raw.Package) == false) { if (packages.TryGetValue(raw.Package, out package) == false) { throw ResourceNotFoundException.Create("downloadable package", kv.Value.Package); } } return(new DownloadableContentDefinition() { ResourcePath = kv.Key, Id = raw.Id, Name = raw.Name, Package = package, Type = raw.Type, }); }
private static ItemBalancePartCollection CreateItemBalancePartCollection( InfoDictionary <ItemDefinition> items, KeyValuePair <string, Raw.ItemBalancePartCollection> kv) { var raw = kv.Value; ItemDefinition type = null; if (string.IsNullOrEmpty(raw.Item) == false) { if (items.TryGetValue(raw.Item, out type) == false) { throw ResourceNotFoundException.Create("item type", raw.Item); } } return(new ItemBalancePartCollection() { Item = type, Mode = raw.Mode, AlphaParts = raw.AlphaParts, BetaParts = raw.BetaParts, GammaParts = raw.GammaParts, DeltaParts = raw.DeltaParts, EpsilonParts = raw.EpsilonParts, ZetaParts = raw.ZetaParts, EtaParts = raw.EtaParts, ThetaParts = raw.ThetaParts, MaterialParts = raw.MaterialParts, }); }
public static InfoDictionary <TravelStationDefinition> Load( InfoDictionary <DownloadableContentDefinition> downloadableContents) { try { var raws = LoaderHelper.DeserializeDump <Dictionary <string, Raw.TravelStationDefinition> >( "Travel Stations"); var stations = new InfoDictionary <TravelStationDefinition>( raws.ToDictionary( kv => kv.Key, kv => CreateTravelStation(downloadableContents, kv))); foreach (var kv in raws) { var stationPath = kv.Value.PreviousStation; if (string.IsNullOrEmpty(stationPath) == true) { continue; } if (stations.TryGetValue(stationPath, out var station) == false) { throw ResourceNotFoundException.Create("travel station", stationPath); } stations[kv.Key].PreviousStation = station; } foreach (var kv in raws.Where(kv => kv.Value is Raw.LevelTravelStationDefinition)) { var raw = (Raw.LevelTravelStationDefinition)kv.Value; if (string.IsNullOrEmpty(raw.DestinationStation) == true) { continue; } if (stations.TryGetValue(raw.DestinationStation, out var destination) == false) { throw ResourceNotFoundException.Create("level travel station", raw.DestinationStation); } var station = (LevelTravelStationDefinition)stations[kv.Key]; station.DestinationStation = (LevelTravelStationDefinition)destination; } return(stations); } catch (Exception e) { throw new InfoLoadException("failed to load travel stations", e); } }
public override object GetValue(NodePort port) { SerializableInfo serializableFieldInfo; InfoDictionary.TryGetValue(port.fieldName, out serializableFieldInfo); if (serializableFieldInfo != null) { return(Application.isPlaying ? serializableFieldInfo.GetRuntimeValue(Context) : serializableFieldInfo.GetEditorValue()); } throw new Exception("No reflected data found for " + port.fieldName); }
private static WeaponTypeDefinition GetWeaponType(InfoDictionary <WeaponTypeDefinition> types, string path) { if (string.IsNullOrEmpty(path) == true) { return(null); } if (types.TryGetValue(path, out var type) == true) { return(type); } throw ResourceNotFoundException.Create("weapon type", path); }
private static ItemDefinition GetItem(InfoDictionary <ItemDefinition> items, string itemPath) { if (string.IsNullOrEmpty(itemPath) == true) { return(null); } if (items.TryGetValue(itemPath, out var item) == true) { return(item); } throw ResourceNotFoundException.Create("item", itemPath); }
private static WeaponBalancePartCollection GetWeaponBalancePartCollection( InfoDictionary <WeaponBalancePartCollection> partLists, string partListPath) { if (string.IsNullOrEmpty(partListPath) == true) { return(null); } if (partLists.TryGetValue(partListPath, out var partList) == true) { return(partList); } throw ResourceNotFoundException.Create("weapon balance part list", partListPath); }
private static List <ItemDefinition> GetItems( InfoDictionary <ItemDefinition> items, IEnumerable <string> itemPaths) { if (itemPaths == null) { return(null); } return(itemPaths.Select(t => { if (items.TryGetValue(t, out var item) == false) { throw ResourceNotFoundException.Create("item type", t); } return item; }).ToList()); }
private static FastTravelStationOrdering CreateFastTravelStationOrdering( InfoDictionary <TravelStationDefinition> stations, InfoDictionary <DownloadableContentDefinition> downloadableContents, KeyValuePair <string, Raw.FastTravelStationOrdering> kv) { var raw = kv.Value; DownloadableContentDefinition dlcExpansion = null; if (string.IsNullOrEmpty(raw.DLCExpansion) == false) { if (downloadableContents.TryGetValue(raw.DLCExpansion, out dlcExpansion) == false) { throw ResourceNotFoundException.Create("downloadable content", kv.Value.DLCExpansion); } } return(new FastTravelStationOrdering() { ResourcePath = kv.Key, Stations = CreateStations(stations, raw.Stations), DLCExpansion = dlcExpansion, }); }
private static List <FastTravelStationDefinition> CreateStations( InfoDictionary <TravelStationDefinition> stations, IEnumerable <string> paths) { if (paths == null) { return(null); } return(paths.Select(path => { if (stations.TryGetValue(path, out var station) == false) { throw ResourceNotFoundException.Create("fast travel station", path); } if (station is FastTravelStationDefinition fastTravelStation) { return fastTravelStation; } throw new InvalidOperationException($"'{path}' is not a {nameof(FastTravelStationDefinition)}"); }).ToList()); }
private static TravelStationDefinition CreateLevelTravelStation( InfoDictionary <DownloadableContentDefinition> downloadableContents, string path, Raw.LevelTravelStationDefinition raw) { DownloadableContentDefinition dlcExpansion = null; if (string.IsNullOrEmpty(raw.DLCExpansion) == false) { if (downloadableContents.TryGetValue(raw.DLCExpansion, out dlcExpansion) == false) { throw ResourceNotFoundException.Create("downloadable content", raw.DLCExpansion); } } return(new LevelTravelStationDefinition() { ResourcePath = path, ResourceName = raw.ResourceName, LevelName = raw.LevelName, DLCExpansion = dlcExpansion, StationDisplayName = raw.StationDisplayName, MissionDependencies = CreateMissionStatusData(raw.MissionDependencies), }); }