private Interactability PurchaseInteraction_GetInteractability(On.RoR2.PurchaseInteraction.orig_GetInteractability orig, PurchaseInteraction self, Interactor activator)
        {
            CharacterBody buddy = activator.GetComponent <CharacterBody>();

            if (self.costType == CostTypeIndex.None)
            {
                if (self.displayNameToken.ToLower() == "lockbox_name")
                {
                    if (buddy && buddy.inventory && buddy.inventory.GetItemCount(ItemIndex.TreasureCache) == 0)
                    {
                        return(Interactability.Disabled);
                    }
                }
            }
            return(orig(self, activator));
        }
示例#2
0
        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));
        }
示例#3
0
        private Interactability PreventEquipmentFromAllowance(On.RoR2.PurchaseInteraction.orig_GetInteractability orig, PurchaseInteraction self, Interactor activator)
        {
            SummonMasterBehavior summonMasterBehavior = self.gameObject.GetComponent <SummonMasterBehavior>();

            if (summonMasterBehavior && summonMasterBehavior.callOnEquipmentSpentOnPurchase)
            {
                CharacterBody characterBody = activator.GetComponent <CharacterBody>();
                if (characterBody && characterBody.inventory)
                {
                    if (bannedEquipmentIndices.Contains(characterBody.inventory.currentEquipmentIndex))
                    {
                        return(Interactability.ConditionsNotMet);
                    }
                }
            }
            return(orig(self, activator));
        }
示例#4
0
        private Interactability PurchaseInteraction_GetInteractability(On.RoR2.PurchaseInteraction.orig_GetInteractability orig, PurchaseInteraction self, Interactor activator)
        {
            var gameObject = self.gameObject;
            TrustyLockpicksComponent component = gameObject.GetComponent <TrustyLockpicksComponent>();

            if (!component)
            {
                component = gameObject.AddComponent <TrustyLockpicksComponent>();
            }
            Highlight           highlight           = gameObject.GetComponent <Highlight>();
            PurchaseInteraction purchaseInteraction = gameObject.GetComponent <PurchaseInteraction>();
            CharacterBody       characterBody       = activator.GetComponent <CharacterBody>();

            Interactability Result(HighlightColor highlightColor, string contextTokenType = "", Interactability interactability = Interactability.Available)
            {
                //var resultContext = (prefix + purchaseInteraction.contextToken);
                if (highlight)
                {
                    highlight.highlightColor = highlightColor;
                }
                if (purchaseInteraction)
                {
                    string context;
                    switch (contextTokenType.ToLower())
                    {
                    case "key":
                        context = prefix + purchaseInteraction.contextToken + "_KEY";
                        break;

                    case "lockpick":
                        context = prefix + purchaseInteraction.contextToken + "_LOCKPICK";
                        break;

                    case "both":
                        context = prefix + purchaseInteraction.contextToken + "_BOTH";
                        break;

                    default:
                        context = component.oldContext;
                        break;
                    }
                    if (purchaseInteraction.contextToken == component.oldContext)
                    {
                        purchaseInteraction.contextToken = context;
                    }
                    Debug.Log("Context + " + context + "");
                }
                return(interactability);
            }

            // If it's been picked and failed before //
            if (component && component.failed)
            {
                Result(red);
                return(orig(self, activator));
            }
            if (characterBody)
            {
                Inventory inventory = characterBody.inventory;
                if (inventory)
                {
                    if (self.isShrine == false && self.available && self.costType == CostTypeIndex.Money) //if not shrine, is available, and is not a lunar pod
                    {
                        bool HasKey          = characterBody.inventory.GetItemCount(catalogIndex) > 0;
                        bool LockpicksActive = inventory.GetEquipmentIndex() == TrustyLockpicks.instance.catalogIndex;
                        //bool EquipmentReady = inventory.GetEquipmentRestockableChargeCount(0) > 0;
                        bool LockpicksReady = LockpicksActive;
                        if (component.oldContext == "")
                        {
                            component.oldContext = purchaseInteraction.contextToken; //Stores the default context once
                        }
                        if (HasKey)                                                  //a
                        {
                            if (LockpicksReady)
                            {
                                return(Result(yellow, "both"));                //a b : has both
                            }
                            else
                            {
                                return(Result(white, "key"));  //a !b : only has key
                            }
                        }
                        else //!a
                        {
                            if (LockpicksReady)
                            {
                                return(Result(yellow, "lockpick"));                //!a b : only lockpicks
                            }
                            if (component && component.oldContext != "")
                            {
                                purchaseInteraction.contextToken = component.oldContext;
                            }
                            Result(yellow); //!a !b :has neither
                            return(orig(self, activator));
                        }
                    }
                }
            }
            if (component && component.oldContext != "")
            {
                purchaseInteraction.contextToken = component.oldContext;
            }
            Result(yellow);
            return(orig(self, activator));
        }
        private Interactability PurchaseInteraction_GetInteractability(On.RoR2.PurchaseInteraction.orig_GetInteractability orig, PurchaseInteraction self, Interactor activator)
        {
            var       gameObject = self.gameObject;
            Highlight highlight  = gameObject.GetComponent <Highlight>();
            //if (!highlight) return orig(self, activator);

            TrustyLockpicksComponent component = gameObject.GetComponent <TrustyLockpicksComponent>();

            //if (attempted) return orig(self, activator);
            if (component && component.failed)
            {
                if (highlight)
                {
                    highlight.highlightColor = Highlight.HighlightColor.teleporter;
                }
                return(orig(self, activator));
            }

            PurchaseInteraction purchaseInteraction = gameObject.GetComponent <PurchaseInteraction>();

            if (!component)
            {
                component = gameObject.AddComponent <TrustyLockpicksComponent>();
            }

            CharacterBody characterBody = activator.GetComponent <CharacterBody>();

            if (characterBody)
            {
                Inventory inventory = characterBody.inventory;
                if (inventory)
                {
                    if (self.isShrine == false && self.available && self.costType == CostTypeIndex.Money) //if not shrine, is available, and is not a lunar pod
                    {
                        EquipmentIndex equipmentIndex = inventory.GetEquipmentIndex();
                        if (equipmentIndex == catalogIndex)
                        {
                            if (inventory.GetEquipmentRestockableChargeCount(0) > 0)
                            {
                                if (highlight)
                                {
                                    highlight.highlightColor = Highlight.HighlightColor.pickup;
                                }
                            }
                            if (purchaseInteraction)
                            {
                                var resultContext = (prefix + purchaseInteraction.contextToken);
                                if (component.oldContext == "")
                                {
                                    component.oldContext = purchaseInteraction.contextToken;
                                }

                                if (purchaseInteraction.contextToken == component.oldContext)
                                {
                                    purchaseInteraction.contextToken = resultContext;
                                }
                            }
                            return(Interactability.Available);
                        }
                    }
                }
            }
            if (highlight)
            {
                highlight.highlightColor = Highlight.HighlightColor.interactive;
            }
            if (component && component.oldContext != "")
            {
                purchaseInteraction.contextToken = component.oldContext;
            }
            return(orig(self, activator));
        }