示例#1
0
        // Not applied in .NET Framework versions below 5.0: FatalExecutionEngineError
        public static void GetNotePosition_Postfix(
            CommunityCenter __instance,
            ref Point __result,
            int area)
        {
            CustomCommunityCentre.Data.BundleMetadata bundleMetadata = Bundles.GetCustomBundleMetadataFromAreaNumber(area);

            if (Bundles.IsAbandonedJojaMartBundleAvailableOrComplete() || bundleMetadata == null)
            {
                return;
            }

            __result = bundleMetadata.NoteTileLocation;
        }
示例#2
0
        public static void GetRewardNameForArea_Postfix(
            JunimoNoteMenu __instance,
            int whichArea,
            ref string __result)
        {
            CustomCommunityCentre.Data.BundleMetadata bundleMetadata = Bundles.GetCustomBundleMetadataFromAreaNumber(whichArea);

            if (Bundles.IsAbandonedJojaMartBundleAvailableOrComplete() || bundleMetadata == null)
            {
                return;
            }

            __result = CustomCommunityCentre.Data.BundleMetadata.GetLocalisedString(
                dict: bundleMetadata.AreaRewardMessage,
                defaultValue: "???");
        }
示例#3
0
        public static void AreaDisplayNameFromNumber_Postfix(
            // Static
            ref string __result,
            int areaNumber)
        {
            CustomCommunityCentre.Data.BundleMetadata bundleMetadata = Bundles.GetCustomBundleMetadataFromAreaNumber(areaNumber);

            if (Bundles.IsAbandonedJojaMartBundleAvailableOrComplete() || bundleMetadata == null)
            {
                return;
            }

            string displayName = CustomCommunityCentre.Data.BundleMetadata.GetLocalisedString(
                dict: bundleMetadata.AreaDisplayName,
                defaultValue: bundleMetadata.AreaName);

            __result = displayName;
        }
示例#4
0
        public static bool PickFarmEvent_Prefix(
            ref StardewValley.Events.FarmEvent __result)
        {
            try
            {
                if (Game1.weddingToday)
                {
                    return(true);
                }
                foreach (Farmer onlineFarmer in Game1.getOnlineFarmers())
                {
                    Friendship spouseFriendship = onlineFarmer.GetSpouseFriendship();
                    if (spouseFriendship != null && spouseFriendship.IsMarried() && spouseFriendship.WeddingDate == Game1.Date)
                    {
                        return(true);
                    }
                }

                foreach (KeyValuePair <string, int> areaNameAndNumber in Bundles.CustomAreaNamesAndNumbers)
                {
                    string mailId = string.Format(Bundles.MailAreaCompleted, areaNameAndNumber.Key);
                    CustomCommunityCentre.Data.BundleMetadata bundleMetadata
                        = Bundles.GetCustomBundleMetadataFromAreaNumber(areaNameAndNumber.Value);
                    if (bundleMetadata?.AreaCompleteCutscene != null &&
                        (Game1.MasterPlayer.mailForTomorrow.Contains(mailId) || Game1.player.mailForTomorrow.Contains($"{mailId}%&NL&%")))
                    {
                        int whichEvent = areaNameAndNumber.Value;
                        __result = new CustomCommunityCentre.AreaCompleteNightEvent(whichEvent);
                        Log.D($"Adding {nameof(CustomCommunityCentre.AreaCompleteNightEvent)} for area {areaNameAndNumber.Value} ({areaNameAndNumber.Key})");
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                HarmonyPatches.ErrorHandler(e);
            }
            return(true);
        }
示例#5
0
        public static void GetAreaBounds_Postfix(
            CommunityCenter __instance,
            ref Rectangle __result,
            int area)
        {
            CustomCommunityCentre.Data.BundleMetadata bundleMetadata = Bundles.GetCustomBundleMetadataFromAreaNumber(area);

            if (Bundles.IsAbandonedJojaMartBundleAvailableOrComplete())
            {
                return;
            }

            // Override any overlapping bundle areas
            foreach (CustomCommunityCentre.Data.BundleMetadata bmd in Bundles.GetAllCustomBundleMetadataEntries())
            {
                if (bmd.AreaName != bundleMetadata?.AreaName && __result != Rectangle.Empty)
                {
                    Rectangle intersection = Rectangle.Intersect(__result, bmd.AreaBounds);
                    if (intersection.Width > 0)
                    {
                        __result.X     += intersection.Width;
                        __result.Width -= intersection.Width;
                    }
                    intersection = Rectangle.Intersect(__result, bmd.AreaBounds);
                    if (intersection.Height > 0)
                    {
                        __result.Y      += intersection.Height;
                        __result.Height -= intersection.Height;
                    }
                }
            }

            // Apply area bounds to custom areas
            if (bundleMetadata != null)
            {
                __result = bundleMetadata.AreaBounds;
            }
        }