Пример #1
0
        public void DoDaFreeeez()
        {
            if (limiter == 1 && counter == 30)
            {
                DeadlyDeadlyGoopManager.FreezeGoopsCircle(this.Owner.sprite.WorldCenter, 40f);

                limiter = 0;
                counter = 0;
            }
        }
        private void Update()
        {
            if (m_attachedPlayer != null && !Dungeon.IsGenerating)
            {
                if (m_attachedPlayer.healthHaver.Armor != armourLastChecked)
                {
                    if (!SaveAPIManager.GetFlag(CustomDungeonFlags.PLAYERHELDMORETHANFIVEARMOUR))
                    {
                        int threshHold = 5;
                        if (m_attachedPlayer.characterIdentity == PlayableCharacters.Robot)
                        {
                            threshHold = 11;
                        }
                        if (m_attachedPlayer.healthHaver.Armor >= threshHold)
                        {
                            SaveAPIManager.SetFlag(CustomDungeonFlags.PLAYERHELDMORETHANFIVEARMOUR, true);
                        }
                    }
                    armourLastChecked = (int)m_attachedPlayer.healthHaver.Armor;
                }
                if (m_attachedPlayer.stats.GetStatValue(PlayerStats.StatType.Health) != hpStatLastChecked)
                {
                    SaveAPIManager.UpdateMaximum(CustomTrackedMaximums.MAX_HEART_CONTAINERS_EVER, m_attachedPlayer.stats.GetStatValue(PlayerStats.StatType.Health));
                    hpStatLastChecked = (int)m_attachedPlayer.stats.GetStatValue(PlayerStats.StatType.Health);
                }
                if (m_attachedPlayer.passiveItems.Count != itemCountLastChecked)
                {
                    OnInventoryItemsChanged();
                    itemCountLastChecked = m_attachedPlayer.passiveItems.Count;
                }
                if (m_attachedPlayer.CurrentGun)
                {
                    if (m_attachedPlayer.CurrentGun.PickupObjectId != gunIDLastChecked)
                    {
                        OnCurrentGunChanged();
                    }
                }

                #region InvisibleO
                if (Challenges.CurrentChallenge == ChallengeType.INVISIBLEO && m_attachedPlayer.IsVisible == true)
                {
                    playerIsInvisibleForChallenge = true;
                    m_attachedPlayer.DoDustUps    = false;
                    m_attachedPlayer.IsVisible    = false;
                }
                if (playerIsInvisibleForChallenge && Challenges.CurrentChallenge != ChallengeType.INVISIBLEO && m_attachedPlayer.IsVisible == false)
                {
                    playerIsInvisibleForChallenge = false;
                    m_attachedPlayer.DoDustUps    = true;
                    m_attachedPlayer.IsVisible    = true;
                }
                if (playerIsInvisibleForChallenge && m_attachedPlayer.gameActor.ShadowObject.GetComponent <Renderer>().enabled == true && !playerShadowInvisible)
                {
                    m_attachedPlayer.gameActor.ShadowObject.GetComponent <Renderer>().enabled = false;
                    playerShadowInvisible = true;
                }
                else if (!playerIsInvisibleForChallenge && m_attachedPlayer.gameActor.ShadowObject.GetComponent <Renderer>().enabled == false && playerShadowInvisible)
                {
                    m_attachedPlayer.gameActor.ShadowObject.GetComponent <Renderer>().enabled = true;
                    playerShadowInvisible = false;
                }
                if (Challenges.CurrentChallenge == ChallengeType.INVISIBLEO && m_attachedPlayer.CurrentGun && m_attachedPlayer.CurrentGun.GetComponent <InvisibleGun>() == null)
                {
                    m_attachedPlayer.CurrentGun.gameObject.AddComponent <InvisibleGun>();
                }
                if (Challenges.CurrentChallenge == ChallengeType.INVISIBLEO && m_attachedPlayer.CurrentSecondaryGun && m_attachedPlayer.CurrentSecondaryGun.GetComponent <InvisibleGun>() == null)
                {
                    m_attachedPlayer.CurrentSecondaryGun.gameObject.AddComponent <InvisibleGun>();
                }
                if (playerIsInvisibleForChallenge && m_attachedPlayer.primaryHand.ForceRenderersOff == false)
                {
                    m_attachedPlayer.primaryHand.ForceRenderersOff = true;
                }
                if (playerIsInvisibleForChallenge && m_attachedPlayer.secondaryHand.ForceRenderersOff == false)
                {
                    m_attachedPlayer.secondaryHand.ForceRenderersOff = true;
                }
                if (Challenges.CurrentChallenge == ChallengeType.INVISIBLEO && GameUIRoot.Instance.GetReloadBarForPlayer(m_attachedPlayer))
                {
                    int i = m_attachedPlayer.PlayerIDX;
                    GameUIRoot.Instance.ForceClearReload(i);
                }
                #endregion

                if (Challenges.CurrentChallenge == ChallengeType.KEEP_IT_COOL)
                {
                    DeadlyDeadlyGoopManager goop = DeadlyDeadlyGoopManager.GetGoopManagerForGoopType(EasyGoopDefinitions.WaterGoop);
                    goop.TimedAddGoopCircle(m_attachedPlayer.specRigidbody.UnitCenter, 2f, 0.01f, true);
                    DeadlyDeadlyGoopManager.FreezeGoopsCircle(m_attachedPlayer.specRigidbody.UnitBottomCenter, 2);
                    if (!m_attachedPlayer.ownerlessStatModifiers.Contains(keepItCoolSpeedBuff))
                    {
                        m_attachedPlayer.ownerlessStatModifiers.Add(keepItCoolSpeedBuff);
                        m_attachedPlayer.stats.RecalculateStats(m_attachedPlayer);
                    }
                    if (m_attachedPlayer.HasPickupID(256))
                    {
                        m_attachedPlayer.RemovePassiveItem(256);
                        IntVector2 bestRewardLocation2 = m_attachedPlayer.CurrentRoom.GetBestRewardLocation(IntVector2.One * 3, RoomHandler.RewardLocationStyle.PlayerCenter, true);
                        Chest      red_Chest           = GameManager.Instance.RewardManager.A_Chest;
                        red_Chest.IsLocked  = false;
                        red_Chest.ChestType = (UnityEngine.Random.value <= 0.5f ? Chest.GeneralChestType.ITEM : Chest.GeneralChestType.WEAPON);
                        Chest spawnedRed = Chest.Spawn(red_Chest, bestRewardLocation2);
                        spawnedRed.lootTable.lootTable = (UnityEngine.Random.value <= 0.5f ? GameManager.Instance.RewardManager.GunsLootTable : GameManager.Instance.RewardManager.ItemsLootTable);
                        spawnedRed.RegisterChestOnMinimap(spawnedRed.GetAbsoluteParentRoom());
                        TextBubble.DoAmbientTalk(m_attachedPlayer.transform, new Vector3(1, 2, 0), "Nice Try", 4f);
                    }
                }
                else if (m_attachedPlayer.ownerlessStatModifiers.Contains(keepItCoolSpeedBuff))
                {
                    m_attachedPlayer.ownerlessStatModifiers.Remove(keepItCoolSpeedBuff);
                    m_attachedPlayer.stats.RecalculateStats(m_attachedPlayer);
                }
            }
        }
Пример #3
0
        private IEnumerator HandleExplosion(Vector3 position, ExplosionData data, Vector2 sourceNormal, Action onExplosionBegin, bool ignoreQueues, CoreDamageTypes damageTypes, bool ignoreDamageCaps)
        {
            if (data.usesComprehensiveDelay)
            {
                yield return(new WaitForSeconds(data.comprehensiveDelay));
            }
            Exploder.OnExplosionTriggered?.Invoke();
            bool addFireGoop       = (damageTypes | CoreDamageTypes.Fire) == damageTypes;
            bool addFreezeGoop     = (damageTypes | CoreDamageTypes.Ice) == damageTypes;
            bool addPoisonGoop     = (damageTypes | CoreDamageTypes.Poison) == damageTypes;
            bool isFreezeExplosion = data.isFreezeExplosion;

            if (!data.isFreezeExplosion && addFreezeGoop)
            {
                isFreezeExplosion = true;
                data.freezeRadius = data.damageRadius;
                data.freezeEffect = GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultFreezeExplosionEffect;
            }
            // Be sure to use a clone of ExplosionManager for this else explosion queueing breaks! //
            // (it won't let you use ExplosionManager's original code on a new Exploder class normally. ;) - [Apache Thunder] //
            if (!ignoreQueues)
            {
                ChaosExplosionManager.Instance.Queue(this);
                while (!ChaosExplosionManager.Instance.IsExploderReady(this))
                {
                    yield return(null);
                }
                ChaosExplosionManager.Instance.Dequeue();
                if (ChaosExplosionManager.Instance.QueueCount == 0)
                {
                    ChaosExplosionManager.Instance.StartCoroutine(HandleCurrentExplosionNotification(0.5f));
                }
            }
            onExplosionBegin?.Invoke();
            float damageRadius            = data.GetDefinedDamageRadius();
            float pushSqrRadius           = data.pushRadius * data.pushRadius;
            float bulletDeletionSqrRadius = damageRadius * damageRadius;

            if (addFreezeGoop)
            {
                DeadlyDeadlyGoopManager.GetGoopManagerForGoopType(GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultFreezeGoop).TimedAddGoopCircle(position.XY(), damageRadius, 0.5f, false);
                DeadlyDeadlyGoopManager.FreezeGoopsCircle(position.XY(), damageRadius);
            }
            if (addFireGoop)
            {
                DeadlyDeadlyGoopManager.GetGoopManagerForGoopType(GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultFireGoop).TimedAddGoopCircle(position.XY(), damageRadius, 0.5f, false);
            }
            if (addPoisonGoop)
            {
                DeadlyDeadlyGoopManager.GetGoopManagerForGoopType(GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultPoisonGoop).TimedAddGoopCircle(position.XY(), damageRadius, 0.5f, false);
            }
            if (!isFreezeExplosion)
            {
                DeadlyDeadlyGoopManager.IgniteGoopsCircle(position.XY(), damageRadius);
            }
            if (data.effect)
            {
                GameObject gameObject;
                if (data.effect.GetComponent <ParticleSystem>() != null || data.effect.GetComponentInChildren <ParticleSystem>() != null)
                {
                    gameObject = SpawnManager.SpawnVFX(data.effect, position, Quaternion.identity);
                }
                else
                {
                    gameObject = SpawnManager.SpawnVFX(data.effect, position, Quaternion.identity);
                }
                if (data.rotateEffectToNormal && gameObject)
                {
                    gameObject.transform.rotation = Quaternion.Euler(0f, 0f, sourceNormal.ToAngle());
                }
                tk2dBaseSprite component = gameObject.GetComponent <tk2dBaseSprite>();
                if (component)
                {
                    component.HeightOffGround += UnityEngine.Random.Range(-0.1f, 0.2f);
                    component.UpdateZDepth();
                }
                ExplosionDebrisLauncher[] componentsInChildren = gameObject.GetComponentsInChildren <ExplosionDebrisLauncher>();
                Vector3    position2   = gameObject.transform.position.WithZ(gameObject.transform.position.y);
                GameObject gameObject2 = new GameObject("SoundSource");
                gameObject2.transform.position = position2;
                if (data.playDefaultSFX)
                {
                    AkSoundEngine.PostEvent("Play_WPN_grenade_blast_01", gameObject2);
                }
                Destroy(gameObject2, 5f);
                for (int i = 0; i < componentsInChildren.Length; i++)
                {
                    if (componentsInChildren[i])
                    {
                        if (sourceNormal == Vector2.zero)
                        {
                            componentsInChildren[i].Launch();
                        }
                        else
                        {
                            componentsInChildren[i].Launch(sourceNormal);
                        }
                    }
                }
                if (gameObject)
                {
                    Transform transform = gameObject.transform.Find("scorch");
                    if (transform)
                    {
                        transform.gameObject.SetLayerRecursively(LayerMask.NameToLayer("BG_Critical"));
                    }
                }
                if (data.doExplosionRing)
                {
                }
            }
            yield return(new WaitForSeconds(data.explosionDelay));

            List <HealthHaver> allHealth = StaticReferenceManager.AllHealthHavers;

            if (allHealth != null && (data.doDamage || data.doForce))
            {
                for (int j = 0; j < allHealth.Count; j++)
                {
                    HealthHaver healthHaver = allHealth[j];
                    if (healthHaver)
                    {
                        if (healthHaver && healthHaver.aiActor)
                        {
                            if (!healthHaver.aiActor.HasBeenEngaged)
                            {
                                goto IL_A82;
                            }
                            if (healthHaver.aiActor.CompanionOwner && data.damageToPlayer == 0f)
                            {
                                goto IL_A82;
                            }
                        }
                        if (!data.ignoreList.Contains(healthHaver.specRigidbody))
                        {
                            if (position.GetAbsoluteRoom() == allHealth[j].transform.position.GetAbsoluteRoom())
                            {
                                for (int k = 0; k < healthHaver.NumBodyRigidbodies; k++)
                                {
                                    SpeculativeRigidbody bodyRigidbody    = healthHaver.GetBodyRigidbody(k);
                                    PlayerController     playerController = (!bodyRigidbody) ? null : (bodyRigidbody.gameActor as PlayerController);
                                    Vector2 a      = healthHaver.transform.position.XY();
                                    Vector2 vector = a - position.XY();
                                    bool    flag   = false;
                                    float   num;
                                    if (bodyRigidbody.HitboxPixelCollider != null)
                                    {
                                        a      = bodyRigidbody.HitboxPixelCollider.UnitCenter;
                                        vector = a - position.XY();
                                        num    = BraveMathCollege.DistToRectangle(position.XY(), bodyRigidbody.HitboxPixelCollider.UnitBottomLeft, bodyRigidbody.HitboxPixelCollider.UnitDimensions);
                                    }
                                    else
                                    {
                                        a      = healthHaver.transform.position.XY();
                                        vector = a - position.XY();
                                        num    = vector.magnitude;
                                    }
                                    if (!playerController || ((!data.doDamage || num >= damageRadius) && (!isFreezeExplosion || num >= data.freezeRadius) && (!data.doForce || num >= data.pushRadius)) || !IsPlayerBlockedByWall(playerController, position))
                                    {
                                        if (playerController)
                                        {
                                            if (!bodyRigidbody.CollideWithOthers)
                                            {
                                                goto IL_A6E;
                                            }
                                            if (playerController.DodgeRollIsBlink && playerController.IsDodgeRolling)
                                            {
                                                goto IL_A6E;
                                            }
                                        }
                                        if (data.doDamage && num < damageRadius)
                                        {
                                            if (playerController)
                                            {
                                                bool flag2 = true;
                                                if (PassiveItem.ActiveFlagItems.ContainsKey(playerController) && PassiveItem.ActiveFlagItems[playerController].ContainsKey(typeof(HelmetItem)) && num > damageRadius * HelmetItem.EXPLOSION_RADIUS_MULTIPLIER)
                                                {
                                                    flag2 = false;
                                                }
                                                if (flag2 && !playerController.IsEthereal)
                                                {
                                                    HealthHaver     healthHaver2   = healthHaver;
                                                    float           damage         = data.damageToPlayer;
                                                    Vector2         direction      = vector;
                                                    string          enemiesString  = StringTableManager.GetEnemiesString("#EXPLOSION", -1);
                                                    CoreDamageTypes damageTypes2   = CoreDamageTypes.None;
                                                    DamageCategory  damageCategory = DamageCategory.Normal;
                                                    healthHaver2.ApplyDamage(damage, direction, enemiesString, damageTypes2, damageCategory, false, null, ignoreDamageCaps);
                                                }
                                            }
                                            else
                                            {
                                                HealthHaver     healthHaver3   = healthHaver;
                                                float           damage         = data.damage;
                                                Vector2         direction      = vector;
                                                string          enemiesString  = StringTableManager.GetEnemiesString("#EXPLOSION", -1);
                                                CoreDamageTypes damageTypes2   = CoreDamageTypes.None;
                                                DamageCategory  damageCategory = DamageCategory.Normal;
                                                healthHaver3.ApplyDamage(damage, direction, enemiesString, damageTypes2, damageCategory, false, null, ignoreDamageCaps);
                                                if (data.IsChandelierExplosion && (!healthHaver || healthHaver.healthHaver.IsDead))
                                                {
                                                    GameStatsManager.Instance.RegisterStatChange(TrackedStats.ENEMIES_KILLED_WITH_CHANDELIERS, 1f);
                                                }
                                            }
                                            flag = true;
                                        }
                                        if (isFreezeExplosion && num < data.freezeRadius)
                                        {
                                            if (healthHaver && healthHaver.gameActor != null && !healthHaver.IsDead && (!healthHaver.aiActor || !healthHaver.aiActor.IsGone))
                                            {
                                                healthHaver.gameActor.ApplyEffect(data.freezeEffect, 1f, null);
                                            }
                                            flag = true;
                                        }
                                        if (data.doForce && num < data.pushRadius)
                                        {
                                            KnockbackDoer knockbackDoer = healthHaver.knockbackDoer;
                                            if (knockbackDoer)
                                            {
                                                float num2 = 1f - num / data.pushRadius;
                                                if (data.preventPlayerForce && healthHaver.GetComponent <PlayerController>())
                                                {
                                                    num2 = 0f;
                                                }
                                                knockbackDoer.ApplyKnockback(vector.normalized, num2 * data.force, false);
                                            }
                                            flag = true;
                                        }
                                        if (flag)
                                        {
                                            break;
                                        }
                                    }
                                    IL_A6E :;
                                }
                            }
                        }
                    }
                    IL_A82 :;
                }
            }
            List <MinorBreakable> allBreakables = StaticReferenceManager.AllMinorBreakables;

            if (allBreakables != null)
            {
                for (int l = 0; l < allBreakables.Count; l++)
                {
                    MinorBreakable minorBreakable = allBreakables[l];
                    if (minorBreakable)
                    {
                        if (!minorBreakable.resistsExplosions)
                        {
                            if (!minorBreakable.OnlyBrokenByCode)
                            {
                                Vector2 vector2 = minorBreakable.CenterPoint - position.XY();
                                if (vector2.sqrMagnitude < pushSqrRadius)
                                {
                                    minorBreakable.Break(vector2.normalized);
                                }
                            }
                        }
                    }
                }
            }
            if (data.doDestroyProjectiles)
            {
                float            duration         = 0.2f;
                PlayerController bestActivePlayer = GameManager.Instance.BestActivePlayer;
                if (bestActivePlayer && bestActivePlayer.CurrentRoom != null && bestActivePlayer.CurrentRoom.area != null && bestActivePlayer.CurrentRoom.area.PrototypeRoomCategory == PrototypeDungeonRoom.RoomCategory.BOSS)
                {
                    duration = 0.035f;
                }
                GameManager.Instance.Dungeon.StartCoroutine(HandleBulletDeletionFrames(position, bulletDeletionSqrRadius, duration));
            }
            if (data.doDamage || data.breakSecretWalls)
            {
                List <MajorBreakable> allMajorBreakables = StaticReferenceManager.AllMajorBreakables;
                if (allMajorBreakables != null)
                {
                    for (int m = 0; m < allMajorBreakables.Count; m++)
                    {
                        MajorBreakable majorBreakable = allMajorBreakables[m];
                        if (majorBreakable)
                        {
                            if (majorBreakable.enabled)
                            {
                                if (!majorBreakable.IgnoreExplosions)
                                {
                                    Vector2 sourceDirection = majorBreakable.CenterPoint - position.XY();
                                    if (sourceDirection.sqrMagnitude < pushSqrRadius && (!majorBreakable.IsSecretDoor || !data.forcePreventSecretWallDamage))
                                    {
                                        if (data.doDamage)
                                        {
                                            majorBreakable.ApplyDamage(data.damage, sourceDirection, false, true, false);
                                        }
                                        if (data.breakSecretWalls && majorBreakable.IsSecretDoor)
                                        {
                                            StaticReferenceManager.AllMajorBreakables[m].ApplyDamage(1E+10f, Vector2.zero, false, true, true);
                                            StaticReferenceManager.AllMajorBreakables[m].ApplyDamage(1E+10f, Vector2.zero, false, true, true);
                                            StaticReferenceManager.AllMajorBreakables[m].ApplyDamage(1E+10f, Vector2.zero, false, true, true);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            if (data.doForce)
            {
                Exploder.DoRadialPush(position, data.debrisForce, data.pushRadius);
            }
            if (data.doScreenShake && GameManager.Instance.MainCameraController != null)
            {
                GameManager.Instance.MainCameraController.DoScreenShake(data.ss, new Vector2?(position), false);
            }
            if (data.doStickyFriction && GameManager.Instance.MainCameraController != null)
            {
                StickyFrictionManager.Instance.RegisterExplosionStickyFriction();
            }
            for (int n = 0; n < StaticReferenceManager.AllRatTrapdoors.Count; n++)
            {
                if (StaticReferenceManager.AllRatTrapdoors[n])
                {
                    StaticReferenceManager.AllRatTrapdoors[n].OnNearbyExplosion(position);
                }
            }
            Destroy(this.gameObject);
            yield break;
        }