Exemple #1
0
        private void HealthbarEvent(float damageAmount, bool fatal, HealthHaver target)
        {
            int     num                    = Mathf.RoundToInt(damageAmount);
            Vector3 worldPosition          = target.transform.position;
            float   heightOffGround        = 1f;
            SpeculativeRigidbody component = target.GetComponent <SpeculativeRigidbody>();

            if (component)
            {
                worldPosition   = component.UnitCenter.ToVector3ZisY(0f);
                heightOffGround = worldPosition.y - component.UnitBottomCenter.y;
                if (component.healthHaver && !component.healthHaver.HasHealthBar && !component.healthHaver.HasRatchetHealthBar && !component.healthHaver.IsBoss)
                {
                    GameObject VFXHealthBarPrefab = PickupObjectDatabase.GetByName("scouter").GetComponent <RatchetScouterItem>().VFXHealthBar;
                    component.healthHaver.HasRatchetHealthBar = true;
                    GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(VFXHealthBarPrefab);
                    SimpleHealthBarController component2 = gameObject.GetComponent <SimpleHealthBarController>();
                    component2.Initialize(component, component.healthHaver);
                }
            }
            else
            {
                AIActor component3 = target.GetComponent <AIActor>();
                if (component3)
                {
                    worldPosition = component3.CenterPosition.ToVector3ZisY(0f);
                    if (component3.sprite)
                    {
                        heightOffGround = worldPosition.y - component3.sprite.WorldBottomCenter.y;
                    }
                }
            }
            num = Mathf.Max(num, 1);
            GameUIRoot.Instance.DoDamageNumber(worldPosition, heightOffGround, num);
        }
Exemple #2
0
 private void KilledEnemyContext(PlayerController sourcePlayer, HealthHaver killedEnemy)
 {
     if (killedEnemy)
     {
         AIActor component = killedEnemy.GetComponent <AIActor>();
         if (component)
         {
             this.m_enemiesKilled.Add(component.EnemyGuid);
             this.UpdateTier(sourcePlayer);
         }
     }
 }
Exemple #3
0
    private void SpawnPopup(HealthHaver dead)
    {
        Enemy enemy = dead.GetComponent <Enemy>();

        if (enemy == null || !enemy.enabled)
        {
            return;
        }
        ScorePopup myPopupPrefab = Instantiate(popupPrefab, dead.transform.position, quaternion.identity);

        myPopupPrefab.DisplayScore(enemy.Value * GlobalStats.DifficultyMultiplier(GlobalStats.instance.SelectedDifficulty));
        myPopupPrefab.DisplayCombo(comboerToRead.NumberAbsorbed);
    }
Exemple #4
0
 private bool EnemyValidForKalibersEye(bool fatal, HealthHaver enemy)
 {
     if (enemy.aiActor && fatal && !enemy.IsBoss && Owner.IsInCombat && enemy.aiActor.EnemyGuid != "249db525a9464e5282d02162c88e0357")
     {
         if (!enemy.aiActor.IgnoreForRoomClear && (enemy.GetComponent <MirrorImageController>() == null))
         {
             return(true);
         }
         return(false);
     }
     else
     {
         return(false);
     }
 }
Exemple #5
0
        // Token: 0x060074CA RID: 29898 RVA: 0x002D920C File Offset: 0x002D740C
        private void ModifyIncomingHealing(HealthHaver source, HealthHaver.ModifyHealingEventArgs args)
        {
            HealingReceivedModificationItem needle = PickupObjectDatabase.GetById(259).GetComponent <HealingReceivedModificationItem>();

            OnImprovedHealingVFX = needle.OnImprovedHealingVFX.gameObject;

            if (args == EventArgs.Empty)
            {
                return;
            }
            if (this.OnImprovedHealingVFX != null)
            {
                source.GetComponent <PlayerController>().PlayEffectOnActor(this.OnImprovedHealingVFX, Vector3.zero, true, false, false);
            }
            args.ModifiedHealing *= this.HealingImprovedBy;
        }
Exemple #6
0
 private void OnEnemyDamaged(float damage, bool fatal, HealthHaver enemy)
 {
     if (fatal)
     {
         if (EnemyValidForKalibersEye(fatal, enemy))
         {
             //ETGModConsole.Log("Enemy valid");
             try
             {
                 float procChance;
                 if (Owner.PlayerHasActiveSynergy("All Seeing"))
                 {
                     procChance = 1f;
                 }
                 else
                 {
                     procChance = 0.5f;
                 }
                 if (UnityEngine.Random.value < procChance)
                 {
                     bool       isJammed        = enemy.aiActor.IsBlackPhantom;
                     string     enemyGuid       = enemy.aiActor.EnemyGuid;
                     Vector2    worldBottomLeft = enemy.sprite.WorldBottomLeft;
                     IntVector2 PosToSpawn      = worldBottomLeft.ToIntVector2();
                     GameManager.Instance.StartCoroutine(this.DoEnemySpawn(enemyGuid, PosToSpawn, isJammed, (enemy.GetComponent <DisplacedImageController>() != null)));
                 }
             }
             catch (Exception e)
             {
                 ETGModConsole.Log(e.Message);
                 ETGModConsole.Log(e.StackTrace);
             }
         }
         //else ETGModConsole.Log("Enemy invalid");
     }
 }
Exemple #7
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;
        }
Exemple #8
0
        public static void DoRadialDamage(float damage, Vector3 position, float radius, bool damagePlayers, bool damageEnemies, bool ignoreDamageCaps = false, VFXPool hitVFX = null)
        {
            List <HealthHaver> allHealthHavers = StaticReferenceManager.AllHealthHavers;

            if (allHealthHavers != null)
            {
                for (int i = 0; i < allHealthHavers.Count; i++)
                {
                    HealthHaver healthHaver = allHealthHavers[i];
                    if (healthHaver)
                    {
                        if (healthHaver.gameObject.activeSelf)
                        {
                            if (!healthHaver.aiActor || !healthHaver.aiActor.IsGone)
                            {
                                if (!healthHaver.aiActor || healthHaver.aiActor.isActiveAndEnabled)
                                {
                                    for (int j = 0; j < healthHaver.NumBodyRigidbodies; j++)
                                    {
                                        SpeculativeRigidbody bodyRigidbody = healthHaver.GetBodyRigidbody(j);
                                        Vector2 a      = healthHaver.transform.position.XY();
                                        Vector2 vector = a - position.XY();
                                        bool    flag   = false;
                                        bool    flag2  = 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 (num < radius)
                                        {
                                            PlayerController component = healthHaver.GetComponent <PlayerController>();
                                            if (component != null)
                                            {
                                                bool flag3 = true;
                                                if (PassiveItem.ActiveFlagItems.ContainsKey(component) && PassiveItem.ActiveFlagItems[component].ContainsKey(typeof(HelmetItem)) && num > radius * HelmetItem.EXPLOSION_RADIUS_MULTIPLIER)
                                                {
                                                    flag3 = false;
                                                }
                                                if (IsPlayerBlockedByWall(component, position))
                                                {
                                                    flag3 = false;
                                                }
                                                if (damagePlayers && flag3 && !component.IsEthereal)
                                                {
                                                    HealthHaver     healthHaver2   = healthHaver;
                                                    float           damage2        = 0.5f;
                                                    Vector2         direction      = vector;
                                                    string          enemiesString  = StringTableManager.GetEnemiesString("#EXPLOSION", -1);
                                                    CoreDamageTypes damageTypes    = CoreDamageTypes.None;
                                                    DamageCategory  damageCategory = DamageCategory.Normal;
                                                    healthHaver2.ApplyDamage(damage2, direction, enemiesString, damageTypes, damageCategory, false, null, ignoreDamageCaps);
                                                    flag2 = true;
                                                }
                                            }
                                            else if (damageEnemies)
                                            {
                                                AIActor aiActor = healthHaver.aiActor;
                                                if (damagePlayers || !aiActor || aiActor.IsNormalEnemy)
                                                {
                                                    HealthHaver     healthHaver3   = healthHaver;
                                                    Vector2         direction      = vector;
                                                    string          enemiesString  = StringTableManager.GetEnemiesString("#EXPLOSION", -1);
                                                    CoreDamageTypes damageTypes    = CoreDamageTypes.None;
                                                    DamageCategory  damageCategory = DamageCategory.Normal;
                                                    healthHaver3.ApplyDamage(damage, direction, enemiesString, damageTypes, damageCategory, false, null, ignoreDamageCaps);
                                                    flag2 = true;
                                                }
                                            }
                                            flag = true;
                                        }
                                        if (flag2 && hitVFX != null)
                                        {
                                            if (bodyRigidbody.HitboxPixelCollider != null)
                                            {
                                                PixelCollider pixelCollider = bodyRigidbody.GetPixelCollider(ColliderType.HitBox);
                                                Vector2       v             = BraveMathCollege.ClosestPointOnRectangle(position, pixelCollider.UnitBottomLeft, pixelCollider.UnitDimensions);
                                                hitVFX.SpawnAtPosition(v, 0f, null, null, null, null, false, null, null, false);
                                            }
                                            else
                                            {
                                                hitVFX.SpawnAtPosition(healthHaver.transform.position.XY(), 0f, null, null, null, null, false, null, null, false);
                                            }
                                        }
                                        if (flag)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }