Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 2
0
        public static void ShouldNoteAppearInArea_Postfix(
            CommunityCenter __instance,
            ref bool __result,
            int area)
        {
            if (Bundles.IsAbandonedJojaMartBundleAvailableOrComplete() || !Bundles.IsCustomArea(area) || !Bundles.AreAnyCustomAreasLoaded())
            {
                return;
            }

            __result = Bundles.ShouldNoteAppearInCustomArea(cc: __instance, areaNumber: area);
        }
Ejemplo n.º 3
0
        public static void AreaNumberFromName_Postfix(
            // Static
            ref int __result,
            string name)
        {
            int id = Bundles.GetCustomAreaNumberFromName(areaName: name);

            if (Bundles.IsAbandonedJojaMartBundleAvailableOrComplete() || id < 0)
            {
                return;
            }

            __result = id;
        }
Ejemplo n.º 4
0
        public static void AreaNameFromNumber_Postfix(
            CommunityCenter __instance,
            ref string __result,
            int areaNumber)
        {
            string name = Bundles.GetCustomAreaNameFromNumber(areaNumber: areaNumber);

            if (Bundles.IsAbandonedJojaMartBundleAvailableOrComplete() || string.IsNullOrEmpty(name))
            {
                return;
            }

            __result = name;
        }
Ejemplo n.º 5
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;
        }
Ejemplo n.º 6
0
        public static void JunimoNoteMenu_ctor_Postfix(
            JunimoNoteMenu __instance,
            bool fromGameMenu,
            int area,
            bool fromThisMenu)
        {
            CommunityCenter cc = Bundles.CC;

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

            IReflectedField <int> whichAreaField = Reflection.GetField
                                                   <int>
                                                       (__instance, "whichArea");

            bool isAreaSet       = false;
            bool isNavigationSet = false;

            foreach (string areaName in Bundles.GetAllAreaNames())
            {
                int areaNumber = CommunityCenter.getAreaNumberFromName(areaName);

                // Set default area for menu view with custom areas
                if (!isAreaSet &&
                    fromGameMenu && !fromThisMenu && !isAreaSet &&
                    cc.shouldNoteAppearInArea(areaNumber) && !Bundles.IsAreaComplete(cc: cc, areaNumber: areaNumber))
                {
                    area = areaNumber;
                    whichAreaField.SetValue(area);
                    isAreaSet = true;
                }

                // Show navigation arrows when custom areas
                if (!isNavigationSet &&
                    areaNumber >= 0 && areaNumber != area && cc.shouldNoteAppearInArea(areaNumber))
                {
                    __instance.areaNextButton.visible = true;
                    __instance.areaBackButton.visible = true;
                    isNavigationSet = true;
                }

                if (isAreaSet && isNavigationSet)
                {
                    break;
                }
            }
        }
Ejemplo n.º 7
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: "???");
        }
Ejemplo n.º 8
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;
        }
Ejemplo n.º 9
0
        public static void AreaNumberFromLocation_Postfix(
            CommunityCenter __instance,
            ref int __result,
            Vector2 tileLocation)
        {
            CustomCommunityCentre.Data.BundleMetadata bundleMetadata = Bundles.GetAllCustomBundleMetadataEntries()
                                                                       .FirstOrDefault(bmd => bmd.AreaBounds.Contains(Utility.Vector2ToPoint(tileLocation)));
            int areaNumber = bundleMetadata != null
                                ? Bundles.GetCustomAreaNumberFromName(bundleMetadata.AreaName)
                                : -1;

            if (Bundles.IsAbandonedJojaMartBundleAvailableOrComplete() || areaNumber < 0)
            {
                return;
            }

            __result = areaNumber;
        }
Ejemplo n.º 10
0
 internal static void DayStartedBehaviours(CommunityCenter cc)
 {
     // Load in new community centre area-bundle data if ready
     if (Bundles.IsAbandonedJojaMartBundleAvailableOrComplete())
     {
         Log.D("Community centre and abandoned joja-mart complete, doing nothing.",
               ModEntry.Config.DebugMode);
     }
     else if (Bundles.IsCommunityCentreDefinitelyComplete(cc))
     {
         Log.D("Community centre complete, unloading any bundle data.",
               ModEntry.Config.DebugMode);
         BundleManager.Save(cc);
     }
     else
     {
         Log.D("Community centre incomplete, loading bundle data.",
               ModEntry.Config.DebugMode);
         BundleManager.Load(cc);
     }
 }
Ejemplo n.º 11
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;
            }
        }
Ejemplo n.º 12
0
        public static void GetMessageForAreaCompletion_Postfix(
            CommunityCenter __instance,
            ref string __result)
        {
            int areaNumber = Reflection.GetField
                             <int>
                                 (obj: __instance, name: "restoreAreaIndex")
                             .GetValue();
            string areaName           = Bundles.GetCustomAreaNameFromNumber(areaNumber);
            string areaNameAsAssetKey = Bundles.GetAreaNameAsAssetKey(areaName);

            if (Bundles.IsAbandonedJojaMartBundleAvailableOrComplete() ||
                !Bundles.IsCustomArea(areaNumber) ||
                string.IsNullOrWhiteSpace(areaName))
            {
                return;
            }

            string message = Game1.content.LoadString(
                $"Strings\\Locations:CommunityCenter_AreaCompletion_{areaNameAsAssetKey}",
                Game1.player.Name);

            __result = message;
        }