Example #1
0
        public static void Junimo_ctor_Postfix(
            Junimo __instance,
            Vector2 position,
            int whichArea)
        {
            if (whichArea >= Bundles.CustomAreaInitialIndex &&
                !Bundles.IsAbandonedJojaMartBundleAvailableOrComplete())
            {
                CustomCommunityCentre.Data.BundleMetadata bundleMetadata = Bundles.GetAllCustomBundleMetadataEntries()
                                                                           .First(bmd => Bundles.GetCustomAreaNumberFromName(bmd.AreaName) == whichArea);

                __instance.friendly.Value = Bundles.IsAreaComplete(cc: Bundles.CC, areaNumber: whichArea);

                int restoreAreaPhase = Reflection.GetField
                                       <int>
                                           (obj: Bundles.CC, name: "restoreAreaPhase")
                                       .GetValue();
                if (restoreAreaPhase != CommunityCenter.PHASE_junimoAppear)
                {
                    Reflection.GetField
                    <Netcode.NetColor>
                        (obj: __instance, name: "color")
                    .GetValue()
                    .Set(bundleMetadata.Colour);
                }
            }
        }
Example #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: "???");
        }
Example #3
0
        public static void ResetSharedState_Postfix(
            CommunityCenter __instance)
        {
            if (Game1.MasterPlayer.mailReceived.Contains("JojaMember"))
            {
                return;
            }

            if (__instance.areAllAreasComplete())
            {
                if (Bundles.AreAnyCustomAreasLoaded())
                {
                    __instance.numberOfStarsOnPlaque.Value += 1;
                }
            }
            else
            {
                if (__instance.mapPath.Value == "Maps\\CommunityCenter_Refurbished")
                {
                    // When all base areas are complete,
                    // CommunityCenter.TransferDataFromSavedLocation() will call CommunityCenter.areAllAreasComplete(),
                    // which will return true and set the map as if the CC were complete.
                    // If any custom areas are incomplete,
                    // we undo the map change here to revert to the incomplete state map.
                    __instance.mapPath.Value = "Maps\\CommunityCenter_Ruins";
                    __instance.updateMap();
                }
                foreach (int areaNumber in Bundles.CustomAreasComplete.Keys)
                {
                    if (Bundles.ShouldNoteAppearInCustomArea(cc: __instance, areaNumber: areaNumber))
                    {
                        string areaName = Bundles.GetCustomAreaNameFromNumber(areaNumber);
                        CustomCommunityCentre.Data.BundleMetadata bundleMetadata = Bundles.GetAllCustomBundleMetadataEntries()
                                                                                   .First(bmd => bmd.AreaName == areaName);

                        Vector2 tileLocation = Utility.PointToVector2(bundleMetadata.NoteTileLocation + bundleMetadata.JunimoOffsetFromNoteTileLocation);

                        Junimo j = new (position : tileLocation * Game1.tileSize, whichArea : areaNumber);
                        __instance.characters.Add(j);
                    }
                }
            }

            CustomCommunityCentre.Events.Game.InvokeOnResetSharedState(communityCentre: __instance);
        }
Example #4
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;
            }
        }