Exemplo n.º 1
0
 public static RecoveryConfig GetRecoveryConfig(Farmer player)
 {
     if (ModConfig.DisablePerPlayerConfig)
     {
         return(ModConfig);
     }
     else
     {
         if (!ModConfig.PlayerRecoveryConfig.ContainsKey(player.UniqueMultiplayerID))
         {
             ModConfig.PlayerRecoveryConfig[player.UniqueMultiplayerID] = new PlayerRecoveryConfig()
             {
                 PlayerName = player.Name,
                 DisableRecoveryConfigInGameChanges = ModConfig.DisableRecoveryConfigInGameChanges,
                 EnableRecoveryService = ModConfig.EnableRecoveryService,
                 RecoverAllItems       = ModConfig.RecoverAllItems,
                 RecoverForFree        = ModConfig.RecoverForFree,
                 DisableClearLostItemsOnRandomRecovery = ModConfig.DisableClearLostItemsOnRandomRecovery
             };
             Helper.WriteConfig <ModConfig>(DataLoader.ModConfig);
             ConfigMenuController.DeleteConfigMenu(MailServicesModEntry.Manifest);
             ConfigMenuController.CreateConfigMenu(MailServicesModEntry.Manifest);
         }
         return(ModConfig.PlayerRecoveryConfig[player.UniqueMultiplayerID]);
     }
 }
        /// <summary>Raised after the game is launched, right before the first update tick. This happens once per game session (unrelated to loading saves). All mods are loaded and initialized at this point, so this is a good time to set up mod integrations.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        private void OnGameLaunched(object sender, GameLaunchedEventArgs e)
        {
            new DataLoader(ModHelper);

            ConfigMenuController.CreateConfigMenu(ModManifest);

            var harmony = HarmonyInstance.Create("Digus.MailServiceMod");

            harmony.Patch(
                original: AccessTools.Method(typeof(GameLocation), nameof(GameLocation.blacksmith)),
                postfix: new HarmonyMethod(typeof(ToolUpgradeOverrides), nameof(ToolUpgradeOverrides.blacksmith))
                );
            harmony.Patch(
                original: AccessTools.Method(typeof(Farmer), nameof(Farmer.addItemsByMenuIfNecessary)),
                prefix: new HarmonyMethod(typeof(ToolUpgradeOverrides), nameof(ToolUpgradeOverrides.addItemsByMenuIfNecessary))
                );
            harmony.Patch(
                original: AccessTools.Method(typeof(GameLocation), nameof(GameLocation.mailbox)),
                prefix: new HarmonyMethod(typeof(ToolUpgradeOverrides), nameof(ToolUpgradeOverrides.mailbox))
                );

            harmony.Patch(
                original: AccessTools.Method(typeof(GameLocation), nameof(GameLocation.mailbox)),
                prefix: new HarmonyMethod(typeof(ItemShipmentQuestOverrides), nameof(ItemShipmentQuestOverrides.mailbox))
                );

            harmony.Patch(
                original: AccessTools.Method(typeof(GameLocation), nameof(GameLocation.answerDialogueAction)),
                prefix: new HarmonyMethod(typeof(GuildRecoveryOverrides), nameof(GuildRecoveryOverrides.answerDialogueAction))
                );
            harmony.Patch(
                original: AccessTools.Method(typeof(Item), nameof(Item.actionWhenPurchased)),
                prefix: new HarmonyMethod(typeof(GuildRecoveryOverrides), nameof(GuildRecoveryOverrides.actionWhenPurchased))
                );

            harmony.Patch(
                original: AccessTools.Method(typeof(GameLocation), nameof(GameLocation.mailbox)),
                prefix: new HarmonyMethod(typeof(GiftShipmentOverrides), nameof(GiftShipmentOverrides.mailbox))
                );
            harmony.Patch(
                original: AccessTools.Method(typeof(GameLocation), nameof(GameLocation.answerDialogueAction)),
                prefix: new HarmonyMethod(typeof(GiftShipmentOverrides), nameof(GiftShipmentOverrides.answerDialogueAction))
                );
        }