Exemplo n.º 1
0
        internal void CheckForFirstHorse(object sender, NpcListChangedEventArgs e)
        {
            // FirstHorseReceived status already known
            if (Creator.FirstHorseReceived)
            {
                Helper.Events.World.NpcListChanged -= CheckForFirstHorse;
            }

            // Check for the arrival of the vanilla horse
            else if (e != null && e.Added != null)
            {
                foreach (NPC npc in e.Added)
                {
                    if (npc is Horse horse)
                    {
                        if (ModApi.IsNotATractorOrCart(horse))
                        {
                            // The first horse is given to the host player
                            AddCreature(horse, 0, Game1.MasterPlayer);
                            Creator.FirstHorseReceived = true;
                            this.Helper.Events.World.NpcListChanged -= this.CheckForFirstHorse;
                            return;
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>Returns an enumerable list of all existing Horse instances. This includes WildHorses and excludes tractors.</summary>
 public static IEnumerable <Horse> GetAllHorses()
 {
     foreach (NPC npc in Utility.getAllCharacters())
     {
         if (npc is Horse horse && ModApi.IsNotATractorOrCart(horse))
         {
             yield return(horse);
         }
     }
     // Horses being ridden don't technically exist, and must be added separately
     foreach (Horse horse in ModEntry.BeingRidden)
     {
         yield return(horse);
     }
 }