예제 #1
0
        private static void CCGiveLunar(ConCommandArgs args)
        {
            int amount = 1;

            if (args.Count > 0)
            {
                amount = args.GetArgInt(0);
            }
            if (amount == 0)
            {
                Log.Message("Nothing happened. Big suprise.");
                return;
            }
            NetworkUser target = Util.LookUpBodyNetworkUser(args.senderBody);

            if (amount > 0)
            {
                target.AwardLunarCoins((uint)amount);
            }
            if (amount < 0)
            {
                amount *= -1;
                target.DeductLunarCoins((uint)(amount));
            }
            Log.Message(string.Format(MagicVars.GIVELUNAR_2, (amount > 0) ? "Gave" : "Deducted", amount));
        }
예제 #2
0
 private static void CreateCostDefGurrenSummon()
 {
     costTypeDefGurrenSummon = new CostTypeDef();
     costTypeDefGurrenSummon.costStringFormatToken = "COST_LUNARCOIN_FORMAT";
     costTypeDefGurrenSummon.isAffordable          = delegate(CostTypeDef costTypeDef, CostTypeDef.IsAffordableContext context)
     {
         CharacterBody characterBody = context.activator.GetComponent <CharacterBody>();
         bool          result        = false;
         if (characterBody && characterBody.bodyIndex == BodyCatalog.FindBodyIndex("LagannBody"))
         {
             var master = characterBody.master;
             if (master)
             {
                 var         gurrenMinionCache = GurrenMinionCache.GetOrSetGurrenStatusCache(master);
                 NetworkUser networkUser       = Util.LookUpBodyNetworkUser(context.activator.gameObject);
                 result = (networkUser &&
                           (ulong)networkUser.lunarCoins >= (ulong)((long)context.cost) &&
                           !gurrenMinionCache.gurrenMinion);
             }
         }
         return(result);
     };
     costTypeDefGurrenSummon.payCost = delegate(CostTypeDef costTypeDef, CostTypeDef.PayCostContext context)
     {
         NetworkUser networkUser = Util.LookUpBodyNetworkUser(context.activator.gameObject);
         bool        flag        = networkUser;
         if (flag)
         {
             networkUser.DeductLunarCoins((uint)context.cost);
         }
     };
     costTypeDefGurrenSummon.colorIndex = ColorCatalog.ColorIndex.LunarCoin;
     CostTypeDefs.Add(costTypeDefGurrenSummon);
 }
예제 #3
0
        private static void CCGiveLunar(ConCommandArgs args)
        {
            if (args.sender == null)
            {
                Log.Message("Can't modify Lunar coins of other users directly.", LogLevel.Error);
                return;
            }
            int amount = 1;

            if (args.Count > 0)
            {
                amount = args.GetArgInt(0);
            }
            string      str    = "Nothing happened. Big suprise.";
            NetworkUser target = RoR2.Util.LookUpBodyNetworkUser(args.senderBody);

            if (amount > 0)
            {
                target.AwardLunarCoins((uint)amount);
                str = string.Format(Lang.GIVELUNAR_2, "Gave", amount);
            }
            if (amount < 0)
            {
                amount *= -1;
                target.DeductLunarCoins((uint)(amount));
                str = string.Format(Lang.GIVELUNAR_2, "Removed", amount);
            }
            Log.MessageNetworked(str, args);
        }
예제 #4
0
            public override void Set(NetworkUser user, string value)
            {
                var v = uint.Parse(value);
                var c = user.lunarCoins;

                if (c > v)
                {
                    user.DeductLunarCoins(c - v);
                }
                else if (c < v)
                {
                    user.AwardLunarCoins(v - c);
                }
            }
예제 #5
0
        internal void LoadPlayer(NetworkUser player)
        {
            var master = player.master;

            foreach (var minion in minions)
            {
                minion.LoadMinion(master);
            }

            var bodyPrefab = BodyCatalog.FindBodyPrefab(characterBodyName);

            master.bodyPrefab = bodyPrefab;

            loadout.LoadData(master.loadout);

            inventory.LoadInventory(master.inventory);

            if (ModSupport.IsSSLoaded)
            {
                ProperSavePlugin.Instance.StartCoroutine(LoadShareSuiteMoney(money));
            }
            player.master.money = money;

            player.masterController.lunarCoinChanceMultiplier = lunarCoinChanceMultiplier;
            var stats = player.masterController.GetComponent <PlayerStatsComponent>().currentStats;

            for (var i = 0; i < statsFields.Length; i++)
            {
                var fieldValue = statsFields[i];
                stats.SetStatValueFromString(StatDef.allStatDefs[i], fieldValue);
            }
            for (var i = 0; i < statsUnlockables.Length; i++)
            {
                var unlockableIndex = statsUnlockables[i];
                stats.AddUnlockable(new UnlockableIndex(unlockableIndex));
            }

            if (ModSupport.IsTLCLoaded || ModSupport.IsBDTLCLoaded)
            {
                Stage.onStageStartGlobal += ResetLunarCoins;
                void ResetLunarCoins(Stage stage)
                {
                    Stage.onStageStartGlobal -= ResetLunarCoins;
                    player.DeductLunarCoins(player.lunarCoins);
                    player.AwardLunarCoins(lunarCoins);
                }
            }
        }
예제 #6
0
        public void LoadPlayer(NetworkUser player)
        {
            foreach (var minion in minions)
            {
                minion.LoadMinion(player.master);
            }

            var bodyPrefab = BodyCatalog.FindBodyPrefab(characterBodyName);

            player.master.bodyPrefab = bodyPrefab;

            loadout.LoadData(player.master);

            inventory.LoadInventory(player.master);

            player.master.money = money;

            player.masterController.SetFieldValue("lunarCoinChanceMultiplier", lunarCoinChanceMultiplier);
            var stats = player.masterController.GetComponent <PlayerStatsComponent>().currentStats;

            for (var i = 0; i < statsFields.Length; i++)
            {
                var fieldValue = statsFields[i];
                stats.SetStatValueFromString(StatDef.allStatDefs[i], fieldValue);
            }
            for (var i = 0; i < statsUnlockables.Length; i++)
            {
                var unlockableIndex = statsUnlockables[i];
                stats.AddUnlockable(new UnlockableIndex(unlockableIndex));
            }

            if (ProperSave.IsTLCDefined)
            {
                Stage.onStageStartGlobal += ResetLunarCoins;
                void ResetLunarCoins(Stage stage)
                {
                    Stage.onStageStartGlobal -= ResetLunarCoins;
                    player.DeductLunarCoins(player.lunarCoins);
                    player.AwardLunarCoins(lunarCoins);
                }
            }
        }
예제 #7
0
        private static void CCGiveLunar(ConCommandArgs args)
        {
            int amount = 1;

            if (args.Count > 0)
            {
                amount = args.GetArgInt(0);
            }
            string      str    = "Nothing happened. Big suprise.";
            NetworkUser target = Util.LookUpBodyNetworkUser(args.senderBody);

            if (amount > 0)
            {
                target.AwardLunarCoins((uint)amount);
                str = string.Format(Lang.GIVELUNAR_2, "Gave", amount);
            }
            if (amount < 0)
            {
                amount *= -1;
                target.DeductLunarCoins((uint)(amount));
                str = string.Format(Lang.GIVELUNAR_2, "Removed", amount);
            }
            Log.Message(str, args);
        }
예제 #8
0
        private void PurchaseInteraction_OnInteractionBegin(On.RoR2.PurchaseInteraction.orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
        {
            if (isCurrentStageBazaar())
            {
                NetworkUser  networkUser  = Util.LookUpBodyNetworkUser(activator.gameObject);
                BazaarPlayer bazaarPlayer = bazaar.GetBazaarPlayer(networkUser);
                if (!self.CanBeAffordedByInteractor(activator))
                {
                    return;
                }

                if (bazaar.IsMoneyLunarPodAvailable())
                {
                    if (bazaar.IsMoneyLunarPod(self.gameObject))
                    {
                        if (bazaarPlayer.lunarExchanges < ModConfig.maxLunarExchanges.Value || ModConfig.infiniteLunarExchanges)
                        {
                            bazaarPlayer.lunarExchanges++;
                            int money = bazaar.GetLunarCoinExchangeMoney();
                            if (!ModConfig.IsShareSuiteMoneySharing())
                            {
                                activator.GetComponent <CharacterBody>().master.money += ((uint)money);
                            }
                            else
                            {
                                //ShareSuite.MoneySharingHooks.AddMoneyExternal(money);
                                bazaar.ShareSuiteMoneyFix(activator, money);
                            }
                            //activator.GetComponent<CharacterBody>().master.money += ((uint)money);
                            //activator.GetComponent<CharacterBody>().master.GiveMoney((uint)money);
                            networkUser.DeductLunarCoins((uint)self.cost);
                            var        goldReward          = (int)((double)ModConfig.lunarCoinWorth.Value * (double)bazaar.CurrentDifficultyCoefficient);
                            GameObject coinEmitterResource = Resources.Load <GameObject>("Prefabs/Effects/CoinEmitter");
                            EffectManager.SpawnEffect(coinEmitterResource, new EffectData()
                            {
                                origin       = self.transform.position,
                                genericFloat = (float)goldReward
                            }, true);
                            EffectManager.SpawnEffect(coinEmitterResource, new EffectData()
                            {
                                origin       = self.transform.position,
                                genericFloat = (float)goldReward
                            }, true);
                            Util.PlaySound("Play_UI_coin", self.gameObject);
                        }

                        return;
                    }
                }
                // New addition that made everything less nice. Added to check if player still has purchases left
                int bazaarChestIndex            = -1;
                List <BazaarItem>   bazaarItems = bazaar.GetBazaarItems();
                PurchaseInteraction bazaarPI;
                for (int i = 0; i < bazaarItems.Count; i++)
                {
                    // Fix for SavedGames. SavedGames somehow breaks the BiggerBazaar chests and BiggerBazaar breaks everything else in return :)
                    if (bazaarItems[i].chestBehavior == null)
                    {
                        continue;
                    }
                    bazaarPI = bazaarItems[i].chestBehavior.GetComponent <PurchaseInteraction>();
                    if (bazaarPI.Equals(self))
                    {
                        if (!bazaar.PlayerHasPurchasesLeft(bazaarPlayer))
                        {
                            return;
                        }

                        //ItemTier tier = ItemCatalog.GetItemDef(PickupCatalog.GetPickupDef(bazaarItems[i].pickupIndex).itemIndex).tier;
                        PickupTier pickupTier = PickupIndexToPickupTier(bazaarItems[i].pickupIndex);
                        if (!bazaar.PlayerHasTierPurchasesLeft(pickupTier, bazaarPlayer))
                        {
                            return;
                        }
                        if (ModConfig.ShareSuite != null && ModConfig.ShareSuiteTotalPurchaseSharing.Value)
                        {
                            bazaar.GetBazaarPlayers().ForEach(x => x.chestPurchases++);
                        }
                        else
                        {
                            bazaarPlayer.chestPurchases++;
                        }

                        bazaarPlayer.IncreaseTierPurchase(pickupTier);
                        bazaarChestIndex = i;
                        break;
                    }
                }
                // Special case for ShareSuite
                if (ModConfig.isShareSuiteActive() && !ModConfig.ShareSuiteItemSharingEnabled.Value)
                {
                    if (bazaarChestIndex != -1)
                    {
                        CharacterMaster master      = activator.GetComponent <CharacterBody>().master;
                        var             isEquipment = PickupCatalog.GetPickupDef(bazaarItems[bazaarChestIndex].pickupIndex).equipmentIndex == EquipmentIndex.None ? false : true;
                        if (!isEquipment)
                        {
                            master.inventory.GiveItem(PickupCatalog.GetPickupDef(bazaarItems[bazaarChestIndex].pickupIndex).itemIndex);
                        }
                        else
                        {
                            if (!ModConfig.isShareSuiteEquipmentSharing())
                            {
                                PickupDropletController.CreatePickupDroplet(PickupCatalog.FindPickupIndex(master.inventory.GetEquipmentIndex()), master.GetBody().gameObject.transform.position + Vector3.up * 1.5f, Vector3.up * 20f + self.transform.forward * 2f);
                            }
                            master.inventory.SetEquipmentIndex(PickupCatalog.GetPickupDef(bazaarItems[bazaarChestIndex].pickupIndex).equipmentIndex);
                        }


                        if (ModConfig.chestCostType.Value == 1)
                        {
                            var netUser = Util.LookUpBodyNetworkUser(master.GetBody());
                            netUser.DeductLunarCoins((uint)self.cost);
                        }
                        else
                        {
                            if (!ModConfig.IsShareSuiteMoneySharing())
                            {
                                master.money -= (uint)self.cost;
                            }
                            else
                            {
                                //ShareSuite.MoneySharingHooks.AddMoneyExternal(-self.cost);
                                bazaar.ShareSuiteMoneyFix(activator, -self.cost);
                            }
                        }

                        bazaarItems[bazaarChestIndex].purchaseCount++;
                        if (!bazaar.IsChestStillAvailable(bazaarItems[bazaarChestIndex]))
                        {
                            self.GetComponent <PurchaseInteraction>().SetAvailable(false);
                        }

                        Vector3 effectPos = self.transform.position;
                        effectPos.y -= 1;
                        EffectManager.SpawnEffect(Resources.Load <GameObject>("Prefabs/Effects/ShrineUseEffect"), new EffectData()
                        {
                            origin   = effectPos,
                            rotation = Quaternion.identity,
                            scale    = 0.01f,
                            color    = (Color32)Color.yellow
                        }, true);
                        PurchaseInteraction.CreateItemTakenOrb(self.gameObject.transform.position, activator.GetComponent <CharacterBody>().gameObject, PickupCatalog.GetPickupDef(bazaarItems[bazaarChestIndex].pickupIndex).itemIndex);

                        return;
                    }
                }
            }
            orig(self, activator);
        }