示例#1
0
        public static bool CheckForMissedRewards_Prefix(
            CommunityCenter __instance)
        {
            try
            {
                Dictionary <int, List <int> > areaNumbersAndBundleNumbers = Reflection.GetField
                                                                            <Dictionary <int, List <int> > >
                                                                                (__instance, "areaToBundleDictionary")
                                                                            .GetValue();

                __instance.missedRewardsChest.Value.items.Clear();

                bool        hasUnclaimedRewards = false;
                List <Item> rewards             = new();
                foreach (KeyValuePair <int, List <int> > areaAndBundles in areaNumbersAndBundleNumbers)
                {
                    int  areaNumber        = areaAndBundles.Key;
                    bool isRewardUnclaimed = areaAndBundles.Value.Any() &&
                                             areaAndBundles.Value
                                             .All(bundleNumber => __instance.bundleRewards.TryGetValue(bundleNumber, out bool isUnclaimed) && isUnclaimed);
                    if (!isRewardUnclaimed || __instance.areasComplete.Count() <= areaNumber || !__instance.areasComplete[areaNumber])
                    {
                        continue;
                    }

                    hasUnclaimedRewards = true;
                    rewards.Clear();
                    JunimoNoteMenu.GetBundleRewards(areaNumber, rewards);
                    foreach (Item item in rewards)
                    {
                        __instance.missedRewardsChest.Value.addItem(item);
                    }
                }

                if ((hasUnclaimedRewards && !__instance.missedRewardsChestVisible.Value) ||
                    (!hasUnclaimedRewards && __instance.missedRewardsChestVisible.Value))
                {
                    if (!hasUnclaimedRewards)
                    {
                        Vector2 missedRewardsChestTile = Reflection.GetField
                                                         <Vector2>
                                                             (obj: __instance, name: "missedRewardsChestTile")
                                                         .GetValue();

                        Bundles.BroadcastPuffSprites(
                            multiplayer: null,
                            location: __instance,
                            tilePosition: missedRewardsChestTile);
                    }
                }
                __instance.showMissedRewardsChestEvent.Fire(arg: hasUnclaimedRewards);
                __instance.missedRewardsChestVisible.Value = hasUnclaimedRewards;
                return(false);
            }
            catch (Exception e)
            {
                HarmonyPatches.ErrorHandler(e);
            }
            return(true);
        }
示例#2
0
        public static bool MarkAreaAsComplete_Prefix(
            CommunityCenter __instance,
            int area)
        {
            try
            {
                if (Bundles.IsCustomArea(area))
                {
                    if (Game1.currentLocation is CommunityCenter)
                    {
                        Bundles.CustomAreasComplete[area] = true;

                        if (__instance.areAllAreasComplete())
                        {
                            Reflection.GetField
                            <bool>
                                (obj: __instance, name: "_isWatchingJunimoGoodbye")
                            .SetValue(true);
                        }
                    }
                    return(false);
                }
            }
            catch (Exception e)
            {
                HarmonyPatches.ErrorHandler(e);
            }
            return(true);
        }
示例#3
0
        public static bool CheckBundle_Prefix(
            CommunityCenter __instance,
            int area)
        {
            try
            {
                if (area < Bundles.CustomAreaInitialIndex)
                {
                    return(true);
                }

                Bundles.SetCustomAreaMutex(cc: __instance, areaNumber: area, isLocked: true);

                return(false);
            }
            catch (Exception e)
            {
                HarmonyPatches.ErrorHandler(e: e);
            }
            return(true);
        }
示例#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 bool InitAreaBundleConversions_Prefix(
            CommunityCenter __instance)
        {
            try
            {
                Dictionary <int, List <int> > areaBundleDict = Reflection.GetField
                                                               <Dictionary <int, List <int> > >
                                                                   (__instance, "areaToBundleDictionary")
                                                               .GetValue();

                if (Bundles.DefaultMaxArea > 0 &&
                    (areaBundleDict == null || areaBundleDict.Count == Bundles.DefaultMaxArea + 1))
                {
                    BundleManager.ReplaceAreaBundleConversions(cc: __instance);
                    return(false);
                }
            }
            catch (Exception e)
            {
                HarmonyPatches.ErrorHandler(e);
            }
            return(true);
        }