예제 #1
0
        private static void DealDamageToEnemiesInArc(PlayerController owner, Vector2 arcOrigin, float arcAngle, float arcRadius, float overrideDamage, float overrideForce, List <GameActorEffect> statusEffects, float jammedDMGMult, float bossDMGMult, float slashDimensions, List <SpeculativeRigidbody> alreadyHit = null)
        {
            RoomHandler roomHandler = owner.CurrentRoom;

            if (roomHandler == null)
            {
                return;
            }
            List <AIActor> activeEnemies = roomHandler.GetActiveEnemies(RoomHandler.ActiveEnemyType.All);

            if (activeEnemies == null)
            {
                return;
            }

            for (int i = 0; i < activeEnemies.Count; i++)
            {
                AIActor aiactor = activeEnemies[i];
                if (aiactor && aiactor.specRigidbody && aiactor.IsNormalEnemy && !aiactor.IsGone && aiactor.healthHaver)
                {
                    if (alreadyHit == null || !alreadyHit.Contains(aiactor.specRigidbody))
                    {
                        for (int j = 0; j < aiactor.healthHaver.NumBodyRigidbodies; j++)
                        {
                            SpeculativeRigidbody bodyRigidbody       = aiactor.healthHaver.GetBodyRigidbody(j);
                            PixelCollider        hitboxPixelCollider = bodyRigidbody.HitboxPixelCollider;
                            if (hitboxPixelCollider != null)
                            {
                                Vector2 vector = BraveMathCollege.ClosestPointOnRectangle(arcOrigin, hitboxPixelCollider.UnitBottomLeft, hitboxPixelCollider.UnitDimensions);
                                float   num    = Vector2.Distance(vector, arcOrigin);
                                if (ObjectWasHitBySlash(vector, arcOrigin, arcAngle, arcRadius, slashDimensions))
                                {
                                    bool          flag    = true;
                                    int           rayMask = CollisionMask.LayerToMask(CollisionLayer.HighObstacle, CollisionLayer.BulletBlocker, CollisionLayer.BulletBreakable);
                                    RaycastResult raycastResult;
                                    if (PhysicsEngine.Instance.Raycast(arcOrigin, vector - arcOrigin, num, out raycastResult, true, true, rayMask, null, false, null, null) && raycastResult.SpeculativeRigidbody != bodyRigidbody)
                                    {
                                        flag = false;
                                    }
                                    RaycastResult.Pool.Free(ref raycastResult);
                                    if (flag)
                                    {
                                        float damage = DealSwordDamageToEnemy(owner, aiactor, arcOrigin, vector, arcAngle, overrideDamage, overrideForce, statusEffects, bossDMGMult, jammedDMGMult);
                                        if (alreadyHit != null)
                                        {
                                            if (alreadyHit.Count == 0)
                                            {
                                                StickyFrictionManager.Instance.RegisterSwordDamageStickyFriction(damage);
                                            }
                                            alreadyHit.Add(aiactor.specRigidbody);
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        public float GetDistanceToPoint(Vector2 point)
        {
            if (base.sprite == null)
            {
                return(100f);
            }
            Vector3 v = BraveMathCollege.ClosestPointOnRectangle(point, base.specRigidbody.UnitBottomLeft, base.specRigidbody.UnitDimensions);

            return(Vector2.Distance(point, v) / 1.5f);
        }
        public static Vector2 ClosestPointOnRigidBody(this SpeculativeRigidbody target, Vector2 pointComparison)
        {
            Vector2 closestPointOnTarget = Vector2.zero;

            if (target != null && target.HitboxPixelCollider != null)
            {
                closestPointOnTarget = BraveMathCollege.ClosestPointOnRectangle(pointComparison, target.HitboxPixelCollider.UnitBottomLeft, target.HitboxPixelCollider.UnitDimensions);
            }
            return(closestPointOnTarget);
        }
예제 #4
0
        // Token: 0x0600006F RID: 111 RVA: 0x00005748 File Offset: 0x00003948
        public float GetDistanceToPoint(Vector2 point)
        {
            bool  flag = base.sprite == null;
            float result;

            if (flag)
            {
                result = 100f;
            }
            else
            {
                Vector3 v = BraveMathCollege.ClosestPointOnRectangle(point, base.specRigidbody.UnitBottomLeft, base.specRigidbody.UnitDimensions);
                result = Vector2.Distance(point, v) / 1.5f;
            }
            return(result);
        }
예제 #5
0
        public static void DoRadialIgnite(GameActorFireEffect fire, Vector3 position, float radius, VFXPool hitVFX = null)
        {
            List <HealthHaver> allHealthHavers = StaticReferenceManager.AllHealthHavers;

            if (allHealthHavers != null)
            {
                float num = radius * radius;
                for (int i = 0; i < allHealthHavers.Count; i++)
                {
                    HealthHaver healthHaver = allHealthHavers[i];
                    if (healthHaver)
                    {
                        if (healthHaver.gameObject.activeSelf)
                        {
                            if (healthHaver.aiActor)
                            {
                                AIActor aiActor = healthHaver.aiActor;
                                if (!aiActor.IsGone)
                                {
                                    if (aiActor.isActiveAndEnabled)
                                    {
                                        if ((aiActor.CenterPosition - position.XY()).sqrMagnitude <= num)
                                        {
                                            aiActor.ApplyEffect(fire, 1f, null);
                                            if (hitVFX != null)
                                            {
                                                if (aiActor.specRigidbody.HitboxPixelCollider != null)
                                                {
                                                    PixelCollider pixelCollider = aiActor.specRigidbody.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(aiActor.CenterPosition, 0f, null, null, null, null, false, null, null, false);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #6
0
 public static void BetterDoToEnemiesInRadius(this RoomHandler room, Vector2 position, float radius, Action <AIActor> action)
 {
     foreach (AIActor actor in room.GetActiveEnemies(RoomHandler.ActiveEnemyType.All))
     {
         if (actor && actor.healthHaver && actor.specRigidbody && actor.IsNormalEnemy)
         {
             PixelCollider hitboxPixelCollider = actor.specRigidbody.HitboxPixelCollider;
             if (hitboxPixelCollider != null)
             {
                 Vector2 vector = BraveMathCollege.ClosestPointOnRectangle(position, hitboxPixelCollider.UnitBottomLeft, hitboxPixelCollider.UnitDimensions);
                 float   num    = Vector2.Distance(actor.specRigidbody.UnitCenter, position);
                 float   num2   = Vector2.Distance(vector, actor.specRigidbody.UnitCenter);
                 if (num < num2 + radius)
                 {
                     action(actor);
                 }
             }
         }
     }
 }
예제 #7
0
 public override void Update()
 {
     if (Owner && !Dungeon.IsGenerating && Owner.IsInCombat && base.transform.position.GetAbsoluteRoom() == Owner.CurrentRoom)
     {
         if (attackTimer > 0)
         {
             attackTimer -= BraveTime.DeltaTime;
         }
         else
         {
             if (base.aiActor.OverrideTarget != null && !isAttacking)
             {
                 Vector2 closestPointOnTarget = BraveMathCollege.ClosestPointOnRectangle(base.sprite.WorldCenter, base.aiActor.OverrideTarget.HitboxPixelCollider.UnitBottomLeft, base.aiActor.OverrideTarget.HitboxPixelCollider.UnitDimensions);
                 if (Vector2.Distance(base.sprite.WorldCenter, closestPointOnTarget) < 5)
                 {
                     StartCoroutine(Attack());
                 }
             }
         }
     }
 }
        private static void DealDamageToEnemiesInArc(GameActor owner, Vector2 arcOrigin, float arcAngle, float arcRadius, SlashData slashParameters, List <SpeculativeRigidbody> alreadyHit = null)
        {
            RoomHandler roomHandler = arcOrigin.GetAbsoluteRoom();

            if (roomHandler == null)
            {
                return;
            }
            if (SlasherIsPlayerOrFriendly(owner))
            {
                List <AIActor> activeEnemies = roomHandler.GetActiveEnemies(RoomHandler.ActiveEnemyType.All);
                if (activeEnemies == null)
                {
                    return;
                }

                for (int i = 0; i < activeEnemies.Count; i++)
                {
                    AIActor aiactor = activeEnemies[i];
                    if (aiactor && aiactor.specRigidbody && aiactor.IsNormalEnemy && !aiactor.IsGone && aiactor.healthHaver)
                    {
                        if (alreadyHit == null || !alreadyHit.Contains(aiactor.specRigidbody))
                        {
                            for (int j = 0; j < aiactor.healthHaver.NumBodyRigidbodies; j++)
                            {
                                SpeculativeRigidbody bodyRigidbody       = aiactor.healthHaver.GetBodyRigidbody(j);
                                PixelCollider        hitboxPixelCollider = bodyRigidbody.HitboxPixelCollider;
                                if (hitboxPixelCollider != null)
                                {
                                    Vector2 vector = BraveMathCollege.ClosestPointOnRectangle(arcOrigin, hitboxPixelCollider.UnitBottomLeft, hitboxPixelCollider.UnitDimensions);
                                    if (ObjectWasHitBySlash(vector, arcOrigin, arcAngle, arcRadius, 90))
                                    {
                                        bool          attackIsNotBlocked = true;
                                        int           rayMask            = CollisionMask.LayerToMask(CollisionLayer.HighObstacle, CollisionLayer.BulletBlocker, CollisionLayer.BulletBreakable);
                                        RaycastResult raycastResult;
                                        if (PhysicsEngine.Instance.Raycast(arcOrigin, vector - arcOrigin, Vector2.Distance(vector, arcOrigin), out raycastResult, true, true, rayMask, null, false, null, null) && raycastResult.SpeculativeRigidbody != bodyRigidbody)
                                        {
                                            attackIsNotBlocked = false;
                                        }
                                        RaycastResult.Pool.Free(ref raycastResult);
                                        if (attackIsNotBlocked)
                                        {
                                            float damage = DealSwordDamageToEnemy(owner, aiactor, arcOrigin, vector, arcAngle, slashParameters);
                                            if (alreadyHit != null)
                                            {
                                                if (alreadyHit.Count == 0)
                                                {
                                                    StickyFrictionManager.Instance.RegisterSwordDamageStickyFriction(damage);
                                                }
                                                alreadyHit.Add(aiactor.specRigidbody);
                                            }
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                List <PlayerController> AllPlayers = new List <PlayerController>();
                if (GameManager.Instance.PrimaryPlayer)
                {
                    AllPlayers.Add(GameManager.Instance.PrimaryPlayer);
                }
                if (GameManager.Instance.SecondaryPlayer)
                {
                    AllPlayers.Add(GameManager.Instance.SecondaryPlayer);
                }
                for (int i = 0; i < AllPlayers.Count; i++)
                {
                    PlayerController player = AllPlayers[i];
                    if (player && player.specRigidbody && player.healthHaver && !player.IsGhost)
                    {
                        if (alreadyHit == null || !alreadyHit.Contains(player.specRigidbody))
                        {
                            SpeculativeRigidbody bodyRigidbody       = player.specRigidbody;
                            PixelCollider        hitboxPixelCollider = bodyRigidbody.HitboxPixelCollider;
                            if (hitboxPixelCollider != null)
                            {
                                Vector2 vector = BraveMathCollege.ClosestPointOnRectangle(arcOrigin, hitboxPixelCollider.UnitBottomLeft, hitboxPixelCollider.UnitDimensions);
                                if (ObjectWasHitBySlash(vector, arcOrigin, arcAngle, arcRadius, 90))
                                {
                                    bool          attackIsNotBlocked = true;
                                    int           rayMask            = CollisionMask.LayerToMask(CollisionLayer.HighObstacle, CollisionLayer.BulletBlocker, CollisionLayer.BulletBreakable);
                                    RaycastResult raycastResult;
                                    if (PhysicsEngine.Instance.Raycast(arcOrigin, vector - arcOrigin, Vector2.Distance(vector, arcOrigin), out raycastResult, true, true, rayMask, null, false, null, null) && raycastResult.SpeculativeRigidbody != bodyRigidbody)
                                    {
                                        attackIsNotBlocked = false;
                                    }
                                    RaycastResult.Pool.Free(ref raycastResult);
                                    if (attackIsNotBlocked)
                                    {
                                        float damage = DealSwordDamageToEnemy(owner, player, arcOrigin, vector, arcAngle, slashParameters);
                                        if (alreadyHit != null)
                                        {
                                            if (alreadyHit.Count == 0)
                                            {
                                                StickyFrictionManager.Instance.RegisterSwordDamageStickyFriction(damage);
                                            }
                                            alreadyHit.Add(player.specRigidbody);
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
예제 #9
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;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }