Esempio n. 1
0
            void SubmitChoice(On.RoR2.PickupPickerController.orig_SubmitChoice orig, RoR2.PickupPickerController pickupPickerController, int integer)
            {
                if (Data.modEnabled)
                {
                    if (Data.mode == DataShop.mode)
                    {
                        System.Type type = typeof(RoR2.PickupPickerController);
                        System.Reflection.FieldInfo info = type.GetField("options", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                        ICollection collection           = info.GetValue(pickupPickerController) as ICollection;
                        int         index = 0;
                        foreach (object item in collection)
                        {
                            if (index == integer)
                            {
                                RoR2.PickupPickerController.Option option = (RoR2.PickupPickerController.Option)item;
                                ItemIndex itemIndex = RoR2.PickupCatalog.GetPickupDef(option.pickupIndex).itemIndex;

                                RoR2.NetworkUIPromptController promptController = pickupPickerController.GetComponent <RoR2.NetworkUIPromptController>();
                                type = typeof(RoR2.NetworkUIPromptController);
                                info = type.GetField("_currentLocalParticipant", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
                                RoR2.LocalUser localUser = (RoR2.LocalUser)info.GetValue(promptController);
                                foreach (NetworkUser networkUser in RoR2.NetworkUser.readOnlyInstancesList)
                                {
                                    if (localUser.currentNetworkUser.netId == networkUser.netId)
                                    {
                                        if (networkUser.isLocalPlayer)
                                        {
                                            DataShop.RemoveScrap(Data.GetItemTier(Data.allItemsIndexes[itemIndex]), Mathf.Min(DataShop.purchaseCost, networkUser.GetCurrentBody().inventory.GetItemCount(itemIndex)));
                                        }
                                        break;
                                    }
                                }
                                break;
                            }
                            index += 1;
                        }
                    }
                    orig(pickupPickerController, integer);
                }
                ;
            }
Esempio n. 2
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);
            }