public Projectile(World world, SpriteBatch batch, Vector2 position, Texture2D texture, short direction,
            Vector2 velocity, object owner, DamageCategory doesDamageTo, int amountOfDamage)
            : base(world, batch, position)
        {
            this.texture = texture;
            this.direction = direction;
            this.velocity = velocity;
            this.owner = owner;
            this.doesDamageTo = doesDamageTo;
            this.amountOfDamage = amountOfDamage;

            facing = SpriteEffects.None;

            if (direction == 1)
            {
                facing = SpriteEffects.FlipHorizontally;
            }

            //Initializes the hat's hotspots.
            List<CollisionHotspot> hotspots = new List<CollisionHotspot>();
            hotspots.Add(new CollisionHotspot(this, new Vector2(6, 0), HOTSPOT_TYPE.top));
            hotspots.Add(new CollisionHotspot(this, new Vector2(0, 3), HOTSPOT_TYPE.left));
            hotspots.Add(new CollisionHotspot(this, new Vector2(9, 3), HOTSPOT_TYPE.right));
            hotspots.Add(new CollisionHotspot(this, new Vector2(6, 6), HOTSPOT_TYPE.bottom));
            Hotspots = hotspots;

            this.World.AddWorldObject(this);
        }
 public static void DamageHook(Action <HealthHaver, float, Vector2, string, CoreDamageTypes, DamageCategory, bool, PixelCollider, bool> orig, HealthHaver hh, float damage, Vector2 direction, string damageSource, CoreDamageTypes damageTypes,
                               DamageCategory damageCategory, bool ignoreInvulnerabilityFrames, PixelCollider hitPixelCollider, bool ignoreDamageCaps)
 {
     damageSource = string.Empty;
     orig(hh, damage, direction, damageSource, damageTypes, damageCategory, ignoreInvulnerabilityFrames, hitPixelCollider, ignoreDamageCaps);
     hh.lastIncurredDamageSource = string.Empty;
 }
Beispiel #3
0
        public void ReceiveDamage(LivingObject attacker, DamageCategory cat, int damage)
        {
            this.HitPoints -= damage;

            if (this.HitPoints <= 0)
            {
                Die();
            }
        }
Beispiel #4
0
 public Move(string n, Types e, DamageCategory cat, byte bpp, byte p, byte a, bool cntct, sbyte pri = 0)
 {
     name = n;
     power = p;
     element = e;
     basePP = bpp;
     accuracy = a;
     category = cat;
     contact = cntct;
     priority = pri;
 }
Beispiel #5
0
 public Move(string n, Types e, DamageCategory cat, byte bpp, byte p, byte a, bool cntct, sbyte pri = 0)
 {
     name     = n;
     power    = p;
     element  = e;
     basePP   = bpp;
     accuracy = a;
     category = cat;
     contact  = cntct;
     priority = pri;
 }
        private static float DealSwordDamageToEnemy(GameActor owner, GameActor targetEnemy, Vector2 arcOrigin, Vector2 contact, float angle, SlashData slashParameters)
        {
            if (targetEnemy.healthHaver)
            {
                float damageToDeal = slashParameters.damage;
                if (targetEnemy.healthHaver && targetEnemy.healthHaver.IsBoss)
                {
                    damageToDeal *= slashParameters.bossDamageMult;
                }
                if ((targetEnemy is AIActor) && (targetEnemy as AIActor).IsBlackPhantom)
                {
                    damageToDeal *= slashParameters.jammedDamageMult;
                }
                DamageCategory category = DamageCategory.Normal;
                if ((owner is AIActor) && (owner as AIActor).IsBlackPhantom)
                {
                    category = DamageCategory.BlackBullet;
                }

                bool wasAlivePreviously = targetEnemy.healthHaver.IsAlive;
                //VFX
                if (slashParameters.doHitVFX && slashParameters.hitVFX != null)
                {
                    slashParameters.hitVFX.SpawnAtPosition(new Vector3(contact.x, contact.y), 0, targetEnemy.transform);
                }
                targetEnemy.healthHaver.ApplyDamage(damageToDeal, contact - arcOrigin, owner.ActorName, CoreDamageTypes.None, category, false, null, false);

                bool fatal = false;
                if (wasAlivePreviously && targetEnemy.healthHaver.IsDead)
                {
                    fatal = true;
                }

                if (slashParameters.OnHitTarget != null)
                {
                    slashParameters.OnHitTarget(targetEnemy, fatal);
                }
            }
            if (targetEnemy.knockbackDoer)
            {
                targetEnemy.knockbackDoer.ApplyKnockback(contact - arcOrigin, slashParameters.enemyKnockbackForce, false);
            }
            if (slashParameters.statusEffects != null && slashParameters.statusEffects.Count > 0)
            {
                foreach (GameActorEffect effect in slashParameters.statusEffects)
                {
                    targetEnemy.ApplyEffect(effect);
                }
            }
            return(slashParameters.damage);
        }
Beispiel #7
0
            private IEnumerator HandleDelayedDamage(SpeculativeRigidbody targetRigidbody, float damage, Vector2 damageVec, PixelCollider hitPixelCollider)
            {
                yield return(new WaitForSeconds(0.5f));

                if (targetRigidbody && targetRigidbody.healthHaver)
                {
                    HealthHaver     healthHaver     = targetRigidbody.healthHaver;
                    string          ownerName       = this.OwnerName;
                    CoreDamageTypes coreDamageTypes = this.damageTypes;
                    DamageCategory  damageCategory  = (!this.IsBlackBullet) ? DamageCategory.Normal : DamageCategory.BlackBullet;
                    healthHaver.ApplyDamage(damage, damageVec, ownerName, coreDamageTypes, damageCategory, false, hitPixelCollider, this.ignoreDamageCaps);
                }
                yield break;
            }
Beispiel #8
0
        public Move(string n, Types e, DamageCategory cat, byte bpp, byte p, byte a, bool cntct, Action<Pokemon, Pokemon, int> ef, byte efa = 0, sbyte pri = 0)
        {
            name = n;
            power = p;
            element = e;
            basePP = bpp;
            accuracy = a;
            effect = ef;
            category = cat;
            contact = cntct;
            priority = pri;
            effectAccuracy = efa;

            if (effectAccuracy == 0) effectAccuracy = accuracy;
        }
Beispiel #9
0
    static DamageCategoryExtensions()
    {
        // Build all parents
        foreach (DamageCategory root in immediateParents.Keys)
        {
            List <DamageCategory> parents = new List <DamageCategory>()
            {
                DamageCategory.Damage
            };
            for (DamageCategory parent = immediateParents.GetValueOrDefault(root); parent != default(DamageCategory) && !parents.Contains(parent); parent = immediateParents.GetValueOrDefault(parent))
            {
                parents.Add(parent);
            }

            allParents[root] = parents;
        }
    }
Beispiel #10
0
        public Move(string n, Types e, DamageCategory cat, byte bpp, byte p, byte a, bool cntct, Action <Pokemon, Pokemon, int> ef, byte efa = 0, sbyte pri = 0)
        {
            name           = n;
            power          = p;
            element        = e;
            basePP         = bpp;
            accuracy       = a;
            effect         = ef;
            category       = cat;
            contact        = cntct;
            priority       = pri;
            effectAccuracy = efa;

            if (effectAccuracy == 0)
            {
                effectAccuracy = accuracy;
            }
        }
Beispiel #11
0
 public Damage(DamageCategory category, float amount) : this()
 {
     Category = category;
     Amount   = amount;
 }
Beispiel #12
0
        private void BreakEgg(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
        {
            float value = UnityEngine.Random.Range(0.0f, 1.0f);
            bool  flag  = value < 0.15;

            if (flag && !Owner.HasPickupID(817))
            {
                PlayerController player    = this.Owner;
                float            curHealth = player.healthHaver.GetCurrentHealth();
                AkSoundEngine.PostEvent("Play_WPN_egg_impact_01", base.gameObject);

                player.PlayEffectOnActor(ResourceCache.Acquire("Global VFX/VFX_Healing_Sparkles_001") as GameObject, Vector3.zero, true, false, false);
                player.healthHaver.ForceSetCurrentHealth(curHealth + 0.5f);

                UnityEngine.Object.Destroy(base.gameObject, 1f);
                player.DropPassiveItem(this);

                PickupObject.ItemQuality itemQuality          = PickupObject.ItemQuality.D;
                PickupObject             itemOfTypeAndQuality = LootEngine.GetItemOfTypeAndQuality <PickupObject>(itemQuality, (UnityEngine.Random.value >= 0.5f) ? GameManager.Instance.RewardManager.GunsLootTable : GameManager.Instance.RewardManager.ItemsLootTable, false);
                if (itemOfTypeAndQuality)
                {
                    LootEngine.SpawnItem(itemOfTypeAndQuality.gameObject, base.transform.position, Vector2.up, 0.1f, true, false, false);
                }
            }

            else
            {
                return;
            }
        }
Beispiel #13
0
 public void OnTakeDamage(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
 {
     this.DamageToEnemiesInRoom = 6f;
     base.Owner.CurrentRoom.ApplyActionToNearbyEnemies(base.Owner.CenterPosition, 100f, delegate(AIActor enemy, float dist)
     {
         if (enemy && enemy.healthHaver)
         {
             enemy.healthHaver.ApplyDamage(this.DamageToEnemiesInRoom, Vector2.zero, string.Empty, CoreDamageTypes.None, DamageCategory.Normal, false, null, false);
         }
     });
 }
Beispiel #14
0
 private void ChaosHole(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
 {
     {
         Projectile projectile = ((Gun)ETGMod.Databases.Items["black_hole_gun"]).DefaultModule.projectiles[0];
         GameObject gameObject = SpawnManager.SpawnProjectile(projectile.gameObject, base.Owner.sprite.WorldCenter, Quaternion.Euler(0f, 0f, (base.Owner.CurrentGun == null) ? 0f : base.Owner.CurrentGun.CurrentAngle), true);
         Projectile component  = gameObject.GetComponent <Projectile>();
         bool       flag       = component != null;
         bool       flag2      = flag;
         if (flag2)
         {
             component.Owner           = base.Owner;
             component.Shooter         = base.Owner.specRigidbody;
             component.baseData.speed  = 4f;
             component.baseData.damage = 0.1f;
         }
     }
 }
Beispiel #15
0
        private void CompanionOnDamaged(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
        {
            m_healthRemaining    = resultValue;
            m_maxHealthRemaining = maxValue;

            if (m_canSpawnRings && RingDropChance > UnityEngine.Random.value)
            {
                if (m_extantCompanion)
                {
                    m_extantCompanion.GetComponent <AIActor>().behaviorSpeculator.Stun(1);
                    m_extantCompanion.GetComponent <AIAnimator>().PlayUntilFinished(HitAnimation);
                    int RingCount = UnityEngine.Random.Range(3, 10);
                    ExpandUtility.SpawnCustomCurrency(m_extantCompanion.GetComponent <SpeculativeRigidbody>().GetUnitCenter(ColliderType.HitBox), RingCount, SonicRing.RingID);
                    AkSoundEngine.PostEvent("Play_EX_SonicLoseRings_01", m_extantCompanion);
                }
            }
            m_canSpawnRings = false;
        }
            private void OnDamaged(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
            {
                PlayerController player = GameManager.Instance.PrimaryPlayer;
                bool             flag   = player.CurrentRoom != null;

                if (flag)
                {
                    player.CurrentRoom.PlayerHasTakenDamageInThisRoom = false;
                }
            }
Beispiel #17
0
 private void OnDamaged(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
 {
     this.BreakStealth(this.StoredPlayer);
 }
 private void OnDamaged(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
 {
     if ((m_attachedPlayer != null) && (m_attachedPlayer.CurrentGun != null) && (m_attachedPlayer.CurrentGun.CanActuallyBeDropped(m_attachedPlayer)))
     {
         if (CurseManager.CurseIsActive("Curse of Butterfingers"))
         {
             if (GameManager.Instance.AnyPlayerHasActiveSynergy("The Last Crusade"))
             {
                 StartCoroutine(GoodButterfingersEffect());
             }
             else
             {
                 StartCoroutine(ButterFingersGun());
             }
         }
     }
 }
Beispiel #19
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;
        }
Beispiel #20
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;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        private void TimeIsTicking(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
        {
            this.Countdown += 1f;
            bool flag = this.Countdown == 1f;

            if (flag)
            {
                string header = "";
                string text   = "";
                header = "The blood flows in...";
                text   = "The cogs start turning.";
                this.Notify(header, text);
                GameManager.Instance.StartCoroutine(TheCountdown());
            }
        }
        private void PlayerTookDamage(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
        {
            if (activeOutline == true)
            {
                GameManager.Instance.StartCoroutine(this.GainOutline());
            }

            else if (activeOutline == false)
            {
                GameManager.Instance.StartCoroutine(this.LoseOutline());
            }
        }
        public BossProjectile(World world, SpriteBatch batch, Vector2 position, Texture2D texture, short direction,
            Vector2 velocity, object owner, DamageCategory doesDamageTo, int amountOfDamage)
            : base(world, batch, position)
        {
            this.texture = texture;
            this.direction = direction;
            this.velocity = velocity;
            this.owner = owner;
            this.doesDamageTo = doesDamageTo;
            this.amountOfDamage = amountOfDamage;

            facing = SpriteEffects.None;

            if (direction == 1)
            {
                facing = SpriteEffects.FlipHorizontally;
            }

            this.World.AddWorldObject(this);
        }
Beispiel #24
0
 private void HandleDamaged(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
 {
     base.healthHaver.FullHeal();
 }
Beispiel #25
0
        private void OnDamaged(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
        {
            PlayerController owner = base.Owner;

            this.BreakStealth(owner);
        }
Beispiel #26
0
        public void ReceiveDamage(LivingObject attacker, DamageCategory cat, int damage)
        {
            this.HitPoints -= damage;

            if (this.HitPoints <= 0)
                Die();
        }
Beispiel #27
0
        public void HealthHaver_ApplyDamageHook(
            HealthHaver self, float damage, Vector2 direction, string sourceName, CoreDamageTypes damageTypes = CoreDamageTypes.None, DamageCategory damageCategory = DamageCategory.Normal,
            bool ignoreInvulnerabilityFrames = false, PixelCollider hitPixelCollider = null, bool ignoreDamageCaps = false)
        {//Killithid's ghosts spawn without correct hitboxes and crash game on hit, this method is a bandaid for that. Kills all enemies and projectiles in room
            try
            {
                self.orig_ApplyDamage(damage, direction, sourceName, damageTypes, damageCategory, ignoreInvulnerabilityFrames, hitPixelCollider, ignoreDamageCaps);
                if (0f < self.GetCurrentHealth() && 0f < damage && ETGModGUI.UseDamageIndicators)
                {
                    ETGDamageIndicatorGUI.HealthHaverTookDamage(self, damage);
                }
            }

            catch (Exception e)
            {
                Debug.Log("[Randomizer] HealthHaverHook Error" + e);
                RandomHandleEnemyInfo.DestroyEverything();
                throw;
            }
        }
Beispiel #28
0
 private void OnDamaged(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
 {
     this.BreakStealth(gun.CurrentOwner as PlayerController);
 }
        private void PlayerTookCrestDamage(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
        {
            PlayerController player    = this.Owner;
            float            curHealth = player.healthHaver.GetCurrentHealth();

            if (curHealth > 0.5f)
            {
                player.healthHaver.ForceSetCurrentHealth(curHealth - 0.5f);
                GameManager.Instance.StartCoroutine(this.Crestgain());
            }
            else
            {
                return;
            }
        }
Beispiel #30
0
        // Token: 0x060004F7 RID: 1271 RVA: 0x0002A6B8 File Offset: 0x000288B8
        private void PlayerTookDamage(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
        {
            bool flag = this.activeOutline;

            if (flag)
            {
                GameManager.Instance.StartCoroutine(this.GainOutline());
            }
            else
            {
                bool flag2 = !this.activeOutline;
                if (flag2)
                {
                    GameManager.Instance.StartCoroutine(this.LoseOutline());
                }
            }
        }
        private void RobotTookDamage(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
        {
            PlayerController player   = this.Owner;
            float            curArmor = player.healthHaver.Armor;

            if (curArmor > 1f)
            {
            }
        }
 private void charmAll(float healthRemaining, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
 {
     if (damageTypes != CoreDamageTypes.Void)
     {
     }
 }
        private void RobotTookCrestDamage(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
        {
            PlayerController player   = this.Owner;
            float            curArmor = player.healthHaver.Armor;

            GameManager.Instance.StartCoroutine(this.RobotCrestgain());
        }
        private void oof(float resultValue, float maxValue, CoreDamageTypes damageTypes, DamageCategory damageCategory, Vector2 damageDirection)
        {
            bool flag3 = this.m_owner.CurrentRoom != null;

            if (flag3)
            {
                AkSoundEngine.PostEvent("Play_ENM_kali_burst_01", base.gameObject);
                this.m_owner.CurrentRoom.ApplyActionToNearbyEnemies(this.m_owner.CenterPosition, 20f, new Action <AIActor, float>(this.ProcessEnemy));
            }
        }
Beispiel #35
0
            protected override HandleDamageResult HandleDamage(SpeculativeRigidbody rigidbody, PixelCollider hitPixelCollider, out bool killedTarget, PlayerController player, bool alreadyPlayerDelayed = false)
            {
                killedTarget = false;
                if (rigidbody.ReflectProjectiles)
                {
                    return(Projectile.HandleDamageResult.NO_HEALTH);
                }
                if (!rigidbody.healthHaver)
                {
                    return(Projectile.HandleDamageResult.NO_HEALTH);
                }
                if (!alreadyPlayerDelayed && Projectile.s_delayPlayerDamage && player)
                {
                    return(Projectile.HandleDamageResult.HEALTH);
                }
                if (rigidbody.spriteAnimator != null && rigidbody.spriteAnimator.QueryInvulnerabilityFrame())
                {
                    return(Projectile.HandleDamageResult.HEALTH);
                }
                bool  flag = !rigidbody.healthHaver.IsDead;
                float num  = this.ModifiedDamage;

                if (this.Owner is AIActor && rigidbody && rigidbody.aiActor && (this.Owner as AIActor).IsNormalEnemy)
                {
                    num = ProjectileData.FixedFallbackDamageToEnemies;
                    if (rigidbody.aiActor.HitByEnemyBullets)
                    {
                        num /= 4f;
                    }
                }
                FieldInfo info = typeof(Projectile).GetField("m_healthHaverHitCount", BindingFlags.NonPublic | BindingFlags.Instance);
                int       m_healthHaverHitCount = (int)info.GetValue(this as Projectile);

                if (this.Owner is PlayerController && this.m_hasPierced && m_healthHaverHitCount >= 1)
                {
                    int num2 = Mathf.Clamp(m_healthHaverHitCount - 1, 0, GameManager.Instance.PierceDamageScaling.Length - 1);
                    num *= GameManager.Instance.PierceDamageScaling[num2];
                }
                if (this.OnWillKillEnemy != null && num >= rigidbody.healthHaver.GetCurrentHealth())
                {
                    this.OnWillKillEnemy(this, rigidbody);
                }
                if (rigidbody.healthHaver.IsBoss)
                {
                    num *= this.BossDamageMultiplier;
                }
                if (this.BlackPhantomDamageMultiplier != 1f && rigidbody.aiActor && rigidbody.aiActor.IsBlackPhantom)
                {
                    num *= this.BlackPhantomDamageMultiplier;
                }
                bool flag2 = false;

                if (this.DelayedDamageToExploders)
                {
                    flag2 = (rigidbody.GetComponent <ExplodeOnDeath>() && rigidbody.healthHaver.GetCurrentHealth() <= num);
                }
                if (!flag2)
                {
                    HealthHaver     healthHaver     = rigidbody.healthHaver;
                    float           damage          = num;
                    Vector2         velocity        = base.specRigidbody.Velocity;
                    CoreDamageTypes coreDamageTypes = this.damageTypes;
                    DamageCategory  damageCategory  = (!this.IsBlackBullet) ? DamageCategory.Normal : DamageCategory.BlackBullet;
                    if (healthHaver.IsBoss)
                    {
                        damage *= (base.Owner as PlayerController).stats.GetStatValue(PlayerStats.StatType.DamageToBosses);
                    }
                    healthHaver.ApplyDamage(damage, velocity, "Soul Orb Projectile", coreDamageTypes, damageCategory, false, hitPixelCollider, this.ignoreDamageCaps);
                    if (player && player.OnHitByProjectile != null)
                    {
                        player.OnHitByProjectile(this, player);
                    }
                }
                else
                {
                    rigidbody.StartCoroutine(this.HandleDelayedDamage(rigidbody, num, base.specRigidbody.Velocity, hitPixelCollider));
                }
                if (this.Owner && this.Owner is AIActor && player)
                {
                    (this.Owner as AIActor).HasDamagedPlayer = true;
                }
                killedTarget = (flag && rigidbody.healthHaver.IsDead);
                if (!killedTarget && rigidbody.gameActor != null)
                {
                    if (this.AppliesPoison && UnityEngine.Random.value < this.PoisonApplyChance)
                    {
                        rigidbody.gameActor.ApplyEffect(this.healthEffect, 1f, null);
                    }
                    if (this.AppliesSpeedModifier && UnityEngine.Random.value < this.SpeedApplyChance)
                    {
                        rigidbody.gameActor.ApplyEffect(this.speedEffect, 1f, null);
                    }
                    if (this.AppliesCharm && UnityEngine.Random.value < this.CharmApplyChance)
                    {
                        rigidbody.gameActor.ApplyEffect(this.charmEffect, 1f, null);
                    }
                    if (this.AppliesFreeze && UnityEngine.Random.value < this.FreezeApplyChance)
                    {
                        rigidbody.gameActor.ApplyEffect(this.freezeEffect, 1f, null);
                    }
                    if (this.AppliesCheese && UnityEngine.Random.value < this.CheeseApplyChance)
                    {
                        rigidbody.gameActor.ApplyEffect(this.cheeseEffect, 1f, null);
                    }
                    if (this.AppliesBleed && UnityEngine.Random.value < this.BleedApplyChance)
                    {
                        rigidbody.gameActor.ApplyEffect(this.bleedEffect, -1f, this);
                    }
                    if (this.AppliesFire && UnityEngine.Random.value < this.FireApplyChance)
                    {
                        rigidbody.gameActor.ApplyEffect(this.fireEffect, 1f, null);
                    }
                    if (this.AppliesStun && UnityEngine.Random.value < this.StunApplyChance && rigidbody.gameActor.behaviorSpeculator)
                    {
                        rigidbody.gameActor.behaviorSpeculator.Stun(this.AppliedStunDuration, true);
                    }
                    for (int i = 0; i < this.statusEffectsToApply.Count; i++)
                    {
                        rigidbody.gameActor.ApplyEffect(this.statusEffectsToApply[i], 1f, null);
                    }
                }
                m_healthHaverHitCount++;
                info.SetValue(this as Projectile, m_healthHaverHitCount);
                return((!killedTarget) ? Projectile.HandleDamageResult.HEALTH : Projectile.HandleDamageResult.HEALTH_AND_KILLED);
            }