Ejemplo n.º 1
0
        public override void Patch()
        {
            base.Patch();

            ObjectInteraction reduceAmmoPrices = RogueLibsInteractions.CreateOriginalInteraction("ReduceAmmoPrices", InteractionType.Button,
                                                                                                 (agent, obj) => obj is AmmoDispenser a && !a.isBrokenShowButtons() && agent.interactionHelper.interactingFar && a.hacked == 0);

            reduceAmmoPrices.Action = (agent, obj) =>
            {
                obj.gc.audioHandler.Play(agent, "Success");
                ((AmmoDispenser)obj).ReduceAmmoPrices(agent);
                return(true);
            };

            ObjectInteraction hackExplode = RogueLibsInteractions.CreateOriginalInteraction("HackExplode", InteractionType.Button,
                                                                                            (agent, obj) => obj is AmmoDispenser a && !a.isBrokenShowButtons() && agent.interactionHelper.interactingFar && ((agent.oma.superSpecialAbility && agent.agentName == "Hacker") || agent.statusEffects.hasTrait("HacksBlowUpObjects")));
            // action is defined in ObjectReal.PressedButton

            ObjectInteraction refillGun = RogueLibsInteractions.CreateOriginalInteraction("RefillGun", InteractionType.Button,
                                                                                          (agent, obj) => obj is AmmoDispenser a && !a.isBrokenShowButtons() && !agent.interactionHelper.interactingFar && agent.inventory.InvItemList.Any(i => i.itemType == "WeaponProjectile"));

            refillGun.Action = (_, obj) =>
            {
                obj.ShowUseOn("RefillGun");
                return(false);
            };

            ObjectInteraction giveMechOil = RogueLibsInteractions.CreateOriginalInteraction("GiveMechOil", InteractionType.Button,
                                                                                            (agent, obj) =>
            {
                if (!(obj is AmmoDispenser a) || a.isBrokenShowButtons() || !agent.statusEffects.hasTrait("OilRestoresHealth"))
                {
                    return(false);
                }

                InvItem invItem = new InvItem
                {
                    invItemName  = "OilContainer",
                    invItemCount = 1
                };
                invItem.ItemSetup(false);
                float num = 1.5f;
                if (agent.statusEffects.hasTrait("OilRestoresMoreHealth") || agent.oma.superSpecialAbility)
                {
                    num = 3f;
                }

                invItem.itemValue = (int)(invItem.itemValue / num);
                float num2        = agent.health / invItem.initCount * invItem.itemValue;
                int num3          = Mathf.Max(obj.determineMoneyCost((int)(agent.healthMax / invItem.initCount * invItem.itemValue - num2), "AmmoDispenser"), 0);
                return(num3 > 0);
            });
Ejemplo n.º 2
0
        public override void Patch()
        {
            base.Patch();

            ObjectInteraction makeOferring = RogueLibsInteractions.CreateOriginalInteraction("MakeOffering", InteractionType.Button,
                                                                                             (agent, obj) => obj is Altar a && !agent.interactionHelper.interactingFar);

            makeOferring.Action = (_, obj) =>
            {
                Altar altar = (Altar)obj;
                if (altar.offeringsMade >= altar.offeringLimit)
                {
                    altar.gc.audioHandler.Play(altar, "CantDo");
                    return(true);
                }
                altar.interactingAgent.SayDialogue("OfferingMustBeInBuilding");
                altar.commander = altar.interactingAgent;
                altar.interactingAgent.mainGUI.invInterface.ShowTarget(altar, "MakeOffering");
                IEnumerator enumerator = (IEnumerator)AccessTools.Method(typeof(Altar), "MakingOffer").Invoke(altar, new object[0]);
                altar.StartCoroutine(enumerator);
                return(false);
            };
        }