Ejemplo n.º 1
0
        public static void Postfix(NPC __instance, ref bool __result)
        {
            try
            {
                Monitor.Log($"NPC: {__instance.Name} - Result: {__result}", LogLevel.Debug);
                Monitor.Log($"Married: {Game1.player.isMarried()}\nSpouse: {Game1.player.spouse}", LogLevel.Debug);
                Monitor.Log($"{(Game1.player.currentLocation == Game1.getLocationFromName(Game1.player.homeLocation))}", LogLevel.Debug);

                Monitor.Log($"Master Game?: {Game1.IsMasterGame}", LogLevel.Debug);
                if (!Game1.IsMasterGame)
                {
                    return;
                }

                NPC spouse = __instance;
                Monitor.Log($"Horse?: {(spouse is Horse)}", LogLevel.Debug);
                if (spouse is Horse)
                {
                    return;
                }
                Monitor.Log($"Roommate?: {spouse.isRoommate()}", LogLevel.Debug);
                if (spouse.isRoommate())
                {
                    return;
                }

                Farmer farmer = spouse.getSpouse();
                Monitor.Log($"Null farmer?: {(farmer == null)}", LogLevel.Debug);
                if (farmer == null)
                {
                    return;
                }
                Monitor.Log($"Divorce Tonight?: {farmer.divorceTonight.Equals(new NetBool(true))}", LogLevel.Debug);
                if (farmer.divorceTonight.Equals(new NetBool(true)))
                {
                    return;
                }

                int          hearts     = farmer.getFriendshipHeartLevelForNPC(spouse.Name);
                Friendship   friendship = farmer.GetSpouseFriendship();
                List <Child> children   = farmer.getChildren();

                spouse.defaultMap.Value = farmer.homeLocation.Value;

                Monitor.Log($"Upgrade Level: {Utility.getHomeOfFarmer(farmer).upgradeLevel}", LogLevel.Debug);
                if (Utility.getHomeOfFarmer(farmer).upgradeLevel < 2)
                {
                    return;
                }
                Monitor.Log($"DaysUntilBirthing: {friendship.DaysUntilBirthing}", LogLevel.Debug);
                if (friendship.DaysUntilBirthing >= 0)
                {
                    return;
                }
                Monitor.Log($"Hearts: {hearts}", LogLevel.Debug);
                if (hearts < 10)
                {
                    return;
                }
                Monitor.Log($"Days Married: {farmer.GetDaysMarried()}", LogLevel.Debug);
                if (farmer.GetDaysMarried() < 7)
                {
                    return;
                }
                Monitor.Log($"# Kids: {children.Count }", LogLevel.Debug);
                if (children.Count >= 2)
                {
                    return;
                }

                if (children.Count == 0)
                {
                    __result = true;
                    Monitor.Log($"{__result}", LogLevel.Debug);
                    return;
                }

                if (children.Count != 0 && children.Count < 2)
                {
                    __result = children[0].Age > 2;
                    Monitor.Log($"{nameof(Postfix)}:\n Kids: {children.Count}\n Result: {__result}", LogLevel.Debug);
                }

                //if (Utility.getHomeOfFarmer(farmer).upgradeLevel >= 2 &&
                //    friendship.DaysUntilBirthing < 0 &&
                //    hearts >= 10 &&
                //    farmer.GetDaysMarried() >= 7)
                //{
                //    if (children.Count != 0)
                //    {
                //        if (children.Count < 2)
                //        {
                //            __result = children[0].Age > 2;
                //            return;
                //        }
                //        __result = false;
                //        return;
                //    }
                //    __result = true;
                //    return;
                //}
                //__result = false;
                //return;
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed in {nameof(Postfix)}:\n {ex}", LogLevel.Error);
            }
        }
Ejemplo n.º 2
0
        public static void Postfix(ref bool __result)
        {
            //if (this is Horse) return false;
            if (!Game1.IsMasterGame)
            {
                return;
            }

            int totalChildren = ModEntry.GetFamilyData().TotalChildren;

            __result = false;

            Farmer farmer = Game1.player;
            NPC    spouse = farmer.getSpouse();

            NetBool trueBool = new NetBool(true);

            if (farmer == null || farmer.divorceTonight.Equals(trueBool))
            {
                return;
            }

            int          heartLevelForNPC = farmer.getFriendshipHeartLevelForNPC(spouse.Name);
            Friendship   spouseFriendship = farmer.GetSpouseFriendship();
            List <Child> children         = farmer.getChildren();

            //spouse.DefaultMap = farmer.homeLocation.ToString();

            if ((Game1.getLocationFromName("FarmHouse") as FarmHouse).upgradeLevel < 2 || spouseFriendship.DaysUntilBirthing >= 0 || (heartLevelForNPC < 10 || farmer.GetDaysMarried() < 7))
            {
                return;
            }

            //this is surely not the most efficient way to check, but I want it to work.
            if (children.Count < totalChildren)
            {
                //If you have 0 children, skips straight to true
                foreach (Child child in children)
                {
                    /*
                     * Toddlers are 55 daysOld, and pregnancy lasts 14 days,
                     * so requiring the previous sibling to be at least 41 days
                     * will ensure that they are out of the crib when the baby is born.
                     */
                    if (child.daysOld < 41)
                    {
                        __result = false;
                        return;
                    }
                }
                __result = true;
            }
        }
Ejemplo n.º 3
0
        public static void Postfix(NPC __instance, ref bool __result)
        {
            if (!Game1.IsMasterGame)
            {
                return;
            }

            int    totalChildren = ModEntry.GetFamilyData().TotalChildren;
            NPC    spouse        = __instance;
            Farmer farmer        = spouse.getSpouse();

            //This is from the original method
            //canGetPregnant() is only ever run on a spouse NPC, so this shouldn't be necessary?
            if (spouse is Horse)
            {
                return;
            }

            //Original kicks out Krobus/Roommates
            if (spouse.isRoommate() && !ModEntry.RoommateConfig())
            {
                return;
            }

            if (farmer == null || farmer.divorceTonight.Equals(new NetBool(true)))
            {
                return;
            }

            int          heartLevelForNPC = farmer.getFriendshipHeartLevelForNPC(spouse.Name);
            Friendship   spouseFriendship = farmer.GetSpouseFriendship();
            List <Child> children         = farmer.getChildren();

            //This is from the original method
            spouse.defaultMap.Value = farmer.homeLocation.Value;

            if (Utility.getHomeOfFarmer(farmer).upgradeLevel < 2 || spouseFriendship.DaysUntilBirthing >= 0 || (heartLevelForNPC < 10 || farmer.GetDaysMarried() < 7))
            {
                return;
            }

            /* Toddlers are 55 daysOld, and pregnancy lasts 14 days,
             * so requiring the previous sibling to be at least 41 days old
             * will ensure that they are out of the crib when the baby is born.
             */
            if (children.Count < totalChildren)
            {
                //If you have 0 children, skips straight to true
                foreach (Child child in children)
                {
                    if (child.daysOld < 41)
                    {
                        __result = false;
                        return;
                    }
                }
                __result = true;
            }
        }