示例#1
0
 // Token: 0x060005D9 RID: 1497 RVA: 0x00018498 File Offset: 0x00016698
 public void ItemDrop()
 {
     if (NetworkServer.active && this.entityLocator)
     {
         ChestBehavior component = this.entityLocator.entity.GetComponent <ChestBehavior>();
         if (component)
         {
             component.ItemDrop();
             return;
         }
         Debug.Log("Parent has no item drops!");
     }
 }
        // Token: 0x06001294 RID: 4756 RVA: 0x0004FF00 File Offset: 0x0004E100
        private void PopulateScene()
        {
            ClassicStageInfo component = SceneInfo.instance.GetComponent <ClassicStageInfo>();

            this.PlaceTeleporter();
            Action action = new Action(this.DefaultPlayerSpawnPointGenerator);

            SceneDirector.GenerateSpawnPointsDelegate generateSpawnPointsDelegate = SceneDirector.onPreGeneratePlayerSpawnPointsServer;
            if (generateSpawnPointsDelegate != null)
            {
                generateSpawnPointsDelegate(this, ref action);
            }
            if (action != null)
            {
                action();
            }
            Run.instance.OnPlayerSpawnPointsPlaced(this);
            while (this.interactableCredit > 0)
            {
                DirectorCard directorCard = this.SelectCard(component.interactableSelection, this.interactableCredit);
                if (directorCard == null)
                {
                    break;
                }
                if (directorCard.CardIsValid())
                {
                    this.interactableCredit -= directorCard.cost;
                    if (Run.instance)
                    {
                        int i = 0;
                        while (i < 10)
                        {
                            DirectorPlacementRule placementRule = new DirectorPlacementRule
                            {
                                placementMode = DirectorPlacementRule.PlacementMode.Random
                            };
                            GameObject gameObject = this.directorCore.TrySpawnObject(new DirectorSpawnRequest(directorCard.spawnCard, placementRule, this.rng));
                            if (gameObject)
                            {
                                PurchaseInteraction component2 = gameObject.GetComponent <PurchaseInteraction>();
                                if (component2 && component2.costType == CostTypeIndex.Money)
                                {
                                    component2.Networkcost = Run.instance.GetDifficultyScaledCost(component2.cost);
                                    break;
                                }
                                break;
                            }
                            else
                            {
                                i++;
                            }
                        }
                    }
                }
            }
            if (Run.instance && Run.instance.stageClearCount == 0)
            {
                this.monsterCredit = 0;
            }
            int num = 0;

            while (this.monsterCredit > 0 && num < 40)
            {
                DirectorCard directorCard2 = this.SelectCard(component.monsterSelection, this.monsterCredit);
                if (directorCard2 == null)
                {
                    break;
                }
                if (directorCard2.CardIsValid())
                {
                    this.monsterCredit -= directorCard2.cost;
                    int j = 0;
                    while (j < 10)
                    {
                        DirectorSpawnRequest directorSpawnRequest = new DirectorSpawnRequest(directorCard2.spawnCard, new DirectorPlacementRule
                        {
                            placementMode = DirectorPlacementRule.PlacementMode.Random
                        }, this.rng);
                        directorSpawnRequest.teamIndexOverride = new TeamIndex?(TeamIndex.Monster);
                        GameObject gameObject2 = this.directorCore.TrySpawnObject(directorSpawnRequest);
                        if (gameObject2)
                        {
                            num++;
                            CharacterMaster component3 = gameObject2.GetComponent <CharacterMaster>();
                            if (component3)
                            {
                                GameObject bodyObject = component3.GetBodyObject();
                                if (bodyObject)
                                {
                                    DeathRewards component4 = bodyObject.GetComponent <DeathRewards>();
                                    if (component4)
                                    {
                                        component4.expReward  = (uint)((float)directorCard2.cost * this.expRewardCoefficient * Run.instance.difficultyCoefficient);
                                        component4.goldReward = (uint)((float)directorCard2.cost * this.expRewardCoefficient * 2f * Run.instance.difficultyCoefficient);
                                    }
                                    foreach (EntityStateMachine entityStateMachine in bodyObject.GetComponents <EntityStateMachine>())
                                    {
                                        entityStateMachine.initialStateType = entityStateMachine.mainStateType;
                                    }
                                }
                                num++;
                                break;
                            }
                            break;
                        }
                        else
                        {
                            j++;
                        }
                    }
                }
            }
            Xoroshiro128Plus xoroshiro128Plus = new Xoroshiro128Plus(this.rng.nextUlong);

            if (SceneInfo.instance.countsAsStage)
            {
                int num2 = 0;
                foreach (CharacterMaster characterMaster in CharacterMaster.readOnlyInstancesList)
                {
                    num2 += characterMaster.inventory.GetItemCount(ItemIndex.TreasureCache);
                }
                if (num2 > 0)
                {
                    GameObject gameObject3 = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(Resources.Load <SpawnCard>("SpawnCards/InteractableSpawnCard/iscLockbox"), new DirectorPlacementRule
                    {
                        placementMode = DirectorPlacementRule.PlacementMode.Random
                    }, xoroshiro128Plus));
                    if (gameObject3)
                    {
                        ChestBehavior component5 = gameObject3.GetComponent <ChestBehavior>();
                        if (component5)
                        {
                            component5.tier2Chance *= (float)num2;
                            component5.tier3Chance *= Mathf.Pow((float)num2, 2f);
                        }
                    }
                }
            }
        }
示例#3
0
 public void Chest_Opened(On.RoR2.ChestBehavior.orig_Open o, RoR2.ChestBehavior s)
 {
     o(s);
     chestsOpened++;
     UpdateTextArea(StageStatsTextAreaName);
 }
示例#4
0
        private static void ChestBehaviorOnRollItem(On.RoR2.ChestBehavior.orig_RollItem orig, RoR2.ChestBehavior self)
        {
            if (!NetworkServer.active)
            {
                Debug.LogWarning("[Server] function 'System.Void RoR2.ChestBehavior::RollItem()' called on client");
                return;
            }

            if (self.GetFieldValue <PickupIndex>("dropPickup") != PickupIndex.none)
            {
                return;
            }

            var chestName = self.name.Replace("(Clone)", "").Trim();

            Logger.LogDebug($"Dropping {self.name} - {self.requiredItemTag}");


            if (ChestLookup.ContainsKey(chestName))
            {
                self.SetFieldValue("dropPickup", GetSelection(ChestLookup[chestName],
                                                              Run.instance.treasureRng.nextNormalizedFloat));
            }
            else if (self.name.ToLower().Contains(Lockbox.ToLower()))
            {
                Logger.LogDebug("Dropping Lockbox");

                var lockboxes = CharacterMaster.readOnlyInstancesList.Sum(x => x.inventory.GetItemCount(ItemIndex.TreasureCache));
                Selection[ItemDropLocation.Lockbox][1].DropChance = DefaultSmallChestTier2DropChance * lockboxes;
                Selection[ItemDropLocation.Lockbox][2].DropChance = DefaultSmallChestTier3DropChance * Mathf.Pow(lockboxes, 2f);
                self.SetFieldValue("dropPickup", GetSelection(ItemDropLocation.Lockbox,
                                                              Run.instance.treasureRng.nextNormalizedFloat));
            }
            else
            {
                Logger.LogError($"Unidentified chest type: {self.name}. Dropping normal loot instead.");

                self.SetFieldValue("dropPickup", GetSelection(ItemDropLocation.SmallChest,
                                                              Run.instance.treasureRng.nextNormalizedFloat));
            }
        }