/// <summary> /// Patches the skin texture. /// </summary> /// <param name="skinColor">Current skin color patch</param> private void PatchSkinTexture(SkinColorModel skinColor) { Asset.AsImage().PatchImage( skinColor.Texture, null, new Rectangle(0, SkinColorTextureHeight, 3, skinColor.TextureHeight)); }
/// <summary>Reads all the content packs for the mod</summary> public void ReadContentPacks() { //Loop through each content pack foreach (IContentPack contentPack in Entry.Helper.ContentPacks.GetOwned()) { //Create new Directory infos for all the different folders Entry.Monitor.Log($"Reading content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version}", LogLevel.Trace); DirectoryInfo hairDirectory = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Hairstyles")); DirectoryInfo accessoriesDirectory = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Accessories")); DirectoryInfo baseDirectory = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Base")); DirectoryInfo dresserDirectory = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Dresser")); DirectoryInfo shoeDirectory = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "Shoes")); DirectoryInfo faceAndNoseDirectory = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "FaceAndNose")); DirectoryInfo skinColorDirectory = new DirectoryInfo(Path.Combine(contentPack.DirectoryPath, "SkinColor")); //If the hair directory exists if (hairDirectory.Exists) { HairModel hair; try { //Create a new hair model hair = contentPack.ReadJsonFile <HairModel>("Hairstyles/hairstyles.json"); hair.Texture = contentPack.LoadAsset <Texture2D>("Hairstyles/hairstyles.png"); //Set the vars in the hair model hair.TextureHeight = hair.Texture.Height; hair.ModName = contentPack.Manifest.Name; NumberOfHairstlyesAdded += hair.NumberOfHairstyles; //Add the hair model to the list HairList.Add(hair); } catch { Entry.Monitor.Log($"{contentPack.Manifest.Name} hairstyles is emtpy. This pack was not added", LogLevel.Warn); } } //If the accessories directory exists if (accessoriesDirectory.Exists) { AccessoryModel accessory; try { //Create the new accessory model accessory = contentPack.ReadJsonFile <AccessoryModel>("Accessories/accessories.json"); accessory.Texture = contentPack.LoadAsset <Texture2D>("Accessories/accessories.png"); //Set the vars in the accessory model accessory.TextureHeight = accessory.Texture.Height; accessory.ModName = contentPack.Manifest.Name; NumberOfAccessoriesAdded += accessory.NumberOfAccessories; //Add the accessory to the accessory list AccessoryList.Add(accessory); } catch { Entry.Monitor.Log($"{contentPack.Manifest.Name} accessories is emtpy. This pack was not added", LogLevel.Warn); } } //If the base directory exists if (baseDirectory.Exists) { //Loop through each file in the folder foreach (FileInfo file in baseDirectory.EnumerateFiles()) { //Check the name if the file and load the texture into the relevant list if (file.Name.Contains("farmer_girl_base.png")) { FemaleBaseTextureList.Add(contentPack.LoadAsset <Texture2D>("Base/farmer_girl_base.png")); } else if (file.Name.Contains("farmer_base.png")) { MaleBaseTextureList.Add(contentPack.LoadAsset <Texture2D>("Base/farmer_base.png")); } else if (file.Name.Contains("bald")) { if (file.Name.Contains("girl_base_bald")) { FemaleBaseBaldTextureList.Add(contentPack.LoadAsset <Texture2D>("Base/farmer_girl_base_bald.png")); } else if (file.Name.Contains("farmer_base_bald")) { MaleBaseBaldTextureList.Add(contentPack.LoadAsset <Texture2D>("Base/farmer_base_bald.png")); } } } } //If the dresser directory exists if (dresserDirectory.Exists) { //Create a new dresser model DresserModel dresser; try { dresser = new DresserModel(); dresser.Texture = contentPack.LoadAsset <Texture2D>("Dresser/dresser.png"); //Set the vars of the Dresser model dresser.TextureHeight = dresser.Texture.Height; dresser.ModName = contentPack.Manifest.Name; //Add the dresser model to the dresser model list DresserList.Add(dresser); } catch { Entry.Monitor.Log($"{contentPack.Manifest.Name} dressers is emtpy. This pack was not added", LogLevel.Warn); } } //If the shoe directory exists if (shoeDirectory.Exists) { //Loop through each file and add the relevant texture to the Shoe list foreach (FileInfo file in shoeDirectory.EnumerateFiles()) { //Always going to find the female shoes first if (file.Name.Contains("female_shoes")) { FemaleShoeTextureList.Add(contentPack.LoadAsset <Texture2D>(Path.Combine("Shoes", file.Name))); } else if (file.Name.Contains("male_shoes")) { MaleShoeTextureList.Add(contentPack.LoadAsset <Texture2D>(Path.Combine("Shoes", file.Name))); } } } //If the Face and Nose directory exists if (faceAndNoseDirectory.Exists) { try { //Create a facenose model and read the json FaceNoseModel model = contentPack.ReadJsonFile <FaceNoseModel>(Path.Combine("FaceAndNose", "count.json")); //Add the count of faces to the dictionary for the base texture MaleBaseFaceNoseCount.Add(MaleBaseTextureList[MaleBaseTextureList.Count - 1], new int[] { model.NumberOfMaleFaces, model.NumberOfMaleNoses }); FemaleBaseFaceNoseCount.Add(FemaleBaseTextureList[FemaleBaseTextureList.Count - 1], new int[] { model.NumberOfFemaleFaces, model.NumberOfFemaleNoses }); //New dictionaries to be added to the dictionary Dictionary <string, Texture2D> currentPackMaleFaceNoseDict = new Dictionary <string, Texture2D>(); Dictionary <string, Texture2D> currentPackFemaleFaceNoseDict = new Dictionary <string, Texture2D>(); //Load the face and nose textures somewhere foreach (FileInfo file in faceAndNoseDirectory.EnumerateFiles()) { //It's always going to find the female faces first if (file.Name.Contains("female_face")) { currentPackFemaleFaceNoseDict.Add(file.Name, contentPack.LoadAsset <Texture2D>(Path.Combine("FaceAndNose", file.Name))); } else if (file.Name.Contains("male_face")) { currentPackMaleFaceNoseDict.Add(file.Name, contentPack.LoadAsset <Texture2D>(Path.Combine("FaceAndNose", file.Name))); } } //Add it to the Dictionary MaleFaceAndNoseTextureDict.Add(MaleBaseTextureList[MaleBaseTextureList.Count - 1], currentPackMaleFaceNoseDict); FemaleFaceAndNoseTextureDict.Add(FemaleBaseTextureList[FemaleBaseTextureList.Count - 1], currentPackFemaleFaceNoseDict); } catch { Entry.Monitor.Log($"{contentPack.Manifest.Name} faces and noses is emtpy. This pack was not added", LogLevel.Warn); } } //If the skin color directory exists if (skinColorDirectory.Exists) { try { //Create a new skin color model SkinColorModel model = new SkinColorModel(); //Set the model info model.Texture = contentPack.LoadAsset <Texture2D>(Path.Combine("SkinColor", "skinColors.png")); model.TextureHeight = model.Texture.Height; model.ModName = contentPack.Manifest.Name; //Add the model to the list SkinColorList.Add(model); } catch { Entry.Monitor.Log($"{contentPack.Manifest.Name} skin colors is emtpy. This pack was not added", LogLevel.Warn); } } } //Add ImageInjector to the Asset Editor to start patching the images Entry.Helper.Content.AssetEditors.Add(new ImageInjector(Entry, this)); }
/// <summary> /// Creates a new SkinColorModel and sets the Texture. /// </summary> private void CreateNewSkinModel() { SkinColor = new SkinColorModel(); SkinColor.Texture = CurrentContentPack.LoadAsset <Texture2D>(Path.Combine("SkinColor", "skinColors.png")); }