// Token: 0x060012AA RID: 4778 RVA: 0x00050500 File Offset: 0x0004E700
        public void SetState(SceneExitController.ExitState newState)
        {
            if (newState == this.exitState)
            {
                return;
            }
            this.exitState = newState;
            switch (this.exitState)
            {
            case SceneExitController.ExitState.Idle:
                break;

            case SceneExitController.ExitState.ExtractExp:
                SceneExitController.isRunning = true;
                this.experienceCollector      = base.gameObject.AddComponent <ConvertPlayerMoneyToExperience>();
                return;

            case SceneExitController.ExitState.TeleportOut:
            {
                ReadOnlyCollection <CharacterMaster> readOnlyInstancesList = CharacterMaster.readOnlyInstancesList;
                for (int i = 0; i < readOnlyInstancesList.Count; i++)
                {
                    CharacterMaster component = readOnlyInstancesList[i].GetComponent <CharacterMaster>();
                    if (component.GetComponent <SetDontDestroyOnLoad>())
                    {
                        GameObject bodyObject = component.GetBodyObject();
                        if (bodyObject)
                        {
                            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/NetworkedObjects/TeleportOutController"), bodyObject.transform.position, Quaternion.identity);
                            gameObject.GetComponent <TeleportOutController>().Networktarget = bodyObject;
                            NetworkServer.Spawn(gameObject);
                        }
                    }
                }
                this.teleportOutTimer = 4f;
                return;
            }

            case SceneExitController.ExitState.Finished:
                if (Run.instance && Run.instance.isGameOverServer)
                {
                    return;
                }
                if (this.useRunNextStageScene)
                {
                    Stage.instance.BeginAdvanceStage(Run.instance.nextStageScene);
                    return;
                }
                if (this.destinationScene)
                {
                    Stage.instance.BeginAdvanceStage(this.destinationScene);
                    return;
                }
                Debug.Log("SceneExitController: destinationScene not set!");
                break;

            default:
                return;
            }
        }
예제 #2
0
 // Token: 0x060014E5 RID: 5349 RVA: 0x00064694 File Offset: 0x00062894
 private static GameObject GetNetworkUserBodyObject(NetworkUser networkUser)
 {
     if (networkUser.masterObject)
     {
         CharacterMaster component = networkUser.masterObject.GetComponent <CharacterMaster>();
         if (component)
         {
             return(component.GetBodyObject());
         }
     }
     return(null);
 }
        // Token: 0x06000691 RID: 1681 RVA: 0x0001AD08 File Offset: 0x00018F08
        private void OnMemberDeathServer(CharacterMaster memberMaster, DamageReport damageReport)
        {
            GameObject   bodyObject   = memberMaster.GetBodyObject();
            DeathRewards deathRewards = (bodyObject != null) ? bodyObject.GetComponent <DeathRewards>() : null;

            if (deathRewards)
            {
                PickupIndex pickupIndex = (PickupIndex)deathRewards.bossPickup;
                if (pickupIndex != PickupIndex.none)
                {
                    this.bossDrops.Add(pickupIndex);
                }
            }
        }
예제 #4
0
 // Token: 0x06000E2B RID: 3627 RVA: 0x00045C7C File Offset: 0x00043E7C
 private void FixedUpdate()
 {
     this.burstTimer -= Time.fixedDeltaTime;
     if (this.burstTimer <= 0f)
     {
         bool flag = false;
         ReadOnlyCollection <PlayerCharacterMasterController> instances = PlayerCharacterMasterController.instances;
         for (int i = 0; i < instances.Count; i++)
         {
             GameObject      gameObject = instances[i].gameObject;
             CharacterMaster component  = gameObject.GetComponent <CharacterMaster>();
             uint            num;
             if (!this.burstSizes.TryGetValue(gameObject, out num))
             {
                 num = (uint)Mathf.CeilToInt(component.money / (float)this.burstCount);
                 this.burstSizes[gameObject] = num;
             }
             if (num > component.money)
             {
                 num = component.money;
             }
             component.money -= num;
             GameObject bodyObject = component.GetBodyObject();
             ulong      num2       = (ulong)(num / 2f / (float)instances.Count);
             if (num > 0u)
             {
                 flag = true;
             }
             if (bodyObject)
             {
                 ExperienceManager.instance.AwardExperience(base.transform.position, bodyObject.GetComponent <CharacterBody>(), num2);
             }
             else
             {
                 TeamManager.instance.GiveTeamExperience(component.teamIndex, num2);
             }
         }
         if (flag)
         {
             this.burstTimer = this.burstInterval;
             return;
         }
         if (this.burstTimer < -2.5f)
         {
             UnityEngine.Object.Destroy(this);
         }
     }
 }
        // 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);
                        }
                    }
                }
            }
        }
예제 #6
0
 // Token: 0x060015D5 RID: 5589 RVA: 0x0006897C File Offset: 0x00066B7C
 private void Start()
 {
     this.sceneDef = SceneCatalog.GetSceneDefForCurrentScene();
     if (NetworkServer.active)
     {
         this.NetworkstartRunTime = Run.instance.fixedTime;
         this.stageSpawnPosition  = this.SampleNodeGraphForSpawnPosition();
         ReadOnlyCollection <CharacterMaster> readOnlyInstancesList = CharacterMaster.readOnlyInstancesList;
         Transform playerSpawnTransform = this.GetPlayerSpawnTransform();
         for (int i = 0; i < readOnlyInstancesList.Count; i++)
         {
             CharacterMaster characterMaster = readOnlyInstancesList[i];
             if (characterMaster && !characterMaster.GetComponent <PlayerCharacterMasterController>() && !characterMaster.GetBodyObject() && characterMaster.gameObject.scene.buildIndex == -1)
             {
                 Vector3    vector   = Vector3.zero;
                 Quaternion rotation = Quaternion.identity;
                 if (playerSpawnTransform)
                 {
                     vector   = playerSpawnTransform.position;
                     rotation = playerSpawnTransform.rotation;
                     BaseAI        component  = readOnlyInstancesList[i].GetComponent <BaseAI>();
                     CharacterBody component2 = readOnlyInstancesList[i].bodyPrefab.GetComponent <CharacterBody>();
                     if (component && component2)
                     {
                         NodeGraph nodeGraph = component.GetNodeGraph();
                         if (nodeGraph)
                         {
                             List <NodeGraph.NodeIndex> list = nodeGraph.FindNodesInRange(vector, 10f, 100f, (HullMask)(1 << (int)component2.hullClassification));
                             if ((float)list.Count > 0f)
                             {
                                 nodeGraph.GetNodePosition(list[UnityEngine.Random.Range(0, list.Count)], out vector);
                             }
                         }
                     }
                 }
                 readOnlyInstancesList[i].Respawn(vector, rotation);
             }
         }
         this.BeginServer();
     }
     if (NetworkClient.active)
     {
         this.RespawnLocalPlayers();
     }
 }
예제 #7
0
        public bool AlternateSpawnBehavior(GameObject spawnTarget, bool canBeElite)
        {
            if (this.currentMonsterCard.CardIsValid() && this.monsterCredit >= (float)this.currentMonsterCard.cost)
            {
                SpawnCard             spawnCard             = this.currentMonsterCard.spawnCard;
                DirectorPlacementRule directorPlacementRule = new DirectorPlacementRule
                {
                    placementMode   = DirectorPlacementRule.PlacementMode.Approximate,
                    spawnOnTarget   = spawnTarget.transform,
                    preventOverhead = this.currentMonsterCard.preventOverhead
                };
                DirectorCore.GetMonsterSpawnDistance(this.currentMonsterCard.spawnDistance, out directorPlacementRule.minDistance, out directorPlacementRule.maxDistance);
                directorPlacementRule.minDistance *= this.spawnDistanceMultiplier;
                directorPlacementRule.maxDistance *= this.spawnDistanceMultiplier;
                GameObject gameObject = DirectorCore.instance.TrySpawnObject(spawnCard, directorPlacementRule, this.rng);
                if (gameObject)
                {
                    int             cost          = this.currentMonsterCard.cost;
                    float           num3          = 1f;
                    float           num4          = 1f;
                    CharacterMaster component     = gameObject.GetComponent <CharacterMaster>();
                    GameObject      bodyObject    = component.GetBodyObject();
                    CharacterBody   characterBody = bodyObject.GetComponent <CharacterBody>();
                    if (this.isBoss)
                    {
                        if (!this.bossGroup)
                        {
                            GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/NetworkedObjects/BossGroup"));
                            NetworkServer.Spawn(gameObject2);
                            this.bossGroup = gameObject2.GetComponent <BossGroup>();
                            this.bossGroup.dropPosition = this.dropPosition;
                        }
                        this.bossGroup.AddMember(component);
                    }
                    // assumes CombatDirector.maximumNumberToSpawnBeforeSkipping == 4f; maybe add a check for this?
                    if (canBeElite) //try to make the mob elite before adding bonus items
                    {
                        if ((float)cost * CombatDirector.eliteMultiplierCost <= this.monsterCredit)
                        {
                            num3 = 4.7f;
                            num4 = 2f;
                            component.inventory.SetEquipmentIndex(EliteCatalog.GetEliteDef(this.currentActiveEliteIndex).eliteEquipmentIndex);
                            cost = (int)((float)cost * CombatDirector.eliteMultiplierCost);

                            //This is where we add the bonus items
                            var minCost = ((int)this.monsterCredit) / 4;  //CombatDirector.maximumNumberToSpawnBeforeSkipping
                            while (cost < minCost)
                            {
                                var newItem   = BalanceMod.Hooks.mobItemSelection.Evaluate(this.rng.nextNormalizedFloat);
                                var itemIndex = newItem.itemIndex;
                                var itemCount = newItem.itemCount;
                                // Debug.Log($"Giving {itemCount} of item {itemIndex}");
                                if (BalanceMod.Hooks.PatchLateGameMonsterSpawns_EnemyItemsInChat)
                                {
                                    Chat.AddPickupMessage(characterBody, ItemCatalog.GetItemDef(itemIndex).nameToken, BalanceMod.Hooks.GetItemColor(itemIndex), (uint)itemCount);
                                }
                                component.inventory.GiveItem(itemIndex, itemCount);
                                cost *= 2;
                            }
                        }
                    }
                    else
                    {                                                //This is where we add the bonus items
                        var minCost = ((int)this.monsterCredit) / 4; //CombatDirector.maximumNumberToSpawnBeforeSkipping
                        while (cost < minCost)
                        {
                            var newItem   = BalanceMod.Hooks.mobItemSelection.Evaluate(this.rng.nextNormalizedFloat);
                            var itemIndex = newItem.itemIndex;
                            var itemCount = newItem.itemCount;
                            // Debug.Log($"Giving {itemCount} of item {itemIndex}");
                            if (BalanceMod.Hooks.PatchLateGameMonsterSpawns_EnemyItemsInChat)
                            {
                                Chat.AddPickupMessage(characterBody, ItemCatalog.GetItemDef(itemIndex).nameToken, BalanceMod.Hooks.GetItemColor(itemIndex), (uint)itemCount);
                            }
                            component.inventory.GiveItem(itemIndex, itemCount);
                            cost *= 2;
                        }
                    }
                    this.monsterCredit -= (float)cost;
                    if (this.isBoss)
                    {
                        int livingPlayerCount = Run.instance.livingPlayerCount;
                        num3 *= Mathf.Pow((float)livingPlayerCount, 1f);
                    }
                    //elites have +400% hp and +100% damage
                    component.inventory.GiveItem(ItemIndex.BoostHp, Mathf.RoundToInt((num3 - 1f) * 10f));
                    component.inventory.GiveItem(ItemIndex.BoostDamage, Mathf.RoundToInt((num4 - 1f) * 10f));
                    DeathRewards component2 = bodyObject.GetComponent <DeathRewards>();
                    if (component2)
                    {
                        component2.expReward  = (uint)((float)cost * this.expRewardCoefficient * Run.instance.compensatedDifficultyCoefficient);
                        component2.goldReward = (uint)((float)cost * this.expRewardCoefficient * 2f * Run.instance.compensatedDifficultyCoefficient);
                    }
                    if (this.spawnEffectPrefab && NetworkServer.active)
                    {
                        Vector3 origin = gameObject.transform.position;
                        if (characterBody)
                        {
                            origin = characterBody.corePosition;
                        }
                        EffectManager.instance.SpawnEffect(this.spawnEffectPrefab, new EffectData
                        {
                            origin = origin
                        }, true);
                    }
                    return(true);
                }
            }
            return(false);
        }
예제 #8
0
        // Token: 0x060013CA RID: 5066 RVA: 0x00054964 File Offset: 0x00052B64
        private void RespawnAllNPCs()
        {
            if (this.sceneDef.suppressNpcEntry)
            {
                return;
            }
            ReadOnlyCollection <CharacterMaster> readOnlyInstancesList = CharacterMaster.readOnlyInstancesList;
            Transform playerSpawnTransform = this.GetPlayerSpawnTransform();

            for (int i = 0; i < readOnlyInstancesList.Count; i++)
            {
                CharacterMaster characterMaster = readOnlyInstancesList[i];
                if (characterMaster && !characterMaster.GetComponent <PlayerCharacterMasterController>() && !characterMaster.GetBodyObject() && characterMaster.gameObject.scene.buildIndex == -1)
                {
                    Vector3    vector   = Vector3.zero;
                    Quaternion rotation = Quaternion.identity;
                    if (playerSpawnTransform)
                    {
                        vector   = playerSpawnTransform.position;
                        rotation = playerSpawnTransform.rotation;
                        BaseAI        component  = readOnlyInstancesList[i].GetComponent <BaseAI>();
                        CharacterBody component2 = readOnlyInstancesList[i].bodyPrefab.GetComponent <CharacterBody>();
                        if (component && component2)
                        {
                            NodeGraph desiredSpawnNodeGraph = component.GetDesiredSpawnNodeGraph();
                            if (desiredSpawnNodeGraph)
                            {
                                List <NodeGraph.NodeIndex> list = desiredSpawnNodeGraph.FindNodesInRange(vector, 10f, 100f, (HullMask)(1 << (int)component2.hullClassification));
                                if ((float)list.Count > 0f)
                                {
                                    desiredSpawnNodeGraph.GetNodePosition(list[UnityEngine.Random.Range(0, list.Count)], out vector);
                                }
                            }
                        }
                    }
                    readOnlyInstancesList[i].Respawn(vector, rotation, false);
                }
            }
        }
예제 #9
0
 // Token: 0x06000DBF RID: 3519 RVA: 0x00043984 File Offset: 0x00041B84
 private bool AttemptSpawnOnTarget(GameObject spawnTarget)
 {
     if (spawnTarget)
     {
         if (this.currentMonsterCard == null)
         {
             this.currentMonsterCard       = this.monsterCards.Evaluate(this.rng.nextNormalizedFloat);
             this.lastAttemptedMonsterCard = this.currentMonsterCard;
             this.currentActiveEliteIndex  = EliteCatalog.eliteList[this.rng.RangeInt(0, EliteCatalog.eliteList.Count)];
         }
         bool  flag = !(this.currentMonsterCard.spawnCard as CharacterSpawnCard).noElites;
         float num  = CombatDirector.maximumNumberToSpawnBeforeSkipping * (flag ? CombatDirector.eliteMultiplierCost : 1f);
         if (this.currentMonsterCard.CardIsValid() && this.monsterCredit >= (float)this.currentMonsterCard.cost && (!this.skipSpawnIfTooCheap || this.monsterCredit <= (float)this.currentMonsterCard.cost * num))
         {
             SpawnCard             spawnCard             = this.currentMonsterCard.spawnCard;
             DirectorPlacementRule directorPlacementRule = new DirectorPlacementRule
             {
                 placementMode   = DirectorPlacementRule.PlacementMode.Approximate,
                 spawnOnTarget   = spawnTarget.transform,
                 preventOverhead = this.currentMonsterCard.preventOverhead
             };
             DirectorCore.GetMonsterSpawnDistance(this.currentMonsterCard.spawnDistance, out directorPlacementRule.minDistance, out directorPlacementRule.maxDistance);
             directorPlacementRule.minDistance *= this.spawnDistanceMultiplier;
             directorPlacementRule.maxDistance *= this.spawnDistanceMultiplier;
             GameObject gameObject = DirectorCore.instance.TrySpawnObject(spawnCard, directorPlacementRule, this.rng);
             if (gameObject)
             {
                 int             num2       = this.currentMonsterCard.cost;
                 float           num3       = 1f;
                 float           num4       = 1f;
                 CharacterMaster component  = gameObject.GetComponent <CharacterMaster>();
                 GameObject      bodyObject = component.GetBodyObject();
                 if (this.isBoss)
                 {
                     if (!this.bossGroup)
                     {
                         GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(Resources.Load <GameObject>("Prefabs/NetworkedObjects/BossGroup"));
                         NetworkServer.Spawn(gameObject2);
                         this.bossGroup = gameObject2.GetComponent <BossGroup>();
                         this.bossGroup.dropPosition = this.dropPosition;
                     }
                     this.bossGroup.AddMember(component);
                 }
                 if (flag && (float)num2 * CombatDirector.eliteMultiplierCost <= this.monsterCredit)
                 {
                     num3 = 4.7f;
                     num4 = 2f;
                     component.inventory.SetEquipmentIndex(EliteCatalog.GetEliteDef(this.currentActiveEliteIndex).eliteEquipmentIndex);
                     num2 = (int)((float)num2 * CombatDirector.eliteMultiplierCost);
                 }
                 int num5 = num2;
                 this.monsterCredit -= (float)num5;
                 if (this.isBoss)
                 {
                     int livingPlayerCount = Run.instance.livingPlayerCount;
                     num3 *= Mathf.Pow((float)livingPlayerCount, 1f);
                 }
                 component.inventory.GiveItem(ItemIndex.BoostHp, Mathf.RoundToInt((num3 - 1f) * 10f));
                 component.inventory.GiveItem(ItemIndex.BoostDamage, Mathf.RoundToInt((num4 - 1f) * 10f));
                 DeathRewards component2 = bodyObject.GetComponent <DeathRewards>();
                 if (component2)
                 {
                     component2.expReward  = (uint)((float)num2 * this.expRewardCoefficient * Run.instance.compensatedDifficultyCoefficient);
                     component2.goldReward = (uint)((float)num2 * this.expRewardCoefficient * 2f * Run.instance.compensatedDifficultyCoefficient);
                 }
                 if (this.spawnEffectPrefab && NetworkServer.active)
                 {
                     Vector3       origin     = gameObject.transform.position;
                     CharacterBody component3 = bodyObject.GetComponent <CharacterBody>();
                     if (component3)
                     {
                         origin = component3.corePosition;
                     }
                     EffectManager.instance.SpawnEffect(this.spawnEffectPrefab, new EffectData
                     {
                         origin = origin
                     }, true);
                 }
                 return(true);
             }
         }
     }
     return(false);
 }
        // Token: 0x06000934 RID: 2356 RVA: 0x00027E88 File Offset: 0x00026088
        private bool AttemptSpawnOnTarget(GameObject spawnTarget)
        {
            if (this.currentMonsterCard == null)
            {
                if (CombatDirector.cvDirectorCombatEnableInternalLogs.value)
                {
                    Debug.Log("Current monster card is null, pick new one.");
                }
                this.PrepareNewMonsterWave(this.monsterCards.Evaluate(this.rng.nextNormalizedFloat));
            }
            if (!spawnTarget)
            {
                if (CombatDirector.cvDirectorCombatEnableInternalLogs.value)
                {
                    Debug.LogFormat("Spawn target {0} is invalid.", new object[]
                    {
                        spawnTarget
                    });
                }
                return(false);
            }
            if (this.spawnCountInCurrentWave >= this.maximumNumberToSpawnBeforeSkipping)
            {
                this.spawnCountInCurrentWave = 0;
                if (CombatDirector.cvDirectorCombatEnableInternalLogs.value)
                {
                    Debug.LogFormat("Spawn count has hit the max ({0}/{1}). Aborting spawn.", new object[]
                    {
                        this.spawnCountInCurrentWave,
                        this.maximumNumberToSpawnBeforeSkipping
                    });
                }
                return(false);
            }
            int cost = this.currentMonsterCard.cost;
            int num  = this.currentMonsterCard.cost;
            int num2 = this.currentMonsterCard.cost;

            CombatDirector.EliteTierDef eliteTierDef = this.currentActiveEliteTier;
            EliteIndex eliteIndex = this.currentActiveEliteIndex;

            num2 = (int)((float)num * this.currentActiveEliteTier.costMultiplier);
            if ((float)num2 <= this.monsterCredit)
            {
                num          = num2;
                eliteTierDef = this.currentActiveEliteTier;
                eliteIndex   = this.currentActiveEliteIndex;
            }
            else
            {
                eliteTierDef = CombatDirector.eliteTiers[0];
                eliteIndex   = EliteIndex.None;
            }
            if (!this.currentMonsterCard.CardIsValid())
            {
                if (CombatDirector.cvDirectorCombatEnableInternalLogs.value)
                {
                    Debug.LogFormat("Spawn card {0} is invalid, aborting spawn.", new object[]
                    {
                        this.currentMonsterCard.spawnCard
                    });
                }
                return(false);
            }
            if (this.monsterCredit < (float)num)
            {
                if (CombatDirector.cvDirectorCombatEnableInternalLogs.value)
                {
                    Debug.LogFormat("Spawn card {0} is too expensive, aborting spawn.", new object[]
                    {
                        this.currentMonsterCard.spawnCard
                    });
                }
                return(false);
            }
            if (this.skipSpawnIfTooCheap && (float)(num2 * this.maximumNumberToSpawnBeforeSkipping) < this.monsterCredit)
            {
                if (CombatDirector.cvDirectorCombatEnableInternalLogs.value)
                {
                    Debug.LogFormat("Card {0} seems too cheap ({1}/{2}). Comparing against most expensive possible ({3})", new object[]
                    {
                        this.currentMonsterCard.spawnCard,
                        num * this.maximumNumberToSpawnBeforeSkipping,
                        this.monsterCredit,
                        this.mostExpensiveMonsterCostInDeck
                    });
                }
                if (this.mostExpensiveMonsterCostInDeck > num)
                {
                    if (CombatDirector.cvDirectorCombatEnableInternalLogs.value)
                    {
                        Debug.LogFormat("Spawn card {0} is too cheap, aborting spawn.", new object[]
                        {
                            this.currentMonsterCard.spawnCard
                        });
                    }
                    return(false);
                }
            }
            SpawnCard             spawnCard             = this.currentMonsterCard.spawnCard;
            DirectorPlacementRule directorPlacementRule = new DirectorPlacementRule
            {
                placementMode   = DirectorPlacementRule.PlacementMode.Approximate,
                spawnOnTarget   = spawnTarget.transform,
                preventOverhead = this.currentMonsterCard.preventOverhead
            };

            DirectorCore.GetMonsterSpawnDistance(this.currentMonsterCard.spawnDistance, out directorPlacementRule.minDistance, out directorPlacementRule.maxDistance);
            directorPlacementRule.minDistance *= this.spawnDistanceMultiplier;
            directorPlacementRule.maxDistance *= this.spawnDistanceMultiplier;
            DirectorSpawnRequest directorSpawnRequest = new DirectorSpawnRequest(spawnCard, directorPlacementRule, this.rng);

            directorSpawnRequest.ignoreTeamMemberLimit = true;
            directorSpawnRequest.teamIndexOverride     = new TeamIndex?(TeamIndex.Monster);
            GameObject gameObject = DirectorCore.instance.TrySpawnObject(directorSpawnRequest);

            if (!gameObject)
            {
                Debug.LogFormat("Spawn card {0} failed to spawn. Aborting cost procedures.", new object[]
                {
                    spawnCard
                });
                return(false);
            }
            this.monsterCredit -= (float)num;
            this.spawnCountInCurrentWave++;
            CharacterMaster component  = gameObject.GetComponent <CharacterMaster>();
            GameObject      bodyObject = component.GetBodyObject();

            if (this.combatSquad)
            {
                this.combatSquad.AddMember(component);
            }
            float          num3 = eliteTierDef.healthBoostCoefficient;
            float          damageBoostCoefficient = eliteTierDef.damageBoostCoefficient;
            EliteDef       eliteDef       = EliteCatalog.GetEliteDef(eliteIndex);
            EquipmentIndex equipmentIndex = (eliteDef != null) ? eliteDef.eliteEquipmentIndex : EquipmentIndex.None;

            if (equipmentIndex != EquipmentIndex.None)
            {
                component.inventory.SetEquipmentIndex(equipmentIndex);
            }
            if (this.combatSquad)
            {
                int livingPlayerCount = Run.instance.livingPlayerCount;
                num3 *= Mathf.Pow((float)livingPlayerCount, 1f);
            }
            component.inventory.GiveItem(ItemIndex.BoostHp, Mathf.RoundToInt((num3 - 1f) * 10f));
            component.inventory.GiveItem(ItemIndex.BoostDamage, Mathf.RoundToInt((damageBoostCoefficient - 1f) * 10f));
            DeathRewards component2 = bodyObject.GetComponent <DeathRewards>();

            if (component2)
            {
                component2.expReward  = (uint)((float)num * this.expRewardCoefficient * Run.instance.compensatedDifficultyCoefficient);
                component2.goldReward = (uint)((float)num * this.expRewardCoefficient * 2f * Run.instance.compensatedDifficultyCoefficient);
            }
            if (this.spawnEffectPrefab && NetworkServer.active)
            {
                Vector3       origin     = gameObject.transform.position;
                CharacterBody component3 = bodyObject.GetComponent <CharacterBody>();
                if (component3)
                {
                    origin = component3.corePosition;
                }
                EffectManager.SpawnEffect(this.spawnEffectPrefab, new EffectData
                {
                    origin = origin
                }, true);
            }
            CombatDirector.OnSpawnedServer onSpawnedServer = this.onSpawnedServer;
            if (onSpawnedServer != null)
            {
                onSpawnedServer.Invoke(gameObject);
            }
            return(true);
        }