//TODO: A method to hook into to Modify each item changed by the mod DONE //flow > Hook > Load UIDs of Modded Items > Mod those items back to what they were //Used for potentially modifying an item then saving that UID and Modification to the Item DB private void chestActivateHook(On.InteractionOpenChest.orig_OnActivate orig, InteractionOpenChest self) { orig(self); ItemContainer chestContainer = outwardUTILS.ReflectionGetValue <ItemContainer>(typeof(InteractionOpenChest), self, "m_chest"); Debug.Log(chestContainer.UID); if (openedChests.Contains(chestContainer.UID)) { Debug.Log("Chest Already been looted"); } else { Debug.Log("this should fire when a chest is opened"); Debug.Log(chestContainer.IsInWorld); Debug.Log(chestContainer.ItemCount); List <Weapon> weapons = chestContainer.GetItemOfType <Weapon>(); Debug.Log("Weapon in chest count"); Debug.Log(weapons.Count); List <Armor> armour = chestContainer.GetItemOfType <Armor>(); Debug.Log("Armor in chest count"); Debug.Log(armour.Count); if (weapons.Count > 0) { var itemMod = Itemreroller.ReRollWeapon(weapons[0]); if (itemMod != null) { modifiedStuff.Add(itemMod); } else { Debug.Log("A Null ItemMod can't be added to a list"); } } if (armour.Count > 0) { var itemMod = Itemreroller.ReRollArmour(armour[0]); if (itemMod != null) { modifiedStuff.Add(itemMod); } else { Debug.Log("A Null ItemMod can't be added to a list"); } } openedChests.Add(chestContainer.UID); } }
public static bool OnActivate(InteractionOpenChest __instance) { // Disable generation content for house stash if (__instance.Item is TreasureChest && (__instance.Item as TreasureChest).SpecialType == ItemContainer.SpecialContainerTypes.Stash) { AccessTools.Field(typeof(TreasureChest), "m_hasGeneratedContent").SetValue(__instance.Item, true); } return(true); }