コード例 #1
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);
            }
        }
コード例 #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 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,
            });
        }
コード例 #4
0
        private static ItemBalancePartCollection GetItemBalancePartCollection(
            InfoDictionary <ItemTypeDefinition> itemTypes, Raw.ItemBalancePartCollection raw)
        {
            if (raw == null)
            {
                return(null);
            }

            ItemTypeDefinition type = null;

            if (string.IsNullOrEmpty(raw.Type) == false)
            {
                if (itemTypes.ContainsKey(raw.Type) == false)
                {
                    throw ResourceNotFoundException.Create("item type", raw.Type);
                }

                type = itemTypes[raw.Type];
            }

            return(new ItemBalancePartCollection()
            {
                Type = 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
                    .DeserializeJson<Dictionary<string, Raw.TravelStationDefinition>>("Travel Stations");
                var defs = new InfoDictionary<TravelStationDefinition>(
                    raws.ToDictionary(kv => kv.Key,
                                      kv => GetTravelStationDefinition(downloadableContents, kv)));
                foreach (var kv in raws.Where(kv => string.IsNullOrEmpty(kv.Value.PreviousStation) == false))
                {
                    if (defs.ContainsKey(kv.Value.PreviousStation) == false)
                    {
                        throw new KeyNotFoundException("could not find travel station '" + kv.Value.PreviousStation +
                                                       "'");
                    }

                    defs[kv.Key].PreviousStation = defs[kv.Value.PreviousStation];
                }
                return defs;
            }
            catch (Exception e)
            {
                throw new InfoLoadException("failed to load travel stations", e);
            }
        }
        private static TravelStationDefinition GetTravelStationDefinition(
            InfoDictionary<DownloadableContentDefinition> downloadableContents,
            KeyValuePair<string, Raw.TravelStationDefinition> kv)
        {
            DownloadableContentDefinition dlcExpansion = null;
            if (string.IsNullOrEmpty(kv.Value.DLCExpansion) == false)
            {
                if (downloadableContents.ContainsKey(kv.Value.DLCExpansion) == false)
                {
                    throw new KeyNotFoundException("could not find downloadable content '" + kv.Value.DLCExpansion + "'");
                }
                dlcExpansion = downloadableContents[kv.Value.DLCExpansion];
            }

            if (kv.Value is Raw.FastTravelStationDefinition)
            {
                return GetFastTravelStationDefinition(dlcExpansion, kv);
            }

            if (kv.Value is Raw.LevelTravelStationDefinition)
            {
                return GetLevelTravelStationDefinition(dlcExpansion, kv);
            }

            throw new InvalidOperationException();
        }
        public static InfoDictionary <TravelStationDefinition> Load(
            InfoDictionary <DownloadableContentDefinition> downloadableContents)
        {
            try
            {
                var raws = LoaderHelper
                           .DeserializeJson <Dictionary <string, Raw.TravelStationDefinition> >("Travel Stations");
                var defs = new InfoDictionary <TravelStationDefinition>(
                    raws.ToDictionary(kv => kv.Key,
                                      kv => GetTravelStationDefinition(downloadableContents, kv)));
                foreach (var kv in raws.Where(kv => string.IsNullOrEmpty(kv.Value.PreviousStation) == false))
                {
                    if (defs.ContainsKey(kv.Value.PreviousStation) == false)
                    {
                        throw new KeyNotFoundException("could not find travel station '" + kv.Value.PreviousStation +
                                                       "'");
                    }

                    defs[kv.Key].PreviousStation = defs[kv.Value.PreviousStation];
                }
                return(defs);
            }
            catch (Exception e)
            {
                throw new InfoLoadException("failed to load travel stations", e);
            }
        }
コード例 #8
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,
            });
        }
コード例 #9
0
        private static TravelStationDefinition GetTravelStationDefinition(
            InfoDictionary <DownloadableContentDefinition> downloadableContents,
            KeyValuePair <string, Raw.TravelStationDefinition> kv)
        {
            DownloadableContentDefinition dlcExpansion = null;

            if (string.IsNullOrEmpty(kv.Value.DLCExpansion) == false)
            {
                if (downloadableContents.ContainsKey(kv.Value.DLCExpansion) == false)
                {
                    throw ResourceNotFoundException.Create("downloadable content", kv.Value.DLCExpansion);
                }
                dlcExpansion = downloadableContents[kv.Value.DLCExpansion];
            }

            if (kv.Value is Raw.FastTravelStationDefinition)
            {
                return(GetFastTravelStationDefinition(dlcExpansion, kv));
            }

            if (kv.Value is Raw.LevelTravelStationDefinition)
            {
                return(GetLevelTravelStationDefinition(dlcExpansion, kv));
            }

            throw new InvalidOperationException();
        }
コード例 #10
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,
            });
        }
コード例 #11
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,
            });
        }
コード例 #12
0
        public static InfoDictionary <ItemBalanceDefinition> Load(InfoDictionary <ItemTypeDefinition> itemTypes)
        {
            try
            {
                var raws = LoaderHelper.DeserializeJson <Dictionary <string, Raw.ItemBalanceDefinition> >("Item Balance");
                var defs =
                    new InfoDictionary <ItemBalanceDefinition>(raws.ToDictionary(kv => kv.Key,
                                                                                 kv =>
                                                                                 GetItemBalanceDefinition(itemTypes, kv)));
                foreach (var kv in raws.Where(kv => string.IsNullOrEmpty(kv.Value.Base) == false))
                {
                    if (defs.ContainsKey(kv.Value.Base) == false)
                    {
                        throw new KeyNotFoundException("could not find item balance '" + kv.Value.Base + "'");
                    }

                    defs[kv.Key].Base = defs[kv.Value.Base];
                }
                return(defs);
            }
            catch (Exception e)
            {
                throw new InfoLoadException("failed to load item balance", e);
            }
        }
コード例 #13
0
        private static WeaponBalancePartCollection GetWeaponBalancePartCollection(
            InfoDictionary <WeaponTypeDefinition> weaponTypes, Raw.WeaponBalancePartCollection raw)
        {
            if (raw == null)
            {
                return(null);
            }

            WeaponTypeDefinition type = null;

            if (string.IsNullOrEmpty(raw.Type) == false)
            {
                if (weaponTypes.ContainsKey(raw.Type) == false)
                {
                    throw ResourceNotFoundException.Create("weapon type", raw.Type);
                }

                type = weaponTypes[raw.Type];
            }

            return(new WeaponBalancePartCollection()
            {
                Type = 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 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,
            });
        }
コード例 #15
0
        protected override Expression VisitParameter(ParameterExpression node)
        {
            InfoDictionary.Add(node, TypeMappings);
            var pair = InfoDictionary.SingleOrDefault(a => a.Key.Equals(node));

            return(!pair.Equals(default(KeyValuePair <Type, MapperInfo>)) ? pair.Value.NewParameter : base.VisitParameter(node));
        }
コード例 #16
0
        public static InfoDictionary<WeaponBalanceDefinition> Load(InfoDictionary<WeaponTypeDefinition> weaponTypes)
        {
            try
            {
                var raws =
                    LoaderHelper.DeserializeJson<Dictionary<string, Raw.WeaponBalanceDefinition>>("Weapon Balance");
                var defs =
                    new InfoDictionary<WeaponBalanceDefinition>(raws.ToDictionary(kv => kv.Key,
                                                                                  kv =>
                                                                                  GetWeaponBalanceDefinition(
                                                                                      weaponTypes, kv)));
                foreach (var kv in raws.Where(kv => string.IsNullOrEmpty(kv.Value.Base) == false))
                {
                    if (defs.ContainsKey(kv.Value.Base) == false)
                    {
                        throw new KeyNotFoundException("could not find weapon balance '" + kv.Value.Base + "'");
                    }

                    defs[kv.Key].Base = defs[kv.Value.Base];
                }
                return defs;
            }
            catch (Exception e)
            {
                throw new InfoLoadException("failed to load weapon balance", e);
            }
        }
コード例 #17
0
        private static CustomizationDefinition GetCustomizationDefinition(
            InfoDictionary <DownloadableContentDefinition> downloadableContents,
            KeyValuePair <string, Raw.CustomizationDefinition> kv)
        {
            DownloadableContentDefinition content = null;

            if (string.IsNullOrEmpty(kv.Value.DLC) == false)
            {
                if (downloadableContents.ContainsKey(kv.Value.DLC) == false)
                {
                    throw ResourceNotFoundException.Create("downloadable content", kv.Value.DLC);
                }
                content = downloadableContents[kv.Value.DLC];
            }

            return(new CustomizationDefinition()
            {
                ResourcePath = kv.Key,
                Name = kv.Value.Name,
                Type = kv.Value.Type,
                Usage = kv.Value.Usage,
                DataName = kv.Value.DataName,
                PrimarySort = kv.Value.PrimarySort,
                SecondarySort = kv.Value.SecondarySort,
                DLC = content,
            });
        }
コード例 #18
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,
            });
        }
コード例 #19
0
ファイル: TestBaseInfo.cs プロジェクト: BartonCline/gisharp
 public void TestGetDefault()
 {
     // The default repository is process global, so we must initialize it only once.
     // It will be used all of the tests
     Repository.Require("GLib", "2.0");
     infos = Repository.Namespaces ["GLib"].Infos;
 }
        protected override Expression VisitMember(MemberExpression node)
        {
            var parameterExpression = node.GetParameterExpression();

            if (parameterExpression == null)
            {
                var baseExpression = node.GetBaseOfMemberExpression();
                if (baseExpression?.NodeType == ExpressionType.Constant)
                {
                    return(this.Visit
                           (
                               Expression.Constant
                               (
                                   GetConstantValue
                                   (
                                       ((ConstantExpression)baseExpression).Value,
                                       node.GetPropertyFullName(),
                                       baseExpression.Type
                                   ),
                                   node.Type
                               )
                           ));
                }

                return(base.VisitMember(node));
            }

            InfoDictionary.Add(parameterExpression, TypeMappings);
            return(GetMappedMemberExpression(node.GetBaseOfMemberExpression(), new List <PropertyMapInfo>()));

            Expression GetMappedMemberExpression(Expression parentExpression, List <PropertyMapInfo> propertyMapInfoList)
            {
                Expression mappedParentExpression = this.Visit(parentExpression);

                FindDestinationFullName(parentExpression.Type, mappedParentExpression.Type, node.GetPropertyFullName(), propertyMapInfoList);

                if (propertyMapInfoList.Any(x => x.CustomExpression != null))
                {
                    var fromCustomExpression = GetMemberExpressionFromCustomExpression
                                               (
                        propertyMapInfoList,
                        propertyMapInfoList.Last(x => x.CustomExpression != null),
                        mappedParentExpression
                                               );

                    this.TypeMappings.AddTypeMapping(ConfigurationProvider, node.Type, fromCustomExpression.Type);
                    return(fromCustomExpression);
                }

                var memberExpression = GetMemberExpressionFromMemberMaps(BuildFullName(propertyMapInfoList), mappedParentExpression);

                this.TypeMappings.AddTypeMapping(ConfigurationProvider, node.Type, memberExpression.Type);

                return(memberExpression);
            }
        }
コード例 #21
0
 private static WeaponBalanceDefinition GetWeaponBalanceDefinition(
     InfoDictionary <WeaponTypeDefinition> weaponTypes, KeyValuePair <string, Raw.WeaponBalanceDefinition> kv)
 {
     return(new WeaponBalanceDefinition()
     {
         ResourcePath = kv.Key,
         Type = GetWeaponType(weaponTypes, kv.Value.Type),
         Manufacturers = GetManufacturers(kv.Value.Manufacturers),
         Parts = GetWeaponBalancePartCollection(weaponTypes, kv.Value.Parts),
     });
 }
コード例 #22
0
 private static WeaponBalanceDefinition GetWeaponBalanceDefinition(
     InfoDictionary<WeaponTypeDefinition> weaponTypes, KeyValuePair<string, Raw.WeaponBalanceDefinition> kv)
 {
     return new WeaponBalanceDefinition()
     {
         ResourcePath = kv.Key,
         Type = GetWeaponType(weaponTypes, kv.Value.Type),
         Manufacturers = GetManufacturers(kv.Value.Manufacturers),
         Parts = GetWeaponBalancePartCollection(weaponTypes, kv.Value.Parts),
     };
 }
コード例 #23
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);
 }
コード例 #24
0
 private static ItemBalanceDefinition GetItemBalanceDefinition(InfoDictionary <ItemTypeDefinition> itemTypes,
                                                               KeyValuePair <string, Raw.ItemBalanceDefinition> kv)
 {
     return(new ItemBalanceDefinition()
     {
         ResourcePath = kv.Key,
         Type = GetItemType(itemTypes, kv.Value.Type),
         Types = GetTypes(itemTypes, kv.Value.Types),
         Manufacturers = GetManufacturers(kv.Value.Manufacturers),
         Parts = GetItemBalancePartCollection(itemTypes, kv.Value.Parts),
     });
 }
コード例 #25
0
 private static ItemBalanceDefinition GetItemBalanceDefinition(InfoDictionary<ItemTypeDefinition> itemTypes,
                                                               KeyValuePair<string, Raw.ItemBalanceDefinition> kv)
 {
     return new ItemBalanceDefinition()
     {
         ResourcePath = kv.Key,
         Type = GetItemType(itemTypes, kv.Value.Type),
         Types = GetTypes(itemTypes, kv.Value.Types),
         Manufacturers = GetManufacturers(kv.Value.Manufacturers),
         Parts = GetItemBalancePartCollection(itemTypes, kv.Value.Parts),
     };
 }
コード例 #26
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);
 }
コード例 #27
0
        protected override Expression VisitMember(MemberExpression node)
        {
            var parameterExpression = node.GetParameterExpression();

            if (parameterExpression == null)
            {
                return(base.VisitMember(node));
            }

            InfoDictionary.Add(parameterExpression, TypeMappings);
            return(GetMappedMemberExpression(node.GetBaseOfMemberExpression(), new List <PropertyMapInfo>()));

            Expression GetMappedMemberExpression(Expression parentExpression, List <PropertyMapInfo> propertyMapInfoList)
            {
                Expression mappedParentExpression = this.Visit(parentExpression);

                FindDestinationFullName(parentExpression.Type, mappedParentExpression.Type, node.GetPropertyFullName(), propertyMapInfoList);

                if (propertyMapInfoList.Any(x => x.CustomExpression != null))//CustomExpression takes precedence over DestinationPropertyInfo
                {
                    return(GetMemberExpression
                           (
                               new FindMemberExpressionsVisitor(mappedParentExpression),
                               GetMemberExpressionFromCustomExpression
                               (
                                   propertyMapInfoList,
                                   propertyMapInfoList.Last(x => x.CustomExpression != null),
                                   mappedParentExpression
                               )
                           ));
                }

                return(GetExpressionForInclude
                       (
                           GetMemberExpressionFromMemberMaps
                           (
                               BuildFullName(propertyMapInfoList),
                               mappedParentExpression
                           )
                       ));
            }

            Expression GetExpressionForInclude(MemberExpression memberExpression)
            => memberExpression.Type.IsLiteralType() ? memberExpression.Expression : memberExpression;

            MemberExpression GetMemberExpression(FindMemberExpressionsVisitor visitor, Expression mappedExpression)
            {
                visitor.Visit(mappedExpression);
                return(visitor.Result);
            }
        }
コード例 #28
0
        private static ItemTypeDefinition GetItemType(InfoDictionary <ItemTypeDefinition> itemTypes, string type)
        {
            if (string.IsNullOrEmpty(type) == true)
            {
                return(null);
            }

            if (itemTypes.ContainsKey(type) == false)
            {
                throw new KeyNotFoundException("could not find item type '" + type + "'");
            }

            return(itemTypes[type]);
        }
コード例 #29
0
        private static ItemTypeDefinition GetItemType(InfoDictionary <ItemTypeDefinition> itemTypes, string type)
        {
            if (string.IsNullOrEmpty(type) == true)
            {
                return(null);
            }

            if (itemTypes.ContainsKey(type) == false)
            {
                throw ResourceNotFoundException.Create("item type", type);
            }

            return(itemTypes[type]);
        }
コード例 #30
0
        private static WeaponTypeDefinition GetWeaponType(InfoDictionary<WeaponTypeDefinition> weaponTypes, string type)
        {
            if (string.IsNullOrEmpty(type) == true)
            {
                return null;
            }

            if (weaponTypes.ContainsKey(type) == false)
            {
                throw new KeyNotFoundException("could not find weapon type '" + type + "'");
            }

            return weaponTypes[type];
        }
コード例 #31
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);
 }
コード例 #32
0
        private static WeaponBalanceDefinition CreateWeaponBalance(
            InfoDictionary <WeaponTypeDefinition> weaponTypes,
            KeyValuePair <string, Raw.WeaponBalanceDefinition> kv,
            InfoDictionary <WeaponBalancePartCollection> partLists)
        {
            var raw = kv.Value;

            return(new WeaponBalanceDefinition()
            {
                ResourcePath = kv.Key,
                WeaponType = GetWeaponType(weaponTypes, raw.WeaponType),
                Manufacturers = GetManufacturers(raw.Manufacturers),
                Parts = GetWeaponBalancePartCollection(partLists, raw.Parts),
            });
        }
 public static InfoDictionary <DownloadableContentDefinition> Load(
     InfoDictionary <DownloadablePackageDefinition> downloadablePackages)
 {
     try
     {
         var raws = LoaderHelper
                    .DeserializeJson <Dictionary <string, Raw.DownloadableContentDefinition> >("Downloadable Contents");
         return(new InfoDictionary <DownloadableContentDefinition>(
                    raws.ToDictionary(kv => kv.Key,
                                      kv => GetDownloadableContent(downloadablePackages, kv))));
     }
     catch (Exception e)
     {
         throw new InfoLoadException("failed to load downloadable contents", e);
     }
 }
コード例 #34
0
        static InfoManager()
        {
            DownloadablePackages = Loaders.DownloadablePackageDefinitionLoader.Load();
            DownloadableContents = Loaders.DownloadableContentDefinitionLoader.Load(DownloadablePackages);
            AssetLibraryManager  = Loaders.AssetLibraryManagerLoader.Load();
            PlayerClasses        = Loaders.PlayerClassDefinitionLoader.Load(DownloadableContents);

            WeaponTypes = Loaders.WeaponTypeDefinitionLoader.Load();
            ItemTypes   = Loaders.ItemTypeDefinitionLoader.Load();

            WeaponBalance  = Loaders.WeaponBalanceDefinitionLoader.Load(WeaponTypes);
            ItemBalance    = Loaders.ItemBalanceDefinitionLoader.Load(ItemTypes);
            Customizations = Loaders.CustomizationDefinitionLoader.Load(DownloadableContents);

            TravelStations = Loaders.TravelStationDefinitionLoader.Load(DownloadableContents);
        }
コード例 #35
0
 public static InfoDictionary <CustomizationDefinition> Load(
     InfoDictionary <DownloadableContentDefinition> downloadableContents)
 {
     try
     {
         var raws = LoaderHelper
                    .DeserializeJson <Dictionary <string, Raw.CustomizationDefinition> >("Customizations");
         return(new InfoDictionary <CustomizationDefinition>(
                    raws.ToDictionary(kv => kv.Key,
                                      kv => GetCustomizationDefinition(downloadableContents, kv))));
     }
     catch (Exception e)
     {
         throw new InfoLoadException("failed to load customizations", e);
     }
 }
コード例 #36
0
        static InfoManager()
        {
            DownloadablePackages = Loaders.DownloadablePackageDefinitionLoader.Load();
            DownloadableContents = Loaders.DownloadableContentDefinitionLoader.Load(DownloadablePackages);
            AssetLibraryManager = Loaders.AssetLibraryManagerLoader.Load();
            PlayerClasses = Loaders.PlayerClassDefinitionLoader.Load(DownloadableContents);

            WeaponTypes = Loaders.WeaponTypeDefinitionLoader.Load();
            ItemTypes = Loaders.ItemTypeDefinitionLoader.Load();

            WeaponBalance = Loaders.WeaponBalanceDefinitionLoader.Load(WeaponTypes);
            ItemBalance = Loaders.ItemBalanceDefinitionLoader.Load(ItemTypes);
            Customizations = Loaders.CustomizationDefinitionLoader.Load(DownloadableContents);

            TravelStations = Loaders.TravelStationDefinitionLoader.Load(DownloadableContents);
        }
コード例 #37
0
 public static InfoDictionary <PlayerClassDefinition> Load(
     InfoDictionary <DownloadableContentDefinition> downloadableContents)
 {
     try
     {
         var raws = LoaderHelper.DeserializeDump <Dictionary <string, Raw.PlayerClassDefinition> >(
             "Player Classes");
         return(new InfoDictionary <PlayerClassDefinition>(
                    raws.ToDictionary(kv => kv.Key,
                                      kv => GetPlayerClassDefinition(downloadableContents, kv))));
     }
     catch (Exception e)
     {
         throw new InfoLoadException("failed to load player classes", e);
     }
 }
 public static InfoDictionary<PlayerClassDefinition> Load(
     InfoDictionary<DownloadableContentDefinition> downloadableContents)
 {
     try
     {
         var raws = LoaderHelper.DeserializeJson<Dictionary<string, Raw.PlayerClassDefinition>>("Player Classes");
         return
             new InfoDictionary<PlayerClassDefinition>(raws.ToDictionary(kv => kv.Key,
                                                                         kv =>
                                                                         GetPlayerClassDefinition(
                                                                             downloadableContents, kv)));
     }
     catch (Exception e)
     {
         throw new InfoLoadException("failed to load player classes", e);
     }
 }
 public static InfoDictionary<DownloadableContentDefinition> Load(
     InfoDictionary<DownloadablePackageDefinition> downloadablePackages)
 {
     try
     {
         var raws =
             LoaderHelper.DeserializeJson<Dictionary<string, Raw.DownloadableContentDefinition>>(
                 "Downloadable Contents");
         return
             new InfoDictionary<DownloadableContentDefinition>(raws.ToDictionary(kv => kv.Key,
                                                                                 kv =>
                                                                                 GetDownloadableContent(
                                                                                     downloadablePackages, kv)));
     }
     catch (Exception e)
     {
         throw new InfoLoadException("failed to load downloadable contents", e);
     }
 }
コード例 #40
0
        private static CustomizationDefinition GetCustomizationDefinition(
            InfoDictionary<DownloadableContentDefinition> downloadableContents,
            KeyValuePair<string, Raw.CustomizationDefinition> kv)
        {
            DownloadableContentDefinition content = null;
            if (string.IsNullOrEmpty(kv.Value.DLC) == false)
            {
                if (downloadableContents.ContainsKey(kv.Value.DLC) == false)
                {
                    throw new KeyNotFoundException("could not find downloadable content " + kv.Value.DLC);
                }
                content = downloadableContents[kv.Value.DLC];
            }

            return new CustomizationDefinition()
            {
                ResourcePath = kv.Key,
                Name = kv.Value.Name,
                Type = kv.Value.Type,
                Usage = kv.Value.Usage,
                DLC = content,
            };
        }
        private static PlayerClassDefinition GetPlayerClassDefinition(
            InfoDictionary<DownloadableContentDefinition> downloadableContents,
            KeyValuePair<string, Raw.PlayerClassDefinition> kv)
        {
            DownloadableContentDefinition content = null;
            if (string.IsNullOrEmpty(kv.Value.DLC) == false)
            {
                if (downloadableContents.ContainsKey(kv.Value.DLC) == false)
                {
                    throw new KeyNotFoundException("could not find downloadable content " + kv.Value.DLC);
                }
                content = downloadableContents[kv.Value.DLC];
            }

            return new PlayerClassDefinition()
            {
                ResourcePath = kv.Key,
                Name = kv.Value.Name,
                Class = kv.Value.Class,
                SortOrder = kv.Value.SortOrder,
                DLC = content,
            };
        }
        private static DownloadableContentDefinition GetDownloadableContent(
            InfoDictionary<DownloadablePackageDefinition> downloadablePackages,
            KeyValuePair<string, Raw.DownloadableContentDefinition> kv)
        {
            DownloadablePackageDefinition package = null;
            if (string.IsNullOrEmpty(kv.Value.Package) == false)
            {
                if (downloadablePackages.ContainsKey(kv.Value.Package) == false)
                {
                    throw new KeyNotFoundException("could not find downloadable package " + kv.Value.Package);
                }
                package = downloadablePackages[kv.Value.Package];
            }

            return new DownloadableContentDefinition()
            {
                ResourcePath = kv.Key,
                Id = kv.Value.Id,
                Name = kv.Value.Name,
                Package = package,
                Type = kv.Value.Type,
            };
        }
コード例 #43
0
        private static ItemBalancePartCollection GetItemBalancePartCollection(
            InfoDictionary<ItemTypeDefinition> itemTypes, Raw.ItemBalancePartCollection raw)
        {
            if (raw == null)
            {
                return null;
            }

            ItemTypeDefinition type = null;
            if (string.IsNullOrEmpty(raw.Type) == false)
            {
                if (itemTypes.ContainsKey(raw.Type) == false)
                {
                    throw new KeyNotFoundException("could not find item type " + raw.Type);
                }

                type = itemTypes[raw.Type];
            }

            return new ItemBalancePartCollection()
            {
                Type = 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,
            };
        }
コード例 #44
0
        private static List<ItemTypeDefinition> GetTypes(InfoDictionary<ItemTypeDefinition> itemTypes,
                                                         List<string> types)
        {
            if (types == null)
            {
                return null;
            }

            return types.Select(t =>
            {
                if (itemTypes.ContainsKey(t) == false)
                {
                    throw new KeyNotFoundException("could not find item type '" + t + "'");
                }

                return itemTypes[t];
            }).ToList();
        }
コード例 #45
0
        private static WeaponBalancePartCollection GetWeaponBalancePartCollection(
            InfoDictionary<WeaponTypeDefinition> weaponTypes, Raw.WeaponBalancePartCollection raw)
        {
            if (raw == null)
            {
                return null;
            }

            WeaponTypeDefinition type = null;
            if (string.IsNullOrEmpty(raw.Type) == false)
            {
                if (weaponTypes.ContainsKey(raw.Type) == false)
                {
                    throw new KeyNotFoundException("could not find weapon type '" + raw.Type + "'");
                }

                type = weaponTypes[raw.Type];
            }

            return new WeaponBalancePartCollection()
            {
                Type = 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,
            };
        }