/// <summary>Returns the string used to reference the given creature's type within A&S</summary> public static string GetInternalType(Character creature) { if (creature is Pet || creature is Horse) { return(ModEntry.Sanitize(creature.GetType().Name)); } else if (creature is FarmAnimal animal) { return(ModEntry.Sanitize(animal.type.Value)); } return(""); }
/************************ ** Public methods *************************/ /// <summary>Registers a creature type to handle skin support for. Must inherit from one of the classes: Pet, Horse, FarmAnimal.</summary> /// <param name="id">The filename for the animal. This will also be its internal ID within Adopt & Skin.</param> /// <param name="hasBaby">If this animal type has a baby skin.</param> /// <param name="canShear">If this animal type has a sheared skin.</param> public static void RegisterType(string id, Type type, bool hasBaby = true, bool canShear = false) { id = ModEntry.Sanitize(id); if (ModEntry.Assets.ContainsKey(id)) { ModEntry.SMonitor.Log("Unable to register type, type already registered: " + id, LogLevel.Debug); return; } // Ensure inherits from one of the accepted classes and register class-specific information if (typeof(Pet).IsAssignableFrom(type)) { HandledPetTypes.Add(id); ModEntry.PetTypeMap.Add(id, type); if (!Stray.PetConstructors.ContainsKey(type)) { Stray.PetConstructors.Add(type, () => new Pet()); } } else if (typeof(Horse).IsAssignableFrom(type)) { HandledHorseTypes.Add(id); ModEntry.HorseTypeMap.Add(id, type); } else if (typeof(FarmAnimal).IsAssignableFrom(type)) { HandledFarmAnimalTypes.Add(id); // Registers the Baby and Sheared sprites, if given if (hasBaby) { RegisterType("Baby" + id, typeof(FarmAnimal), false, false); } if (canShear) { RegisterType("Sheared" + id, typeof(FarmAnimal), false, false); } } else { ModEntry.SMonitor.Log("Unable to register type, type does not inherit from any of the classes Pet, Horse, or FarmAnimal: " + id, LogLevel.Debug); return; } // Create an entry for assets to be added in ModEntry ModEntry.Assets.Add(id, new Dictionary <int, AnimalSkin>()); }
public static bool HasShearedSprite(string type) { return(ModEntry.Assets.ContainsKey("sheared" + ModEntry.Sanitize(type))); }
public static bool HasBabySprite(string type) { return(ModEntry.Assets.ContainsKey("baby" + ModEntry.Sanitize(type))); }
/// <summary>Returns whether the given type contains the word "cow"</summary> public static bool IsCow(string type) { return(ModEntry.Sanitize(type).Contains("cow")); }
/// <summary>Returns whether the given type contains the word "chicken"</summary> public static bool IsChicken(string type) { return(ModEntry.Sanitize(type).Contains("chicken")); }
/// <summary>Returns true if the given creature subtype (i.e. Dog, Cat, WhiteChicken) has at least one custom skin loaded for it in A&S.</summary> public static bool HasSkins(string type) { return(ModEntry.Assets.ContainsKey(ModEntry.Sanitize(type)) && (ModEntry.Assets[ModEntry.Sanitize(type)]).Count > 0); }
/// <summary>Returns true if the given creature subtype (i.e. Dog, Cat, WhiteChicken) is being handled by A&S</summary> public static bool IsRegisteredType(string type) { return(ModEntry.Assets.ContainsKey(ModEntry.Sanitize(type))); }