Esempio n. 1
0
 public static void Initialize(IModHelper _helper, IMonitor _monitor, ModConfig _config)
 {
     helper  = _helper;
     monitor = _monitor;
     config  = _config;
 }
Esempio n. 2
0
        public override void Entry(IModHelper helper)
        {
            config = Helper.ReadConfig <ModConfig>();
            if (!config.EnableMod)
            {
                return;
            }
            ZombiePatches.Initialize(Helper, Monitor, config);
            Utils.Initialize(Helper, Monitor, config);

            SMonitor = Monitor;

            Helper.Events.GameLoop.GameLaunched          += GameLoop_GameLaunched;
            Helper.Events.GameLoop.SaveLoaded            += GameLoop_SaveLoaded;
            Helper.Events.GameLoop.DayStarted            += GameLoop_DayStarted;
            Helper.Events.GameLoop.OneSecondUpdateTicked += GameLoop_OneSecondUpdateTicked;

            Helper.ConsoleCommands.Add("infect", "Infect an NPC with zombie virus. Usage: infect <npc>", new Action <string, string[]>(Utils.InfectNPC));
            Helper.ConsoleCommands.Add("infectplayer", "Infect local player with zombie virus.", new Action <string, string[]>(Utils.InfectPlayer));


            var harmony = HarmonyInstance.Create(ModManifest.UniqueID);

            harmony.Patch(
                original: AccessTools.Method(typeof(NPC), nameof(NPC.draw), new Type[] { typeof(SpriteBatch), typeof(float) }),
                prefix: new HarmonyMethod(typeof(ZombiePatches), nameof(ZombiePatches.NPC_draw_prefix))
                );

            harmony.Patch(
                original: AccessTools.Method(typeof(Farmer), nameof(Farmer.draw), new Type[] { typeof(SpriteBatch) }),
                prefix: new HarmonyMethod(typeof(ZombiePatches), nameof(ZombiePatches.Farmer_draw_prefix))
                );

            harmony.Patch(
                original: AccessTools.Method(typeof(Farmer), nameof(Farmer.eatObject)),
                prefix: new HarmonyMethod(typeof(ZombiePatches), nameof(ZombiePatches.Farmer_eatObject_prefix))
                );


            harmony.Patch(
                original: AccessTools.Constructor(typeof(DialogueBox), new Type[] { typeof(string), typeof(List <Response>), typeof(int) }),
                prefix: new HarmonyMethod(typeof(ZombiePatches), nameof(ZombiePatches.DialogueBox_complex_prefix))
                );
            harmony.Patch(
                original: AccessTools.Method(typeof(NPC), nameof(NPC.showTextAboveHead)),
                prefix: new HarmonyMethod(typeof(ZombiePatches), nameof(ZombiePatches.NPC_showTextAboveHead_Prefix))
                );
            harmony.Patch(
                original: AccessTools.Method(typeof(NPC), nameof(NPC.getHi)),
                postfix: new HarmonyMethod(typeof(ZombiePatches), nameof(ZombiePatches.NPC_getHi_Postfix))
                );
            harmony.Patch(
                original: AccessTools.Method(typeof(Dialogue), "parseDialogueString"),
                prefix: new HarmonyMethod(typeof(ZombiePatches), nameof(ZombiePatches.Dialogue_prefix))
                );

            harmony.Patch(
                original: AccessTools.Method(typeof(ShopMenu), nameof(ShopMenu.setUpShopOwner)),
                postfix: new HarmonyMethod(typeof(ZombiePatches), nameof(ZombiePatches.setUpShopOwner_postfix))
                );

            harmony.Patch(
                original: AccessTools.Method(typeof(NPC), nameof(NPC.tryToReceiveActiveObject)),
                prefix: new HarmonyMethod(typeof(ZombiePatches), nameof(ZombiePatches.NPC_tryToReceiveActiveObject_prefix))
                );
        }