Exemplo n.º 1
0
        private IEnumerable <ResourceMappingPath> StudioVoiceCategoryMapper(ResourceMappingPath path,
                                                                            ResourceMappingMode mode)
        {
            var mappedParts = path.ResourcePathParts.ToList();
            var itemParts   = mappedParts[4].Split('_');

            for (var i = 99; i >= 0; i--)
            {
                mappedParts[3] = $"{i:00}";
                // for replacement only sync within personality
                if (mode == ResourceMappingMode.Replacement)
                {
                    itemParts[1]   = mappedParts[3];
                    mappedParts[4] = string.Join("_", itemParts);
                    yield return(ResourceMappingPath.FromParts(mappedParts));
                }

                if (mode == ResourceMappingMode.Sync)
                {
                    for (var j = MaxPersonalityId; j >= -2; j--)
                    {
                        // first number matches folder
                        itemParts[1]   = mappedParts[3];
                        itemParts[2]   = $"{j:00}";
                        mappedParts[4] = string.Join("_", itemParts);
                        yield return(ResourceMappingPath.FromParts(mappedParts));
                    }
                }
            }
        }
Exemplo n.º 2
0
        private IEnumerable <ResourceMappingPath> SubsMapper(ResourceMappingPath path, ResourceMappingMode mode)
        {
            Logger.LogDebug($"ResourceMapping: {nameof(SubsMapper)} {path}");
            // Subs
            //  abdata/list/h/sound/voice/[*num1]/hvoice_c[personality]_[num2](_[*num3])
            var mappedParts = path.ResourcePathParts.ToList();
            var voiceParts  = mappedParts[6].Split('_');

            var prefix = voiceParts[0];

            if (prefix.Substring(prefix.Length - 4, 2).Equals("ev", StringComparison.OrdinalIgnoreCase))
            {
                prefix = prefix.Substring(0, prefix.Length - 4);
            }

            for (var i = MaxHVoiceModifier + 1; i >= MinHVoiceModifier; i--)
            {
                voiceParts[0] = i > MaxHVoiceModifier ? prefix : $"{prefix}ev{i:00}";
                foreach (var num1 in EnumerateLevels(99, 0))
                {
                    mappedParts[5] = $"{num1:00}";
                    mappedParts[6] = string.Join("_", voiceParts);
                    yield return(ResourceMappingPath.FromParts(mappedParts));
                }
            }
        }
        private IEnumerable <ResourceMappingPath> PersonalityNameMapper(ResourceMappingPath path, ResourceMappingMode mode)
        {
            var gameMapPaths = new List <string> {
                "abdata", "list", "characustom", string.Empty, string.Empty
            };
            var studioMapPaths = new List <string> {
                "abdata", "studio", "info", string.Empty, string.Empty
            };

            var studioFirst = path.ResourcePathParts[1].Equals("studio", StringComparison.OrdinalIgnoreCase);

            // 0        1        2             3         4
            // abdata / list   / characustom / [*num1] / cha_sample_voice_[*num1]
            // abdata / studio / info        / [*num1] / voicegroup_[*num1]

            var secondary = new List <ResourceMappingPath>();

            foreach (var i in EnumerateLevels(99, 0))
            {
                var num1 = $"{i:00}";
                gameMapPaths[3]   = studioMapPaths[3] = num1;
                gameMapPaths[4]   = $"cha_sample_voice_{num1}";
                studioMapPaths[4] = $"voicegroup_{num1}";

                yield return(ResourceMappingPath.FromParts(studioFirst ? studioMapPaths : gameMapPaths));

                secondary.Add(ResourceMappingPath.FromParts(studioFirst ? gameMapPaths : studioMapPaths));
            }

            foreach (var secondaryPath in secondary)
            {
                yield return(secondaryPath);
            }
        }
Exemplo n.º 4
0
 private static IEnumerable <ResourceMappingPath> GetMappingForPath(string calculatedModificationPath,
                                                                    Object asset, IAssetOrResourceLoadedContext context)
 {
     return(TextResourceRedirector.Instance.TextResourceHelper.ResourceMappingHelper.GetMappingForPath(
                ResourceMappingPath.FromAssetContext(calculatedModificationPath, asset, context),
                ResourceMappingMode.Replacement));
 }
Exemplo n.º 5
0
        private bool PersonalityNameChecker(ResourceMappingPath path, ResourceMappingMode mode)
        {
            Logger.LogDebug($"{nameof(PersonalityNameChecker)}: {path}: {path.ResourcePathParts.Count}");

            if (path.ResourcePathParts.Count == 5)
            {
                // abdata/studio/info/[*num1]/voicegroup_[*num1]
                if (path.ResourcePathParts[4].StartsWith("voicegroup_"))
                {
                    return(path.ResourcePathParts[1].Equals("studio", StringComparison.OrdinalIgnoreCase) &&
                           path.ResourcePathParts[2].Equals("info", StringComparison.OrdinalIgnoreCase));
                }

                // abdata/list/characustom/[*num1]/cha_sample_voice_[*num1]
                if (path.ResourcePathParts[4].StartsWith("cha_sample_voice_"))
                {
                    return(path.ResourcePathParts[2].Equals("characustom", StringComparison.OrdinalIgnoreCase) &&
                           path.ResourcePathParts[1].Equals("list", StringComparison.OrdinalIgnoreCase));
                }
            }

            else if (path.ResourcePathParts.Count == 6)
            {
                // abdata/etcetra/list/config/[*num1]/00
                return(path.ResourcePathParts[5] == "00" && path.ResourcePath.StartsWith("abdata/etcetra/list/config"));
            }

            return(false);
        }
Exemplo n.º 6
0
        private IEnumerable <ResourceMappingPath> StudioItemListMapper(ResourceMappingPath path,
                                                                       ResourceMappingMode mode)
        {
            var mappedParts = path.ResourcePathParts.ToList();
            var itemParts   = mappedParts[4].Split('_');

            for (var i = 99; i >= 0; i--)
            {
                mappedParts[3] = $"{i:00}";
                for (var j = 99; j >= 0; j--)
                {
                    // first number matches folder
                    itemParts[1]   = mappedParts[3];
                    itemParts[3]   = $"{j:00}";
                    mappedParts[4] = string.Join("_", itemParts);
                    yield return(ResourceMappingPath.FromParts(mappedParts));

                    // sometimes last number is single digit
                    if (j > 10)
                    {
                        continue;
                    }
                    itemParts[3]   = $"{j}";
                    mappedParts[4] = string.Join("_", itemParts);
                    yield return(ResourceMappingPath.FromParts(mappedParts));
                }
            }
        }
        private IEnumerable <ResourceMappingPath> AdvMapper(ResourceMappingPath path, ResourceMappingMode mode)
        {
            var mappedParts = path.ResourcePathParts.ToList();

            foreach (var i in EnumerateLevels())
            {
                mappedParts[4] = $"{i:00}";
                yield return(ResourceMappingPath.FromParts(mappedParts));
            }
        }
Exemplo n.º 8
0
        private IEnumerable <ResourceMappingPath> AdvMapper(ResourceMappingPath path, ResourceMappingMode mode)
        {
            var mappedParts = path.ResourcePathParts.ToList();

            for (var i = 99; i >= 0; i--)
            {
                mappedParts[4] = $"{i:00}";
                yield return(ResourceMappingPath.FromParts(mappedParts));
            }
        }
Exemplo n.º 9
0
        private bool MakerPoseChecker(ResourceMappingPath path, ResourceMappingMode mode)
        {
            if (path.ResourcePathParts.Count == 4 &&
                path.ResourcePathParts[3].StartsWith("cus_pose") &&
                path.ResourcePathParts[1].Equals("custom", StringComparison.OrdinalIgnoreCase) &&
                path.ResourcePathParts[2].Equals("customscenelist", StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }

            return(false);
        }
        private bool CommunicationChecker(ResourceMappingPath path, ResourceMappingMode mode)
        {
            if (path.ResourcePathParts.Count >= 3 &&
                path.ResourcePathParts[1].Equals("communication", StringComparison.OrdinalIgnoreCase) &&
                path.ResourcePathParts[2].StartsWith("info_"))
            {
                Logger.LogDebug($"ResourceMapping: {nameof(CommunicationChecker)} {path} -- {path.ResourcePathParts.Count}");
                return(true);
            }

            return(false);
        }
Exemplo n.º 11
0
        private bool SubsChecker(ResourceMappingPath path, ResourceMappingMode mode)

        {
            Logger.LogDebug($"ResourceMapping: {nameof(SubsChecker)} {path}  -- {path.ResourcePathParts.Count}");
            // Subs
            //  abdata/list/h/sound/voice/[*num1]/hvoice_c[personality]_[*num2]_[whatever]
            if (path.ResourcePathParts.Count == 7 && path.ResourcePath.StartsWith(@"abdata\list\h\sound\voice"))
            {
                Logger.LogDebug($"ResourceMapping: {nameof(SubsChecker)} {path} -- {path.ResourcePathParts.Count}: YES");
                return(true);
            }
            return(false);
        }
        private bool SubsChecker(ResourceMappingPath path, ResourceMappingMode mode)
        {
            Logger.LogDebug($"ResourceMapping: {nameof(SubsChecker)} {path} -- {path.ResourcePathParts.Count}");
            if (path.ResourcePathParts.Count >= 5 &&
                path.ResourcePathParts[4].StartsWith("personality_voice_") &&
                path.ResourcePathParts[1].Equals("h", StringComparison.OrdinalIgnoreCase) &&
                path.ResourcePathParts[2].Equals("list", StringComparison.OrdinalIgnoreCase))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 13
0
        private bool StudioItemListChecker(ResourceMappingPath path, ResourceMappingMode mode)
        {
            if (path.ResourcePathParts.Count == 5 &&
                path.ResourcePathParts[4].StartsWith("itemlist_") &&
                path.ResourcePathParts[1].Equals("studio", StringComparison.OrdinalIgnoreCase) &&
                path.ResourcePathParts[2].Equals("info", StringComparison.OrdinalIgnoreCase))

            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 14
0
        private bool StudioVoiceCategoryChecker(ResourceMappingPath path, ResourceMappingMode mode)
        {
            if (mode == ResourceMappingMode.Replacement && !IsStudio)
            {
                return(false);
            }
            if (path.ResourcePathParts.Count == 5 &&
                path.ResourcePathParts[4].StartsWith("voicecategory_") &&
                path.ResourcePathParts[1].Equals("studio", StringComparison.OrdinalIgnoreCase) &&
                path.ResourcePathParts[2].Equals("info", StringComparison.OrdinalIgnoreCase))

            {
                return(true);
            }

            return(false);
        }
        private IEnumerable <ResourceMappingPath> SubsMapper(ResourceMappingPath path, ResourceMappingMode mode)
        {
            // abdata/h/list/[*num1]/personality_voice_c[personality]_[*num2]_[num3]
            var mappedParts = path.ResourcePathParts.ToList();
            var voiceParts  = mappedParts[4].Split('_');

            foreach (var i in EnumerateLevels())
            {
                mappedParts[3] = $"{i:00}_00";
                // max num2 = 10
                for (var j = 10; j >= 0; j--)
                {
                    voiceParts[3]  = $"{j:00}";
                    mappedParts[4] = string.Join("_", voiceParts);
                    yield return(ResourceMappingPath.FromParts(mappedParts));
                }
            }
        }
Exemplo n.º 16
0
        private IEnumerable <ResourceMappingPath> StudioVoiceMapper(ResourceMappingPath path, ResourceMappingMode mode)
        {
            var mappedParts = path.ResourcePathParts.ToList();
            var voiceParts  = mappedParts[4].Split('_');

            for (var i = 99; i >= 0; i--)
            {
                mappedParts[3] = $"{i:00}";

                for (var j = 99; j >= 0; j--)
                {
                    // voice_[personality]_[j]_00
                    voiceParts[2]  = $"{j:00}";
                    mappedParts[4] = string.Join("_", voiceParts);
                    yield return(ResourceMappingPath.FromParts(mappedParts));
                }
            }
        }
Exemplo n.º 17
0
        private IEnumerable <ResourceMappingPath> MakerPoseMapper(ResourceMappingPath path, ResourceMappingMode mode)
        {
            var mappedParts = path.ResourcePathParts.ToList();

            if (mappedParts[3].Equals("cus_pose", StringComparison.OrdinalIgnoreCase))
            {
                mappedParts[3] = "cus_pose_trial";
            }
            else if (mappedParts[3].Equals("cus_pose_trial", StringComparison.OrdinalIgnoreCase))
            {
                mappedParts[3] = "cus_pose";
            }
            else
            {
                yield break;
            }

            yield return(ResourceMappingPath.FromParts(mappedParts));
        }
Exemplo n.º 18
0
        private bool AdvChecker(ResourceMappingPath path, ResourceMappingMode mode)
        {
            /*
             * return path.ResourcePathParts.Count >= 6 &&
             *     path.ResourcePathParts[1].Equals("adv", StringComparison.OrdinalIgnoreCase) &&
             *     path.ResourcePathParts[2].Equals("scenario", StringComparison.OrdinalIgnoreCase) &&
             *     int.TryParse(path.ResourcePathParts[4], out var _);
             */
            if (path.ResourcePathParts.Count >= 5 &&
                path.ResourcePathParts[1].Equals("adv", StringComparison.OrdinalIgnoreCase) &&
                path.ResourcePathParts[2].Equals("scenario", StringComparison.OrdinalIgnoreCase) &&
                int.TryParse(path.ResourcePathParts[4], out var _))
            {
                Logger.LogDebug($"ResourceMapping: {nameof(AdvChecker)} {path} -- {path.ResourcePathParts.Count}");
                return(true);
            }

            return(false);
        }
        private bool PersonalityNameChecker(ResourceMappingPath path, ResourceMappingMode mode)
        {
            Logger.LogDebug($"{nameof(PersonalityNameChecker)}: {path}: {path.ResourcePathParts.Count}");

            if (path.ResourcePathParts.Count != 5)
            {
                return(false);
            }

            if (path.ResourcePathParts[4].StartsWith("voicegroup_"))
            {
                return(path.ResourcePathParts[1].Equals("studio", StringComparison.OrdinalIgnoreCase) &&
                       path.ResourcePathParts[2].Equals("info", StringComparison.OrdinalIgnoreCase));
            }

            if (path.ResourcePathParts[4].StartsWith("cha_sample_voice_"))
            {
                return(path.ResourcePathParts[2].Equals("characustom", StringComparison.OrdinalIgnoreCase) &&
                       path.ResourcePathParts[1].Equals("list", StringComparison.OrdinalIgnoreCase));
            }

            return(false);
        }
Exemplo n.º 20
0
        private IEnumerable <ResourceMappingPath> CommunicationMapper(ResourceMappingPath path, ResourceMappingMode mode)
        {
            var mappedParts    = path.ResourcePathParts.ToList();
            var altMappedParts = mappedParts[3].StartsWith("communication_") ? mappedParts.ToList() : null;

            if (altMappedParts != null)
            {
                altMappedParts[3] = altMappedParts[3].StartsWith("communication_off_")
                    ? altMappedParts[3].Replace("communication_off_", "communication_")
                    : altMappedParts[3].Replace("communication_", "communication_off_");
            }

            for (var i = 99; i >= 0; i--)
            {
                mappedParts[2] = $"info_{i:00}";
                yield return(ResourceMappingPath.FromParts(mappedParts));

                if (altMappedParts != null)
                {
                    altMappedParts[2] = mappedParts[2];
                    yield return(ResourceMappingPath.FromParts(altMappedParts));
                }
            }
        }
 public T this[ResourceMappingPath key]
 {
     get => _cache[key];
 public bool TryGetValue(ResourceMappingPath key, out T value)
 {
     return(_cache.TryGetValue(key, out value));
 }
 public bool Remove(ResourceMappingPath key)
 {
     return(_cache.Remove(key));
 }
 private bool TryGetCachedMapperIds(ResourceMappingPath path, ResourceMappingMode mode,
                                    out List <int> mapperIds)
 {
     return(_pathToMapperIdCache[mode].TryGetValue(path, out mapperIds));
 }
 private void SetCachedMapperIds(ResourceMappingPath path, ResourceMappingMode mode,
                                 IEnumerable <int> mapperIds)
 {
     _pathToMapperIdCache[mode][path] = mapperIds.ToList();
 }
Exemplo n.º 26
0
        private IEnumerable <ResourceMappingPath> PersonalityNameMapper(ResourceMappingPath path,
                                                                        ResourceMappingMode mode)
        {
            var handled      = new HashSet <ResourceMappingPath>();
            var mapPartsList = new List <List <string> >
            {
                new List <string> {
                    "abdata", "list", "characustom", string.Empty, string.Empty
                },
                new List <string> {
                    "abdata", "etcetra", "list", "config", string.Empty, "00"
                },
                new List <string> {
                    "abdata", "studio", "info", string.Empty, string.Empty
                },
            };

            var gameMapParts   = mapPartsList[0];
            var gameEtcParts   = mapPartsList[1];
            var studioMapParts = mapPartsList[2];

            var studioFirst = path.ResourcePathParts[1].Equals("studio", StringComparison.OrdinalIgnoreCase);

            // 0        1         2             3         4                          5
            // abdata / list    / characustom / [*num1] / cha_sample_voice_[*num1]
            // abdata / studio  / info        / [*num1] / voicegroup_[*num1]
            // abdata / etcetra / list        / config  / [*num1]                  / 00

            var secondary = new List <ResourceMappingPath>();

            IEnumerable <ResourceMappingPath> PrepMapping(List <string> parts)
            {
                var mapPath = ResourceMappingPath.FromParts(parts);

                if (!handled.Contains(mapPath))
                {
                    handled.Add(mapPath);
                    var isStudioAsset = mapPath.ResourcePathParts[1]
                                        .Equals("studio", StringComparison.OrdinalIgnoreCase);

                    if ((studioFirst && isStudioAsset) || (!studioFirst && !isStudioAsset))
                    {
                        yield return(mapPath);
                    }
                    else
                    {
                        secondary.Add(mapPath);
                    }
                }
            }

            foreach (var i in EnumerateLevels(99, 0))
            {
                var num1 = $"{i:00}";
                gameEtcParts[4]   = gameMapParts[3] = studioMapParts[3] = num1;
                gameMapParts[4]   = $"cha_sample_voice_{num1}";
                studioMapParts[4] = $"voicegroup_{num1}";

                foreach (var mapper in mapPartsList.SelectMany(PrepMapping))
                {
                    yield return(mapper);
                }
            }

            foreach (var secondaryPath in secondary)
            {
                yield return(secondaryPath);
            }
        }
 public bool ContainsKey(ResourceMappingPath key)
 {
     return(_cache.ContainsKey(key));
 }
 private void SetCachedMappingPaths(ResourceMappingPath path, ResourceMappingMode mode,
                                    IEnumerable <ResourceMappingPath> paths)
 {
     _pathToMappingPathCache[mode][path] = paths.ToList();
 }
 public void Add(ResourceMappingPath key, T value)
 {
     CapacityCheck();
     _cache.Add(key, value);
 }
 private bool TryGetCachedMappingPaths(ResourceMappingPath path, ResourceMappingMode mode,
                                       out List <ResourceMappingPath> paths)
 {
     return(_pathToMappingPathCache[mode].TryGetValue(path, out paths));
 }