Exemple #1
0
 void AttemptInteraction(On.RoR2.Interactor.orig_AttemptInteraction orig, RoR2.Interactor interactor, GameObject gameObject)
 {
     if (Data.modEnabled && interactor.GetComponent <NetworkBehaviour>().hasAuthority)
     {
         if (Data.mode == DataShop.mode)
         {
             latestInteractionName = gameObject.name;
             DataShop.purchaseCost = 0;
             DataShop.purchaseTier = -1;
             if (gameObject.name.ToLower().Contains("duplicator"))
             {
                 Util.LogComponentsOfObject(gameObject);
             }
             if (gameObject.name == "Scrapper(Clone)")
             {
                 DataShop.purchaseCost = gameObject.GetComponent <ScrapperController>().maxItemsToScrapAtATime;
             }
             else
             {
                 RoR2.PurchaseInteraction purchaseInteraction = purchaseInteraction = gameObject.GetComponent <RoR2.PurchaseInteraction>();
                 if (purchaseInteraction != null)
                 {
                     if (DataShop.costTypeTier.ContainsKey(purchaseInteraction.costType))
                     {
                         DataShop.purchaseTier = DataShop.costTypeTier[purchaseInteraction.costType];
                         DataShop.purchaseCost = purchaseInteraction.cost;
                     }
                 }
             }
         }
     }
     orig(interactor, gameObject);
 }
Exemple #2
0
        private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, RoR2.PurchaseInteraction self, RoR2.Interactor activator)
        {
            //Get the lowercase name of the Interacted Object
            string objName = self.gameObject.name.ToLower();

            //Check if its a supported Chest
            if (!objName.Contains("chest1") && !objName.Contains("chest2") && !objName.Contains("goldchest") && !objName.Contains("equipmentbarrel") && !objName.Contains("isclockbox"))
            {
                orig.Invoke(self, activator);
                return;
            }

            //Get the chest type
            //Too lazy and tired to make it prettier
            int chestType = objName.Contains("chest1") ? 0 : objName.Contains("chest2") ? 1 : objName.Contains("goldchest") ? 2 : objName.Contains("isclockbox") ? 3 : -1;

            //Randomly Select Tier
            double tier = GetRandomTier(chestType);

            //Send every client a message that a chest has been opened
            ExampleFuncClient.Invoke(activator.gameObject, check =>
            {
                //Check which client opened the chest and wheter or not he is idling
                Debug.Log("Check: " + check);
                if (check == 0)
                {
                    orig.Invoke(self, activator);
                }
                if (check != 0)
                {
                    return;
                }


                if (objName.Contains("equipmentbarrel"))
                {
                    //Signal the server that a chest has been opened
                    //Give the player that opend it and the chest position
                    ExampleCommandClientCustom.Invoke(x =>
                    {
                        x.Write("Chest");
                        x.Write(activator.gameObject);
                        x.Write(self.gameObject.transform);
                        //Specify tier as Equipment
                        x.Write((double)6);
                    });
                }
                else
                {
                    // RNG Value was above specified percantage values
                    // Cancel the drop

                    /*if (tier == 0)
                     * {
                     *  Debug.Log("Mhh Unlucky you found nothing in this Chest.");
                     *  return;
                     * }*/

                    //Signal the server that a chest has been opened
                    //Give the player that opend it and the chest position
                    ExampleCommandClientCustom.Invoke(x =>
                    {
                        x.Write("Chest");
                        x.Write(activator.gameObject);
                        x.Write(self.gameObject.transform);
                        x.Write(tier);
                    });
                }
            });
        }
Exemple #3
0
 // Token: 0x06000D3A RID: 3386 RVA: 0x0003B6CB File Offset: 0x000398CB
 private void Awake()
 {
     this.networkIdentity = base.GetComponent <NetworkIdentity>();
     this.interactor      = base.GetComponent <Interactor>();
     this.inputBank       = base.GetComponent <InputBankTest>();
 }
Exemple #4
0
 // Token: 0x06000B58 RID: 2904 RVA: 0x00032130 File Offset: 0x00030330
 public void OnInteractionBegin(Interactor activator)
 {
     this.AttemptGrant(activator.GetComponent <CharacterBody>());
 }
Exemple #5
0
 // Token: 0x06000B4E RID: 2894 RVA: 0x00031DF2 File Offset: 0x0002FFF2
 public string GetContextString(Interactor activator)
 {
     return(string.Format(Language.GetString(this.pickupIndex.GetInteractContextToken()), this.GetDisplayName()));
 }
Exemple #6
0
        private static void OnShopPurchase(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, RoR2.PurchaseInteraction self, RoR2.Interactor activator)
        {
            if (!self.CanBeAffordedByInteractor(activator))
            {
                return;
            }
            #region Sharedmoney

            if (ShareSuite.MoneyIsShared.Value)
            {
                switch (self.costType)
                {
                case CostTypeIndex.Money:
                {
                    // Remove money from shared money pool
                    orig(self, activator);
                    MoneySharingHooks.SharedMoneyValue -= self.cost;
                    return;
                }

                case CostTypeIndex.PercentHealth:
                {
                    // Share the damage taken from a sacrifice
                    // as it generates shared money
                    orig(self, activator);
                    var teamMaxHealth = 0;
                    foreach (var playerCharacterMasterController in PlayerCharacterMasterController.instances)
                    {
                        var charMaxHealth = playerCharacterMasterController.master.GetBody().maxHealth;
                        if (charMaxHealth > teamMaxHealth)
                        {
                            teamMaxHealth = (int)charMaxHealth;
                        }
                    }

                    var purchaseInteraction = self.GetComponent <PurchaseInteraction>();
                    var shrineBloodBehavior = self.GetComponent <ShrineBloodBehavior>();
                    var amount = (uint)(teamMaxHealth * purchaseInteraction.cost / 100.0 *
                                        shrineBloodBehavior.goldToPaidHpRatio);

                    if (ShareSuite.MoneyScalarEnabled.Value)
                    {
                        amount *= (uint)ShareSuite.MoneyScalar.Value;
                    }

                    MoneySharingHooks.SharedMoneyValue += (int)amount;
                    return;
                }
                }
            }
            orig(self, activator);

            #endregion
        }
 // Token: 0x06001191 RID: 4497 RVA: 0x0004CC2D File Offset: 0x0004AE2D
 public override void HandleInteractionServer(Interactor activator)
 {
     base.HandleInteractionServer(activator);
     this.outer.SetNextState(new RouletteChestController.Startup());
 }
 // Token: 0x060010AE RID: 4270 RVA: 0x00049245 File Offset: 0x00047445
 public bool CanBeAffordedByInteractor(Interactor activator)
 {
     return(CostTypeCatalog.GetCostTypeDef(this.costType).IsAffordable(this.cost, activator));
 }
Exemple #9
0
        // Token: 0x06000B8C RID: 2956 RVA: 0x0004C19C File Offset: 0x0004A39C
        public bool CanBeAffordedByInteractor(Interactor activator)
        {
            NetworkUser networkUser = Util.LookUpBodyNetworkUser(activator.gameObject);

            return(networkUser && (ulong)networkUser.lunarCoins >= (ulong)((long)this.GetCostForInteractor(activator)));
        }
Exemple #10
0
 // Token: 0x06000B8B RID: 2955 RVA: 0x000092C4 File Offset: 0x000074C4
 private int GetCostForInteractor(Interactor activator)
 {
     return(this.cost);
 }
Exemple #11
0
 // Token: 0x06000B8A RID: 2954 RVA: 0x000025DA File Offset: 0x000007DA
 public void OnInteractionBegin(Interactor activator)
 {
 }
Exemple #12
0
        // Token: 0x0600138F RID: 5007 RVA: 0x0005F7EC File Offset: 0x0005D9EC
        public void OnInteractionBegin(Interactor activator)
        {
            if (!this.CanBeAffordedByInteractor(activator))
            {
                return;
            }
            CharacterBody component = activator.GetComponent <CharacterBody>();

            switch (this.costType)
            {
            case CostType.Money:
                if (component)
                {
                    CharacterMaster master = component.master;
                    if (master)
                    {
                        master.money -= (uint)this.cost;
                    }
                }
                break;

            case CostType.PercentHealth:
            {
                HealthComponent component2 = activator.GetComponent <HealthComponent>();
                if (component2)
                {
                    float health = component2.health;
                    float num    = component2.fullHealth * (float)this.cost / 100f;
                    if (health > num)
                    {
                        component2.TakeDamage(new DamageInfo
                            {
                                damage     = num,
                                attacker   = base.gameObject,
                                position   = base.transform.position,
                                damageType = DamageType.BypassArmor
                            });
                    }
                }
                break;
            }

            case CostType.Lunar:
            {
                NetworkUser networkUser = Util.LookUpBodyNetworkUser(activator.gameObject);
                if (networkUser)
                {
                    networkUser.DeductLunarCoins((uint)this.cost);
                }
                break;
            }

            case CostType.WhiteItem:
            case CostType.GreenItem:
            case CostType.RedItem:
            {
                ItemTier itemTier = PurchaseInteraction.CostTypeToItemTier(this.costType);
                if (component)
                {
                    Inventory inventory = component.inventory;
                    if (inventory)
                    {
                        ItemIndex            itemIndex  = ItemIndex.None;
                        ShopTerminalBehavior component3 = base.GetComponent <ShopTerminalBehavior>();
                        if (component3)
                        {
                            itemIndex = component3.CurrentPickupIndex().itemIndex;
                        }
                        WeightedSelection <ItemIndex> weightedSelection = new WeightedSelection <ItemIndex>(8);
                        foreach (ItemIndex itemIndex2 in ItemCatalog.allItems)
                        {
                            if (itemIndex2 != itemIndex)
                            {
                                int itemCount = inventory.GetItemCount(itemIndex2);
                                if (itemCount > 0 && ItemCatalog.GetItemDef(itemIndex2).tier == itemTier)
                                {
                                    weightedSelection.AddChoice(itemIndex2, (float)itemCount);
                                }
                            }
                        }
                        List <ItemIndex> list = new List <ItemIndex>();
                        int num2 = 0;
                        while (weightedSelection.Count > 0 && num2 < this.cost)
                        {
                            int num3 = weightedSelection.EvaluteToChoiceIndex(this.rng.nextNormalizedFloat);
                            WeightedSelection <ItemIndex> .ChoiceInfo choice = weightedSelection.GetChoice(num3);
                            ItemIndex value = choice.value;
                            int       num4  = (int)choice.weight;
                            num4--;
                            if (num4 <= 0)
                            {
                                weightedSelection.RemoveChoice(num3);
                            }
                            else
                            {
                                weightedSelection.ModifyChoiceWeight(num3, (float)num4);
                            }
                            list.Add(value);
                            num2++;
                        }
                        for (int i = num2; i < this.cost; i++)
                        {
                            list.Add(itemIndex);
                        }
                        for (int j = 0; j < list.Count; j++)
                        {
                            ItemIndex itemIndex3 = list[j];
                            PurchaseInteraction.CreateItemTakenOrb(component.corePosition, base.gameObject, itemIndex3);
                            inventory.RemoveItem(itemIndex3, 1);
                            if (itemIndex3 != itemIndex)
                            {
                                Action <PurchaseInteraction, Interactor> action = PurchaseInteraction.onItemSpentOnPurchase;
                                if (action != null)
                                {
                                    action(this, activator);
                                }
                            }
                        }
                    }
                }
                break;
            }
            }
            IEnumerable <StatDef> statDefsToIncrement = this.purchaseStatNames.Select(new Func <string, StatDef>(StatDef.Find));

            StatManager.OnPurchase <IEnumerable <StatDef> >(component, this.costType, statDefsToIncrement);
            this.onPurchase.Invoke(activator);
            this.lastActivator = activator;
        }
Exemple #13
0
            void InteractionResult(On.RoR2.Interactor.orig_RpcInteractionResult orig, RoR2.Interactor interactor, bool boolean)
            {
                if (Data.modEnabled)
                {
                    if (Data.mode == DataShop.mode)
                    {
                        if (interactor.GetComponent <NetworkBehaviour>().hasAuthority)
                        {
                            if (boolean)
                            {
                                if (DataShop.purchaseTier != -1 && DataShop.purchaseCost > 0)
                                {
                                    DataShop.RemoveScrap(DataShop.purchaseTier, DataShop.purchaseCost);
                                }

                                Dictionary <string, string> specialCases = new Dictionary <string, string>()
                                {
                                    { "BrokenDroneMissile", "BrokenMissileDrone" },
                                };
                                string prefix       = "Broken";
                                string suffix       = "Master(Clone)";
                                string adjustedName = latestInteractionName;
                                if (adjustedName.Length > suffix.Length)
                                {
                                    adjustedName = adjustedName.Substring(0, adjustedName.Length - suffix.Length);
                                }
                                adjustedName = prefix + adjustedName;
                                if (specialCases.ContainsKey(adjustedName))
                                {
                                    adjustedName = specialCases[adjustedName];
                                }
                                if (Data.allDroneNames.ContainsKey(adjustedName))
                                {
                                    DataShop.AddScrap(characterBody, 6);
                                }
                            }
                        }
                    }
                }
                orig(interactor, boolean);
            }
 // Token: 0x0600119A RID: 4506 RVA: 0x0004CE2D File Offset: 0x0004B02D
 public override void HandleInteractionServer(Interactor activator)
 {
     base.HandleInteractionServer(activator);
     base.rouletteChestController.EndCycleServer(activator);
 }
 // Token: 0x060014C6 RID: 5318 RVA: 0x00058AA7 File Offset: 0x00056CA7
 public string GetContextString(Interactor activator)
 {
     return(Language.GetString(this.contextString));
 }
Exemple #16
0
 // Token: 0x06000F78 RID: 3960 RVA: 0x0004C31E File Offset: 0x0004A51E
 Interactability IInteractable.GetInteractability(Interactor activator)
 {
     return(this.interactability);
 }
 // Token: 0x060014C8 RID: 5320 RVA: 0x00058ACB File Offset: 0x00056CCB
 public void OnInteractionBegin(Interactor activator)
 {
     base.GetComponent <EntityStateMachine>().SetNextState(new Opening());
 }
Exemple #18
0
 // Token: 0x06000F79 RID: 3961 RVA: 0x0004C326 File Offset: 0x0004A526
 void IInteractable.OnInteractionBegin(Interactor activator)
 {
     this.onActivation.Invoke();
 }
 // Token: 0x060010B8 RID: 4280 RVA: 0x0000AC89 File Offset: 0x00008E89
 public bool ShouldIgnoreSpherecastForInteractibility(Interactor activator)
 {
     return(false);
 }
 // Token: 0x0600118E RID: 4494 RVA: 0x0000409B File Offset: 0x0000229B
 public virtual void HandleInteractionServer(Interactor activator)
 {
 }