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 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); }
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)); } } } }
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); }
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 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); }
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); }
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); }
protected void RegisterMapping(ResourceMappingChecker checker, ResourceMappingMapper mapper, ResourceMappingMode mappingMode, ResourceGameMode replacementGameMode = ResourceGameMode.All, string pathToWhitelist = null) { // turn off replacement if not supported by current mode if (!IsCurrentGameMode(replacementGameMode)) { mappingMode &= ~ResourceMappingMode.Replacement; } if (mappingMode == ResourceMappingMode.None) { return; } var mapperId = GetMapperId(mapper); var mapperEntries = _checkers.GetOrInit(checker); var entry = mapperEntries.FirstOrDefault(e => e.MapperId == mapperId); if (entry == null) { mapperEntries.Add(new MapperEntry(mapperId, mappingMode)); } else { entry.Mode |= mappingMode; } if (_checkerModes.ContainsKey(checker)) { _checkerModes[checker] |= mappingMode; } else { _checkerModes[checker] = mappingMode; } if (!pathToWhitelist.IsNullOrEmpty()) { WhiteListPaths.Add(pathToWhitelist); } if (!HasReplacementMappingsForCurrentGameMode && (mappingMode & ResourceMappingMode.Replacement) == ResourceMappingMode.Replacement && (replacementGameMode & _currentModeFlag) == _currentModeFlag) { HasReplacementMappingsForCurrentGameMode = true; } ResetCaches(); }
private IEnumerable <ResourceMappingMapper> GetMappers(ResourceMappingChecker checker, ResourceMappingMode mode) { if (!_checkers.TryGetValue(checker, out var mapperEntries)) { yield break; } foreach (var id in mapperEntries.Where(e => (e.Mode & mode) == mode).Select(e => e.MapperId)) { if (_mappers.TryGetValue(id, out var mapper)) { yield return(mapper); } } }
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 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); }
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> 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)); } } }
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)); }
private void SetPathUnmapped(ResourceMappingPath path, ResourceMappingMode mode) { _unmappedPathCache.GetOrInit(mode).Add(path); }
private void SetCachedMappingPaths(ResourceMappingPath path, ResourceMappingMode mode, IEnumerable <ResourceMappingPath> paths) { _pathToMappingPathCache[mode][path] = paths.ToList(); }
private bool TryGetCachedMappingPaths(ResourceMappingPath path, ResourceMappingMode mode, out List <ResourceMappingPath> paths) { return(_pathToMappingPathCache[mode].TryGetValue(path, out paths)); }
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)); } } }
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(); }
private IEnumerable <ResourceMappingChecker> GetCheckers(ResourceMappingMode mode) { return(_checkers.Where(e => (_checkerModes[e.Key] & mode) == mode).Select(e => e.Key)); }
internal MapperEntry(int mapperId, ResourceMappingMode mode) { MapperId = mapperId; Mode = mode; }
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)); } } }
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)); } }
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)); } }
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); } }
public ResourceMappingModeCache <T> this[ResourceMappingMode key] => _cache.GetOrInit(key, () => new ResourceMappingModeCache <T>($"{_name} ({key})", _maxCacheSize, _delayCleaning));
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); } }