Ejemplo n.º 1
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)
        {
            helper.Events.GameLoop.UpdateTicking += UpdateTicking;
            Config          = Helper.ReadConfig <ModConfig>();
            magnetRangeMult = Config.MagnetRangeMult;
            magnetSpeedMult = Config.MagnetSpeedMult;
            noLootBounce    = Config.NoLootBounce;
            noLootWave      = Config.NoLootWave;

            ObjectPatches.Initialize(Monitor);

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

            harmony.Patch(
                original: AccessTools.Method(typeof(Debris), "playerInRange"),
                prefix: new HarmonyMethod(typeof(ObjectPatches), nameof(ObjectPatches.playerInRange_Prefix))
                );
        }
Ejemplo n.º 2
0
    /// <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)
    {
        var harmony = new Harmony(this.ModManifest.UniqueID); // this could spawn a gateway to hell

        Helper1 = helper;
        harmony.Patch(
            original: AccessTools.Method(typeof(Utility), nameof(Utility.getGiftFromNPC)),
            prefix: new HarmonyMethod(typeof(ObjectPatches), nameof(ObjectPatches.getGiftFromNPC_Prefix))
            );
        foreach (IContentPack contentPack in this.Helper.ContentPacks.GetOwned())
        {
            this.Monitor.Log($"Reading content pack: {contentPack.Manifest.Name} {contentPack.Manifest.Version} from {contentPack.DirectoryPath}");
            if (!contentPack.HasFile("content.json"))
            {
                Monitor.Log($"{contentPack.Manifest.Name} {contentPack.Manifest.Version} is missing a \"content.json\" file.", LogLevel.Error);
                contentPack.WriteJsonFile("content.json", new ModData());
            }
            else
            {
                ModData modData = contentPack.ReadJsonFile <ModData>("content.json");
                Data.Add(modData);
                Monitor.Log($"Added ModData to Data.");
                foreach (ModData m in Data)
                {
                    foreach (NPCGifts n in m.NPCGifts)
                    {
                        foreach (ItemNames i in n.ItemNames)
                        {
                            Monitor.Log($"ItemNames is null: {i == null}");
                            Monitor.Log($"Priority: {n.Priority}");
                        }
                    }
                }
            }
        }
        ObjectPatches.Initialize(Monitor, helper);
        helper.Events.GameLoop.SaveLoaded += GameLoop_SaveLoaded;
    }