예제 #1
0
        public static void GameLocation_MakeMapModifications_Prefix(GameLocation __instance, HashSet <string> ____appliedMapOverrides)
        {
            if (!ModEntry.config.EnableMod || !Game1.player.IsMainPlayer)
            {
                return;
            }

            Dictionary <string, CustomRenovationData> renovationDict = ModEntry.PHelper.Content.Load <Dictionary <string, CustomRenovationData> >("CustomRenovations", ContentSource.GameContent);

            ModEntry.PMonitor.Log($"Checking {renovationDict.Count} renovations with {__instance.Name}");
            foreach (var kvp in renovationDict)
            {
                ModEntry.PMonitor.Log($"Checking {kvp.Key} location {kvp.Value.gameLocation} with {__instance.Name}; mail: {Game1.player.mailReceived.Contains(kvp.Key)}");
                if (kvp.Value.gameLocation == __instance.Name)
                {
                    if (____appliedMapOverrides.Contains(kvp.Key))
                    {
                        ____appliedMapOverrides.Remove(kvp.Key);
                    }
                    if (Game1.player.mailReceived.Contains(kvp.Key))
                    {
                        ModEntry.PMonitor.Log($"Adding renovation {kvp.Key} to {__instance.Name}");
                        __instance.ApplyMapOverride(kvp.Value.mapPath, kvp.Value.SourceRect(), kvp.Value.SourceRect());
                    }
                }
            }
        }
예제 #2
0
        private static void ApplyMapOverride(string spouseName, string map_name, string override_key_name, Rectangle?source_rect = null, Rectangle?destination_rect = null)
        {
            if (Config.EnableMod && outdoorAreas == null)
            {
                return;
            }
            GameLocation l = Game1.getLocationFromName(Config.EnableMod && outdoorAreas.dict.TryGetValue(spouseName, out OutdoorArea area) ? area.location : "Farm");

            if (l == null)
            {
                l = Game1.getFarm();
            }
            SMonitor.Log($"Applying patio map override for {spouseName} in {l.Name}");
            if (AccessTools.FieldRefAccess <GameLocation, HashSet <string> >(l, "_appliedMapOverrides").Contains("spouse_patio"))
            {
                AccessTools.FieldRefAccess <GameLocation, HashSet <string> >(l, "_appliedMapOverrides").Remove("spouse_patio");
            }
            if (AccessTools.FieldRefAccess <GameLocation, HashSet <string> >(l, "_appliedMapOverrides").Contains(spouseName + "_spouse_patio"))
            {
                AccessTools.FieldRefAccess <GameLocation, HashSet <string> >(l, "_appliedMapOverrides").Remove(spouseName + "_spouse_patio");
            }
            l.ApplyMapOverride(map_name, spouseName + "_spouse_patio", source_rect, destination_rect);
        }