コード例 #1
0
        public static bool IsHeartInRoom(Action <CaterpillarDevourHeartBehavior> orig, CaterpillarDevourHeartBehavior self)
        {
            AIActor          m_aiActor      = (AIActor)typeof(CaterpillarDevourHeartBehavior).GetField("m_aiActor", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(self);
            PlayerController companionOwner = m_aiActor.CompanionOwner;

            if (!companionOwner || companionOwner.CurrentRoom == null)
            {
                return(false);
            }
            List <HealthPickup> componentsAbsoluteInRoom = companionOwner.CurrentRoom.GetComponentsAbsoluteInRoom <HealthPickup>();

            for (int i = 0; i < componentsAbsoluteInRoom.Count; i++)
            {
                HealthPickup healthPickup = componentsAbsoluteInRoom[i];
                if (healthPickup)
                {
                    if (healthPickup.armorAmount != 0)
                    {
                        componentsAbsoluteInRoom.RemoveAt(i);
                        i--;
                    }
                }
            }
            HealthPickup closestToPosition = BraveUtility.GetClosestToPosition <HealthPickup>(componentsAbsoluteInRoom, m_aiActor.CenterPosition, new HealthPickup[0]);

            if (closestToPosition != null)
            {
                typeof(CaterpillarDevourHeartBehavior).GetField("m_targetHeart", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(self, closestToPosition);
                return(true);
            }
            return(false);
        }
        public static Vector2 GetVectorToNearestEnemy(this Vector3 bulletPos, float angleFromAim = 0, float angleVariance = 0, PlayerController playerToScaleAccuracyOff = null)
        {
            Vector2 dirVec               = UnityEngine.Random.insideUnitCircle;
            Vector2 bulletPosition       = bulletPos;
            Func <AIActor, bool> isValid = (AIActor a) => a && a.HasBeenEngaged && a.healthHaver && a.healthHaver.IsVulnerable;
            IntVector2           bulletPositionIntVector2 = bulletPosition.ToIntVector2();
            AIActor closestToPosition = BraveUtility.GetClosestToPosition <AIActor>(GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(bulletPositionIntVector2).GetActiveEnemies(RoomHandler.ActiveEnemyType.All), bulletPosition, isValid, new AIActor[]
            {
            });

            if (closestToPosition)
            {
                dirVec = closestToPosition.CenterPosition - bulletPosition;
            }
            if (angleFromAim != 0)
            {
                dirVec = dirVec.Rotate(angleFromAim);
            }
            if (angleVariance != 0)
            {
                if (playerToScaleAccuracyOff != null)
                {
                    angleVariance *= playerToScaleAccuracyOff.stats.GetStatValue(PlayerStats.StatType.Accuracy);
                }
                float positiveVariance = angleVariance * 0.5f;
                float negativeVariance = positiveVariance * -1f;
                float finalVariance    = UnityEngine.Random.Range(negativeVariance, positiveVariance);
                dirVec = dirVec.Rotate(finalVariance);
            }
            return(dirVec);
        }
        public static Vector2 GetPositionOfNearestEnemy(this Vector2 startPosition, bool canTargetNonRoomClear, bool targetSprite = false, List <AIActor> excludedActors = null)
        {
            List <AIActor> exclude = new List <AIActor>();

            if (excludedActors != null && excludedActors.Count > 0)
            {
                exclude.AddRange(excludedActors);
            }
            Func <AIActor, bool> isValid           = (AIActor a) => a && a.HasBeenEngaged && a.healthHaver && a.healthHaver.IsVulnerable && a.healthHaver.IsAlive && !a.IsGone && !exclude.Contains(a) && a.IsWorthShootingAt && a.isActiveAndEnabled && a.CanTargetPlayers && a.GetComponent <CompanionController>() == null;
            IntVector2           intVectorStartPos = startPosition.ToIntVector2();

            RoomHandler.ActiveEnemyType enemyType = RoomHandler.ActiveEnemyType.RoomClear;
            if (canTargetNonRoomClear)
            {
                enemyType = RoomHandler.ActiveEnemyType.All;
            }
            AIActor closestToPosition = BraveUtility.GetClosestToPosition <AIActor>(GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(intVectorStartPos).GetActiveEnemies(enemyType), startPosition, isValid, new AIActor[] { });

            if (closestToPosition == null)
            {
                return(Vector2.zero);
            }
            if (targetSprite && closestToPosition.sprite)
            {
                return(closestToPosition.sprite.WorldCenter);
            }
            else
            {
                return(closestToPosition.specRigidbody.UnitCenter);
            }
        }
コード例 #4
0
        private void HitEnemy(Projectile projectile, SpeculativeRigidbody enemy, bool killed)
        {
            projectile.Speed           *= 1.2f;
            projectile.baseData.damage *= .8f;

            PierceProjModifier orAddComponent = projectile.gameObject.GetOrAddComponent <PierceProjModifier>();

            orAddComponent.penetratesBreakables = true;
            orAddComponent.penetration++;
            Vector2 dirVec = UnityEngine.Random.insideUnitCircle;
            float   num    = this.ChanceToSeekEnemyOnBounce;

            if (UnityEngine.Random.value < num && enemy.aiActor)
            {
                Func <AIActor, bool> isValid = (AIActor a) => a && a.HasBeenEngaged && a.healthHaver && a.healthHaver.IsVulnerable;
                AIActor closestToPosition    = BraveUtility.GetClosestToPosition <AIActor>(enemy.aiActor.ParentRoom.GetActiveEnemies(RoomHandler.ActiveEnemyType.All), enemy.UnitCenter, isValid, new AIActor[]
                {
                    enemy.aiActor
                });
                if (closestToPosition)
                {
                    dirVec = closestToPosition.CenterPosition - projectile.transform.position.XY();
                }
            }
            projectile.SendInDirection(dirVec, false, true);
        }
コード例 #5
0
 public override void OnReloadPressed(PlayerController player, Gun gun, bool bSOMETHING)
 {
     if (ActiveBullets.Count > 0)
     {
         foreach (Projectile bullet in ActiveBullets)
         {
             if (bullet)
             {
                 Vector2 dirVec               = UnityEngine.Random.insideUnitCircle;
                 Vector2 bulletPosition       = bullet.sprite.WorldCenter;
                 Func <AIActor, bool> isValid = (AIActor a) => a && a.HasBeenEngaged && a.healthHaver && a.healthHaver.IsVulnerable;
                 IntVector2           bulletPositionIntVector2 = bulletPosition.ToIntVector2();
                 AIActor closestToPosition = BraveUtility.GetClosestToPosition <AIActor>(GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(bulletPositionIntVector2).GetActiveEnemies(RoomHandler.ActiveEnemyType.All), bullet.sprite.WorldCenter, isValid, new AIActor[]
                 {
                 });
                 if (closestToPosition)
                 {
                     dirVec = closestToPosition.CenterPosition - bullet.transform.position.XY();
                 }
                 bullet.SendInDirection(dirVec, false, true);
                 if (!player.PlayerHasActiveSynergy("Pistols Requiem"))
                 {
                     BulletsToRemoveFromActiveBullets.Add(bullet);
                 }
             }
         }
         foreach (Projectile bullet in BulletsToRemoveFromActiveBullets)
         {
             ActiveBullets.Remove(bullet);
         }
         BulletsToRemoveFromActiveBullets.Clear();
     }
     base.OnReloadPressed(player, gun, bSOMETHING);
 }
コード例 #6
0
 public override void OnEffectApplied(GameActor actor, RuntimeGameActorEffectData effectData, float partialAmount = 1)
 {
     base.OnEffectApplied(actor, effectData, partialAmount);
     effectData.OnActorPreDeath = delegate(Vector2 dir)
     {
         if (actor is AIActor)
         {
             AIActor aiActor = actor as AIActor;
             if (aiActor.GetAbsoluteParentRoom() == GameManager.Instance.GetActivePlayerClosestToPoint(actor.CenterPosition).CurrentRoom&& !aiActor.IgnoreForRoomClear && !noNoGUIDs.Contains(aiActor.EnemyGuid))
             {
                 Vector2    dirVec     = UnityEngine.Random.insideUnitCircle;
                 GameObject gameObject = SpawnManager.SpawnProjectile(((Gun)ETGMod.Databases.Items[39]).DefaultModule.projectiles[0].gameObject, actor.CenterPosition, Quaternion.Euler(0, 0, 0));
                 Projectile proj       = gameObject.GetComponent <Projectile>();
                 if (proj != null)
                 {
                     proj.Owner               = actor;
                     proj.Shooter             = aiActor.specRigidbody;
                     proj.collidesWithEnemies = false;
                     proj.collidesWithPlayer  = true;
                     proj.MakeLookLikeEnemyBullet(true);
                     proj.gameObject.AddComponent <PierceDeadActors>();
                     PlayerController closestToPos = BraveUtility.GetClosestToPosition <PlayerController>(GameManager.Instance.AllPlayers.ToList(), aiActor.CenterPosition);
                     if (closestToPos)
                     {
                         dirVec = closestToPos.CenterPosition - proj.transform.position.XY();
                     }
                     proj.SendInDirection(dirVec, false, true);
                 }
             }
         }
     };
     actor.healthHaver.OnPreDeath += effectData.OnActorPreDeath;
 }
コード例 #7
0
            private BeamController DoTongueFlick(Projectile proj)
            {
                Func <AIActor, bool> isValid = (AIActor a) => a && a.HasBeenEngaged && a.healthHaver && a.healthHaver.IsVulnerable;
                AIActor closestToPosition    = BraveUtility.GetClosestToPosition <AIActor>(m_projectile.Owner.GetAbsoluteParentRoom().GetActiveEnemies(RoomHandler.ActiveEnemyType.All), m_projectile.sprite.WorldCenter, isValid, affectedEnemies.ToArray());

                this.affectedEnemies.Add(closestToPosition);
                BeamController tongue = Stuff.FreeFireBeamFromAnywhere((PickupObjectDatabase.GetById(759) as Gun).DefaultModule.projectiles[0], m_projectile.Owner as PlayerController, m_projectile.gameObject, Vector2.zero, false, (closestToPosition.specRigidbody.UnitCenter - m_projectile.sprite.WorldCenter).ToAngle(), m_beamDuration);

                tongue.projectile.baseData.damage *= 0.5f;
                return(tongue);
            }
コード例 #8
0
        private bool IsJunkInATrapRoom()
        {
            PlayerController companionOwner = m_aiActor.CompanionOwner;

            if (m_aiActor.GetAbsoluteParentRoom() == null)
            {
                return(false);
            }
            if (!companionOwner || companionOwner.CurrentRoom == null)
            {
                return(false);
            }
            if (companionOwner.CurrentRoom.area.PrototypeRoomNormalSubcategory != PrototypeDungeonRoom.RoomNormalSubCategory.TRAP)
            {
                return(false);
            }
            // if (ExcludedRooms.Contains(companionOwner.CurrentRoom.GetRoomName().ToLower())) { return false; }
            if (companionOwner.CurrentRoom != m_aiActor.GetAbsoluteParentRoom())
            {
                return(false);
            }
            List <DebrisObject> componentsAbsoluteInRoom = companionOwner.CurrentRoom.GetComponentsAbsoluteInRoom <DebrisObject>();

            if (componentsAbsoluteInRoom == null | componentsAbsoluteInRoom.Count == 0)
            {
                return(false);
            }
            for (int i = 0; i < componentsAbsoluteInRoom.Count; i++)
            {
                PickupObject JunkPickup = componentsAbsoluteInRoom[i].GetComponentInChildren <PickupObject>();
                if (JunkPickup)
                {
                    if (JunkPickup.PickupObjectId != 127 && JunkPickup.PickupObjectId != 148 &&
                        JunkPickup.PickupObjectId != 580 && JunkPickup.PickupObjectId != 641)
                    {
                        componentsAbsoluteInRoom.RemoveAt(i); i--;
                    }
                }
                else
                {
                    componentsAbsoluteInRoom.RemoveAt(i); i--;
                }
            }
            DebrisObject closestToPosition = BraveUtility.GetClosestToPosition(componentsAbsoluteInRoom, m_aiActor.CenterPosition, new DebrisObject[0]);

            if (closestToPosition != null)
            {
                m_targetJunk = closestToPosition; return(true);
            }
            return(false);
        }
コード例 #9
0
        public static Vector2 GetVectorToNearestEnemy(this Projectile bullet, bool checkIsWorthShooting = true)
        {
            Vector2 dirVec               = UnityEngine.Random.insideUnitCircle;
            Vector2 bulletPosition       = bullet.sprite.WorldCenter;
            Func <AIActor, bool> isValid = (AIActor a) => a && a.HasBeenEngaged && a.healthHaver && a.healthHaver.IsVulnerable && a.healthHaver.IsAlive && ((checkIsWorthShooting && a.IsWorthShootingAt) || !checkIsWorthShooting);
            IntVector2           bulletPositionIntVector2 = bulletPosition.ToIntVector2();
            AIActor closestToPosition = BraveUtility.GetClosestToPosition <AIActor>(GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(bulletPositionIntVector2).GetActiveEnemies(RoomHandler.ActiveEnemyType.All), bullet.sprite.WorldCenter, isValid, new AIActor[] { });

            if (closestToPosition)
            {
                dirVec = closestToPosition.CenterPosition - bullet.transform.position.XY();
            }
            return(dirVec);
        }
コード例 #10
0
        public static float GetDegreeToNearestEnemy(this Projectile bullet)
        {
            Vector2 dirVec               = UnityEngine.Random.insideUnitCircle;
            Vector2 bulletPosition       = bullet.sprite.WorldCenter;
            Func <AIActor, bool> isValid = (AIActor a) => a && a.HasBeenEngaged && a.healthHaver && a.healthHaver.IsVulnerable;
            IntVector2           bulletPositionIntVector2 = bulletPosition.ToIntVector2();
            AIActor closestToPosition = BraveUtility.GetClosestToPosition <AIActor>(GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(bulletPositionIntVector2).GetActiveEnemies(RoomHandler.ActiveEnemyType.All), bullet.sprite.WorldCenter, isValid, new AIActor[]
            {
            });

            if (closestToPosition)
            {
                dirVec = closestToPosition.CenterPosition - bullet.transform.position.XY();
            }
            return(MiscToolbox.Vector2ToDegree(dirVec));
        }
        public static AIActor GetNearestEnemyToPosition(this Vector2 position, bool checkIsWorthShootingAt = true, RoomHandler.ActiveEnemyType type = RoomHandler.ActiveEnemyType.RoomClear, Func <AIActor, bool> overrideValidityCheck = null)
        {
            Func <AIActor, bool> isValid = (AIActor a) => a && a.HasBeenEngaged && a.healthHaver && a.healthHaver.IsVulnerable && a.healthHaver.IsAlive && ((checkIsWorthShootingAt && a.IsWorthShootingAt) || !checkIsWorthShootingAt);

            if (overrideValidityCheck != null)
            {
                isValid = overrideValidityCheck;
            }
            AIActor closestToPosition = BraveUtility.GetClosestToPosition <AIActor>(GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(position.ToIntVector2()).GetActiveEnemies(type), position, isValid, new AIActor[] { });

            if (closestToPosition)
            {
                return(closestToPosition);
            }
            else
            {
                return(null);
            }
        }
コード例 #12
0
ファイル: D6.cs プロジェクト: UnstableStrafe/CelsItems
 private void FindItem(PlayerController user)
 {
     pickupsInRoom.Clear();
     DebrisObject[] shitOnGround = FindObjectsOfType <DebrisObject>();
     foreach (DebrisObject debris in shitOnGround)
     {
         bool isValid = DetermineIfValid(debris);
         if (isValid && debris.transform.position.GetAbsoluteRoom() == user.CurrentRoom)
         {
             pickupsInRoom.Add(debris);
         }
     }
     if (pickupsInRoom.Any())
     {
         DebrisObject target = BraveUtility.GetClosestToPosition(pickupsInRoom, user.CenterPosition);
         if (target)
         {
             RerollItem(target);
         }
     }
     else
     {
         Gun[] gunsonground = FindObjectsOfType <Gun>();
         foreach (Gun gunDebris in gunsonground)
         {
             PickupObject itemness = gunDebris.gameObject.GetComponent <PickupObject>();
             if ((itemness != null) && gunDebris.CurrentOwner == null && gunDebris.gameObject.transform.position != Vector3.zero)
             {
                 gunsInRoom.Add(gunDebris);
             }
         }
         if (gunsInRoom.Any())
         {
             Gun targetGun = BraveUtility.GetClosestToPosition(gunsInRoom, user.CenterPosition);
             if (targetGun)
             {
                 RerollGun(targetGun);
             }
         }
     }
 }
コード例 #13
0
        private void Update()
        {
            bool flag = this.m_projectile == null;

            if (flag)
            {
                this.m_projectile = base.GetComponent <Projectile>();
            }
            bool flag2 = this.speculativeRigidBoy == null;

            if (flag2)
            {
                this.speculativeRigidBoy = base.GetComponent <SpeculativeRigidbody>();
            }
            this.elapsed += BraveTime.DeltaTime;
            bool flag3 = this.elapsed > 0.15f;

            if (player.HasPickupID(529) || player.HasPickupID(135) && player.HasPickupID(ETGMod.Databases.Items["Assault Fleet"].PickupObjectId))
            {
                flag3 = this.elapsed > .10f;
            }
            if (flag3)
            {
                Vector2 dirVec = UnityEngine.Random.insideUnitCircle;

                Func <AIActor, bool> isValid = (AIActor a) => a && a.HasBeenEngaged && a.healthHaver && a.healthHaver.IsVulnerable;
                AIActor closestToPosition    = BraveUtility.GetClosestToPosition <AIActor>(player.CurrentRoom.GetActiveEnemies(RoomHandler.ActiveEnemyType.All), m_projectile.sprite.WorldCenter, isValid);
                if (closestToPosition)
                {
                    this.spawnAngle = Vector2.Angle(m_projectile.sprite.WorldCenter, closestToPosition.sprite.WorldCenter);
                }

                this.SpawnProjectile(this.projectileToSpawn, this.m_projectile.sprite.WorldCenter, this.m_projectile.transform.eulerAngles.z + this.spawnAngle, null);
                this.elapsed = 0f;
            }
        }
        public static Vector2 GetVectorToNearestEnemy(this Vector2 bulletPosition, float angleFromAim = 0, float angleVariance = 0, PlayerController playerToScaleAccuracyOff = null, List <AIActor> excludedActors = null)
        {
            List <AIActor> exclude = new List <AIActor>();

            if (excludedActors != null && excludedActors.Count > 0)
            {
                exclude.AddRange(excludedActors);
            }
            Vector2 dirVec = UnityEngine.Random.insideUnitCircle;
            Func <AIActor, bool> isValid = (AIActor a) => a && a.HasBeenEngaged && a.healthHaver && a.healthHaver.IsVulnerable && !exclude.Contains(a) && a.IsWorthShootingAt && a.isActiveAndEnabled && a.CanTargetPlayers && a.GetComponent <CompanionController>() == null;
            IntVector2           bulletPositionIntVector2 = bulletPosition.ToIntVector2();
            AIActor closestToPosition = BraveUtility.GetClosestToPosition <AIActor>(GameManager.Instance.Dungeon.data.GetAbsoluteRoomFromPosition(bulletPositionIntVector2).GetActiveEnemies(RoomHandler.ActiveEnemyType.All), bulletPosition, isValid, new AIActor[]
            {
            });

            if (closestToPosition)
            {
                dirVec = closestToPosition.CenterPosition - bulletPosition;
            }
            if (angleFromAim != 0)
            {
                dirVec = dirVec.Rotate(angleFromAim);
            }
            if (angleVariance != 0)
            {
                if (playerToScaleAccuracyOff != null)
                {
                    angleVariance *= playerToScaleAccuracyOff.stats.GetStatValue(PlayerStats.StatType.Accuracy);
                }
                float positiveVariance = angleVariance * 0.5f;
                float negativeVariance = positiveVariance * -1f;
                float finalVariance    = UnityEngine.Random.Range(negativeVariance, positiveVariance);
                dirVec = dirVec.Rotate(finalVariance);
            }
            return(dirVec);
        }