Esempio n. 1
0
        private static bool FriendshipCanDecay(NPC npc, Friendship friendship)
        {
            if (Game1.player.spouse == npc.Name)
            {
                return(true);
            }
            if (friendship.IsDating() && friendship.Points < 2500)
            {
                return(true);
            }

            var isPreBouquet = npc.datable.Value && !friendship.IsDating() && !npc.isMarried();

            return((!isPreBouquet && friendship.Points < 2500) || (isPreBouquet && friendship.Points < 2000));
        }
Esempio n. 2
0
        /*********
        ** Public methods
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="player">The player.</param>
        /// <param name="npc">The NPC.</param>
        /// <param name="constants">The constant assumptions.</param>
        /// <param name="friendship">The current friendship data.</param>
        public FriendshipModel(SFarmer player, NPC npc, Friendship friendship, ConstantData constants)
        {
            // flags
            this.CanDate       = npc.datable.Value;
            this.IsDating      = friendship.IsDating();
            this.CanHousemate  = npc.Name == "Krobus";
            this.IsSpouse      = friendship.IsMarried() && !this.CanHousemate;
            this.IsHousemate   = friendship.IsMarried() && this.CanHousemate;
            this.IsDivorced    = friendship.IsDivorced();
            this.Status        = friendship.Status;
            this.TalkedToday   = friendship.TalkedToToday;
            this.GiftsToday    = friendship.GiftsToday;
            this.GiftsThisWeek = friendship.GiftsThisWeek;

            // points
            this.MaxPoints      = this.IsSpouse || this.IsHousemate ? constants.SpouseMaxFriendship : NPC.maxFriendshipPoints;
            this.Points         = friendship.Points;
            this.PointsPerLevel = NPC.friendshipPointsPerHeartLevel;
            this.FilledHearts   = this.Points / NPC.friendshipPointsPerHeartLevel;
            this.LockedHearts   = this.CanDate && !this.IsDating ? constants.DatingHearts : 0;
            this.EmptyHearts    = this.MaxPoints / NPC.friendshipPointsPerHeartLevel - this.FilledHearts - this.LockedHearts;
            if (this.IsSpouse || this.IsHousemate)
            {
                this.StardropPoints = constants.SpouseFriendshipForStardrop;
                this.HasStardrop    = !player.mailReceived.Contains(Constants.Constant.MailLetters.ReceivedSpouseStardrop);
            }
        }
Esempio n. 3
0
        private void drawFarmerSlot(SpriteBatch b, int i)
        {
            long   farmerID = (long)names[i];
            Farmer farmer   = Game1.getFarmerMaybeOffline(farmerID);

            if (farmer != null)
            {
                int gender = (!farmer.IsMale) ? 1 : 0;
                ClickableTextureComponent clickableTextureComponent = sprites[i];
                int       x        = clickableTextureComponent.bounds.X;
                int       y        = clickableTextureComponent.bounds.Y;
                Rectangle origClip = b.GraphicsDevice.ScissorRectangle;
                Rectangle newClip  = origClip;
                newClip.Height = Math.Min(newClip.Bottom, rowPosition(i)) - newClip.Y - 4;
                b.GraphicsDevice.ScissorRectangle = newClip;
                FarmerRenderer.isDrawingForUI     = true;
                try
                {
                    farmer.FarmerRenderer.draw(b, new FarmerSprite.AnimationFrame(farmer.bathingClothes ? 108 : 0, 0, secondaryArm: false, flip: false), farmer.bathingClothes ? 108 : 0, new Rectangle(0, farmer.bathingClothes ? 576 : 0, 16, 32), new Vector2(x, y), Vector2.Zero, 0.8f, 2, Color.White, 0f, 1f, farmer);
                }
                finally
                {
                    b.GraphicsDevice.ScissorRectangle = origClip;
                }
                FarmerRenderer.isDrawingForUI = false;
                Friendship friendship     = Game1.player.team.GetFriendship(Game1.player.UniqueMultiplayerID, farmerID);
                bool       spouse         = friendship.IsMarried();
                float      lineHeight     = Game1.smallFont.MeasureString("W").Y;
                float      russianOffsetY = (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.ru) ? ((0f - lineHeight) / 2f) : 0f;
                b.DrawString(Game1.dialogueFont, farmer.Name, new Vector2(xPositionOnScreen + IClickableMenu.borderWidth * 3 / 2 + 96 - 20, (float)(sprites[i].bounds.Y + 48) + russianOffsetY - 24f), Game1.textColor);
                string text2 = (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.pt) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635") : ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').First() : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').Last());
                if (spouse)
                {
                    text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11636") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11637"));
                }
                else if (farmer.isMarried() && !farmer.hasRoommate())
                {
                    text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_MaleNPC") : Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_FemaleNPC"));
                }
                else if (!Game1.player.isMarried() && friendship.IsDating())
                {
                    text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11639") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11640"));
                }
                else if (friendship.IsDivorced())
                {
                    text2 = ((gender == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11642") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11643"));
                }
                int width = (IClickableMenu.borderWidth * 3 + 128 - 40 + 192) / 2;
                text2 = Game1.parseText(text2, Game1.smallFont, width);
                Vector2 textSize = Game1.smallFont.MeasureString(text2);
                b.DrawString(Game1.smallFont, text2, new Vector2((float)(xPositionOnScreen + 192 + 8) - textSize.X / 2f, (float)sprites[i].bounds.Bottom - (textSize.Y - lineHeight)), Game1.textColor);
                if (spouse)
                {
                    b.Draw(Game1.objectSpriteSheet, new Vector2(xPositionOnScreen + IClickableMenu.borderWidth * 7 / 4 + 192, sprites[i].bounds.Y), Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, 801, 16, 16), Color.White, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0.88f);
                }
                else if (friendship.IsDating())
                {
                    b.Draw(Game1.objectSpriteSheet, new Vector2(xPositionOnScreen + IClickableMenu.borderWidth * 7 / 4 + 192, sprites[i].bounds.Y), Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, 458, 16, 16), Color.White, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0.88f);
                }
            }
        }
Esempio n. 4
0
        private void drawNPCSlot(SpriteBatch b, int i)
        {
            if (isCharacterSlotClickable(i) && characterSlots[i].bounds.Contains(Game1.getMouseX(), Game1.getMouseY()))
            {
                b.Draw(Game1.staminaRect, new Rectangle(xPositionOnScreen + IClickableMenu.borderWidth - 4, sprites[i].bounds.Y - 4, characterSlots[i].bounds.Width, characterSlots[i].bounds.Height - 12), Color.White * 0.25f);
            }
            sprites[i].draw(b);
            string     name           = names[i] as string;
            int        heartLevel     = Game1.player.getFriendshipHeartLevelForNPC(name);
            bool       datable        = isDatable(name);
            Friendship friendship     = getFriendship(name);
            bool       spouse         = friendship.IsMarried();
            bool       housemate      = spouse && isRoommateOfAnyone(name);
            float      lineHeight     = Game1.smallFont.MeasureString("W").Y;
            float      russianOffsetY = (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.ru || LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.ko) ? ((0f - lineHeight) / 2f) : 0f;

            b.DrawString(Game1.dialogueFont, npcNames[name], new Vector2((float)(xPositionOnScreen + IClickableMenu.borderWidth * 3 / 2 + 64 - 20 + 96) - Game1.dialogueFont.MeasureString(npcNames[name]).X / 2f, (float)(sprites[i].bounds.Y + 48) + russianOffsetY - (float)(datable ? 24 : 20)), Game1.textColor);
            for (int hearts = 0; hearts < Math.Max(Utility.GetMaximumHeartsForCharacter(Game1.getCharacterFromName(name)), 10); hearts++)
            {
                int xSource = (hearts < heartLevel) ? 211 : 218;
                if (datable && !friendship.IsDating() && !spouse && hearts >= 8)
                {
                    xSource = 211;
                }
                if (hearts < 10)
                {
                    b.Draw(Game1.mouseCursors, new Vector2(xPositionOnScreen + 320 - 8 + hearts * 32, sprites[i].bounds.Y + 64 - 28), new Rectangle(xSource, 428, 7, 6), (datable && !friendship.IsDating() && !spouse && hearts >= 8) ? (Color.Black * 0.35f) : Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.88f);
                }
                else
                {
                    b.Draw(Game1.mouseCursors, new Vector2(xPositionOnScreen + 320 - 8 + (hearts - 10) * 32, sprites[i].bounds.Y + 64), new Rectangle(xSource, 428, 7, 6), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.88f);
                }
            }
            if (datable | housemate)
            {
                string text2 = (LocalizedContentManager.CurrentLanguageCode != LocalizedContentManager.LanguageCode.pt) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635") : ((getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').First() : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11635").Split('/').Last());
                if (housemate)
                {
                    text2 = Game1.content.LoadString("Strings\\StringsFromCSFiles:Housemate");
                }
                else if (spouse)
                {
                    text2 = ((getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11636") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11637"));
                }
                else if (isMarriedToAnyone(name))
                {
                    text2 = ((getGender(name) == 0) ? Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_MaleNPC") : Game1.content.LoadString("Strings\\UI:SocialPage_MarriedToOtherPlayer_FemaleNPC"));
                }
                else if (!Game1.player.isMarried() && friendship.IsDating())
                {
                    text2 = ((getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11639") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11640"));
                }
                else if (getFriendship(name).IsDivorced())
                {
                    text2 = ((getGender(name) == 0) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11642") : Game1.content.LoadString("Strings\\StringsFromCSFiles:SocialPage.cs.11643"));
                }
                int width = (IClickableMenu.borderWidth * 3 + 128 - 40 + 192) / 2;
                text2 = Game1.parseText(text2, Game1.smallFont, width);
                Vector2 textSize = Game1.smallFont.MeasureString(text2);
                b.DrawString(Game1.smallFont, text2, new Vector2((float)(xPositionOnScreen + 192 + 8) - textSize.X / 2f, (float)sprites[i].bounds.Bottom - (textSize.Y - lineHeight)), Game1.textColor);
            }
            if (!getFriendship(name).IsMarried() && !kidsNames.Contains(name))
            {
                b.Draw(Game1.mouseCursors, new Vector2(xPositionOnScreen + 384 + 264, sprites[i].bounds.Y + 32 - 12), new Rectangle(229, 410, 14, 14), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.88f);
                b.Draw(Game1.mouseCursors, new Vector2(xPositionOnScreen + 384 + 324, sprites[i].bounds.Y + 32), new Rectangle(227 + ((getFriendship(name).GiftsThisWeek >= 2) ? 9 : 0), 425, 9, 9), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.88f);
                b.Draw(Game1.mouseCursors, new Vector2(xPositionOnScreen + 384 + 364, sprites[i].bounds.Y + 32), new Rectangle(227 + ((getFriendship(name).GiftsThisWeek >= 1) ? 9 : 0), 425, 9, 9), Color.White, 0f, Vector2.Zero, 4f, SpriteEffects.None, 0.88f);
            }
            if (spouse)
            {
                b.Draw(Game1.objectSpriteSheet, new Vector2(xPositionOnScreen + IClickableMenu.borderWidth * 7 / 4 + 192, sprites[i].bounds.Y), Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, housemate ? 808 : 460, 16, 16), Color.White, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0.88f);
            }
            else if (friendship.IsDating())
            {
                b.Draw(Game1.objectSpriteSheet, new Vector2(xPositionOnScreen + IClickableMenu.borderWidth * 7 / 4 + 192, sprites[i].bounds.Y), Game1.getSourceRectForStandardTileSheet(Game1.objectSpriteSheet, housemate ? 808 : 458, 16, 16), Color.White, 0f, Vector2.Zero, 2f, SpriteEffects.None, 0.88f);
            }
        }
Esempio n. 5
0
        public static bool NPC_tryToReceiveActiveObject_Prefix(NPC __instance, ref Farmer who, Dictionary <string, string> ___dialogue, ref List <int> __state)
        {
            try
            {
                if (ModEntry.GetSpouses(who, true).ContainsKey(__instance.Name) && Game1.NPCGiftTastes.ContainsKey(__instance.Name))
                {
                    Monitor.Log($"Gift to spouse {__instance.Name}");
                    __state = new List <int> {
                        who.friendshipData[__instance.Name].GiftsToday,
                        who.friendshipData[__instance.Name].GiftsThisWeek,
                        0,
                        0
                    };
                    if (Config.MaxGiftsPerSpousePerDay < 0 || who.friendshipData[__instance.Name].GiftsToday < Config.MaxGiftsPerSpousePerDay)
                    {
                        who.friendshipData[__instance.Name].GiftsToday = 0;
                    }
                    else
                    {
                        who.friendshipData[__instance.Name].GiftsToday = 1;
                        __state[2] = 1; // flag to say we set it to 1
                    }
                    if (Config.MaxGiftsPerSpousePerWeek < 0 || who.friendshipData[__instance.Name].GiftsThisWeek < Config.MaxGiftsPerSpousePerWeek)
                    {
                        who.friendshipData[__instance.Name].GiftsThisWeek = 0;
                    }
                    else
                    {
                        who.friendshipData[__instance.Name].GiftsThisWeek = 2;
                        __state[3] = 1; // flag to say we set it to 2
                    }
                }
                string safe_name = __instance.Name.ToLower().Replace(' ', '_');
                if (who.ActiveObject.HasContextTag("propose_roommate_" + safe_name))
                {
                    Monitor.Log($"Roommate proposal item {who.ActiveObject.Name} to {__instance.Name}");

                    if (who.getFriendshipHeartLevelForNPC(__instance.Name) >= 10 && who.HouseUpgradeLevel >= 1)
                    {
                        Monitor.Log($"proposal success!");
                        AccessTools.Method(typeof(NPC), "engagementResponse").Invoke(__instance, new object[] { who, true });
                        return(false);
                    }
                    Game1.drawObjectDialogue(Game1.parseText(Game1.content.LoadString("Strings\\Characters:MovieInvite_NoTheater", __instance.displayName)));
                    return(false);
                }
                else if (who.ActiveObject.ParentSheetIndex == 808 && __instance.Name.Equals("Krobus"))
                {
                    if (who.getFriendshipHeartLevelForNPC(__instance.Name) >= 10 && who.HouseUpgradeLevel >= 1)
                    {
                        AccessTools.Method(typeof(NPC), "engagementResponse").Invoke(__instance, new object[] { who, true });
                        return(false);
                    }
                }
                else if (who.ActiveObject.ParentSheetIndex == 458)
                {
                    Monitor.Log($"Try give bouquet to {__instance.Name}");

                    if (ModEntry.GetSpouses(who, true).ContainsKey(__instance.Name))
                    {
                        who.spouse = __instance.Name;
                        ModEntry.ResetSpouses(who);
                        Game1.currentLocation.playSound("dwop", NetAudio.SoundContext.NPC);
                        if (ModEntry.customSpouseRoomsAPI == null)
                        {
                            FarmHouse fh = Utility.getHomeOfFarmer(who);
                            fh.showSpouseRoom();
                            Helper.Reflection.GetMethod(fh, "resetLocalState").Invoke();
                        }
                        return(false);
                    }

                    if (!__instance.datable.Value)
                    {
                        if (ModEntry.myRand.NextDouble() < 0.5)
                        {
                            Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3955", __instance.displayName));
                            return(false);
                        }
                        __instance.CurrentDialogue.Push(new Dialogue((ModEntry.myRand.NextDouble() < 0.5) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3956") : Game1.LoadStringByGender(__instance.Gender, "Strings\\StringsFromCSFiles:NPC.cs.3957"), __instance));
                        Game1.drawDialogue(__instance);
                        return(false);
                    }
                    else
                    {
                        if (who.friendshipData.ContainsKey(__instance.Name) && who.friendshipData[__instance.Name].IsDating())
                        {
                            Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\UI:AlreadyDatingBouquet", __instance.displayName));
                            return(false);
                        }
                        if (who.friendshipData.ContainsKey(__instance.Name) && who.friendshipData[__instance.Name].IsDivorced())
                        {
                            __instance.CurrentDialogue.Push(new Dialogue(Game1.content.LoadString("Strings\\Characters:Divorced_bouquet"), __instance));
                            Game1.drawDialogue(__instance);
                            return(false);
                        }
                        if (who.friendshipData.ContainsKey(__instance.Name) && who.friendshipData[__instance.Name].Points < Config.MinPointsToDate / 2f)
                        {
                            __instance.CurrentDialogue.Push(new Dialogue((ModEntry.myRand.NextDouble() < 0.5) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3958") : Game1.LoadStringByGender(__instance.Gender, "Strings\\StringsFromCSFiles:NPC.cs.3959"), __instance));
                            Game1.drawDialogue(__instance);
                            return(false);
                        }
                        if (who.friendshipData.ContainsKey(__instance.Name) && who.friendshipData[__instance.Name].Points < Config.MinPointsToDate)
                        {
                            __instance.CurrentDialogue.Push(new Dialogue((ModEntry.myRand.NextDouble() < 0.5) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3960") : Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3961"), __instance));
                            Game1.drawDialogue(__instance);
                            return(false);
                        }
                        Friendship friendship = who.friendshipData[__instance.Name];
                        if (!friendship.IsDating())
                        {
                            friendship.Status = FriendshipStatus.Dating;
                            Multiplayer mp = ModEntry.SHelper.Reflection.GetField <Multiplayer>(typeof(Game1), "multiplayer").GetValue();
                            mp.globalChatInfoMessage("Dating", new string[]
                            {
                                who.Name,
                                __instance.displayName
                            });
                        }
                        __instance.CurrentDialogue.Push(new Dialogue((ModEntry.myRand.NextDouble() < 0.5) ? Game1.LoadStringByGender(__instance.Gender, "Strings\\StringsFromCSFiles:NPC.cs.3962") : Game1.LoadStringByGender(__instance.Gender, "Strings\\StringsFromCSFiles:NPC.cs.3963"), __instance));
                        who.changeFriendship(25, __instance);
                        who.reduceActiveItemByOne();
                        who.completelyStopAnimatingOrDoingAction();
                        __instance.doEmote(20, true);
                        Game1.drawDialogue(__instance);
                        return(false);
                    }
                }
                else if (who.ActiveObject.ParentSheetIndex == 460)
                {
                    Monitor.Log($"Try give pendant to {__instance.Name}");
                    if (who.isEngaged())
                    {
                        Monitor.Log($"Tried to give pendant while engaged");

                        __instance.CurrentDialogue.Push(new Dialogue((ModEntry.myRand.NextDouble() < 0.5) ? Game1.LoadStringByGender(__instance.Gender, "Strings\\StringsFromCSFiles:NPC.cs.3965") : Game1.LoadStringByGender(__instance.Gender, "Strings\\StringsFromCSFiles:NPC.cs.3966"), __instance));
                        Game1.drawDialogue(__instance);
                        return(false);
                    }
                    if (!__instance.datable.Value || __instance.isMarriedOrEngaged() || (who.friendshipData.ContainsKey(__instance.Name) && who.friendshipData[__instance.Name].Points < Config.MinPointsToMarry * 0.6f))
                    {
                        Monitor.Log($"Tried to give pendant to someone not datable");

                        if (ModEntry.myRand.NextDouble() < 0.5)
                        {
                            Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3969", __instance.displayName));
                            return(false);
                        }
                        __instance.CurrentDialogue.Push(new Dialogue((__instance.Gender == 1) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3970") : Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3971"), __instance));
                        Game1.drawDialogue(__instance);
                        return(false);
                    }
                    else if (__instance.datable.Value && who.friendshipData.ContainsKey(__instance.Name) && who.friendshipData[__instance.Name].Points < Config.MinPointsToMarry)
                    {
                        Monitor.Log($"Tried to give pendant to someone not marriable");

                        if (!who.friendshipData[__instance.Name].ProposalRejected)
                        {
                            __instance.CurrentDialogue.Push(new Dialogue((ModEntry.myRand.NextDouble() < 0.5) ? Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3972") : Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3973"), __instance));
                            Game1.drawDialogue(__instance);
                            who.changeFriendship(-20, __instance);
                            who.friendshipData[__instance.Name].ProposalRejected = true;
                            return(false);
                        }
                        __instance.CurrentDialogue.Push(new Dialogue((ModEntry.myRand.NextDouble() < 0.5) ? Game1.LoadStringByGender(__instance.Gender, "Strings\\StringsFromCSFiles:NPC.cs.3974") : Game1.LoadStringByGender(__instance.Gender, "Strings\\StringsFromCSFiles:NPC.cs.3975"), __instance));
                        Game1.drawDialogue(__instance);
                        who.changeFriendship(-50, __instance);
                        return(false);
                    }
                    else
                    {
                        Monitor.Log($"Tried to give pendant to someone marriable");
                        if (!__instance.datable.Value || who.HouseUpgradeLevel >= 1)
                        {
                            typeof(NPC).GetMethod("engagementResponse", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(__instance, new object[] { who, false });
                            return(false);
                        }
                        Monitor.Log($"Can't marry");
                        if (ModEntry.myRand.NextDouble() < 0.5)
                        {
                            Game1.drawObjectDialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3969", __instance.displayName));
                            return(false);
                        }
                        __instance.CurrentDialogue.Push(new Dialogue(Game1.content.LoadString("Strings\\StringsFromCSFiles:NPC.cs.3972"), __instance));
                        Game1.drawDialogue(__instance);
                        return(false);
                    }
                }
                else if (who.ActiveObject.ParentSheetIndex == 809 && !who.ActiveObject.bigCraftable.Value)
                {
                    Monitor.Log($"Tried to give movie ticket to {__instance.Name}");
                    if (ModEntry.GetSpouses(who, true).ContainsKey(__instance.Name) && Utility.doesMasterPlayerHaveMailReceivedButNotMailForTomorrow("ccMovieTheater") && !__instance.Name.Equals("Krobus") && who.lastSeenMovieWeek.Value < Game1.Date.TotalWeeks && !Utility.isFestivalDay(Game1.dayOfMonth, Game1.currentSeason) && Game1.timeOfDay <= 2100 && __instance.lastSeenMovieWeek.Value < Game1.Date.TotalWeeks && MovieTheater.GetResponseForMovie(__instance) != "reject")
                    {
                        Monitor.Log($"Tried to give movie ticket to spouse");
                        foreach (MovieInvitation invitation in who.team.movieInvitations)
                        {
                            if (invitation.farmer == who)
                            {
                                return(true);
                            }
                        }
                        foreach (MovieInvitation invitation2 in who.team.movieInvitations)
                        {
                            if (invitation2.invitedNPC == __instance)
                            {
                                return(true);
                            }
                        }

                        Monitor.Log($"Giving movie ticket to spouse");

                        if (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.en)
                        {
                            __instance.CurrentDialogue.Push(new Dialogue(__instance.GetDispositionModifiedString("Strings\\Characters:MovieInvite_Spouse_" + __instance.Name, new object[0]), __instance));
                        }
                        else if (LocalizedContentManager.CurrentLanguageCode == LocalizedContentManager.LanguageCode.en && ___dialogue != null && ___dialogue.ContainsKey("MovieInvitation"))
                        {
                            __instance.CurrentDialogue.Push(new Dialogue(___dialogue["MovieInvitation"], __instance));
                        }
                        else
                        {
                            __instance.CurrentDialogue.Push(new Dialogue(__instance.GetDispositionModifiedString("Strings\\Characters:MovieInvite_Invited", new object[0]), __instance));
                        }
                        Game1.drawDialogue(__instance);
                        who.reduceActiveItemByOne();
                        who.completelyStopAnimatingOrDoingAction();
                        who.currentLocation.localSound("give_gift");
                        MovieTheater.Invite(who, __instance);
                        if (who == Game1.player)
                        {
                            ModEntry.mp.globalChatInfoMessage("MovieInviteAccept", new string[]
                            {
                                Game1.player.displayName,
                                __instance.displayName
                            });
                            return(false);
                        }
                    }
                    return(true);
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed in {nameof(NPC_tryToReceiveActiveObject_Prefix)}:\n{ex}", LogLevel.Error);
            }
            return(true);
        }
Esempio n. 6
0
        //This version of loadDataToLocations reduces the redundancies and double/triple loops that occur.
        //This should decrease the runtime.
        public static void loadDataToLocations(List <GameLocation> gamelocations)
        {
            foreach (GameLocation i in gamelocations)
            {
                GameLocation generalLocation = Game1.getLocationFromName(i.name);
                //FarmHouse / Cabins
                if (i is FarmHouse)
                {
                    FarmHouse farmLocation = (generalLocation as FarmHouse);
                    farmLocation.setMapForUpgradeLevel((i as FarmHouse).upgradeLevel);
                    farmLocation.wallPaper.Set((i as FarmHouse).wallPaper);
                    farmLocation.floor.Set((i as FarmHouse).floor);
                    farmLocation.furniture.Set((i as FarmHouse).furniture);
                    farmLocation.fireplaceOn.Value   = (i as FarmHouse).fireplaceOn;
                    farmLocation.fridge.Value        = (i as FarmHouse).fridge;
                    farmLocation.farmerNumberOfOwner = (i as FarmHouse).farmerNumberOfOwner;
                    farmLocation.resetForPlayerEntry();
                    foreach (Furniture furniture in (farmLocation as FarmHouse).furniture)
                    {
                        furniture.updateDrawPosition();
                    }
                    farmLocation.lastTouchActionLocation = Game1.player.getTileLocation();
                    //Farms
                }
                else if (i is Farm)
                {
                    Farm realLocation = (generalLocation as Farm);
                    foreach (Building building in ((Farm)i).buildings)
                    {
                        building.load();
                    }
                    realLocation.buildings.Set(((Farm)i).buildings);
                    foreach (FarmAnimal farmAnimal in ((Farm)i).animals.Values)
                    {
                        farmAnimal.reload(null);
                    }
                    realLocation.animals.MoveFrom((i as Farm).animals);
                    realLocation.piecesOfHay.Value = (i as Farm).piecesOfHay;
                    realLocation.resourceClumps.Set((i as Farm).resourceClumps);
                    realLocation.hasSeenGrandpaNote = (i as Farm).hasSeenGrandpaNote;
                    realLocation.grandpaScore       = (i as Farm).grandpaScore;
                }
                else if (i is Beach)
                {
                    (generalLocation as Beach).bridgeFixed.Value = (i as Beach).bridgeFixed;
                }
                else if (i is Woods)
                {
                    (generalLocation as Woods).stumps.MoveFrom((i as Woods).stumps);
                    (generalLocation as Woods).hasUnlockedStatue.Value = (i as Woods).hasUnlockedStatue.Value;
                }
                else if (i is CommunityCenter)
                {
                    (generalLocation as CommunityCenter).areasComplete.Set((i as CommunityCenter).areasComplete);
                }
                else if (i is SeedShop)
                {
                    (generalLocation as SeedShop).itemsFromPlayerToSell.MoveFrom((i as SeedShop).itemsFromPlayerToSell);
                    (generalLocation as SeedShop).itemsToStartSellingTomorrow.MoveFrom((i as SeedShop).itemsToStartSellingTomorrow);
                }
                else if (i is Town)
                {
                    (generalLocation as Town).daysUntilCommunityUpgrade.Value = (i as Town).daysUntilCommunityUpgrade;
                }
                else if (i is Forest)
                {
                    Forest forestLocation = (generalLocation as Forest);
                    if (Game1.dayOfMonth % 7 % 5 == 0)
                    {
                        forestLocation.travelingMerchantDay = true;
                        forestLocation.travelingMerchantBounds.Clear();
                        forestLocation.travelingMerchantBounds.Add(new Rectangle(1472, 640, 492, 112));
                        forestLocation.travelingMerchantBounds.Add(new Rectangle(1652, 744, 76, 48));
                        forestLocation.travelingMerchantBounds.Add(new Rectangle(1812, 744, 104, 48));
                        foreach (Rectangle r in forestLocation.travelingMerchantBounds)
                        {
                            Utility.clearObjectsInArea(r, forestLocation);
                        }
                    }
                    forestLocation.log = (i as Forest).log;
                }
                //General Locations (GameLocations)

                foreach (NPC c in i.characters)
                {
                    if (c.DefaultPosition.Equals(Vector2.Zero))
                    {
                        c.Position = c.DefaultPosition;
                    }
                    c.currentLocation = generalLocation;
                    if (c.datingFarmer)
                    {
                        Friendship friendship = Game1.player.friendshipData[c.Name];
                        if (!friendship.IsDating())
                        {
                            friendship.Status = FriendshipStatus.Dating;
                        }
                        c.datingFarmer = false;
                    }
                }
                foreach (TerrainFeature terrainFeature in i.terrainFeatures.Values)
                {
                    terrainFeature.loadSprite();
                }
                foreach (KeyValuePair <Vector2, StardewValley.Object> v in i.objects.Pairs)
                {
                    v.Value.initializeLightSource(v.Key, false);
                    v.Value.reloadSprite();
                }
                generalLocation.characters.Set(i.characters);
                generalLocation.netObjects.Set(i.netObjects.Pairs);
                generalLocation.numberOfSpawnedObjectsOnMap = i.numberOfSpawnedObjectsOnMap;
                generalLocation.terrainFeatures.Set(i.terrainFeatures.Pairs);
                generalLocation.largeTerrainFeatures.Set(i.largeTerrainFeatures);
                for (int c = 0; c <= generalLocation.characters.Count; c++)
                {
                    generalLocation.characters[c].reloadSprite();
                }
            }
            //////////////////////////
            Game1.player.currentLocation = Utility.getHomeOfFarmer(Game1.player);
        }