internal static int GetRandomSkin(string type) { type = Sanitize(type); if (!ModApi.HasSkins(type)) { return(0); } int randomLookup = Randomizer.Next(0, Assets[type].Keys.Count); return(Assets[type].ElementAt(randomLookup).Key); }
/************************ ** Skin Handling *************************/ /// <param name="creature">The creature (Pet, Horse, or FarmAnimal) to set the skin for</param> /// <param name="skinID">The file ID of the skin to set.</param> internal static int SetSkin(Character creature, int skinID) { if (!ModApi.IsInDatabase(creature) || !ModApi.HasSkins(ModApi.GetInternalType(creature))) { return(0); } SkinMap[GetLongID(creature)] = skinID; UpdateSkin(creature); return(skinID); }
internal static AnimalSkin GetSkin(Character creature) { if (!ModApi.HasSkins(ModApi.GetInternalType(creature)) || !ModApi.IsInDatabase(creature)) { return(null); } int skinID; string type = ModApi.GetInternalType(creature); // Take care of Strays and WildHorses if (Creator.StrayInfo != null && ModApi.IsStray(creature)) { skinID = Creator.StrayInfo.SkinID; } else if (Creator.HorseInfo != null && ModApi.IsWildHorse(creature)) { skinID = Creator.HorseInfo.SkinID; } // Take care of FarmAnimal subtypes else if (creature is FarmAnimal animal) { skinID = SkinMap[GetLongID(creature)]; if (ModApi.HasBabySprite(type) && animal.age.Value < animal.ageWhenMature.Value) { type = "baby" + type; } else if (ModApi.HasShearedSprite(type) && animal.showDifferentTextureWhenReadyForHarvest.Value && animal.currentProduce.Value <= 0) { type = "sheared" + type; } } // Take care of owned Pets and Horses else { skinID = SkinMap[GetLongID(creature)]; } if (!Assets[ModApi.GetInternalType(creature)].ContainsKey(skinID)) { ModEntry.SMonitor.Log($"{creature.Name}'s skin ID no longer exists in `/assets/skins`. Skin will be randomized.", LogLevel.Alert); skinID = RandomizeSkin(creature); } else if (skinID == 0) { return(null); } return(GetSkin(type, skinID)); }
internal static int GetRandomSkin(string type) { type = Sanitize(type); if (!ModApi.HasSkins(type)) { return(0); } // ** TODO: Find out why erroring with stray spawn, issue in GetSkin likely. // Issue related to lack of cat skins? Fix this // Android: A Button works, but not right click int randomLookup = Randomizer.Next(0, Assets[type].Keys.Count); return(Assets[type].ElementAt(randomLookup).Key); }