예제 #1
0
        /// <summary>The event called after the list of NPCs in a location changes.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnNpcListChanged(object sender, NpcListChangedEventArgs e)
        {
            if (!this.IsEnabled)
            {
                return;
            }

            // workaround for mines not spawning a ladder on monster levels
            if (e.Location is MineShaft mine && e.IsCurrentLocation)
            {
                if (mine.mustKillAllMonstersToAdvance() && mine.characters.All(p => p is Horse))
                {
                    IReflectedField <bool> hasLadder = this.Helper.Reflection.GetField <bool>(mine, "ladderHasSpawned");
                    if (!hasLadder.GetValue())
                    {
                        mine.createLadderAt(mine.mineEntrancePosition(Game1.player));
                        hasLadder.SetValue(true);
                    }
                }
            }

            // workaround for instantly-built tractors spawning a horse
            if (Context.IsMainPlayer && e.Location is BuildableGameLocation buildableLocation)
            {
                Horse[] horses = e.Added.OfType <Horse>().ToArray();
                if (horses.Any())
                {
                    HashSet <Guid> tractorIDs = new HashSet <Guid>(this.GetGaragesIn(buildableLocation).Select(p => p.HorseId));
                    foreach (Horse horse in horses)
                    {
                        if (tractorIDs.Contains(horse.HorseId) && !TractorManager.IsTractor(horse))
                        {
                            horse.Name = TractorManager.GetTractorName(horse.HorseId);
                        }
                    }
                }
            }
        }
예제 #2
0
        /// <summary>The event called after the list of NPCs in a location changes.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnNpcListChanged(object sender, NpcListChangedEventArgs e)
        {
            if (!this.IsEnabled)
            {
                return;
            }

            // workaround for instantly-built tractors spawning a horse
            if (Context.IsMainPlayer && e.Location is BuildableGameLocation buildableLocation)
            {
                Horse[] horses = e.Added.OfType <Horse>().ToArray();
                if (horses.Any())
                {
                    HashSet <Guid> tractorIDs = new HashSet <Guid>(this.GetGaragesIn(buildableLocation).Select(p => p.HorseId));
                    foreach (Horse horse in horses)
                    {
                        if (tractorIDs.Contains(horse.HorseId) && !TractorManager.IsTractor(horse))
                        {
                            horse.Name = TractorManager.GetTractorName(horse.HorseId);
                        }
                    }
                }
            }
        }
예제 #3
0
 private void World_NpcListChanged(object sender, NpcListChangedEventArgs e)
 {
     CheckForSwarmRoomLadderSpawn(e);
     CheckForCombatWithheldDialogue(e);
 }
예제 #4
0
 private static void WorldOnNpcListChanged(object sender, NpcListChangedEventArgs e)
 {
     throw new NotImplementedException();
 }
 /// <summary>Raised after NPCs are added or removed in a location.</summary>
 /// <param name="sender">The event sender.</param>
 /// <param name="e">The event arguments.</param>
 protected virtual void OnNpcListChanged(object sender, NpcListChangedEventArgs e)
 {
 }