private static void LoadPacks()
        {
            var currentPacks = new List <LocalizationPack>();

            var directoryInfo = new DirectoryInfo(Path.Combine(Application.dataPath, "Mods", "Localization/" + alias_s_CurrentLocale));

            FileInfo[] files;

            try
            {
                files = directoryInfo.GetFiles("*.json", SearchOption.AllDirectories);
            }
            catch (DirectoryNotFoundException ex)
            {
                UberDebug.LogError("Failed to load localization packs in: {0}", directoryInfo.FullName);
                UberDebug.LogException(ex);
                return;
            }

            foreach (FileInfo file in files.Where(file => file.Exists))
            {
                try
                {
                    using (var streamReader = new StreamReader(file.FullName))
                    {
                        currentPacks.Add(JsonConvert.DeserializeObject <LocalizationPack>(streamReader.ReadToEnd()));
                    }
                }
                catch (Exception ex)
                {
                    UberDebug.LogError("Failed to load localization pack: {0}", file.FullName);
                    UberDebug.LogException(ex);
                }
            }

            if (CurrentPack == null)
            {
                return;
            }

            foreach (LocalizationPack currentPack in currentPacks)
            {
                foreach (KeyValuePair <string, string> keyValuePair in currentPack.Strings)
                {
                    if (CurrentPack.Strings.ContainsKey(keyValuePair.Key) == true)
                    {
                        CurrentPack.Strings.Remove(keyValuePair.Key);
                    }

                    CurrentPack.Strings.Add(keyValuePair.Key, keyValuePair.Value);
                }
            }
        }
예제 #2
0
        public static void RevealLocationsByType(List <LocationType> types)
        {
            var instance  = GlobalMapRules.Instance;
            var globalMap = Game.Instance.Player.GlobalMap;

            foreach (var blueprint in Utilities.GetScriptableObjects <BlueprintLocation>())
            {
                if (types.Contains(blueprint.Type))
                {
                    try
                    {
                        var locationData = globalMap.GetLocationData(blueprint);
                        locationData.EdgesOpened = true;
                        locationData.Reveal();

                        var locationObject = instance.GetLocationObject(blueprint);
                        if ((bool)instance)
                        {
                            if ((bool)locationObject)
                            {
                                instance.RevealLocation(locationObject);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        modLogger.Log(ex.ToString());
                    }
                }
            }

            foreach (var blueprint in Utilities.GetScriptableObjects <BlueprintMapEdge>())
            {
                try
                {
                    globalMap.GetEdgeData(blueprint).UpdateExplored(1f, 1);
                    if ((bool)((UnityEngine.Object)instance))
                    {
                        instance.GetEdgeObject(blueprint).UpdateRenderers();
                    }
                }
                catch (Exception ex)
                {
                    UberDebug.LogException(ex);
                }
            }
        }