Esempio n. 1
0
 /// <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("");
 }
Esempio n. 2
0
        /************************
        ** 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>());
        }
Esempio n. 3
0
 public static bool HasShearedSprite(string type)
 {
     return(ModEntry.Assets.ContainsKey("sheared" + ModEntry.Sanitize(type)));
 }
Esempio n. 4
0
 public static bool HasBabySprite(string type)
 {
     return(ModEntry.Assets.ContainsKey("baby" + ModEntry.Sanitize(type)));
 }
Esempio n. 5
0
 /// <summary>Returns whether the given type contains the word "cow"</summary>
 public static bool IsCow(string type)
 {
     return(ModEntry.Sanitize(type).Contains("cow"));
 }
Esempio n. 6
0
 /// <summary>Returns whether the given type contains the word "chicken"</summary>
 public static bool IsChicken(string type)
 {
     return(ModEntry.Sanitize(type).Contains("chicken"));
 }
Esempio n. 7
0
 /// <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);
 }
Esempio n. 8
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)));
 }