private Interactability PurchaseInteraction_GetInteractability(On.RoR2.PurchaseInteraction.orig_GetInteractability orig, PurchaseInteraction self, Interactor activator) { var gameObject = self.gameObject; Highlight highlight = gameObject.GetComponent <Highlight>(); BulletstormChestInteractorComponent bulletstormChestInteractor = gameObject.GetComponent <BulletstormChestInteractorComponent>(); if (bulletstormChestInteractor && bulletstormChestInteractor.hasUsedLockpicks) { if (highlight) { highlight.highlightColor = Highlight.HighlightColor.teleporter; } return(orig(self, activator)); } return(orig(self, activator)); }
private bool AttemptUnlock(GameObject chestObject, InteractionDriver interactionDriver, float UnlockChance) { if (!interactionDriver) { return(false); } Highlight highlight = chestObject.GetComponent <Highlight>(); PurchaseInteraction purchaseInteraction = chestObject.GetComponent <PurchaseInteraction>(); if (!highlight || !purchaseInteraction) { return(false); } BulletstormChestInteractorComponent chestComponent = chestObject.GetComponent <BulletstormChestInteractorComponent>(); if (chestComponent && chestComponent.hasUsedLockpicks) { return(false); } GameObject selectedEffect = UnlockEffect; Vector3 offset = Vector3.up * 1f; if (!purchaseInteraction.isShrine && purchaseInteraction.available && purchaseInteraction.costType == CostTypeIndex.Money) { Interactor interactor = interactionDriver.interactor; //interactionDriver.interactor.AttemptInteraction(chestObject); if (Util.CheckRoll(UnlockChance)) { purchaseInteraction.SetAvailable(false); //purchaseInteraction.Networkavailable = false; purchaseInteraction.gameObject.GetComponent <ChestBehavior>().Open(); //purchaseInteraction.cost = 0; //purchaseInteraction.Networkcost = 0; purchaseInteraction.onPurchase.Invoke(interactor); purchaseInteraction.lastActivator = interactor; Util.PlaySound(UnlockSound, interactor.gameObject); EffectManager.SimpleEffect(UnlockEffect, chestObject.transform.position + offset, Quaternion.identity, true); } else { purchaseInteraction.cost = Mathf.CeilToInt(purchaseInteraction.cost * cfgPriceMultiplier.Value); //https://discord.com/channels/562704639141740588/562704639569428506/916819003064864788 purchaseInteraction.Networkcost = purchaseInteraction.cost; //weaver generated shit ^ selectedEffect = Fail_LockEffect; //purchaseInteraction.displayNameToken = (prefix + purchaseInteraction.displayNameToken); chestObject.AddComponent <BulletstormChestInteractorComponent>().hasUsedLockpicks = true; //does this even work? lol EffectManager.SimpleEffect(selectedEffect, chestObject.transform.position + offset, Quaternion.identity, true); } return(true); } else { return(false); } }