public static bool PosIsNearAnyBoneOnBeam(this BasicBeamController beam, Vector2 positionToCheck, float distance)
        {
            LinkedList <BasicBeamController.BeamBone> bones;

            bones = OMITBReflectionHelpers.ReflectGetField <LinkedList <BasicBeamController.BeamBone> >(typeof(BasicBeamController), "m_bones", beam);
            //if (beam.UsesBones)
            //{
            foreach (BasicBeamController.BeamBone bone in bones)
            {
                Vector2 bonepos = beam.GetBonePosition(bone);
                if (Vector2.Distance(positionToCheck, bonepos) < distance)
                {
                    return(true);
                }
            }

            /* }
             * else
             * {
             *   List<Vector2> posCheck = new List<Vector2>();
             *   for (int i = 1; i <= 100; i++)
             *   {
             *       posCheck.Add(beam.Origin + beam.Direction.normalized * (bones.Last.Value.Position - bones.First.Value.Position).magnitude * (i * 0.01f));
             *   }
             *   foreach (Vector2 pos in posCheck)
             *   {
             *       if (Vector2.Distance(pos, positionToCheck) < distance) return true;
             *   }
             * }*/
            return(false);
        }
Example #2
0
        private void Update()
        {
            if (projectile.baseData.range > distanceTilSplit)
            {
                originalRange = projectile.baseData.range; projectile.baseData.range = distanceTilSplit;
            }
            if ((basicBeamController.ApproximateDistance >= distanceTilSplit) && subBeams.Count < amtToSplitTo)
            {
                CreateNewSubBeams();
            }
            if ((basicBeamController.ApproximateDistance < distanceTilSplit) && subBeams.Count > 0)
            {
                ClearExtantSubBeams();
            }
            float currentAngle = basicBeamController.GetFinalBoneDirection();
            float startAngle   = currentAngle + (splitAngles * 0.5f);

            if (subBeams.Count > 0)
            {
                for (int i = 0; i < subBeams.Count; i++)
                {
                    BasicBeamController particularSubBeam = subBeams.ElementAt(i).Key;
                    LinkedList <BasicBeamController.BeamBone> bones;
                    bones = OMITBReflectionHelpers.ReflectGetField <LinkedList <BasicBeamController.BeamBone> >(typeof(BasicBeamController), "m_bones", basicBeamController);
                    LinkedListNode <BasicBeamController.BeamBone> linkedListNode = bones.Last;
                    Vector2 bonePosition = basicBeamController.GetBonePosition(linkedListNode.Value);

                    float angleOffset = subBeams.ElementAt(i).Value;
                    particularSubBeam.Direction = (startAngle - angleOffset).DegreeToVector2();
                    particularSubBeam.Origin    = bonePosition;
                    particularSubBeam.LateUpdatePosition(bonePosition);
                }
            }
        }
 public static bool IsSecretlyTheMineFlayer(this AIActor target)
 {
     if (target)
     {
         foreach (AIActor maybeFlayer in StaticReferenceManager.AllEnemies)
         {
             if (maybeFlayer && maybeFlayer.EnemyGuid == "8b0dd96e2fe74ec7bebc1bc689c0008a" && maybeFlayer.behaviorSpeculator)
             {
                 List <MineFlayerShellGameBehavior> activeShellGames = maybeFlayer.behaviorSpeculator.FindAttackBehaviors <MineFlayerShellGameBehavior>();
                 if (activeShellGames.Count > 0)
                 {
                     foreach (MineFlayerShellGameBehavior behav in activeShellGames)
                     {
                         AIActor myBell = OMITBReflectionHelpers.ReflectGetField <AIActor>(typeof(MineFlayerShellGameBehavior), "m_myBell", behav);
                         if (myBell != null)
                         {
                             if (myBell == target)
                             {
                                 return(true);
                             }
                         }
                     }
                 }
             }
         }
     }
     return(false);
 }
        public static AIActor GetAttackBehaviourOwner(this BehaviorBase behav)
        {
            AIActor actor = null;

            actor = OMITBReflectionHelpers.ReflectGetField <AIActor>(typeof(BehaviorBase), "m_aiActor", behav);
            return(actor);
        }
        private void HandlePreCollision(SpeculativeRigidbody myRigidbody, PixelCollider myPixelCollider, SpeculativeRigidbody otherRigidbody, PixelCollider otherPixelCollider)
        {
            try
            {
                if (otherRigidbody)
                {
                    foreach (MajorBreakable breakable in otherRigidbody.GetComponentsInChildren <MajorBreakable>())
                    {
                        breakable.TemporarilyInvulnerable = true;
                        //ETGModConsole.Log(breakable.sprite.CurrentSprite.name);
                        if (breakable.HitPoints < breakable.MaxHitPoints)
                        {
                            float missingHP = breakable.MaxHitPoints - breakable.HitPoints;

                            breakable.HitPoints += (missingHP * 0.2f);
                            if (breakable.GetComponent <Chest>())
                            {
                                breakable.GetComponent <Chest>().ForceKillFuse();
                                int idleID = OMITBReflectionHelpers.ReflectGetField <int>(typeof(Chest), "m_cachedSpriteForCoop", breakable.GetComponent <Chest>());
                                OMITBReflectionHelpers.ReflectSetField <bool>(typeof(MajorBreakable), "m_inZeroHPState", false, breakable);
                                breakable.sprite.SetSprite(idleID);
                            }
                        }
                        breakable.StartCoroutine(ResetInvul(breakable));
                    }
                }
            }
            catch (Exception e)
            {
                ETGModConsole.Log(e.Message);
                ETGModConsole.Log(e.StackTrace);
            }
        }
        protected override void DoActiveEffect(PlayerController user)
        {
            tk2dBaseSprite cursor      = OMITBReflectionHelpers.ReflectGetField <tk2dBaseSprite>(typeof(TargetedAttackPlayerItem), "m_extantReticleQuad", this);
            Vector2        overridePos = cursor.WorldCenter;

            TeleportPlayerToCursorPosition.StartTeleport(user, overridePos);
            base.DoActiveEffect(user);
        }
Example #7
0
 private void DoTick()
 {
     if (UnityEngine.Random.value < chancePerTick)
     {
         LinkedList <BasicBeamController.BeamBone> bones;
         bones = OMITBReflectionHelpers.ReflectGetField <LinkedList <BasicBeamController.BeamBone> >(typeof(BasicBeamController), "m_bones", basicBeamController);
         LinkedListNode <BasicBeamController.BeamBone> linkedListNode = bones.Last;
         Vector2 bonePosition = basicBeamController.GetBonePosition(linkedListNode.Value);
         Blank(bonePosition);
     }
 }
Example #8
0
        public static void GunAttackHook(Action <Gun, ProjectileModule, ProjectileData, GameObject> orig, Gun self, ProjectileModule mod, ProjectileData data = null, GameObject overrideObject = null)
        {
            try
            {
                orig(self, mod, data, overrideObject);
                if (self != null && mod != null && self.GunPlayerOwner())
                {
                    if (self.GunPlayerOwner().HasPickupID(BombardierShellsID))
                    {
                        float knockbackAmt = 40f;
                        float projDamage   = 10;

                        Dictionary <ProjectileModule, ModuleShootData> moduleData = OMITBReflectionHelpers.ReflectGetField <Dictionary <ProjectileModule, ModuleShootData> >(typeof(Gun), "m_moduleData", self);

                        if (overrideObject)
                        {
                            Projectile projectile = overrideObject.GetComponent <Projectile>();
                            projDamage = projectile.baseData.damage;
                        }
                        else if (mod.shootStyle == ProjectileModule.ShootStyle.Charged && moduleData != null)
                        {
                            ProjectileModule.ChargeProjectile chargeProjectile = mod.GetChargeProjectile(moduleData[mod].chargeTime);
                            if (chargeProjectile != null)
                            {
                                Projectile projectile = chargeProjectile.Projectile;
                                projDamage = projectile.baseData.damage;
                            }
                        }
                        else
                        {
                            Projectile projectile = mod.GetCurrentProjectile(moduleData[mod], self.GunPlayerOwner());
                            projDamage = projectile.baseData.damage;
                        }

                        float multiplier = projDamage / 10;
                        knockbackAmt *= multiplier;
                        knockbackAmt  = Mathf.Min(100, knockbackAmt);

                        if (self.GunPlayerOwner().PlayerHasActiveSynergy("Forward Thinking"))
                        {
                            knockbackAmt *= -0.5f;
                        }
                        self.GunPlayerOwner().knockbackDoer.ApplyKnockback((self.GunPlayerOwner().sprite.WorldCenter - self.GunPlayerOwner().unadjustedAimPoint.XY()).normalized, knockbackAmt);
                    }
                }
            }
            catch (Exception e)
            {
                ETGModConsole.Log(e.Message);
                ETGModConsole.Log(e.StackTrace);
            }
        }
Example #9
0
        private void DoTick()
        {
            //ETGModConsole.Log("Tick Triggered");
            if (UnityEngine.Random.value < chancePerTick)
            {
                LinkedList <BasicBeamController.BeamBone> bones;
                bones = OMITBReflectionHelpers.ReflectGetField <LinkedList <BasicBeamController.BeamBone> >(typeof(BasicBeamController), "m_bones", basicBeamController);
                LinkedListNode <BasicBeamController.BeamBone> linkedListNode = bones.Last;
                Vector2 bonePosition = basicBeamController.GetBonePosition(linkedListNode.Value);

                Explode(bonePosition, basicBeamController.GetFinalBoneDirection());
            }
        }
 public static int GetBoneCount(this BasicBeamController beam)
 {
     if (!beam.UsesBones)
     {
         return(1);
     }
     else
     {
         LinkedList <BasicBeamController.BeamBone> bones;
         bones = OMITBReflectionHelpers.ReflectGetField <LinkedList <BasicBeamController.BeamBone> >(typeof(BasicBeamController), "m_bones", beam);
         return(bones.Count());
     }
 }
 public static float GetFinalBoneDirection(this BasicBeamController beam)
 {
     if (!beam.UsesBones)
     {
         return(beam.Direction.ToAngle());
     }
     else
     {
         LinkedList <BasicBeamController.BeamBone> bones;
         bones = OMITBReflectionHelpers.ReflectGetField <LinkedList <BasicBeamController.BeamBone> >(typeof(BasicBeamController), "m_bones", beam);
         LinkedListNode <BasicBeamController.BeamBone> linkedListNode = bones.Last;
         return(linkedListNode.Value.RotationAngle);
     }
 }
        public static BasicBeamController.BeamBone GetIndexedBone(this BasicBeamController beam, int boneIndex)
        {
            LinkedList <BasicBeamController.BeamBone> bones;

            bones = OMITBReflectionHelpers.ReflectGetField <LinkedList <BasicBeamController.BeamBone> >(typeof(BasicBeamController), "m_bones", beam);
            if (bones == null)
            {
                return(null);
            }
            if (bones.ElementAt(boneIndex) == null)
            {
                Debug.LogError("Attempted to fetch a beam bone at an invalid index"); return(null);
            }
            return(bones.ElementAt(boneIndex));
        }
 public void Update()
 {
     if (basicBeamControllerSelf)
     {
         LinkedList <BasicBeamController.BeamBone> bones;
         bones = OMITBReflectionHelpers.ReflectGetField <LinkedList <BasicBeamController.BeamBone> >(typeof(BasicBeamController), "m_bones", basicBeamControllerSelf);
         if (bones != null)
         {
             if (bones.Count > boneNumLastChecked)
             {
                 if (UnityEngine.Random.value <= 0.5f)
                 {
                     SpawnSubTendril(bones.Count - 1);
                 }
             }
             boneNumLastChecked = bones.Count;
         }
     }
 }
        public static Vector2 GetIndexedBonePosition(this BasicBeamController beam, int boneIndex)
        {
            LinkedList <BasicBeamController.BeamBone> bones;

            bones = OMITBReflectionHelpers.ReflectGetField <LinkedList <BasicBeamController.BeamBone> >(typeof(BasicBeamController), "m_bones", beam);

            if (bones.ElementAt(boneIndex) == null)
            {
                Debug.LogError("Attempted to fetch the position of a beam bone at an invalid index"); return(Vector2.zero);
            }
            if (!beam.UsesBones)
            {
                return(beam.Origin + BraveMathCollege.DegreesToVector(beam.Direction.ToAngle(), bones.ElementAt(boneIndex).PosX));
            }
            if (beam.ProjectileAndBeamMotionModule != null)
            {
                return(bones.ElementAt(boneIndex).Position + beam.ProjectileAndBeamMotionModule.GetBoneOffset(bones.ElementAt(boneIndex), beam, beam.projectile.Inverted));
            }
            return(bones.ElementAt(boneIndex).Position);
        }
 public static bool IsInMinecart(this AIActor target)
 {
     if (target && target.behaviorSpeculator)
     {
         foreach (MovementBehaviorBase behavbase in target.behaviorSpeculator.MovementBehaviors)
         {
             if (behavbase is RideInCartsBehavior)
             {
                 RideInCartsBehavior cartRiding = behavbase as RideInCartsBehavior;
                 bool isRidingCart = OMITBReflectionHelpers.ReflectGetField <bool>(typeof(RideInCartsBehavior), "m_ridingCart", cartRiding);
                 return(isRidingCart);
             }
         }
         return(false);
     }
     else
     {
         return(false);
     }
 }
Example #16
0
        public static Vector2 GetCursorPosition(this PlayerController user, float noCursorControllerRange)
        {
            Vector2 m_cachedBlinkPosition = Vector2.zero;

            GungeonActions m_activeActions = OMITBReflectionHelpers.ReflectGetField <GungeonActions>(typeof(PlayerController), "m_activeActions", user);

            bool IsKeyboardAndMouse = BraveInput.GetInstanceForPlayer(user.PlayerIDX).IsKeyboardAndMouse(false);

            if (IsKeyboardAndMouse)
            {
                m_cachedBlinkPosition = user.unadjustedAimPoint.XY() - (user.CenterPosition - user.specRigidbody.UnitCenter);
            }
            else
            {
                m_cachedBlinkPosition = user.PositionInDistanceFromAimDir(5);
                //if (m_activeActions != null) { m_cachedBlinkPosition += m_activeActions.Aim.Vector.normalized * BraveTime.DeltaTime * 15f; }
            }

            m_cachedBlinkPosition = BraveMathCollege.ClampToBounds(m_cachedBlinkPosition, GameManager.Instance.MainCameraController.MinVisiblePoint, GameManager.Instance.MainCameraController.MaxVisiblePoint);
            return(m_cachedBlinkPosition);
        }
        private static IEnumerator HandleBlinkTeleport(PlayerController Owner, Vector2 targetPoint, Vector2 targetDirection)
        {
            //targetPoint = (targetPoint - new Vector2(0.30f, 0.125f));

            Owner.PlayEffectOnActor(EasyVFXDatabase.BloodiedScarfPoofVFX, Vector3.zero, false, true, false);

            AkSoundEngine.PostEvent("Play_ENM_wizardred_vanish_01", Owner.gameObject);
            List <AIActor> m_rollDamagedEnemies = OMITBReflectionHelpers.ReflectGetField <List <AIActor> >(typeof(PlayerController), "m_rollDamagedEnemies", Owner);

            if (m_rollDamagedEnemies != null)
            {
                m_rollDamagedEnemies.Clear();
                FieldInfo m_rollDamagedEnemiesClear = typeof(PlayerController).GetField("m_rollDamagedEnemies", BindingFlags.Instance | BindingFlags.NonPublic);
                m_rollDamagedEnemiesClear.SetValue(Owner, m_rollDamagedEnemies);
            }

            if (Owner.knockbackDoer)
            {
                Owner.knockbackDoer.ClearContinuousKnockbacks();
            }
            Owner.IsEthereal = true;
            Owner.IsVisible  = false;
            float RecoverySpeed = GameManager.Instance.MainCameraController.OverrideRecoverySpeed;
            bool  IsLerping     = GameManager.Instance.MainCameraController.IsLerping;

            yield return(new WaitForSeconds(0.1f));

            GameManager.Instance.MainCameraController.OverrideRecoverySpeed = 80f;
            GameManager.Instance.MainCameraController.IsLerping             = true;
            if (Owner.IsPrimaryPlayer)
            {
                GameManager.Instance.MainCameraController.UseOverridePlayerOnePosition = true;
                GameManager.Instance.MainCameraController.OverridePlayerOnePosition    = targetPoint;
                yield return(new WaitForSeconds(0.12f));

                Owner.specRigidbody.Velocity = Vector2.zero;
                Owner.specRigidbody.Position = new Position(targetPoint);
                GameManager.Instance.MainCameraController.UseOverridePlayerOnePosition = false;
            }
            else
            {
                GameManager.Instance.MainCameraController.UseOverridePlayerTwoPosition = true;
                GameManager.Instance.MainCameraController.OverridePlayerTwoPosition    = targetPoint;
                yield return(new WaitForSeconds(0.12f));

                Owner.specRigidbody.Velocity = Vector2.zero;
                Owner.specRigidbody.Position = new Position(targetPoint);
                GameManager.Instance.MainCameraController.UseOverridePlayerTwoPosition = false;
            }
            GameManager.Instance.MainCameraController.OverrideRecoverySpeed = RecoverySpeed;
            GameManager.Instance.MainCameraController.IsLerping             = IsLerping;
            Owner.IsEthereal = false;
            Owner.IsVisible  = true;
            Owner.PlayEffectOnActor(EasyVFXDatabase.BloodiedScarfPoofVFX, Vector3.zero, false, true, false);
            //m_CurrentlyBlinking = false;
            if (Owner.CurrentFireMeterValue <= 0f)
            {
                yield break;
            }
            Owner.CurrentFireMeterValue = Mathf.Max(0f, Owner.CurrentFireMeterValue -= 0.5f);
            if (Owner.CurrentFireMeterValue == 0f)
            {
                Owner.IsOnFire = false;
                yield break;
            }
            // yield return null;
            //CorrectForWalls(Owner);
            yield break;
        }
Example #18
0
        public static List <string> GeneratePalette(bool canReturnMimics = false, bool canReturnBosses = false)
        {
            List <string> templist = new List <string>();
            Dungeon       d        = GameManager.Instance.Dungeon;

            if (d != null)
            {
                DungeonData ddata = d.data;
                foreach (AIActor enemy in StaticReferenceManager.AllEnemies)
                {
                    if (enemy.GetComponent <CompanionController>() == null)
                    {
                        if (EnemyIsValid(enemy.EnemyGuid, canReturnMimics, canReturnBosses))
                        {
                            if (!templist.Contains(enemy.EnemyGuid))
                            {
                                templist.Add(enemy.EnemyGuid);
                            }
                        }
                    }
                }
                if (ddata != null)
                {
                    foreach (RoomHandler room in ddata.rooms)
                    {
                        //Debug.Log("-------- Checking ROOM: " + room.GetRoomName());
                        List <PrototypeRoomObjectLayer> hiddenlist;

                        hiddenlist = OMITBReflectionHelpers.ReflectGetField <List <PrototypeRoomObjectLayer> >(typeof(RoomHandler), "remainingReinforcementLayers", room);
                        //Debug.Log("Wavecheck passed the Reflection");
                        if (hiddenlist != null && hiddenlist.Count > 0)
                        {
                            foreach (PrototypeRoomObjectLayer layer in hiddenlist)
                            {
                                if (layer != null)
                                {
                                    if (layer.placedObjects != null)
                                    {
                                        foreach (PrototypePlacedObjectData objData in layer.placedObjects)
                                        {
                                            if (objData != null)
                                            {
                                                if (objData.unspecifiedContents != null)
                                                {
                                                    if (objData.unspecifiedContents.GetComponent <AIActor>() != null)
                                                    {
                                                        if (EnemyIsValid(objData.unspecifiedContents.GetComponent <AIActor>().EnemyGuid, canReturnMimics, canReturnBosses))
                                                        {
                                                            if (!templist.Contains(objData.unspecifiedContents.GetComponent <AIActor>().EnemyGuid))
                                                            {
                                                                templist.Add(objData.unspecifiedContents.GetComponent <AIActor>().EnemyGuid);
                                                            }
                                                        }
                                                    }
                                                }
                                                else if (objData.placeableContents != null)
                                                {
                                                    foreach (DungeonPlaceableVariant variantTier in objData.placeableContents.variantTiers)
                                                    {
                                                        if (variantTier.enemyPlaceableGuid != null)
                                                        {
                                                            //Debug.Log("FOUND ENEMY GUID: " + variantTier.enemyPlaceableGuid);
                                                            if (!templist.Contains(variantTier.enemyPlaceableGuid))
                                                            {
                                                                templist.Add(variantTier.enemyPlaceableGuid);
                                                            }
                                                        }
                                                    }
                                                }
                                                else
                                                {
                                                    Debug.LogError("unspecifiedContents AND placeableContents are NULL!");
                                                }
                                            }
                                            else
                                            {
                                                Debug.LogError("Object data in the placed objects list is NULL!");
                                            }
                                        }
                                    }
                                    else
                                    {
                                        Debug.LogError("List of placed objects in the layer is NULL!");
                                    }
                                }
                                else
                                {
                                    Debug.LogError("Individual object layer is NULL!");
                                }
                            }
                        }
                        else
                        {
                            Debug.Log("There are no reinforcement waves in room: " + room.GetRoomName());
                        }
                    }
                }
            }
            return(templist);
        }
        private void DisplacedImageSpawnHook(Action <DisplaceBehavior> orig, DisplaceBehavior sourceBehaviour)
        {
            orig(sourceBehaviour);
            AIActor attkOwner = sourceBehaviour.GetAttackBehaviourOwner();

            if (attkOwner != null)
            {
                if (attkOwner.GetComponent <CustomEnemyTagsSystem>() != null && attkOwner.GetComponent <CustomEnemyTagsSystem>().isKalibersEyeMinion)
                {
                    AIActor image = OMITBReflectionHelpers.ReflectGetField <AIActor>(typeof(DisplaceBehavior), "m_image", sourceBehaviour);
                    if (image != null)
                    {
                        PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(image.specRigidbody, null, false);

                        CustomEnemyTagsSystem tags = image.gameObject.GetOrAddComponent <CustomEnemyTagsSystem>();
                        tags.isKalibersEyeMinion = true;
                        tags.ignoreForGoodMimic  = true;

                        if (attkOwner.CompanionOwner != null)
                        {
                            CompanionController orAddComponent = image.gameObject.GetOrAddComponent <CompanionController>();
                            orAddComponent.companionID = CompanionController.CompanionIdentifier.NONE;
                            orAddComponent.Initialize(attkOwner.CompanionOwner);
                        }

                        image.OverrideHitEnemies    = true;
                        image.CollisionDamage       = 0.5f;
                        image.CollisionDamageTypes |= CoreDamageTypes.Electric;

                        CompanionisedEnemyBulletModifiers companionisedBullets = image.gameObject.GetOrAddComponent <CompanionisedEnemyBulletModifiers>();
                        companionisedBullets.jammedDamageMultiplier = 2f;
                        companionisedBullets.TintBullets            = true;
                        companionisedBullets.TintColor        = ExtendedColours.honeyYellow;
                        companionisedBullets.baseBulletDamage = 10f;
                        companionisedBullets.scaleSpeed       = true;
                        companionisedBullets.scaleDamage      = true;
                        companionisedBullets.scaleSize        = false;
                        companionisedBullets.doPostProcess    = false;
                        if (attkOwner.CompanionOwner != null)
                        {
                            companionisedBullets.enemyOwner = attkOwner.CompanionOwner;
                        }

                        image.ApplyEffect(GameManager.Instance.Dungeon.sharedSettingsPrefab.DefaultPermanentCharmEffect, 1f, null);
                        image.gameObject.AddComponent <KillOnRoomClear>();


                        if (EasyEnemyTypeLists.MultiPhaseEnemies.Contains(image.EnemyGuid) || EasyEnemyTypeLists.EnemiesWithInvulnerablePhases.Contains(image.EnemyGuid))
                        {
                            EraseFromExistenceOnRoomClear destroyTrickyEnemy = image.gameObject.AddComponent <EraseFromExistenceOnRoomClear>();
                            destroyTrickyEnemy.Delay = 1f;
                        }
                        image.IsHarmlessEnemy = true;
                        image.RegisterOverrideColor(Color.grey, "Ressurection");
                        image.IgnoreForRoomClear = true;
                        if (image.gameObject.GetComponent <SpawnEnemyOnDeath>())
                        {
                            UnityEngine.Object.Destroy(image.gameObject.GetComponent <SpawnEnemyOnDeath>());
                        }
                    }
                }
            }
        }
        private static int GetChestCachedSpriteID(this Chest self)
        {
            int idleID = OMITBReflectionHelpers.ReflectGetField <int>(typeof(Chest), "m_cachedSpriteForCoop", self);

            return(idleID);
        }
 public static void SetChestCachedSpriteID(this Chest self, int desiredVal)
 {
     OMITBReflectionHelpers.ReflectSetField <int>(typeof(Chest), "m_cachedSpriteForCoop", desiredVal, self);
 }
        public static ChestFuseController GetFuse(this Chest chest)
        {
            ChestFuseController fuse = OMITBReflectionHelpers.ReflectGetField <ChestFuseController>(typeof(Chest), "extantFuse", chest);

            return(fuse);
        }
Example #23
0
        private void CreateNewSubBeams()
        {
            ClearExtantSubBeams();
            float ProjectileInterval = splitAngles / ((float)amtToSplitTo - 1);
            float currentAngle       = basicBeamController.GetFinalBoneDirection();
            float startAngle         = currentAngle + (splitAngles * 0.5f);
            int   iteration          = 0;

            for (int i = 0; i < amtToSplitTo; i++)
            {
                LinkedList <BasicBeamController.BeamBone> bones;
                bones = OMITBReflectionHelpers.ReflectGetField <LinkedList <BasicBeamController.BeamBone> >(typeof(BasicBeamController), "m_bones", basicBeamController);
                LinkedListNode <BasicBeamController.BeamBone> linkedListNode = null;
                if (bones != null)
                {
                    linkedListNode = bones.Last;
                }
                else
                {
                    Debug.LogError("Bones was NULL"); return;
                }

                Vector2 bonePosition = basicBeamController.GetBonePosition(linkedListNode.Value);

                float finalAngle = startAngle - (ProjectileInterval * iteration);

                GameObject newSubBeamPrefab = FakePrefab.Clone(projectile.gameObject);
                if (newSubBeamPrefab == null)
                {
                    Debug.LogError("BeamSplitComp: Cloned Beam Prefab was NULL!");
                }

                BeamController controllerPrefab = newSubBeamPrefab.GetComponent <BeamController>();
                if (controllerPrefab == null)
                {
                    Debug.LogError("BeamSplitComp: ControllerPrefab was NULL!");
                }
                if (controllerPrefab is BasicBeamController)
                {
                    GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(controllerPrefab.gameObject);

                    BasicBeamController newBasicSubBeam = gameObject.GetComponent <BasicBeamController>();
                    newBasicSubBeam.State              = BasicBeamController.BeamState.Firing;
                    newBasicSubBeam.HitsPlayers        = false;
                    newBasicSubBeam.HitsEnemies        = true;
                    newBasicSubBeam.Origin             = bonePosition;
                    newBasicSubBeam.Direction          = finalAngle.DegreeToVector2();
                    newBasicSubBeam.usesChargeDelay    = false;
                    newBasicSubBeam.muzzleAnimation    = string.Empty;
                    newBasicSubBeam.chargeAnimation    = string.Empty;
                    newBasicSubBeam.beamStartAnimation = string.Empty;
                    newBasicSubBeam.projectile.Owner   = this.projectile.Owner;
                    newBasicSubBeam.Owner              = this.basicBeamController.Owner;
                    newBasicSubBeam.Gun = this.basicBeamController.Gun;
                    if (originalRange > 0)
                    {
                        newBasicSubBeam.projectile.baseData.range = originalRange;
                    }
                    newBasicSubBeam.projectile.baseData.damage *= dmgMultOnSplit;

                    if (newBasicSubBeam.GetComponent <BeamSplittingModifier>())
                    {
                        Destroy(newBasicSubBeam.GetComponent <BeamSplittingModifier>());
                    }

                    subBeams.Add(newBasicSubBeam, (ProjectileInterval * iteration));
                }
                else
                {
                    Debug.LogError("BeamSplitComp: Controller prefab was not beam????");
                }

                iteration++;
            }
        }
Example #24
0
        protected override void DoEffect(PlayerController user)
        {
            IPlayerInteractable nearestInteractable = user.CurrentRoom.GetNearestInteractable(user.CenterPosition, 1f, user);

            if (!(nearestInteractable is Chest))
            {
                return;
            }

            AkSoundEngine.PostEvent("Play_ENM_electric_charge_01", user.gameObject);

            Chest rerollChest = nearestInteractable as Chest;
            int   selected    = UnityEngine.Random.Range(1, 15);

            ETGModConsole.Log(selected.ToString());

            VFXToolbox.GlitchScreenForSeconds(1.5f);


            switch (selected)
            {
            case 1:     //Blow up chest
                if (user.PlayerHasActiveSynergy("KEYGEN"))
                {
                    SpareChest(rerollChest);
                }
                else
                {
                    Exploder.DoDefaultExplosion(rerollChest.specRigidbody.UnitCenter, Vector2.zero);
                    if (rerollChest.IsMimic)
                    {
                        OMITBReflectionHelpers.ReflectSetField <bool>(typeof(Chest), "m_isMimic", false, rerollChest);
                    }
                    rerollChest.majorBreakable.Break(Vector2.zero);
                    if (rerollChest.GetChestTier() == ChestToolbox.ChestTier.RAT)
                    {
                        UnityEngine.Object.Destroy(rerollChest.gameObject);
                    }
                }
                break;

            case 2:     //Open Chest
                rerollChest.ForceOpen(user);
                break;

            case 3:     //Break Lock
                if (user.PlayerHasActiveSynergy("KEYGEN"))
                {
                    SpareChest(rerollChest);
                }
                else
                {
                    if (rerollChest.IsLocked)
                    {
                        rerollChest.BreakLock();
                    }
                    else
                    {
                        rerollChest.majorBreakable.Break(Vector2.zero);
                    }
                }
                break;

            case 4:     //Duplicate Chest
                DupeChest(rerollChest, user);
                break;

            case 5:     //Turn into mimic
                if (!rerollChest.IsMimic)
                {
                    rerollChest.overrideMimicChance = 100; rerollChest.MaybeBecomeMimic();
                }
                rerollChest.ForceOpen(user);
                break;

            case 6:     //Englitch
                List <GlobalDungeonData.ValidTilesets> bannedGlitchFloors = new List <GlobalDungeonData.ValidTilesets>()
                {
                    GlobalDungeonData.ValidTilesets.CATACOMBGEON,
                    GlobalDungeonData.ValidTilesets.HELLGEON,
                    GlobalDungeonData.ValidTilesets.OFFICEGEON,
                    GlobalDungeonData.ValidTilesets.FORGEGEON,
                };
                if (!bannedGlitchFloors.Contains(GameManager.Instance.Dungeon.tileIndices.tilesetId))
                {
                    rerollChest.BecomeGlitchChest();
                }
                else
                {
                    if (!rerollChest.IsMimic)
                    {
                        rerollChest.MaybeBecomeMimic();
                    }
                    rerollChest.ForceOpen(user);
                }
                break;

            case 7:     //Enrainbow
                if (UnityEngine.Random.value <= 0.65f)
                {
                    UpgradeChest(rerollChest, user);
                }
                else
                {
                    rerollChest.BecomeRainbowChest();
                }
                break;

            case 8:     //Reroll
                RerollChest(rerollChest, user);
                break;

            case 9:     //Turn into pickups
                if (user.PlayerHasActiveSynergy("KEYGEN"))
                {
                    SpareChest(rerollChest);
                }
                else
                {
                    for (int i = 0; i < 5; i++)
                    {
                        LootEngine.SpawnItem(PickupObjectDatabase.GetById(BraveUtility.RandomElement(BabyGoodChanceKin.lootIDlist)).gameObject, rerollChest.sprite.WorldCenter, Vector2.zero, 0);
                    }
                    LootEngine.SpawnCurrency(rerollChest.sprite.WorldCenter, UnityEngine.Random.Range(5, 11));
                    user.CurrentRoom.DeregisterInteractable(rerollChest);
                    rerollChest.DeregisterChestOnMinimap();
                    UnityEngine.Object.Destroy(rerollChest.gameObject);
                }
                break;

            case 10:     //Fuse
                if (user.PlayerHasActiveSynergy("KEYGEN"))
                {
                    SpareChest(rerollChest);
                }
                else
                {
                    var type = typeof(Chest);
                    var func = type.GetMethod("TriggerCountdownTimer", BindingFlags.Instance | BindingFlags.NonPublic);
                    var ret  = func.Invoke(rerollChest, null);
                    AkSoundEngine.PostEvent("Play_OBJ_fuse_loop_01", rerollChest.gameObject);
                }
                break;

            case 11:     //Unlock
                if (rerollChest.IsLocked)
                {
                    rerollChest.ForceUnlock();
                }
                else
                {
                    rerollChest.ForceOpen(user);
                }
                break;

            case 12:     //Enjam
                rerollChest.gameObject.GetOrAddComponent <JammedChestBehav>();
                break;

            case 13:     //TeleportChest
                TeleportChest(rerollChest, user);
                break;

            case 14:     //Drill
                FauxDrill(rerollChest, user);
                break;
            }
        }
            private void OnRoomChanged(RoomHandler room)
            {
                //ETGModConsole.Log("OnRoomChanged Ran");
                List <string> dialoguesToSay     = new List <string>();
                int           previousStatements = 0;

                Chest[]      allChests    = FindObjectsOfType <Chest>();
                List <Chest> chestsInRoom = new List <Chest>();

                foreach (Chest chest in allChests)
                {
                    if (chest.transform.position.GetAbsoluteRoom() == Owner.CurrentRoom && !chest.IsOpen && !chest.IsBroken)
                    {
                        //ETGModConsole.Log("Found a chest in the room");

                        chestsInRoom.Add(chest);
                    }
                }
                if (chestsInRoom.Count > 0)
                {
                    foreach (Chest possibleMimic in chestsInRoom)
                    {
                        if (possibleMimic.IsMimic)
                        {
                            if (chestsInRoom.Count > 1)
                            {
                                dialoguesToSay.Add("One of these chests is a mimic... be careful!");
                            }
                            else
                            {
                                dialoguesToSay.Add("Be careful, that chest's a mimic!");
                            }
                            previousStatements++;
                        }
                    }
                    foreach (Chest possibleSecretRainbow in chestsInRoom)
                    {
                        if (possibleSecretRainbow.ChestIdentifier == Chest.SpecialChestIdentifier.SECRET_RAINBOW)
                        {
                            if (chestsInRoom.Count > 1)
                            {
                                dialoguesToSay.Add("That Chest is a Secret Rainbow Chest!");
                            }
                            else if (previousStatements > 0)
                            {
                                dialoguesToSay.Add("One of these Chests is also secretly a Rainbow Chest!");
                            }
                            else
                            {
                                dialoguesToSay.Add("One of these Chests is secretly a Rainbow Chest!");
                            }
                            previousStatements++;
                        }
                    }
                    if (chestsInRoom.Count > 1)
                    {
                        int amtOfDetectedGuns     = 0;
                        int amtOfDetectedPassives = 0;
                        int amtOfDetectedActives  = 0;
                        int weirdNonItems         = 0;
                        foreach (Chest chest in chestsInRoom)
                        {
                            int type = GetChestType(chest);
                            //ETGModConsole.Log("Detected Type: " + type);
                            if (type == 0)
                            {
                                amtOfDetectedGuns++;
                            }
                            if (type == 1)
                            {
                                amtOfDetectedPassives++;
                            }
                            if (type == 2)
                            {
                                amtOfDetectedActives++;
                            }
                            if (type == -1)
                            {
                                weirdNonItems++;
                            }
                        }

                        List <string> detectedItemCounts = new List <string>();

                        //Count guns
                        if (amtOfDetectedGuns > 1)
                        {
                            detectedItemCounts.Add(string.Format("{0} guns", amtOfDetectedGuns));
                        }
                        else if (amtOfDetectedGuns > 0)
                        {
                            detectedItemCounts.Add("1 gun");
                        }

                        //Count passives
                        if (amtOfDetectedPassives > 1)
                        {
                            detectedItemCounts.Add(string.Format("{0} passive items", amtOfDetectedPassives));
                        }
                        else if (amtOfDetectedPassives > 0)
                        {
                            detectedItemCounts.Add("1 passive item");
                        }

                        //Count actives
                        if (amtOfDetectedActives > 1)
                        {
                            detectedItemCounts.Add(string.Format("{0} active items", amtOfDetectedActives));
                        }
                        else if (amtOfDetectedActives > 0)
                        {
                            detectedItemCounts.Add("1 active item");
                        }

                        //Other shit
                        if (weirdNonItems > 1)
                        {
                            detectedItemCounts.Add(string.Format("{0} pickups, I think.", weirdNonItems));
                        }
                        else if (weirdNonItems > 0)
                        {
                            detectedItemCounts.Add("1 pickup, I think.");
                        }

                        //ETGModConsole.Log("Full Detected Item Counts Dialogue Strings!");
                        foreach (string itemCountsDiag in detectedItemCounts)
                        {
                            ETGModConsole.Log(itemCountsDiag);
                        }

                        string detectedShitDialogue = "";
                        if (detectedItemCounts.Count > 0)
                        {
                            for (int i = 0; i < detectedItemCounts.Count; i++)
                            {
                                //ETGModConsole.Log("Iteration: " + i);
                                //ETGModConsole.Log("Index: " + (i - 1));
                                string prefix = "";
                                if (i == (detectedItemCounts.Count - 1))
                                {
                                    prefix = ", and ";
                                }
                                else if (i != 0)
                                {
                                    prefix = ", ";
                                }
                                //ETGModConsole.Log("Prefix: " + prefix);
                                if (detectedItemCounts[i] != null)
                                {
                                    detectedShitDialogue += (prefix + detectedItemCounts[i]);
                                }
                                //ETGModConsole.Log("Detected Shit Proceedural: " + detectedShitDialogue);
                            }

                            string finalComment = string.Format("Hmm.. out of these chests I'm sensing {0}.", detectedShitDialogue);
                            dialoguesToSay.Add(finalComment);
                        }
                        else
                        {
                            dialoguesToSay.Add("Oh dear... I think I have experienced a bug while counting items!");
                        }
                    }
                    else
                    {
                        //ETGModConsole.Log("There was but one chest");
                        string contentsComment = "I think I may have glitched out...";
                        int    type            = GetChestType(chestsInRoom[0]);
                        if (type == 0)
                        {
                            contentsComment = "That chest definitely has a gun in it!";
                        }
                        else if (type == 1)
                        {
                            contentsComment = "That chest contains a passive item, I think.";
                        }
                        else if (type == 2)
                        {
                            contentsComment = "That chest contains an active item!";
                        }
                        else if (type == -1)
                        {
                            contentsComment = "That chest doesn't seem to contain... any items at all?";
                        }
                        else if (type == -2 && !GameStatsManager.Instance.IsRainbowRun)
                        {
                            contentsComment = "Oooh! A Rainbow Chest! Lucky you!";
                        }
                        if (previousStatements > 0)
                        {
                            contentsComment = "Also, " + contentsComment;
                        }
                        dialoguesToSay.Add(contentsComment);
                        previousStatements++;
                    }
                }

                foreach (AIActor enemy in StaticReferenceManager.AllEnemies)
                {
                    if (enemy.EnemyGuid == "479556d05c7c44f3b6abb3b2067fc778")
                    {
                        if (enemy.specRigidbody && enemy.CurrentRoom() == room)
                        {
                            if (enemy.GetComponent <WallMimicController>() != null)
                            {
                                bool isHidden = OMITBReflectionHelpers.ReflectGetField <bool>(typeof(WallMimicController), "m_isHidden", enemy.GetComponent <WallMimicController>());
                                if (isHidden)
                                {
                                    dialoguesToSay.Add("The walls in here look hungry...");
                                }
                            }
                        }
                    }
                }

                foreach (RoomHandler adjacentRoom in room.connectedRooms)
                {
                    if (adjacentRoom.area.PrototypeRoomCategory == PrototypeDungeonRoom.RoomCategory.BOSS && !adjacentRoom.hasEverBeenVisited)
                    {
                        List <string> Bossnames = new List <string>();
                        foreach (AIActor roomEnemy in adjacentRoom.GetActiveEnemies(RoomHandler.ActiveEnemyType.All))
                        {
                            if (roomEnemy.healthHaver && roomEnemy.healthHaver.IsBoss)
                            {
                                string bossName = roomEnemy.GetActorName();
                                if (!string.IsNullOrEmpty(roomEnemy.healthHaver.overrideBossName))
                                {
                                    bossName = StringTableManager.GetEnemiesString(roomEnemy.healthHaver.overrideBossName, -1);
                                }
                                Bossnames.Add(bossName);
                            }
                        }
                        if (Bossnames.Count > 0)
                        {
                            dialoguesToSay.Add(string.Format("Looks like the {0}... good luck.", BraveUtility.RandomElement(Bossnames)));
                        }
                        else
                        {
                            dialoguesToSay.Add("There's a boss nearby...  but I can't tell what it is?");
                        }
                    }
                    else if (adjacentRoom.area.PrototypeRoomCategory == PrototypeDungeonRoom.RoomCategory.SECRET && !adjacentRoom.hasEverBeenVisited)
                    {
                        dialoguesToSay.Add("The walls in here look suspicious.");
                    }
                    else if (adjacentRoom.area.PrototypeRoomCategory == PrototypeDungeonRoom.RoomCategory.REWARD && !adjacentRoom.hasEverBeenVisited)
                    {
                        dialoguesToSay.Add("I think I can sense some loot around here.");
                    }
                    if (adjacentRoom.area.PrototypeRoomCategory != PrototypeDungeonRoom.RoomCategory.SECRET)
                    {
                        Minimap.Instance.RevealMinimapRoom(adjacentRoom, true, true, false);
                    }
                }

                if (dialoguesToSay.Count > 0)
                {
                    StartCoroutine(Say(dialoguesToSay));
                }
            }