/// <summary>
        /// GetNotePosition() throws FatalEngineExecutionError when patched.
        /// Mimics ShouldNoteAppearInArea() using a static position in place of GetNotePosition().
        /// </summary>
        public static bool ShouldNoteAppearInArea_Prefix(CommunityCenter __instance, ref bool __result, int area)
        {
            try
            {
                if (Bundles.IsCommunityCentreComplete() && Bundles.IsAbandonedJojaMartBundleAvailable() &&
                    (Game1.netWorldState.Value.BundleData.Keys.Any(key => key.StartsWith(Bundles.CommunityCentreAreaName))))
                {
                    Log.D($"ShouldNoteAppearInArea removing custom bundle data.",
                          ModEntry.Instance.Config.DebugMode);
                    Bundles.SaveAndUnloadBundleData();
                }

                if (area != Bundles.CommunityCentreAreaNumber)
                {
                    return(true);
                }
                __result = !Bundles.IsCommunityCentreKitchenComplete() &&
                           __instance.numberOfCompleteBundles() > (ModEntry.Instance.Config.DebugMode ? 0 : 2);
                return(false);
            }
            catch (ArgumentOutOfRangeException e)
            {
                Log.D($"Error in {nameof(ShouldNoteAppearInArea_Prefix)}, may be non-critical:\n{e}",
                      ModEntry.Instance.Config.DebugMode);
                return(false);
            }
            catch (Exception e)
            {
                Log.E($"Error in {nameof(ShouldNoteAppearInArea_Prefix)}:\n{e}");
            }

            return(true);
        }
        /// <summary>
        /// Basic implementation of new CommunityCenter area.
        /// </summary>
        public static bool AreaNameFromNumber_Prefix(ref string __result, int areaNumber)
        {
            try
            {
                if (areaNumber != Bundles.CommunityCentreAreaNumber || Bundles.IsCommunityCentreComplete() || Bundles.IsAbandonedJojaMartBundleAvailable())
                {
                    return(true);
                }
                __result = Bundles.CommunityCentreAreaName;
                return(false);
            }
            catch (Exception e)
            {
                Log.E($"Error in {nameof(AreaNameFromNumber_Prefix)}:\n{e}");
            }

            return(true);
        }
        /// <summary>
        /// Basic implementation of new CommunityCenter area.
        /// </summary>
        public static bool AreaDisplayNameFromNumber_Prefix(ref string __result, int areaNumber)
        {
            try
            {
                if (areaNumber != Bundles.CommunityCentreAreaNumber || Bundles.IsCommunityCentreComplete() || Bundles.IsAbandonedJojaMartBundleAvailable())
                {
                    return(true);
                }
                __result = ModEntry.Instance.Helper.Translation.Get("world.community_centre.kitchen");
                return(false);
            }
            catch (Exception e)
            {
                Log.E($"Error in {nameof(AreaDisplayNameFromNumber_Prefix)}:\n{e}");
            }

            return(true);
        }
        /// <summary>
        /// GetNotePosition() throws FatalEngineExecutionError when patched.
        /// Mimics IsJunimoNoteAtArea() using a static p value in place of GetNotePosition().
        /// </summary>
        public static bool IsJunimoNoteAtArea_Prefix(CommunityCenter __instance, ref bool __result, int area)
        {
            try
            {
                Log.T($"CC_IsJunimoNoteAtArea_Prefix(area={area})");
                if (area != Bundles.CommunityCentreAreaNumber || Bundles.IsCommunityCentreComplete() || Bundles.IsAbandonedJojaMartBundleAvailable())
                {
                    return(true);
                }

                var p = Bundles.CommunityCentreNotePosition;
                __result = __instance.map.GetLayer("Buildings").Tiles[p.X, p.Y] != null;
                return(false);
            }
            catch (Exception e)
            {
                Log.E($"Error in {nameof(IsJunimoNoteAtArea_Prefix)}:\n{e}");
            }

            return(true);
        }
        /// <summary>
        /// GetNotePosition() throws FatalEngineExecutionError when patched.
        /// Mimics AddJunimoNote() using a constant position value in place of GetNotePosition().
        /// </summary>
        public static bool AddJunimoNote_Prefix(CommunityCenter __instance, int area)
        {
            try
            {
                Log.T($"CC_AddJunimoNote_Prefix(area={area})");

                if (area != Bundles.CommunityCentreAreaNumber || Bundles.IsCommunityCentreComplete() || Bundles.IsAbandonedJojaMartBundleAvailable())
                {
                    return(true);
                }

                var p = Bundles.CommunityCentreNotePosition;

                var          tileFrames = CommunityCenter.getJunimoNoteTileFrames(area, __instance.Map);
                const string layer      = "Buildings";
                __instance.Map.GetLayer(layer).Tiles[p.X, p.Y]
                    = new AnimatedTile(__instance.Map.GetLayer(layer), tileFrames, 70L);
                Game1.currentLightSources.Add(new LightSource(
                                                  4, new Vector2(p.X * 64, p.Y * 64), 1f));
                __instance.temporarySprites.Add(new TemporaryAnimatedSprite(
                                                    6, new Vector2(p.X * 64, p.Y * 64), Color.White)
                {
                    layerDepth   = 1f,
                    interval     = 50f,
                    motion       = new Vector2(1f, 0f),
                    acceleration = new Vector2(-0.005f, 0f)
                });
                __instance.temporarySprites.Add(new TemporaryAnimatedSprite(
                                                    6, new Vector2(p.X * 64 - 12, p.Y * 64 - 12), Color.White)
                {
                    scale        = 0.75f,
                    layerDepth   = 1f,
                    interval     = 50f,
                    motion       = new Vector2(1f, 0f),
                    acceleration = new Vector2(-0.005f, 0f),
                    delayBeforeAnimationStart = 50
                });
                __instance.temporarySprites.Add(new TemporaryAnimatedSprite(
                                                    6, new Vector2(p.X * 64 - 12, p.Y * 64 + 12), Color.White)
                {
                    layerDepth   = 1f,
                    interval     = 50f,
                    motion       = new Vector2(1f, 0f),
                    acceleration = new Vector2(-0.005f, 0f),
                    delayBeforeAnimationStart = 100
                });
                __instance.temporarySprites.Add(new TemporaryAnimatedSprite(
                                                    6, new Vector2(p.X * 64, p.Y * 64), Color.White)
                {
                    layerDepth   = 1f,
                    scale        = 0.75f,
                    interval     = 50f,
                    motion       = new Vector2(1f, 0f),
                    acceleration = new Vector2(-0.005f, 0f),
                    delayBeforeAnimationStart = 150
                });

                return(false);
            }
            catch (Exception e)
            {
                Log.E($"Error in {nameof(AddJunimoNote_Prefix)}:\n{e}");
            }

            return(true);
        }
        /// <summary>
        /// GetAreaBounds() throws FatalEngineExecutionError when patched.
        /// Mimics LoadArea() using a static areaToRefurbish value in place of GetAreaBounds().
        /// </summary>
        public static bool LoadArea_Prefix(CommunityCenter __instance, int area, bool showEffects)
        {
            try
            {
                Log.T($"CC_LoadArea_Prefix(area={area})");
                if (area != Bundles.CommunityCentreAreaNumber || Bundles.IsCommunityCentreComplete() || Bundles.IsAbandonedJojaMartBundleAvailable())
                {
                    return(true);
                }

                var areaToRefurbish = area != Bundles.CommunityCentreAreaNumber
                                        ? ModEntry.Instance.Helper.Reflection.GetMethod(__instance, "getAreaBounds").Invoke <Rectangle>(area)
                                        : Bundles.CommunityCentreArea;
                var refurbishedMap = Game1.game1.xTileContent.Load <Map>("Maps\\CommunityCenter_Refurbished");

                //PyTK.Extensions.PyMaps.mergeInto(__instance.Map, refurbishedMap, Vector2.Zero, ModEntry.CommunityCentreArea);
                //__instance.addLightGlows();
                //return false;

                var adjustMapLightPropertiesForLamp = ModEntry.Instance.Helper.Reflection.GetMethod(
                    __instance, "adjustMapLightPropertiesForLamp");

                for (var x = areaToRefurbish.X; x < areaToRefurbish.Right; x++)
                {
                    for (var y = areaToRefurbish.Y; y < areaToRefurbish.Bottom; y++)
                    {
                        if (refurbishedMap.GetLayer("Back").Tiles[x, y] != null)
                        {
                            __instance.map.GetLayer("Back").Tiles[x, y].TileIndex
                                = refurbishedMap.GetLayer("Back").Tiles[x, y].TileIndex;
                        }
                        if (refurbishedMap.GetLayer("Buildings").Tiles[x, y] != null)
                        {
                            __instance.map.GetLayer("Buildings").Tiles[x, y] = new StaticTile(
                                __instance.map.GetLayer("Buildings"), __instance.map.TileSheets[0],
                                BlendMode.Alpha, refurbishedMap.GetLayer("Buildings").Tiles[x, y].TileIndex);
                            adjustMapLightPropertiesForLamp.Invoke(
                                refurbishedMap.GetLayer("Buildings").Tiles[x, y].TileIndex, x, y, "Buildings");
                            if (Game1.player.getTileX() == x && Game1.player.getTileY() == y)
                            {
                                Game1.player.Position = new Vector2(2080f, 576f);
                            }
                            if (refurbishedMap.GetLayer("Buildings").Tiles[x, y].TileIndex == Bundles.FridgeTileIndexes[Bundles.FridgeTilesToUse][1])
                            {
                                Bundles.FridgeTilePosition = new Vector2(x, y);
                            }
                        }
                        else
                        {
                            __instance.map.GetLayer("Buildings").Tiles[x, y] = null;
                        }
                        if (refurbishedMap.GetLayer("Front").Tiles[x, y] != null)
                        {
                            __instance.map.GetLayer("Front").Tiles[x, y] = new StaticTile(
                                __instance.map.GetLayer("Front"), __instance.map.TileSheets[0],
                                BlendMode.Alpha, refurbishedMap.GetLayer("Front").Tiles[x, y].TileIndex);
                            adjustMapLightPropertiesForLamp.Invoke(
                                refurbishedMap.GetLayer("Front").Tiles[x, y].TileIndex, x, y, "Front");
                        }
                        else
                        {
                            __instance.map.GetLayer("Front").Tiles[x, y] = null;
                        }
                        if (refurbishedMap.GetLayer("Paths").Tiles[x, y] != null &&
                            refurbishedMap.GetLayer("Paths").Tiles[x, y].TileIndex == 8)
                        {
                            Game1.currentLightSources.Add(new LightSource(
                                                              4, new Vector2(x * 64, y * 64), 2f));
                        }
                        if (showEffects && Game1.random.NextDouble() < 0.58 &&
                            refurbishedMap.GetLayer("Buildings").Tiles[x, y] == null)
                        {
                            __instance.temporarySprites.Add(new TemporaryAnimatedSprite(
                                                                6, new Vector2(x * 64, y * 64), Color.White)
                            {
                                layerDepth   = 1f,
                                interval     = 50f,
                                motion       = new Vector2(Game1.random.Next(17) / 10f, 0f),
                                acceleration = new Vector2(-0.005f, 0f),
                                delayBeforeAnimationStart = Game1.random.Next(500)
                            });
                        }
                    }
                }
                Log.D("End of LoadAreaPrefix",
                      ModEntry.Instance.Config.DebugMode);
                return(false);
            }
            catch (Exception e)
            {
                Log.E($"Error in {nameof(LoadArea_Prefix)}:\n{e}");
            }

            return(true);
        }
        /// <summary>
        /// Basic implementation of new CommunityCenter area.
        /// </summary>
        public static bool AreaNumberFromLocation_Prefix(ref int __result, Vector2 tileLocation)
        {
            try
            {
                Log.T($"CC_AreaNumberFromLocation_Prefix(tileLocation={tileLocation.ToString()})");
                if (!new Rectangle(0, 0, 11, 11).Contains(Utility.Vector2ToPoint(tileLocation)) || Bundles.IsCommunityCentreComplete() || Bundles.IsAbandonedJojaMartBundleAvailable())
                {
                    return(true);
                }
                __result = Bundles.CommunityCentreAreaNumber;
                return(false);
            }
            catch (Exception e)
            {
                Log.E($"Error in {nameof(AreaNumberFromLocation_Prefix)}:\n{e}");
            }

            return(true);
        }