// 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); }
// Token: 0x06000933 RID: 2355 RVA: 0x00027CB8 File Offset: 0x00025EB8 private unsafe void PrepareNewMonsterWave(DirectorCard monsterCard) { if (CombatDirector.cvDirectorCombatEnableInternalLogs.value) { Debug.LogFormat("Preparing monster wave {0}", new object[] { monsterCard.spawnCard }); } this.currentMonsterCard = monsterCard; this.currentActiveEliteTier = CombatDirector.eliteTiers[0]; if (!(this.currentMonsterCard.spawnCard as CharacterSpawnCard).noElites) { for (int i = 1; i < CombatDirector.eliteTiers.Length; i++) { CombatDirector.EliteTierDef eliteTierDef = CombatDirector.eliteTiers[i]; if (!eliteTierDef.isAvailable()) { if (CombatDirector.cvDirectorCombatEnableInternalLogs.value) { Debug.LogFormat("Elite tier index {0} is unavailable", new object[] { i }); } } else { float num = (float)this.currentMonsterCard.cost * eliteTierDef.costMultiplier * this.eliteBias; if (num <= this.monsterCredit) { this.currentActiveEliteTier = eliteTierDef; if (CombatDirector.cvDirectorCombatEnableInternalLogs.value) { Debug.LogFormat("Found valid elite tier index {0}", new object[] { i }); } } else if (CombatDirector.cvDirectorCombatEnableInternalLogs.value) { Debug.LogFormat("Elite tier index {0} is too expensive ({1}/{2})", new object[] { i, num, this.monsterCredit }); } } } } else if (CombatDirector.cvDirectorCombatEnableInternalLogs.value) { Debug.LogFormat("Card {0} cannot be elite. Skipping elite procedure.", new object[] { this.currentMonsterCard.spawnCard }); } this.currentActiveEliteIndex = *this.rng.NextElementUniform <EliteIndex>(this.currentActiveEliteTier.eliteTypes); if (CombatDirector.cvDirectorCombatEnableInternalLogs.value) { Debug.LogFormat("Assigned elite index {0}", new object[] { this.currentActiveEliteIndex }); } this.lastAttemptedMonsterCard = this.currentMonsterCard; this.spawnCountInCurrentWave = 0; }