public override void Entry(IModHelper helper) { // Initialize variables // config = Helper.ReadConfig <ModConfig>(); monitor = Monitor; modHelper = helper; companionsManager = new CompanionsManager(); //**********************// // Patch methods // HarmonyInstance harmony = HarmonyInstance.Create("Redwood.FollowerNPC"); Type[] isCollidingPositionTypes0 = new Type[] { typeof(Rectangle), typeof(xTile.Dimensions.Rectangle), typeof(bool), typeof(int), typeof(bool), typeof(Character), typeof(bool), typeof(bool), typeof(bool) }; Type[] isCollidingPositionTypes1 = new Type[] { typeof(GameLocation), typeof(Rectangle), typeof(xTile.Dimensions.Rectangle), typeof(bool), typeof(int), typeof(bool), typeof(Character), typeof(bool), typeof(bool), typeof(bool) }; MethodInfo isCollidingPositionOriginal = typeof(GameLocation).GetMethod("isCollidingPosition", isCollidingPositionTypes0); MethodInfo isCollidingPositionprefix = typeof(Patches).GetMethod("Prefix", isCollidingPositionTypes1); MethodInfo isCollidingPositionpostfix = typeof(Patches).GetMethod("Postfix", isCollidingPositionTypes1); harmony.Patch(isCollidingPositionOriginal, new HarmonyMethod(isCollidingPositionprefix), new HarmonyMethod(isCollidingPositionpostfix)); //Type[] movePositionTypes0 = new Type[] { typeof(GameTime), typeof(Rectangle), typeof(GameLocation) }; //Type[] movePositionTypes1 = new Type[] { typeof(NPC), typeof(GameTime), typeof(Rectangle), typeof(GameLocation) }; //MethodInfo movePositionOriginal = typeof(NPC).GetMethod("MovePosition"); //MethodInfo movePositionPrefix = typeof(Patches).GetMethod("Prefix", movePositionTypes1); //harmony.Patch(movePositionOriginal, new HarmonyMethod(movePositionPrefix), null); Type[] updateMovementTypes0 = new Type[] { typeof(GameLocation), typeof(GameTime) }; Type[] updateMovementTypes1 = new Type[] { typeof(NPC), typeof(GameLocation), typeof(GameTime) }; MethodInfo updateMovementOriginal = typeof(NPC).GetMethod("updateMovement"); MethodInfo updateMovementPrefix = typeof(Patches).GetMethod("Prefix", updateMovementTypes1); harmony.Patch(updateMovementOriginal, new HarmonyMethod(updateMovementPrefix), null); applyVelocity = typeof(Character).GetMethod("applyVelocity", BindingFlags.NonPublic | BindingFlags.Instance); //**********************// // Subscribe to events // Helper.Events.Input.ButtonReleased += Input_ButtonReleased; //**********************// }
public override void Entry(IModHelper helper) { // Initialize variables // config = Helper.ReadConfig <ModConfig>(); monitor = Monitor; modHelper = helper; companionsManager = new CompanionsManager(); //**********************// // Patch methods // HarmonyInstance harmony = HarmonyInstance.Create("Redwood.FollowerNPC"); Type[] isCollidingPositionTypes0 = new Type[] { typeof(Rectangle), typeof(xTile.Dimensions.Rectangle), typeof(bool), typeof(int), typeof(bool), typeof(Character), typeof(bool), typeof(bool), typeof(bool) }; Type[] isCollidingPositionTypes1 = new Type[] { typeof(GameLocation), typeof(Rectangle), typeof(xTile.Dimensions.Rectangle), typeof(bool), typeof(int), typeof(bool), typeof(Character), typeof(bool), typeof(bool), typeof(bool) }; MethodInfo isCollidingPositionOriginal = typeof(GameLocation).GetMethod("isCollidingPosition", isCollidingPositionTypes0); MethodInfo isCollidingPositionprefix = typeof(Patches).GetMethod("Prefix", isCollidingPositionTypes1); MethodInfo isCollidingPositionpostfix = typeof(Patches).GetMethod("Postfix", isCollidingPositionTypes1); harmony.Patch(isCollidingPositionOriginal, new HarmonyMethod(isCollidingPositionprefix), new HarmonyMethod(isCollidingPositionpostfix)); //Type[] movePositionTypes0 = new Type[] { typeof(GameTime), typeof(Rectangle), typeof(GameLocation) }; //Type[] movePositionTypes1 = new Type[] { typeof(NPC), typeof(GameTime), typeof(Rectangle), typeof(GameLocation) }; //MethodInfo movePositionOriginal = typeof(NPC).GetMethod("MovePosition"); //MethodInfo movePositionPrefix = typeof(Patches).GetMethod("Prefix", movePositionTypes1); //harmony.Patch(movePositionOriginal, new HarmonyMethod(movePositionPrefix), null); Type[] updateMovementTypes0 = new Type[] { typeof(GameLocation), typeof(GameTime) }; Type[] updateMovementTypes1 = new Type[] { typeof(NPC), typeof(GameLocation), typeof(GameTime) }; MethodInfo updateMovementOriginal = typeof(NPC).GetMethod("updateMovement"); MethodInfo updateMovementPrefix = typeof(Patches).GetMethod("Prefix", updateMovementTypes1); harmony.Patch(updateMovementOriginal, new HarmonyMethod(updateMovementPrefix), null); Type[] faceTowardFarmerForPeriodTypes1 = new Type[] { typeof(NPC) }; MethodInfo faceTowardFarmerForPeriodOriginal = typeof(NPC).GetMethod("faceTowardFarmerForPeriod"); MethodInfo faceTowardFarmerForPeriodPrefix = typeof(Patches).GetMethod("Prefix", faceTowardFarmerForPeriodTypes1); harmony.Patch(faceTowardFarmerForPeriodOriginal, new HarmonyMethod(faceTowardFarmerForPeriodPrefix), null); Type[] gainExperienceTypes1 = new Type[] { typeof(Farmer), typeof(int).MakeByRefType() }; MethodInfo gainExperienceOriginal = typeof(Farmer).GetMethod("gainExperience"); MethodInfo gainExperiencePrefix = typeof(Patches).GetMethod("Prefix", gainExperienceTypes1); harmony.Patch(gainExperienceOriginal, new HarmonyMethod(gainExperiencePrefix), null); fishingLeftAnim = new List <FarmerSprite.AnimationFrame> { new FarmerSprite.AnimationFrame(0, 4000, false, true, null, false), new FarmerSprite.AnimationFrame(0, 4000, false, true, null, false) }; fishingRightAnim = new List <FarmerSprite.AnimationFrame> { new FarmerSprite.AnimationFrame(20, 4000), new FarmerSprite.AnimationFrame(21, 4000) }; applyVelocity = typeof(Character).GetMethod("applyVelocity", BindingFlags.NonPublic | BindingFlags.Instance); //**********************// // Subscribe to events // //Helper.Events.Input.ButtonReleased += Input_ButtonReleased; //**********************// }
public static CompanionBuff InitializeBuffFromCompanionName(string companionName, Farmer farmer, CompanionsManager cm) { NPC n = Game1.getCharacterFromName(companionName); CompanionBuff companionBuff; switch (companionName) { case "Abigail": companionBuff = new Buffs.AbigailBuff(farmer, n); break; case "Alex": companionBuff = new Buffs.AlexBuff(farmer, n); break; case "Elliott": companionBuff = new Buffs.ElliottBuff(farmer, n); break; case "Emily": companionBuff = new Buffs.EmilyBuff(farmer, n); break; case "Haley": companionBuff = new Buffs.HaleyBuff(farmer, n); break; case "Harvey": companionBuff = new Buffs.HarveyBuff(farmer, n); break; case "Leah": companionBuff = new Buffs.LeahBuff(farmer, n); (companionBuff as Buffs.LeahBuff).SetForageFoundDialogue(new string[] { cm.npcDialogueScripts["Leah"]["companionPerk1"], cm.npcDialogueScripts["Leah"]["companionPerk2a"], cm.npcDialogueScripts["Leah"]["companionPerk2b"], }); break; case "Maru": companionBuff = new Buffs.MaruBuff(farmer, n); break; case "Penny": companionBuff = new Buffs.PennyBuff(farmer, n); break; case "Sam": companionBuff = new Buffs.SamBuff(farmer, n); break; case "Sebastian": companionBuff = new Buffs.SebastianBuff(farmer, n); break; case "Shane": companionBuff = new Buffs.ShaneBuff(farmer, n); break; default: companionBuff = new Buffs.AbigailBuff(farmer, n); break; } companionBuff.buff.millisecondsDuration = 1200000; Game1.buffsDisplay.addOtherBuff(companionBuff.buff); companionBuff.buff.which = -420; if (companionBuff.statBuffs != null) { foreach (Buff b in companionBuff.statBuffs) { if (b != null) { b.millisecondsDuration = 1200000; Game1.buffsDisplay.addOtherBuff(b); b.which = -420; } } } companionBuff.manager = cm; return(companionBuff); }
public CompanionBuff(Farmer farmer, NPC npc, CompanionsManager manager) { buffOwner = farmer; buffGranter = npc; this.manager = manager; }