 f033b1aa74
			
		
	
	f033b1aa74
	
	
	
		
			
			clean up some stuff revert pet clearing fix initial cache creation not happening without changes/redraws fix draw conditions when framework inactive
		
			
				
	
	
		
			76 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			76 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using MareSynchronos.API.Data;
 | |
| 
 | |
| using MareSynchronos.API.Data.Enum;
 | |
| 
 | |
| namespace MareSynchronos.PlayerData.Data;
 | |
| 
 | |
| public class CharacterData
 | |
| {
 | |
|     public Dictionary<ObjectKind, string> CustomizePlusScale { get; set; } = [];
 | |
|     public Dictionary<ObjectKind, HashSet<FileReplacement>> FileReplacements { get; set; } = [];
 | |
|     public Dictionary<ObjectKind, string> GlamourerString { get; set; } = [];
 | |
|     public string HeelsData { get; set; } = string.Empty;
 | |
|     public string HonorificData { get; set; } = string.Empty;
 | |
|     public string ManipulationString { get; set; } = string.Empty;
 | |
|     public string PetNamesData { get; set; } = string.Empty;
 | |
|     public string MoodlesData { get; set; } = string.Empty;
 | |
| 
 | |
|     public void SetFragment(ObjectKind kind, CharacterDataFragment? fragment)
 | |
|     {
 | |
|         if (kind == ObjectKind.Player)
 | |
|         {
 | |
|             var playerFragment = (fragment as CharacterDataFragmentPlayer);
 | |
|             HeelsData = playerFragment?.HeelsData ?? string.Empty;
 | |
|             HonorificData = playerFragment?.HonorificData ?? string.Empty;
 | |
|             ManipulationString = playerFragment?.ManipulationString ?? string.Empty;
 | |
|             MoodlesData = playerFragment?.MoodlesData ?? string.Empty;
 | |
|             PetNamesData = playerFragment?.PetNamesData ?? string.Empty;
 | |
|         }
 | |
| 
 | |
|         if (fragment is null)
 | |
|         {
 | |
|             CustomizePlusScale.Remove(kind);
 | |
|             FileReplacements.Remove(kind);
 | |
|             GlamourerString.Remove(kind);
 | |
|         }
 | |
|         else
 | |
|         {
 | |
|             CustomizePlusScale[kind] = fragment.CustomizePlusScale;
 | |
|             FileReplacements[kind] = fragment.FileReplacements;
 | |
|             GlamourerString[kind] = fragment.GlamourerString;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public API.Data.CharacterData ToAPI()
 | |
|     {
 | |
|         Dictionary<ObjectKind, List<FileReplacementData>> fileReplacements =
 | |
|             FileReplacements.ToDictionary(k => k.Key, k => k.Value.Where(f => f.HasFileReplacement && !f.IsFileSwap)
 | |
|             .GroupBy(f => f.Hash, StringComparer.OrdinalIgnoreCase)
 | |
|             .Select(g =>
 | |
|         {
 | |
|             return new FileReplacementData()
 | |
|             {
 | |
|                 GamePaths = g.SelectMany(f => f.GamePaths).Distinct(StringComparer.OrdinalIgnoreCase).ToArray(),
 | |
|                 Hash = g.First().Hash,
 | |
|             };
 | |
|         }).ToList());
 | |
| 
 | |
|         foreach (var item in FileReplacements)
 | |
|         {
 | |
|             var fileSwapsToAdd = item.Value.Where(f => f.IsFileSwap).Select(f => f.ToFileReplacementDto());
 | |
|             fileReplacements[item.Key].AddRange(fileSwapsToAdd);
 | |
|         }
 | |
| 
 | |
|         return new API.Data.CharacterData()
 | |
|         {
 | |
|             FileReplacements = fileReplacements,
 | |
|             GlamourerData = GlamourerString.ToDictionary(d => d.Key, d => d.Value),
 | |
|             ManipulationData = ManipulationString,
 | |
|             HeelsData = HeelsData,
 | |
|             CustomizePlusData = CustomizePlusScale.ToDictionary(d => d.Key, d => d.Value),
 | |
|             HonorificData = HonorificData,
 | |
|             PetNamesData = PetNamesData,
 | |
|             MoodlesData = MoodlesData
 | |
|         };
 | |
|     }
 | |
| } |