예제 #1
0
        /************************
        ** 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);
        }
예제 #2
0
        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));
        }
예제 #3
0
        /// <summary>Adds the given Pet, Horse, or FarmAnimal into the A&S database</summary>
        internal void AddCreature(Character creature, int skinID = 0, Farmer owner = null)
        {
            string type = ModApi.GetInternalType(creature);

            if (ModApi.IsInDatabase(creature) || !ModApi.IsRegisteredType(type))
            {
                return;
            }

            // Set internal IDs
            SetShortID(creature, GetUnusedShortID());
            IDToCategory[GetLongID(creature)] = ModApi.GetCreatureCategory(type);

            // Set ownership
            if (creature is Horse)
            {
                if (owner != null)
                {
                    HorseOwnershipMap.Add(GetLongID(creature), owner);
                    // DEBUG
                    Monitor.Log($"Horse ID: {GetShortID(creature)}\nOwner: {owner.Name}", LogLevel.Debug);
                }
                else
                {
                    Monitor.Log($"No adopter able to be detected. Horse {GetShortID(creature)} will be owned by the host player.", LogLevel.Debug);
                    HorseOwnershipMap.Add(GetLongID(creature), Game1.MasterPlayer);
                }
            }

            // Give a skin
            if (skinID != 0)
            {
                SetSkin(creature, skinID);
            }
            else
            {
                RandomizeSkin(creature);
            }
        }
예제 #4
0
        /// <summary>Adds the given Pet, Horse, or FarmAnimal into the A&S database</summary>
        internal void AddCreature(Character creature, int skinID = 0)
        {
            string type = ModApi.GetInternalType(creature);

            if (ModApi.IsInDatabase(creature) || !ModApi.IsRegisteredType(type))
            {
                return;
            }

            // Set internal IDs
            SetShortID(creature, GetUnusedShortID());
            IDToCategory[GetLongID(creature)] = ModApi.GetCreatureCategory(type);

            // Give a skin
            if (skinID != 0)
            {
                SetSkin(creature, skinID);
            }
            else
            {
                RandomizeSkin(creature);
            }
        }
예제 #5
0
 internal static int RandomizeSkin(Character creature)
 {
     return(SetSkin(creature, GetRandomSkin(ModApi.GetInternalType(creature))));
 }