Example #1
0
        private void Interactor_PerformInteraction(On.RoR2.Interactor.orig_PerformInteraction orig, Interactor self, GameObject interactableObject)
        {
            PurchaseInteraction purchaseInteraction = interactableObject.GetComponent <PurchaseInteraction>();

            if (purchaseInteraction)
            {
                TrustyLockpicksComponent component = interactableObject.GetComponent <TrustyLockpicksComponent>();
                if (!component || (component && !component.failed))
                {
                    CharacterBody characterBody = self.GetComponent <CharacterBody>();
                    if (characterBody)
                    {
                        Inventory inventory = characterBody.inventory;
                        if (inventory)
                        {
                            int InventoryCount = characterBody.inventory.GetItemCount(catalogIndex);
                            if (InventoryCount > 0)
                            {
                                purchaseInteraction.GetInteractability(self);

                                if (purchaseInteraction.isShrine == false && purchaseInteraction.available && purchaseInteraction.costType == CostTypeIndex.Money) //if not shrine, is available, and is not a lunar pod
                                {
                                    purchaseInteraction.SetAvailable(false);
                                    purchaseInteraction.Networkavailable = false;

                                    purchaseInteraction.gameObject.GetComponent <ChestBehavior>().Open();

                                    //purchaseInteraction.cost = 0;
                                    //purchaseInteraction.Networkcost = 0;

                                    purchaseInteraction.onPurchase.Invoke(self);
                                    purchaseInteraction.lastActivator = self;

                                    inventory.RemoveItem(catalogIndex);
                                }
                            }
                        }
                    }
                }
            }
            orig(self, interactableObject);
        }