Пример #1
0
        public static void NPC_marriageDuties_Postfix(NPC __instance)
        {
            try
            {
                if (ModEntry.tempOfficialSpouse == __instance)
                {
                    ModEntry.tempOfficialSpouse = null;
                }
                return;

                // custom dialogues


                // dialogues

                if (__instance.currentMarriageDialogue is null || __instance.currentMarriageDialogue.Count == 0)
                {
                    return;
                }

                bool gotDialogue = false;

                for (int i = 0; i < __instance.currentMarriageDialogue.Count; i++)
                {
                    MarriageDialogueReference mdr = __instance.currentMarriageDialogue[i];

                    if (mdr.DialogueFile == "Strings\\StringsFromCSFiles")
                    {
                        foreach (string[] array in csMarriageDialoguesChoose)
                        {
                            string key = array[ModEntry.myRand.Next(0, array.Length)];
                            if (array.Contains(key))
                            {
                                Dictionary <string, string> marriageDialogues = null;
                                try
                                {
                                    marriageDialogues = ModEntry.SHelper.Content.Load <Dictionary <string, string> >("Characters\\Dialogue\\MarriageDialogue" + __instance.Name, ContentSource.GameContent);
                                }
                                catch (Exception)
                                {
                                }
                                MarriageDialogueReference mdrn;
                                if (marriageDialogues != null && marriageDialogues.ContainsKey(key))
                                {
                                    mdrn = new MarriageDialogueReference("Characters\\Dialogue\\MarriageDialogue" + __instance.Name, key, mdr.IsGendered, mdr.Substitutions.ToArray());
                                }
                                else
                                {
                                    mdrn = new MarriageDialogueReference("Characters\\Dialogue\\MarriageDialogue" + __instance.Name, key, mdr.IsGendered, mdr.Substitutions.ToArray());
                                }
                                if (mdrn != null)
                                {
                                    __instance.currentMarriageDialogue[i] = mdrn;
                                }
                                gotDialogue = true;
                                break;
                            }
                        }
                        if (!gotDialogue)
                        {
                            if (csMarriageDialoguesReplace.Contains(mdr.DialogueKey))
                            {
                                Dictionary <string, string> marriageDialogues = null;
                                try
                                {
                                    marriageDialogues = ModEntry.SHelper.Content.Load <Dictionary <string, string> >("Characters\\Dialogue\\MarriageDialogue" + __instance.Name, ContentSource.GameContent);
                                }
                                catch (Exception)
                                {
                                }
                                if (marriageDialogues != null && marriageDialogues.ContainsKey(mdr.DialogueKey))
                                {
                                    MarriageDialogueReference mdrn = new MarriageDialogueReference("Characters\\Dialogue\\MarriageDialogue" + __instance.Name, mdr.DialogueKey, mdr.IsGendered, mdr.Substitutions.ToArray());

                                    if (mdrn != null)
                                    {
                                        __instance.currentMarriageDialogue[i] = mdrn;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                    else if (mdr.DialogueFile == "MarriageDialogue")
                    {
                        foreach (string[] array in csMarriageDialoguesChoose)
                        {
                            string key = array[ModEntry.myRand.Next(0, array.Length)];
                            if (array.Contains(key))
                            {
                                Dictionary <string, string> marriageDialogues = null;
                                try
                                {
                                    marriageDialogues = ModEntry.SHelper.Content.Load <Dictionary <string, string> >("Characters\\Dialogue\\MarriageDialogue" + __instance.Name, ContentSource.GameContent);
                                }
                                catch (Exception)
                                {
                                }
                                if (marriageDialogues != null && marriageDialogues.ContainsKey(key))
                                {
                                    MarriageDialogueReference mdrn = new MarriageDialogueReference("Characters\\Dialogue\\MarriageDialogue" + __instance.Name, key, mdr.IsGendered, mdr.Substitutions.ToArray());
                                    if (mdrn != null)
                                    {
                                        __instance.currentMarriageDialogue[i] = mdrn;
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }

/*
 *              return;
 *              if (Config.RemoveSpouseOrdinaryDialogue && __instance.Name != Game1.player.spouse && __instance.currentMarriageDialogue.Count > 0)
 *              {
 *                  __instance.CurrentDialogue.Clear();
 *                  foreach (MarriageDialogueReference mdr in __instance.currentMarriageDialogue)
 *                  {
 *                      __instance.CurrentDialogue.Push(mdr.GetDialogue(__instance));
 *                      __instance.currentMarriageDialogue.Clear();
 *                  }
 *              }
 */
            }
            catch (Exception ex)
            {
                Monitor.Log($"Failed in {nameof(NPC_marriageDuties_Postfix)}:\n{ex}", LogLevel.Error);
            }
        }
Пример #2
0
 public bool spouseObstacleCheck(MarriageDialogueReference backToBedMessage, IGameLocationWrapper currentLocation,
                                 bool force = false) => false;