/// <summary>A Harmony prefix patch that excludes designated NPCs from visiting <see cref="IslandSouth"/>.</summary> /// <param name="npc">The NPC being checked.</param> /// <param name="__result">The original method's return value. True if the NPC can visit the island today; false if they cannot.</param> public static bool IslandSouth_CanVisitIslandToday(NPC npc, ref bool __result) { try { List <string> exclusions = ModEntry.GetNPCExclusions(npc.Name); //get exclusion data for the provided NPC if (exclusions.Exists(entry => entry.StartsWith("All", StringComparison.OrdinalIgnoreCase) || //if this NPC is excluded from everything entry.StartsWith("IslandEvent", StringComparison.OrdinalIgnoreCase) || //if this NPC is excluded from town quests entry.StartsWith("IslandVisit", StringComparison.OrdinalIgnoreCase) //OR if this NPC is excluded from item delivery quests )) { ModEntry.Instance.Monitor.Log($"Excluded NPC from possible island visit: {npc.Name}", LogLevel.Trace); __result = false; //return false (prevent this NPC visiting the island today) return(false); //skip the original method } return(true); //run the original method } catch (Exception ex) { ModEntry.Instance.Monitor.LogOnce($"Harmony patch \"{nameof(IslandSouth_CanVisitIslandToday)}\" has encountered an error and may revert to default behavior. Full error message:\n{ex.ToString()}", LogLevel.Error); return(true); //run the original method } }
/// <summary>Prevents this NPC from being invited to the movie theater, depending on their exclusion data.</summary> /// <param name="npc">The NPC being invited.</param> /// <returns>True if this NPC was excluded.</returns> public static bool ExcludeNPCFromTheaterInvitation(NPC npc) { try { List <string> exclusions = ModEntry.GetNPCExclusions(npc.Name); //get this NPC's exclusion data foreach (string exclusion in exclusions) //for each of this NPC's exclusion settings { if (exclusion.StartsWith("All", StringComparison.OrdinalIgnoreCase) || //if this NPC is excluded from everything exclusion.StartsWith("TownEvent", StringComparison.OrdinalIgnoreCase) || //OR if this NPC is excluded from town events exclusion.StartsWith("MovieInvite", StringComparison.OrdinalIgnoreCase)) //OR if this NPC is excluded from movie invitations { DrawMovieExclusionDialogue(npc); //generate exclusion dialogue for this NPC if (ModEntry.Instance.Monitor.IsVerbose) { ModEntry.Instance.Monitor.Log($"Excluded NPC from being invited to a movie: {npc.Name}", LogLevel.Trace); } return(true); //this NPC was excluded } } } catch (Exception ex) { ModEntry.Instance.Monitor.LogOnce($"Harmony patch \"{nameof(HarmonyPatch_MovieInvitation)}\" has encountered an error. Method \"{nameof(ExcludeNPCFromTheaterInvitation)}\" might revert to default behavior. Full error message:\n{ex.ToString()}", LogLevel.Error); } return(false); //this NPC was NOT excluded }
/// <summary>Checks whether the given NPC's birthday should be displayed on calendars.</summary> /// <returns>True if the NPC's birthday should be included on calendars. False if it should be excluded.</returns> public static bool IncludeBirthday(NPC npc) { List<string> excluded = ModEntry.GetNPCExclusions(npc.Name, false); //get exclusion data for this NPC if (excluded.Exists(entry => entry.StartsWith("All", StringComparison.OrdinalIgnoreCase) //if this NPC is excluded from everything || entry.StartsWith("TownEvent", StringComparison.OrdinalIgnoreCase) //OR if this NPC is excluded from town events || entry.StartsWith("Calendar", StringComparison.OrdinalIgnoreCase) //OR this NPC is excluded from birthday calendars )) { ModEntry.Instance.Monitor.VerboseLog($"Excluded NPC's birthday from a calendar: {npc.Name}"); return false; //exclude this NPC } return true; //allow this NPC }