Ejemplo n.º 1
0
        // Method that is used to postfix world change events
        private static void WorldChangeEvent_setUp_Postfix(WorldChangeEvent __instance)
        {
            try
            {
                switch (__instance.whichEvent.Value)
                {
                // If the world change event in question is building the Joja greenhouse, add Joja greenhouse conversation topic
                case 0:
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT("joja_Greenhouse", Config.JojaGreenhouseDuration);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Failed to add Joja greenhouse conversation topic with exception: {ex}", LogLevel.Error);
                    }
                    break;

                // If the world change event is the abandoned JojaMart being struck by lightning, add JojaMart lightning conversation topic
                case 12:
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT("jojaMartStruckByLightning", Config.JojaLightningDuration);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Failed to add abandonded JojaMart struck by lightning conversation topic with exception: {ex}", LogLevel.Error);
                    }
                    break;

                // If the world change event is Willy's boat being repaired, add Willy boat repair conversation topic
                case 13:
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT("willyBoatRepaired", Config.WillyBoatRepairDuration);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Failed to add Willy's boat repaired conversation topic with exception: {ex}", LogLevel.Error);
                    }
                    break;

                // If the world change event in question is Leo arriving in the valley, add Leo arrival conversation topic
                case 14:
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT("leoValleyArrival", Config.LeoArrivalDuration);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Failed to add Leo arrival to the valley conversation topic with exception: {ex}", LogLevel.Error);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed to do world change event postfix with exception: {ex}", LogLevel.Error);
            }
        }
Ejemplo n.º 2
0
        // Method that is used to postfix
        private static void Farmer_doDivorce_Postfix(Farmer __instance, DivorceState __state)
        {
            switch (__state)
            {
            // If the prefix failed, don't do the postfix
            case DivorceState.UnAssigned:
                Monitor.Log($"Failed to log divorce state in prefix, skipping divorce conversation topic postfix", LogLevel.Error);
                break;

            // If the prefix logged that the player is not married, obviously they can't get divorced
            case DivorceState.UnMarriedNoDivorce:
                Monitor.Log($"Player tried to get divorced when they were not married", LogLevel.Warn);
                break;

            // If the prefix logged that the player is married to another player, add divorce conversation topics to both players
            case DivorceState.MultiplayerDivorce:

                // Add divorce conversation topic to current player's player spouse
                try
                {
                    // Get spouse
                    long?  spouseID = __instance.team.GetSpouse(__instance.UniqueMultiplayerID);
                    Farmer spouse   = Game1.getFarmerMaybeOffline(spouseID.Value);

                    // Check if spouse is offline or nonexistent, otherwise add divorce conversation topic to spouse
                    if (spouse is null)
                    {
                        Monitor.Log($"Player was married to multiplayer spouse in prefix but multiplayer spouse not found in postfix", LogLevel.Error);
                    }
                    else
                    {
                        MCTHelperFunctions.AddOrExtendCT(spouse, "divorce", Config.DivorceDuration);
                        if (!Game1.getOnlineFarmers().Contains(spouse))
                        {
                            Monitor.Log($"Added divorce conversation topic to offline multiplayer spouse, unknown behavior may result", LogLevel.Warn);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Monitor.Log($"Failed to add player's spouse divorce conversation topic with exception: {ex}", LogLevel.Error);
                }

                // Add divorce conversation topic to current player
                goto case DivorceState.NPCDivorce;

            // If the prefix logged that the player is married to an NPC, only add divorce conversation topic to player
            case DivorceState.NPCDivorce:
                try
                {
                    MCTHelperFunctions.AddOrExtendCT(__instance, "divorce", Config.DivorceDuration);
                }
                catch (Exception ex)
                {
                    Monitor.Log($"Failed to add player's divorce conversation topic with exception: {ex}", LogLevel.Error);
                }
                break;
            }
        }
Ejemplo n.º 3
0
 // Method that is used to postfix
 private static void Utility_getWeddingEvent_Postfix(Farmer farmer)
 {
     try
     {
         MCTHelperFunctions.AddOrExtendCT(farmer, "wedding", Config.WeddingDuration);
     }
     catch (Exception ex)
     {
         Monitor.Log($"Failed to add wedding conversation topic with exception: {ex}", LogLevel.Error);
     }
 }
Ejemplo n.º 4
0
        /*********
        ** Public methods
        *********/
        /// <summary>The mod entry point, called after the mod is first loaded.</summary>
        /// <param name="helper">Provides simplified APIs for writing mods.</param>
        public override void Entry(IModHelper helper)
        {
            // Read in config file and create if needed
            try
            {
                this.Config = this.Helper.ReadConfig <ModConfig>();
            }
            catch (Exception)
            {
                this.Config = new ModConfig();
                this.Monitor.Log(this.Helper.Translation.Get("IllFormattedConfig"), LogLevel.Warn);
            }

            // Initialize the error logger and config in all the other files via a helper function
            MCTHelperFunctions.Initialize(this.Monitor, this.Config, helper);

            // Do the Harmony things
            var harmony = new Harmony(this.ModManifest.UniqueID);

            RepeatPatcher.Apply(harmony);
            WeddingPatcher.Apply(harmony);
            BirthPatcher.Apply(harmony);
            DivorcePatcher.Apply(harmony);
            LuauPatcher.Apply(harmony);
            WorldChangePatcher.Apply(harmony);
            NightEventPatcher.Apply(harmony);
            IslandPatcher.Apply(harmony);

            // Adds a command to check current active conversation topics
            helper.ConsoleCommands.Add("vl.mct.current_CTs", "Returns a list of the current active dialogue events.", MCTHelperFunctions.console_GetCurrentCTs);

            // Adds a command to see if player has a given mail flag
            helper.ConsoleCommands.Add("vl.mct.has_flag", "Checks if the player has a mail flag.\n\nUsage: vl.mct_hasflag <flagName>\n- flagName: the possible mail flag name.", MCTHelperFunctions.console_HasMailFlag);

            // Adds a command to add a conversation topic
            helper.ConsoleCommands.Add("vl.mct.add_CT", "Adds the specified conversation topic with duration of 1 day.\n\nUsage: vl.mct_add_CT <topicName> <duration>\n- topicName: the conversation topic to add.\n- duration: duration of conversation topic to add.", MCTHelperFunctions.console_AddConversationTopic);

            // Adds a command to remove a conversation topic
            helper.ConsoleCommands.Add("vl.mct.remove_CT", "Removes the specified conversation topic.\n\nUsage: vl.mct_remove_CT <topicName>\n- topicName: the conversation topic to remove.", MCTHelperFunctions.console_RemoveConversationTopic);

            // Adds a command to check if a conversation topic is repeatable
            helper.ConsoleCommands.Add("vl.mct.is_repeatable_CT", "Checks whether the specified conversation topic is repeatable.\n\nUsage: vl.mct_remove_CT <topicName>\n- topicName: the conversation topic to check.", MCTHelperFunctions.console_IsRepeatableCT);

            // Adds a command to print all repeatable conversation topics
            helper.ConsoleCommands.Add("vl.mct.repeatable_CTs", "Returns a list of all repeatable conversation topics.", MCTHelperFunctions.console_AllRepeatableCTs);

            // Add GMCM
            helper.Events.GameLoop.GameLaunched += this.RegisterGMCM;

            // Add asset editor
            helper.Events.Content.AssetRequested += this.OnAssetRequested;
        }
        // Method that is used to postfix FairyEvent
        private static void FairyEvent_setUp_Postfix(bool __result)
        {
            // If the event did not trigger, then no need to do anything
            if (__result)
            {
                return;
            }

            // Add the fairy event conversation topic
            try
            {
                MCTHelperFunctions.AddOrExtendCT("fairyFarmVisit", Config.FairyVisitDuration);
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed to add fairy visit conversation topic with exception: {ex}", LogLevel.Error);
            }
        }
Ejemplo n.º 6
0
 // Method that is used to postfix
 private static void BirthingEvent_setUp_Postfix(bool ___isMale)
 {
     // If a player married to an NPC has a child, add conversation topics depending on gender
     try
     {
         if (___isMale)
         {
             MCTHelperFunctions.AddOrExtendCT("babyBoy", Config.BirthDuration);
         }
         else
         {
             MCTHelperFunctions.AddOrExtendCT("babyGirl", Config.BirthDuration);
         }
     }
     catch (Exception ex)
     {
         Monitor.Log($"Failed to add birth conversation topic with exception: {ex}", LogLevel.Error);
     }
 }
Ejemplo n.º 7
0
        private static void PlayerCoupleBirthingEvent_setUp_Postfix(bool __result, Farmer ___spouse, bool ___isMale)
        {
            // If two players are married and have a child, add the conversation topic for having a new baby to both players
            try
            {
                if (!__result)
                {
                    if (___isMale)
                    {
                        MCTHelperFunctions.AddOrExtendCT("babyBoy", Config.BirthDuration);
                    }
                    else
                    {
                        MCTHelperFunctions.AddOrExtendCT("babyGirl", Config.BirthDuration);
                    }
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed to add player's childbirth conversation topic with exception: {ex}", LogLevel.Error);
            }

            try
            {
                if (!__result)
                {
                    if (___isMale)
                    {
                        MCTHelperFunctions.AddOrExtendCT(___spouse, "babyBoy", Config.BirthDuration);
                    }
                    else
                    {
                        MCTHelperFunctions.AddOrExtendCT(___spouse, "babyGirl", Config.BirthDuration);
                    }
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed to add spouse's childbirth conversation topic with exception: {ex}", LogLevel.Error);
            }
        }
Ejemplo n.º 8
0
 // Method that is used to postfix
 private static void Event_governorTaste_Postfix(Event __instance)
 {
     try
     {
         string governorReactionString = __instance.eventCommands[__instance.CurrentCommand + 1];
         if (governorReactionString.EndsWith("6"))
         {
             MCTHelperFunctions.AddOrExtendCT("luauShorts", Config.LuauDuration);
         }
         else if (governorReactionString.EndsWith("4"))
         {
             MCTHelperFunctions.AddOrExtendCT("luauBest", Config.LuauDuration);
         }
         else if (governorReactionString.EndsWith("0"))
         {
             MCTHelperFunctions.AddOrExtendCT("luauPoisoned", Config.LuauDuration);
         }
     }
     catch (Exception ex)
     {
         Monitor.Log($"Failed to add luau conversation topic with exception: {ex}", LogLevel.Error);
     }
 }
        // Method that is used to postfix WitchEvent
        private static void WitchEvent_setUp_Postfix(WitchEvent __instance, bool __result, Building ___targetBuilding)
        {
            // If the event did not trigger, then no need to do anything
            if (__result)
            {
                return;
            }

            // Add the right witch event conversation topics depending on the witch visit
            try
            {
                // If the witch is visiting a coop, add one of the witch coop conversation topics
                if (___targetBuilding is Coop)
                {
                    // If the witch is a golden witch (post-perfection coop visit), add the golden witch conversation topic
                    if (__instance.goldenWitch)
                    {
                        MCTHelperFunctions.AddOrExtendCT("goldenWitchCoopVisit", Config.WitchVisitDuration);
                    }
                    // Otherwise add the normal witch coop visit conversation topic
                    else
                    {
                        MCTHelperFunctions.AddOrExtendCT("witchCoopVisit", Config.WitchVisitDuration);
                    }
                }
                // Otherwise, if the witch is visiting a Slime Hutch, add the witch slime hut conversation topic
                else if (___targetBuilding.buildingType.Equals("Slime Hutch"))
                {
                    MCTHelperFunctions.AddOrExtendCT("witchSlimeHutVisit", Config.WitchVisitDuration);
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed to add witch visit conversation topic with exception: {ex}", LogLevel.Error);
            }
        }
Ejemplo n.º 10
0
        private static void ParrotUpgradePerch_PerformCompleteAnimation_Postfix(NetString ___upgradeName)
        {
            // Check if the upgrade name is null and then whether it's the right upgrade, and don't do anything if it's not
            if (___upgradeName.Value is not "Resort")
            {
                return;
            }

            // Make sure to add resort built conversation topic to all farmers in the game
            try
            {
                foreach (Farmer f in Game1.getAllFarmers())
                {
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT(f, "islandResortUnlocked", Config.IslandResortDuration);
                    }
                    catch (Exception ex)
                    {// Check to see if the farmer in question is online, and return different exception messages depending
                        if (!Game1.getOnlineFarmers().Contains(f))
                        {
                            Monitor.Log($"Failed to add resort built conversation topic to an offline farmer with exception: {ex}", LogLevel.Error);
                        }
                        else
                        {
                            Monitor.Log($"Failed to add resort built conversation topic to an online farmer with exception: {ex}", LogLevel.Error);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed to add resort built conversation topic with exception: {ex}", LogLevel.Error);
                return;
            }
        }
Ejemplo n.º 11
0
 // Method that is used to postfix
 private static void Farmer_dayupdate_Postfix(Farmer __instance, List <string> __state)
 {
     // Remove the mail flags associated with each conversation topic added by this mod that is ending today
     try
     {
         foreach (string s in __state)
         {
             if (MCTHelperFunctions.IsRepeatableCTAddedByMod(s))
             {
                 foreach (NPC npc in Utility.getAllCharacters())
                 {
                     if (npc.isVillager())
                     {
                         __instance.mailReceived.Remove(npc.Name + "_" + s);
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         Monitor.Log($"Failed to remove conversation topic mail flags with exception: {ex}", LogLevel.Error);
     }
 }
Ejemplo n.º 12
0
 private void OnAssetRequested(object sender, AssetRequestedEventArgs e)
 {
     JojaEventAssetEditor.Edit(e);
     MCTHelperFunctions.LoadRepeatTopics(e);
 }
Ejemplo n.º 13
0
        // Method that is used to postfix SoundInTheNightEvent
        private static void SoundInTheNightEvent_setUp_Postfix(bool __result, NetInt ___behavior)
        {
            // If the event didn't actually happen, no need to do anything
            if (__result)
            {
                return;
            }

            // Decide what to do based on the type of sound in the night event
            try
            {
                switch (___behavior.Value)
                {
                // If the sound in the night event is the UFO landing, add UFO landing conversation topic
                case 0:
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT("UFOLandedOnFarm", Config.UFOLandedDuration);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Failed to add UFO landed on farm conversation topic with exception: {ex}", LogLevel.Error);
                    }
                    break;

                // If the sound in the night event in question is a meteorite landing on the farm, add meteorite conversation topic
                case 1:
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT("meteoriteLandedOnFarm", Config.MeteoriteLandedDuration);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Failed to add meteorite landed on farm conversation topic with exception: {ex}", LogLevel.Error);
                    }
                    break;

                // If the sound in the night event in question is an owl statue landing on the farm, add owl statue conversation topic
                case 3:
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT("owlStatueLandedOnFarm", Config.OwlStatueDuration);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Failed to add owl statue landed on farm conversation topic with exception: {ex}", LogLevel.Error);
                    }
                    break;

                // If the sound in the night event in question is the railroad earthquake, add the railroad earthquake conversation topic
                case 4:
                    try
                    {
                        MCTHelperFunctions.AddOrExtendCT("railroadEarthquake", Config.MeteoriteLandedDuration);
                    }
                    catch (Exception ex)
                    {
                        Monitor.Log($"Failed to add railroad earthquake conversation topic with exception: {ex}", LogLevel.Error);
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed to do sound in the night event postfix with exception: {ex}", LogLevel.Error);
            }
        }