private IEnumerator Start()
        {
            name      = "GlitchTrapDoor";
            Lock.name = "GlitchLock";

            if (!loadLevelOnPitFall)
            {
                GeneratePitfallRoom();
            }

            m_blendTex       = new Texture2D(64, 64, TextureFormat.RGBA32, false);
            m_blendTexColors = new Color[4096];
            for (int i = 0; i < m_blendTexColors.Length; i++)
            {
                m_blendTexColors[i] = Color.black;
            }
            m_blendTex.SetPixels(m_blendTexColors);
            m_blendTex.Apply();
            BlendMaterial.SetFloat("_BlendMin", RevealPercentage);
            BlendMaterial.SetTexture("_BlendTex", m_blendTex);
            BlendMaterial.SetVector("_BaseWorldPosition", new Vector4(transform.position.x, transform.position.y, transform.position.z, 0f));
            LockBlendMaterial.SetFloat("_BlendMin", RevealPercentage);
            LockBlendMaterial.SetTexture("_BlendTex", m_blendTex);
            LockBlendMaterial.SetVector("_BaseWorldPosition", new Vector4(transform.position.x, transform.position.y, transform.position.z, 0f));
            parentRoom = transform.position.GetAbsoluteRoom();
            BlendMaterial.SetTexture("_SubTex", (parentRoom.RoomVisualSubtype != 1) ? StoneFloorTex : DirtFloorTex);
            LockBlendMaterial.SetTexture("_SubTex", (parentRoom.RoomVisualSubtype != 1) ? StoneFloorTex : DirtFloorTex);

            if (loadLevelOnPitFall)
            {
                SpeculativeRigidbody specRigidbody = base.specRigidbody;
                specRigidbody.OnEnterTrigger = (SpeculativeRigidbody.OnTriggerDelegate)Delegate.Combine(specRigidbody.OnEnterTrigger, new SpeculativeRigidbody.OnTriggerDelegate(HandleTriggerEntered));
                SpeculativeRigidbody specRigidbody2 = base.specRigidbody;
                specRigidbody2.OnExitTrigger = (SpeculativeRigidbody.OnTriggerExitDelegate)Delegate.Combine(specRigidbody2.OnExitTrigger, new SpeculativeRigidbody.OnTriggerExitDelegate(HandleTriggerExited));
            }

            if (FlightCollider)
            {
                SpeculativeRigidbody flightCollider = FlightCollider;
                flightCollider.OnTriggerCollision = (SpeculativeRigidbody.OnTriggerDelegate)Delegate.Combine(flightCollider.OnTriggerCollision, new SpeculativeRigidbody.OnTriggerDelegate(HandleFlightCollider));
            }

            List <IntVector2>    CachedPositions            = new List <IntVector2>();
            IntVector2           RandomGlitchEnemyPosition1 = ChaosObjectRandomizer.GetRandomAvailableCellForPlacable(GameManager.Instance.Dungeon, parentRoom, CachedPositions, false, true);
            IntVector2           RandomGlitchEnemyPosition2 = ChaosObjectRandomizer.GetRandomAvailableCellForPlacable(GameManager.Instance.Dungeon, parentRoom, CachedPositions, false, true);
            IntVector2           RandomGlitchEnemyPosition3 = ChaosObjectRandomizer.GetRandomAvailableCellForPlacable(GameManager.Instance.Dungeon, parentRoom, CachedPositions, false, true);
            ChaosGlitchedEnemies m_GlitchEnemyDatabase      = new ChaosGlitchedEnemies();

            m_GlitchEnemyDatabase.SpawnGlitchedRat(parentRoom, RandomGlitchEnemyPosition1);
            m_GlitchEnemyDatabase.SpawnGlitchedRat(parentRoom, RandomGlitchEnemyPosition2);
            m_GlitchEnemyDatabase.SpawnGlitchedRat(parentRoom, RandomGlitchEnemyPosition3);
            Destroy(m_GlitchEnemyDatabase);
            CachedPositions.Clear();

            parentRoom.RegisterInteractable(Lock);

            yield break;
        }
예제 #2
0
 private void SpawnEnemies(string[] selectedEnemyGuids)
 {
     if (useGlitchedActorPrefab)
     {
         IntVector2 pos = specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor);
         if (aiActor.IsFalling && !IsGlitchedLJ)
         {
             return;
         }
         if (GameManager.Instance.Dungeon.CellIsPit(specRigidbody.UnitCenter.ToVector3ZUp(0f)) && !IsGlitchedLJ)
         {
             return;
         }
         RoomHandler roomFromPosition     = GameManager.Instance.Dungeon.GetRoomFromPosition(pos);
         List <SpeculativeRigidbody> list = new List <SpeculativeRigidbody>();
         list.Add(specRigidbody);
         Vector2 unitBottomLeft = specRigidbody.UnitBottomLeft;
         for (int i = 0; i < ActorPrefabSpawnCount; i++)
         {
             if (IsGlitchedLJ)
             {
                 if (transform.position.GetAbsoluteRoom() != null)
                 {
                     ChaosGlitchedEnemies m_GlitchedEnemyDatabase = new ChaosGlitchedEnemies();
                     RoomHandler          CurrentRoom             = transform.position.GetAbsoluteRoom();
                     IntVector2           actorPosition           = specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor) - CurrentRoom.area.basePosition;
                     m_GlitchedEnemyDatabase.SpawnGlitchedSuperReaper(CurrentRoom, actorPosition);
                     Destroy(m_GlitchedEnemyDatabase);
                     return;
                 }
             }
             else
             {
                 if (ActorObjectTarget == null)
                 {
                     return;
                 }
                 AIActor.AwakenAnimationType AnimationType = AIActor.AwakenAnimationType.Default;
                 AIActor    aiactor = null;
                 GameObject CachedTargetActorObject     = Instantiate(ActorObjectTarget);
                 bool       ExplodesOnDeath             = false;
                 bool       spawnsGlitchedObjectOnDeath = false;
                 if (UnityEngine.Random.value <= 0.25f)
                 {
                     ExplodesOnDeath = true;
                 }
                 if (UnityEngine.Random.value <= 0.15f)
                 {
                     spawnsGlitchedObjectOnDeath = true;
                 }
                 ChaosGlitchedEnemies m_GlitchedEnemyDatabase = new ChaosGlitchedEnemies();
                 aiactor = AIActor.Spawn(m_GlitchedEnemyDatabase.GenerateGlitchedActorPrefab(CachedTargetActorObject, ActorOverrideSource, ExplodesOnDeath, spawnsGlitchedObjectOnDeath), specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor), roomFromPosition, true, AnimationType, true);
                 Destroy(m_GlitchedEnemyDatabase);
                 if (aiactor == null)
                 {
                     return;
                 }
                 if (aiActor.IsBlackPhantom)
                 {
                     aiactor.BecomeBlackPhantom();
                 }
                 if (aiactor)
                 {
                     aiactor.specRigidbody.Initialize();
                     Vector2 a      = unitBottomLeft - (aiactor.specRigidbody.UnitBottomLeft - aiactor.transform.position.XY());
                     Vector2 vector = a + new Vector2(Mathf.Max(0f, specRigidbody.UnitDimensions.x - aiactor.specRigidbody.UnitDimensions.x), 0f);
                     aiactor.transform.position = Vector2.Lerp(a, vector, (ActorPrefabSpawnCount != 1) ? i / (ActorPrefabSpawnCount - 1f) : 0f);
                     aiactor.specRigidbody.Reinitialize();
                     a      -= new Vector2(PhysicsEngine.PixelToUnit(extraPixelWidth), 0f);
                     vector += new Vector2(PhysicsEngine.PixelToUnit(extraPixelWidth), 0f);
                     Vector2       a2            = Vector2.Lerp(a, vector, (ActorPrefabSpawnCount != 1) ? i / (ActorPrefabSpawnCount - 1f) : 0.5f);
                     IntVector2    intVector     = PhysicsEngine.UnitToPixel(a2 - aiactor.transform.position.XY());
                     CollisionData collisionData = null;
                     if (PhysicsEngine.Instance.RigidbodyCastWithIgnores(aiactor.specRigidbody, intVector, out collisionData, true, true, null, false, list.ToArray()))
                     {
                         intVector = collisionData.NewPixelsToMove;
                     }
                     CollisionData.Pool.Free(ref collisionData);
                     aiactor.transform.position += PhysicsEngine.PixelToUnit(intVector).ToVector3ZUp(1f);
                     aiactor.specRigidbody.Reinitialize();
                     if (i == 0)
                     {
                         aiactor.aiAnimator.FacingDirection = 180f;
                     }
                     else if (i == ActorPrefabSpawnCount - 1)
                     {
                         aiactor.aiAnimator.FacingDirection = 0f;
                     }
                     HandleSpawn(aiactor);
                     list.Add(aiactor.specRigidbody);
                     Destroy(CachedTargetActorObject);
                 }
             }
         }
         if (list.Count > 0)
         {
             for (int j = 0; j < list.Count; j++)
             {
                 for (int k = 0; k < list.Count; k++)
                 {
                     if (j != k)
                     {
                         list[j].RegisterGhostCollisionException(list[k]);
                     }
                 }
             }
         }
     }
     else if (spawnPosition == SpawnPosition.InsideCollider)
     {
         IntVector2 pos = specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor);
         if (aiActor.IsFalling)
         {
             return;
         }
         if (GameManager.Instance.Dungeon.CellIsPit(specRigidbody.UnitCenter.ToVector3ZUp(0f)))
         {
             return;
         }
         RoomHandler roomFromPosition     = GameManager.Instance.Dungeon.GetRoomFromPosition(pos);
         List <SpeculativeRigidbody> list = new List <SpeculativeRigidbody>();
         list.Add(specRigidbody);
         Vector2 unitBottomLeft = specRigidbody.UnitBottomLeft;
         for (int i = 0; i < selectedEnemyGuids.Length; i++)
         {
             AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(selectedEnemyGuids[i]);
             AIActor aiactor      = AIActor.Spawn(orLoadByGuid, specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor), roomFromPosition, false, AIActor.AwakenAnimationType.Default, true);
             if (aiActor.IsBlackPhantom)
             {
                 aiactor.ForceBlackPhantom = true;
             }
             if (aiactor)
             {
                 aiactor.specRigidbody.Initialize();
                 Vector2 a      = unitBottomLeft - (aiactor.specRigidbody.UnitBottomLeft - aiactor.transform.position.XY());
                 Vector2 vector = a + new Vector2(Mathf.Max(0f, specRigidbody.UnitDimensions.x - aiactor.specRigidbody.UnitDimensions.x), 0f);
                 aiactor.transform.position = Vector2.Lerp(a, vector, (selectedEnemyGuids.Length != 1) ? i / (selectedEnemyGuids.Length - 1f) : 0f);
                 aiactor.specRigidbody.Reinitialize();
                 a      -= new Vector2(PhysicsEngine.PixelToUnit(extraPixelWidth), 0f);
                 vector += new Vector2(PhysicsEngine.PixelToUnit(extraPixelWidth), 0f);
                 Vector2       a2            = Vector2.Lerp(a, vector, (selectedEnemyGuids.Length != 1) ? i / (selectedEnemyGuids.Length - 1f) : 0.5f);
                 IntVector2    intVector     = PhysicsEngine.UnitToPixel(a2 - aiactor.transform.position.XY());
                 CollisionData collisionData = null;
                 if (PhysicsEngine.Instance.RigidbodyCastWithIgnores(aiactor.specRigidbody, intVector, out collisionData, true, true, null, false, list.ToArray()))
                 {
                     intVector = collisionData.NewPixelsToMove;
                 }
                 CollisionData.Pool.Free(ref collisionData);
                 // aiactor.transform.position += PhysicsEngine.PixelToUnit(intVector);
                 aiactor.transform.position += PhysicsEngine.PixelToUnit(intVector).ToVector3ZUp(1f);
                 aiactor.specRigidbody.Reinitialize();
                 if (i == 0)
                 {
                     aiactor.aiAnimator.FacingDirection = 180f;
                 }
                 else if (i == selectedEnemyGuids.Length - 1)
                 {
                     aiactor.aiAnimator.FacingDirection = 0f;
                 }
                 HandleSpawn(aiactor);
                 list.Add(aiactor.specRigidbody);
             }
         }
         for (int j = 0; j < list.Count; j++)
         {
             for (int k = 0; k < list.Count; k++)
             {
                 if (j != k)
                 {
                     list[j].RegisterGhostCollisionException(list[k]);
                 }
             }
         }
     }
     else if (spawnPosition == SpawnPosition.ScreenEdge)
     {
         for (int l = 0; l < selectedEnemyGuids.Length; l++)
         {
             AIActor orLoadByGuid2 = EnemyDatabase.GetOrLoadByGuid(selectedEnemyGuids[l]);
             AIActor spawnedActor  = AIActor.Spawn(orLoadByGuid2, specRigidbody.UnitCenter.ToIntVector2(VectorConversions.Floor), aiActor.ParentRoom, false, AIActor.AwakenAnimationType.Default, true);
             if (spawnedActor)
             {
                 Vector2       cameraBottomLeft = BraveUtility.ViewportToWorldpoint(new Vector2(0f, 0f), ViewportType.Gameplay);
                 Vector2       cameraTopRight   = BraveUtility.ViewportToWorldpoint(new Vector2(1f, 1f), ViewportType.Gameplay);
                 IntVector2    bottomLeft       = cameraBottomLeft.ToIntVector2(VectorConversions.Ceil);
                 IntVector2    topRight         = cameraTopRight.ToIntVector2(VectorConversions.Floor) - IntVector2.One;
                 CellValidator cellValidator    = delegate(IntVector2 c) {
                     for (int num2 = 0; num2 < spawnedActor.Clearance.x; num2++)
                     {
                         for (int num3 = 0; num3 < spawnedActor.Clearance.y; num3++)
                         {
                             if (GameManager.Instance.Dungeon.data.isTopWall(c.x + num2, c.y + num3))
                             {
                                 return(false);
                             }
                             if (GameManager.Instance.Dungeon.data[c.x + num2, c.y + num3].isExitCell)
                             {
                                 return(false);
                             }
                         }
                     }
                     return(c.x >= bottomLeft.x && c.y >= bottomLeft.y && c.x + spawnedActor.Clearance.x - 1 <= topRight.x && c.y + spawnedActor.Clearance.y - 1 <= topRight.y);
                 };
                 Func <IntVector2, float> cellWeightFinder = delegate(IntVector2 c) {
                     float a3 = float.MaxValue;
                     a3 = Mathf.Min(a3, c.x - cameraBottomLeft.x);
                     a3 = Mathf.Min(a3, c.y - cameraBottomLeft.y);
                     a3 = Mathf.Min(a3, cameraTopRight.x - c.x + spawnedActor.Clearance.x);
                     return(Mathf.Min(a3, cameraTopRight.y - c.y + spawnedActor.Clearance.y));
                 };
                 Vector2    b = spawnedActor.specRigidbody.UnitCenter - spawnedActor.transform.position.XY();
                 IntVector2?randomWeightedAvailableCell = spawnedActor.ParentRoom.GetRandomWeightedAvailableCell(new IntVector2?(spawnedActor.Clearance), new CellTypes?(spawnedActor.PathableTiles), false, cellValidator, cellWeightFinder, 0.25f);
                 if (randomWeightedAvailableCell == null)
                 {
                     Debug.LogError("Screen Edge Spawn FAILED!", spawnedActor);
                     Destroy(spawnedActor);
                 }
                 else
                 {
                     spawnedActor.transform.position = Pathfinder.GetClearanceOffset(randomWeightedAvailableCell.Value, spawnedActor.Clearance) - b;
                     spawnedActor.specRigidbody.Reinitialize();
                     HandleSpawn(spawnedActor);
                 }
             }
         }
     }
     else if (spawnPosition == SpawnPosition.InsideRadius)
     {
         Vector2 unitCenter = specRigidbody.GetUnitCenter(ColliderType.HitBox);
         List <SpeculativeRigidbody> list2 = new List <SpeculativeRigidbody>();
         list2.Add(specRigidbody);
         for (int m = 0; m < selectedEnemyGuids.Length; m++)
         {
             Vector2 vector2 = unitCenter + UnityEngine.Random.insideUnitCircle * spawnRadius;
             if (GameManager.Instance.CurrentLevelOverrideState == GameManager.LevelOverrideState.CHARACTER_PAST && SceneManager.GetActiveScene().name == "fs_robot")
             {
                 RoomHandler entrance = GameManager.Instance.Dungeon.data.Entrance;
                 Vector2     lhs      = entrance.area.basePosition.ToVector2() + new Vector2(7f, 7f);
                 Vector2     lhs2     = entrance.area.basePosition.ToVector2() + new Vector2(38f, 36f);
                 vector2 = Vector2.Min(lhs2, Vector2.Max(lhs, vector2));
             }
             AIActor orLoadByGuid3 = EnemyDatabase.GetOrLoadByGuid(selectedEnemyGuids[m]);
             AIActor aiactor2      = AIActor.Spawn(orLoadByGuid3, unitCenter.ToIntVector2(VectorConversions.Floor), aiActor.ParentRoom, true, AIActor.AwakenAnimationType.Default, true);
             if (aiactor2)
             {
                 aiactor2.specRigidbody.Initialize();
                 Vector2 unit = vector2 - aiactor2.specRigidbody.GetUnitCenter(ColliderType.HitBox);
                 aiactor2.specRigidbody.ImpartedPixelsToMove = PhysicsEngine.UnitToPixel(unit);
                 HandleSpawn(aiactor2);
                 list2.Add(aiactor2.specRigidbody);
             }
         }
         for (int n = 0; n < list2.Count; n++)
         {
             for (int num = 0; num < list2.Count; num++)
             {
                 if (n != num)
                 {
                     list2[n].RegisterGhostCollisionException(list2[num]);
                 }
             }
         }
     }
     else
     {
         Debug.LogError("Unknown spawn type: " + spawnPosition);
     }
 }
예제 #3
0
        private void EnemyModRandomizer(AIActor targetActor)
        {
            // Finding too many issues being caused with Bosses to allow shader modifications on them.
            if (targetActor.healthHaver != null && targetActor.healthHaver.IsBoss)
            {
                return;
            }

            bool hasAltSkin = false;
            bool hasShader  = false;

            if (GameManager.Instance.Dungeon.tileIndices.tilesetId == GlobalDungeonData.ValidTilesets.PHOBOSGEON)
            {
                if (targetActor.EnemyGuid == "ba928393c8ed47819c2c5f593100a5bc")
                {
                    ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: ChaosPrefabs.StoneCubeCollection_West);
                }
            }

            if (ChaosConsole.isHardMode | ChaosConsole.isUltraMode)
            {
                if (ChaosLists.PreventBeingJammedOverrideList.Contains(targetActor.EnemyGuid))
                {
                    targetActor.PreventBlackPhantom = true;
                }
                if (ChaosLists.PreventDeathOnBossKillList.Contains(targetActor.EnemyGuid))
                {
                    targetActor.PreventAutoKillOnBossDeath = true;
                }
                if (targetActor.EnemyGuid == "eeb33c3a5a8e4eaaaaf39a743e8767bc")
                {
                    targetActor.AlwaysShowOffscreenArrow = true;
                }

                if ((targetActor.EnemyGuid == "128db2f0781141bcb505d8f00f9e4d47" | targetActor.EnemyGuid == "b54d89f9e802455cbb2b8a96a31e8259") && UnityEngine.Random.value < 0.3f)
                {
                    if (RedShotGunMan.BootlegRedShotGunManCollection == null)
                    {
                        RedShotGunMan.Init();
                    }
                    targetActor.optionalPalette             = null;
                    targetActor.procedurallyOutlined        = false;
                    targetActor.sprite.OverrideMaterialMode = tk2dBaseSprite.SpriteMaterialOverrideMode.NONE;
                    targetActor.sprite.renderer.material.SetTexture("_PaletteTex", null);
                    FieldInfo field = typeof(AIActor).GetField("m_isPaletteSwapped", BindingFlags.Instance | BindingFlags.NonPublic);
                    field.SetValue(targetActor, false);
                    if (targetActor.EnemyGuid == "128db2f0781141bcb505d8f00f9e4d47")
                    {
                        ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: RedShotGunMan.BootlegRedShotGunManCollection);
                    }
                    else
                    {
                        ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: BlueShotGunMan.BootlegBlueShotGunManCollection);
                    }
                    targetActor.OverrideDisplayName = ("Bootleg " + targetActor.GetActorName());
                    targetActor.ActorName          += "ALT";
                    hasAltSkin = true;
                    return;
                }
                if ((targetActor.EnemyGuid == "01972dee89fc4404a5c408d50007dad5" | targetActor.EnemyGuid == "db35531e66ce41cbb81d507a34366dfe") && UnityEngine.Random.value < 0.3f)
                {
                    float Selector = UnityEngine.Random.Range(0, 3);
                    if (Selector < 1)
                    {
                        if (BulletMan.BootlegBulletManCollection == null)
                        {
                            BulletMan.Init(targetActor);
                        }
                        ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: ChaosPrefabs.BulletManMonochromeCollection, overrideShader: ShaderCache.Acquire("tk2d/BlendVertexColorUnlitTilted"));
                        targetActor.OverrideDisplayName = ("1-Bit " + targetActor.GetActorName());
                        targetActor.ActorName          += "ALT";
                        hasAltSkin = true;
                        return;
                    }
                    else if (Selector >= 1)
                    {
                        ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: ChaosPrefabs.BulletManUpsideDownCollection);
                        targetActor.OverrideDisplayName = ("Bizarro " + targetActor.GetActorName());
                        targetActor.ActorName          += "ALT";
                        hasAltSkin = true;
                        return;
                    }
                    else if (Selector >= 2)
                    {
                        ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: BulletMan.BootlegBulletManCollection, overrideShader: ShaderCache.Acquire("tk2d/BlendVertexColorUnlitTilted"));
                        targetActor.OverrideDisplayName = ("Bootleg " + targetActor.GetActorName());
                        targetActor.ActorName          += "ALT";
                        hasAltSkin = true;
                        return;
                    }
                    return;
                }
                if (targetActor.EnemyGuid == "88b6b6a93d4b4234a67844ef4728382c" && UnityEngine.Random.value < 0.32f)
                {
                    if (BulletManBandana.BootlegBulletManBandanaCollection == null)
                    {
                        BulletManBandana.Init(targetActor);
                    }
                    ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: BulletManBandana.BootlegBulletManBandanaCollection, overrideShader: ShaderCache.Acquire("tk2d/BlendVertexColorUnlitTilted"));
                    targetActor.OverrideDisplayName = ("Bootleg " + targetActor.GetActorName());
                    targetActor.ActorName          += "ALT";
                    hasAltSkin = true;
                    return;
                }
                if (targetActor.EnemyGuid == "14ea47ff46b54bb4a98f91ffcffb656d" && BraveUtility.RandomBool())
                {
                    if (RatGrenade.RatGrenadeCollection == null)
                    {
                        RatGrenade.Init(targetActor);
                    }
                    ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: RatGrenade.RatGrenadeCollection);
                    targetActor.healthHaver.gameObject.AddComponent <ChaosExplodeOnDeath>();
                    ExplodeOnDeath RatExplodeComponent = targetActor.healthHaver.gameObject.GetComponent <ExplodeOnDeath>();
                    RatExplodeComponent.explosionData            = EnemyDatabase.GetOrLoadByGuid("b4666cb6ef4f4b038ba8924fd8adf38f").gameObject.GetComponent <ExplodeOnDeath>().explosionData;
                    RatExplodeComponent.deathType                = OnDeathBehavior.DeathType.Death;
                    RatExplodeComponent.triggerName              = string.Empty;
                    RatExplodeComponent.immuneToIBombApp         = false;
                    RatExplodeComponent.LinearChainExplosion     = false;
                    RatExplodeComponent.LinearChainExplosionData = EnemyDatabase.GetOrLoadByGuid("b4666cb6ef4f4b038ba8924fd8adf38f").gameObject.GetComponent <ExplodeOnDeath>().LinearChainExplosionData;
                    targetActor.CorpseObject = null;
                    hasAltSkin = true;
                    return;
                }

                if (targetActor.EnemyGuid == "2feb50a6a40f4f50982e89fd276f6f15" && BraveUtility.RandomBool())
                {
                    if (Bullat.BootlegBullatCollection == null)
                    {
                        Bullat.Init(targetActor);
                    }
                    ChaosUtility.ApplyCustomTexture(targetActor, prebuiltCollection: Bullat.BootlegBullatCollection);
                    AIActor TinyBlobulord = EnemyDatabase.GetOrLoadByGuid("d1c9781fdac54d9e8498ed89210a0238");
                    targetActor.behaviorSpeculator.OtherBehaviors    = TinyBlobulord.behaviorSpeculator.OtherBehaviors;
                    targetActor.behaviorSpeculator.TargetBehaviors   = TinyBlobulord.behaviorSpeculator.TargetBehaviors;
                    targetActor.behaviorSpeculator.OverrideBehaviors = TinyBlobulord.behaviorSpeculator.OverrideBehaviors;
                    targetActor.behaviorSpeculator.AttackBehaviors   = TinyBlobulord.behaviorSpeculator.AttackBehaviors;
                    targetActor.behaviorSpeculator.MovementBehaviors = TinyBlobulord.behaviorSpeculator.MovementBehaviors;
                    targetActor.DiesOnCollison       = true;
                    targetActor.procedurallyOutlined = false;
                    targetActor.OverrideDisplayName  = ("Bootleg " + targetActor.GetActorName());
                    hasAltSkin = true;
                    return;
                }

                if (!hasAltSkin && targetActor.EnemyGuid != "5e0af7f7d9de4755a68d2fd3bbc15df4")
                {
                    if (UnityEngine.Random.value <= 0.2f && !targetActor.IsBlackPhantom)
                    {
                        ChaosShaders.Instance.BecomeHologram(targetActor, BraveUtility.RandomBool());
                        hasShader = true;
                        return;
                    }
                    else if (UnityEngine.Random.value <= 0.16f && !targetActor.IsBlackPhantom)
                    {
                        ChaosShaders.Instance.ApplySpaceShader(targetActor.sprite);
                        hasShader = true;
                        return;
                    }
                    else if (UnityEngine.Random.value <= 0.15f && !targetActor.IsBlackPhantom)
                    {
                        ChaosShaders.Instance.BecomeRainbow(targetActor);
                        hasShader = true;
                        return;
                    }
                    else if (UnityEngine.Random.value <= 0.1f && !targetActor.IsBlackPhantom)
                    {
                        ChaosShaders.Instance.BecomeCosmicHorror(targetActor.sprite);
                        hasShader = true;
                        return;
                    }
                    else if (UnityEngine.Random.value <= 0.065f && !targetActor.IsBlackPhantom)
                    {
                        ChaosShaders.Instance.BecomeGalaxy(targetActor.sprite);
                        hasShader = true;
                        return;
                    }
                }
            }

            if (!hasAltSkin && !hasShader && ChaosConsole.GlitchEnemies && targetActor.EnemyGuid != "5e0af7f7d9de4755a68d2fd3bbc15df4" && !targetActor.IsBlackPhantom && UnityEngine.Random.value <= ChaosConsole.GlitchRandomActors)
            {
                float RandomIntervalFloat       = UnityEngine.Random.Range(0.02f, 0.06f);
                float RandomDispFloat           = UnityEngine.Random.Range(0.1f, 0.16f);
                float RandomDispIntensityFloat  = UnityEngine.Random.Range(0.1f, 0.4f);
                float RandomColorProbFloat      = UnityEngine.Random.Range(0.05f, 0.2f);
                float RnadomColorIntensityFloat = UnityEngine.Random.Range(0.1f, 0.25f);

                if (!targetActor.sprite.usesOverrideMaterial && !ChaosLists.DontGlitchMeList.Contains(targetActor.EnemyGuid))
                {
                    ChaosShaders.Instance.BecomeGlitched(targetActor, RandomIntervalFloat, RandomDispFloat, RandomDispIntensityFloat, RandomColorProbFloat, RnadomColorIntensityFloat);
                    if (!targetActor.healthHaver.IsBoss && !ChaosLists.blobsAndCritters.Contains(targetActor.EnemyGuid) && targetActor.GetComponent <ChaosSpawnGlitchObjectOnDeath>() == null)
                    {
                        if (UnityEngine.Random.value <= 0.25)
                        {
                            targetActor.gameObject.AddComponent <ChaosSpawnGlitchObjectOnDeath>();
                        }
                    }
                    ChaosGlitchedEnemies.GlitchExistingEnemy(targetActor);
                    if (!ChaosConsole.randomEnemySizeEnabled)
                    {
                        if (targetActor.healthHaver != null)
                        {
                            if (!targetActor.healthHaver.IsBoss)
                            {
                                targetActor.healthHaver.SetHealthMaximum(targetActor.healthHaver.GetMaxHealth() / 1.5f, null, false);
                            }
                            else
                            {
                                targetActor.healthHaver.SetHealthMaximum(targetActor.healthHaver.GetMaxHealth() / 1.25f, null, false);
                            }
                        }
                    }
                    if (UnityEngine.Random.value <= 0.1f && targetActor.EnemyGuid != "4d37ce3d666b4ddda8039929225b7ede" && targetActor.EnemyGuid != "19b420dec96d4e9ea4aebc3398c0ba7a" && targetActor.GetComponent <ExplodeOnDeath>() == null && targetActor.GetComponent <ChaosSpawnGlitchObjectOnDeath>() == null && targetActor.GetComponent <ChaosSpawnGlitchEnemyOnDeath>() == null)
                    {
                        try { targetActor.gameObject.AddComponent <ChaosExplodeOnDeath>(); } catch (Exception) { }
                    }
                }
                return;
            }
        }
예제 #4
0
 public ChaosGlitchedEnemyRandomizer()
 {
     m_GlitchEnemyDatabase = new ChaosGlitchedEnemies();
 }
예제 #5
0
        private void InitObjectMods(Dungeon dungeon)
        {
            // Disable victory music for Ser Manuel if not on tutorial floor. (it can cause double music bug if you kill him on other floors)
            if (dungeon.LevelOverrideType != GameManager.LevelOverrideState.TUTORIAL)
            {
                ChaosPrefabs.SerManuel.healthHaver.forcePreventVictoryMusic = true;
            }
            else
            {
                ChaosPrefabs.SerManuel.healthHaver.forcePreventVictoryMusic = false;
            }

            // Assign pitfall destination to entrance on Floor 1 if in Bossrush mode and special entrance room to Miniboss room path is available.
            if (GameManager.Instance.CurrentGameMode == GameManager.GameMode.BOSSRUSH |
                GameManager.Instance.CurrentGameMode == GameManager.GameMode.SUPERBOSSRUSH)
            {
                List <RoomHandler> RoomList         = dungeon.data.rooms;
                RoomHandler        MinibossEntrance = null;
                foreach (RoomHandler specificRoom in RoomList)
                {
                    if (specificRoom.GetRoomName().ToLower().StartsWith("elevatormaintenance") && dungeon.tileIndices.tilesetId == GlobalDungeonData.ValidTilesets.CASTLEGEON)
                    {
                        MinibossEntrance = specificRoom;
                        if (dungeon.data.Entrance != null && dungeon.data.Entrance.GetRoomName().ToLower().StartsWith("elevator entrance"))
                        {
                            dungeon.data.Entrance.TargetPitfallRoom     = specificRoom;
                            dungeon.data.Entrance.ForcePitfallForFliers = true;
                        }
                    }
                }
            }
            if (ChaosConsole.isHardMode | ChaosConsole.isUltraMode | ChaosConsole.GlitchEverything)
            {
                foreach (BraveBehaviour targetObject in FindObjectsOfType <BraveBehaviour>())
                {
                    ChaosShaders.Instance.ChaosShaderRandomizer(targetObject, UnityEngine.Random.value);
                }
            }
            else if (dungeon.IsGlitchDungeon | ChaosDungeonFlows.isGlitchFlow)
            {
                foreach (AIActor enemy in FindObjectsOfType <AIActor>())
                {
                    if (!ChaosLists.DontGlitchMeList.Contains(enemy.EnemyGuid) && !enemy.IsBlackPhantom && !enemy.healthHaver.IsBoss)
                    {
                        if (UnityEngine.Random.value <= 0.6f && !enemy.healthHaver.IsBoss)
                        {
                            ChaosShaders.Instance.BecomeGlitched(enemy, 0.04f, 0.07f, 0.05f, 0.07f, 0.05f);
                            ChaosGlitchedEnemies.GlitchExistingEnemy(enemy);
                        }
                        if (UnityEngine.Random.value <= 0.25f && !enemy.healthHaver.IsBoss && !ChaosLists.blobsAndCritters.Contains(enemy.EnemyGuid) && enemy.GetComponent <ChaosSpawnGlitchObjectOnDeath>() == null)
                        {
                            enemy.gameObject.AddComponent <ChaosSpawnGlitchObjectOnDeath>();
                        }
                    }
                }
                foreach (BraveBehaviour targetObject in FindObjectsOfType <BraveBehaviour>())
                {
                    if (UnityEngine.Random.value <= ChaosConsole.GlitchRandomAll && targetObject.aiActor == null)
                    {
                        ChaosShaders.Instance.BecomeGlitched(targetObject, 0.04f, 0.07f, 0.05f, 0.07f, 0.05f);
                    }
                }
            }

            if (dungeon.LevelOverrideType == GameManager.LevelOverrideState.RESOURCEFUL_RAT | dungeon.LevelOverrideType == GameManager.LevelOverrideState.TUTORIAL | dungeon.LevelOverrideType != GameManager.LevelOverrideState.NONE)
            {
                if (ChaosConsole.debugMimicFlag)
                {
                    ETGModConsole.Log("[DEBUG] This floor has been excluded from having additional objects.", false);
                }
            }
            else
            {
                ChaosObjectRandomizer randomizer = new ChaosObjectRandomizer();
                randomizer.PlaceRandomObjects(dungeon, GameManager.Instance.CurrentFloor);
                Destroy(randomizer);
            }

            if (dungeon.LevelOverrideType == GameManager.LevelOverrideState.RESOURCEFUL_RAT | dungeon.LevelOverrideType == GameManager.LevelOverrideState.TUTORIAL | dungeon.LevelOverrideType != GameManager.LevelOverrideState.NONE)
            {
                if (ChaosConsole.debugMimicFlag)
                {
                    ETGModConsole.Log("[DEBUG] This floor has been excluded from having additional glitch enemies.", false);
                }
            }
            else
            {
                ChaosGlitchedEnemyRandomizer m_GlitchEnemyRandomizer = new ChaosGlitchedEnemyRandomizer();
                m_GlitchEnemyRandomizer.PlaceRandomEnemies(dungeon, GameManager.Instance.CurrentFloor);
                Destroy(m_GlitchEnemyRandomizer);
            }

            if (ChaosUtility.RatDungeon != null)
            {
                ChaosUtility.RatDungeon = null;
            }
        }