コード例 #1
0
        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,
            });
        }
コード例 #2
0
 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;
     }
 }
コード例 #3
0
        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,
            });
        }
コード例 #4
0
        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,
            });
        }
コード例 #5
0
        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,
            });
        }
コード例 #6
0
        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,
            });
        }
コード例 #8
0
        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,
            });
        }
コード例 #9
0
        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);
            }
        }
コード例 #10
0
ファイル: DataReaderNode.cs プロジェクト: FBast/ReflexityAI
        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);
        }
コード例 #11
0
 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);
 }
コード例 #12
0
 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);
 }
コード例 #13
0
 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);
 }
コード例 #14
0
 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());
 }
コード例 #15
0
        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,
            });
        }
コード例 #16
0
        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());
        }
コード例 #17
0
        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),
            });
        }