Exemplo n.º 1
0
        public ShareSuite()
        {
            InitWrap();
            On.RoR2.Console.Awake += (orig, self) =>
            {
                FrogtownInterface.Init(Config);
                orig(self);
            };
            CommandHelper.AddToConsoleWhenReady();

            #region Hook registration

            // Register all the hooks
            GeneralHooks.OverrideBossScaling();
            GeneralHooks.OnPlaceTeleporter();
            GeneralHooks.OnTpInteraction();
            ItemSharingHooks.OnGrantItem();
            ItemSharingHooks.OnShopPurchase();
            ItemSharingHooks.OnPurchaseDrop();
            MoneySharingHooks.SharedMoneyValue = 0;
            MoneySharingHooks.ModifyGoldReward();
            MoneySharingHooks.BrittleCrownHook();
            MoneySharingHooks.SplitTpMoney();
            EquipmentSharingHooks.OnGrantEquipment();

            #endregion
        }
Exemplo n.º 2
0
 private void ReloadHooks(object _ = null, System.EventArgs __ = null)
 {
     if (previouslyEnabled && !ModIsEnabled.Value)
     {
         GeneralHooks.UnHook();
         MoneySharingHooks.UnHook();
         ItemSharingHooks.UnHook();
         EquipmentSharingHooks.UnHook();
         previouslyEnabled = false;
     }
     if (!previouslyEnabled && ModIsEnabled.Value)
     {
         previouslyEnabled = true;
         GeneralHooks.Hook();
         MoneySharingHooks.Hook();
         ItemSharingHooks.Hook();
         EquipmentSharingHooks.Hook();
     }
 }
Exemplo n.º 3
0
        private void ReloadHooks(object _ = null, EventArgs __ = null)
        {
            if (_previouslyEnabled && !ModIsEnabled.Value)
            {
                GeneralHooks.UnHook();
                MoneySharingHooks.UnHook();
                ItemSharingHooks.UnHook();
                EquipmentSharingHooks.UnHook();
                ChatHandler.UnHook();
                _previouslyEnabled = false;
            }

            if (!_previouslyEnabled && ModIsEnabled.Value)
            {
                _previouslyEnabled = true;
                GeneralHooks.Hook();
                MoneySharingHooks.Hook();
                ItemSharingHooks.Hook();
                EquipmentSharingHooks.Hook();
                ChatHandler.Hook();
            }
        }
Exemplo n.º 4
0
        private static void OnShopPurchase(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig,
                                           PurchaseInteraction self, Interactor activator)
        {
            if (!self.CanBeAffordedByInteractor(activator))
            {
                return;
            }

            if (!GeneralHooks.IsMultiplayer())
            {
                orig(self, activator);
                return;
            }

            if (self.costType == CostTypeIndex.None)
            {
                orig(self, activator);
                return;
            }

            var shop = self.GetComponent <ShopTerminalBehavior>();

            #region Cauldronfix

            if (printerCosts.Contains(self.costType))
            {
                if (ShareSuite.PrinterCauldronFixEnabled.Value)
                {
                    var characterBody = activator.GetComponent <CharacterBody>();
                    var inventory     = characterBody.inventory;


                    var item = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex())?.itemIndex;

                    if (item == null)
                    {
                        RoR2.Console.print("ShareSuite: PickupCatalog is null.");
                    }
                    else
                    {
                        inventory.GiveItem(item.Value);
                    }

                    orig(self, activator);
                    ChatHandler.SendRichCauldronMessage(inventory.GetComponent <CharacterMaster>(),
                                                        shop.CurrentPickupIndex());
                    return;
                }
            }

            #endregion Cauldronfix

            #region EquipDronefix

            if (ShareSuite.EquipmentShared.Value)
            {
                if (self.costType == CostTypeIndex.Equipment)
                {
                    var rng       = self.GetComponent <Xoroshiro128Plus>();
                    var itemIndex = ItemIndex.None;

                    var costTypeDef = CostTypeCatalog.GetCostTypeDef(self.costType);
                    if (shop)
                    {
                        itemIndex = PickupCatalog.GetPickupDef(shop.CurrentPickupIndex()).itemIndex;
                    }

                    var payCostResults = costTypeDef.PayCost(self.cost,
                                                             activator, self.gameObject, rng, itemIndex);

                    if (payCostResults.equipmentTaken.Count >= 1)
                    {
                        orig(self, activator);
                        EquipmentSharingHooks.RemoveAllUnBlacklistedEquipment();
                        return;
                    }
                }
            }

            #endregion

            orig(self, activator);
        }