private void HandleRatBossSetup()
        {
            GameObject SpecialRatBoss = DungeonPlaceableUtility.InstantiateDungeonPlaceable(EnemyDatabase.GetOrLoadByGuid("6868795625bd46f3ae3e4377adce288b").gameObject, m_ParentRoom, new IntVector2(17, 28), true, AIActor.AwakenAnimationType.Awaken, true);
            AIActor    RatBossAIActor = SpecialRatBoss.GetComponent <AIActor>();

            if (RatBossAIActor != null)
            {
                PickupObject.ItemQuality targetQuality = (UnityEngine.Random.value >= 0.2f) ? ((!BraveUtility.RandomBool()) ? PickupObject.ItemQuality.C : PickupObject.ItemQuality.D) : PickupObject.ItemQuality.B;
                GenericLootTable         lootTable     = (!BraveUtility.RandomBool()) ? GameManager.Instance.RewardManager.GunsLootTable : GameManager.Instance.RewardManager.ItemsLootTable;
                PickupObject             item          = LootEngine.GetItemOfTypeAndQuality <PickupObject>(targetQuality, lootTable, false);
                PickupObject             item2         = LootEngine.GetItemOfTypeAndQuality <PickupObject>(targetQuality, lootTable, false);
                Destroy(RatBossAIActor.gameObject.GetComponent <ResourcefulRatDeathController>());
                Destroy(RatBossAIActor.gameObject.GetComponent <ResourcefulRatRewardRoomController>());
                RatBossAIActor.State        = AIActor.ActorState.Awakening;
                RatBossAIActor.StealthDeath = true;
                RatBossAIActor.healthHaver.gameObject.AddComponent <ExpandSpawnGlitchObjectOnDeath>();
                ExpandSpawnGlitchObjectOnDeath ObjectSpawnerComponent = RatBossAIActor.healthHaver.gameObject.GetComponent <ExpandSpawnGlitchObjectOnDeath>();
                ObjectSpawnerComponent.spawnRatCorpse     = true;
                ObjectSpawnerComponent.ratCorpseSpawnsKey = true;
                ObjectSpawnerComponent.parentEnemyWasRat  = true;
                if (item && item2)
                {
                    RatBossAIActor.AdditionalSafeItemDrops = new List <PickupObject> {
                        item, item2
                    };
                }
                RatBossAIActor.healthHaver.enabled = true;
                RatBossAIActor.healthHaver.forcePreventVictoryMusic = true;
                RatBossAIActor.ConfigureOnPlacement(m_ParentRoom);
                RatBossAIActor.specRigidbody.CollideWithOthers = true;
            }
        }
Beispiel #2
0
        public void OnDestruction(Projectile projectile)
        {
            AIActor childAIActor = projectile.GetComponentInChildren <AIActor>();

            List <SpeculativeRigidbody> m_IgnoreRigidBodies = new List <SpeculativeRigidbody>();

            if (childAIActor)
            {
                childAIActor.specRigidbody.enabled = true;
                childAIActor.specRigidbody.HitboxPixelCollider.IsTrigger = true;
                childAIActor.specRigidbody.HitboxPixelCollider.CollisionLayerIgnoreOverride |= CollisionMask.LayerToMask(CollisionLayer.Projectile);
                childAIActor.specRigidbody.AddCollisionLayerIgnoreOverride(CollisionMask.LayerToMask(CollisionLayer.PlayerHitBox, CollisionLayer.PlayerCollider));
                childAIActor.sprite.UpdateZDepth();
                childAIActor.specRigidbody.UpdateCollidersOnScale    = true;
                childAIActor.specRigidbody.UpdateCollidersOnRotation = true;
                childAIActor.specRigidbody.Reinitialize();
                childAIActor.specRigidbody.OnPreRigidbodyCollision = (SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate)Delegate.Combine(childAIActor.specRigidbody.OnPreRigidbodyCollision, new SpeculativeRigidbody.OnPreRigidbodyCollisionDelegate(HandlePreCollision));

                if (m_FiresJammedEnemies && UnityEngine.Random.value <= 0.9f)
                {
                    childAIActor.CanDropCurrency = false;
                }

                Dungeonator.RoomHandler CurrentRoom = projectile.transform.position.GetAbsoluteRoom();

                if (childAIActor.EnemyGuid == "128db2f0781141bcb505d8f00f9e4d47" | childAIActor.EnemyGuid == "b54d89f9e802455cbb2b8a96a31e8259")
                {
                    childAIActor.healthHaver.spawnBulletScript = false;
                }

                if (CurrentRoom == null)
                {
                    childAIActor.gameObject.transform.parent = null;
                    if (childAIActor.gameObject.GetComponent <ExplodeOnDeath>() && childAIActor.gameObject.GetComponent <ExplodeOnDeath>().explosionData != null)
                    {
                        childAIActor.gameObject.GetComponent <ExplodeOnDeath>().explosionData.ignoreList     = new List <SpeculativeRigidbody>();
                        childAIActor.gameObject.GetComponent <ExplodeOnDeath>().explosionData.damageToPlayer = 0;
                        if (projectile.Owner && (projectile.Owner is PlayerController))
                        {
                            childAIActor.gameObject.GetComponent <ExplodeOnDeath>().explosionData.ignoreList.Add(projectile.Owner.specRigidbody);
                        }
                    }
                    childAIActor.healthHaver.ApplyDamage(10000, Vector2.zero, "Self Destruct", CoreDamageTypes.None, DamageCategory.Unstoppable, true, ignoreDamageCaps: true);
                    return;
                }
                childAIActor.gameObject.transform.parent = CurrentRoom.hierarchyParent;
                float SurvivalOdds = 0.08f;
                if (m_FiresJammedEnemies)
                {
                    SurvivalOdds += 0.03f;
                }
                if (UnityEngine.Random.value <= SurvivalOdds && CurrentRoom.HasActiveEnemies(Dungeonator.RoomHandler.ActiveEnemyType.RoomClear))
                {
                    if (childAIActor.EnemyScale == Vector2.one)
                    {
                        childAIActor.procedurallyOutlined = true;
                    }
                    ;
                    ExpandUtility.CorrectForWalls(childAIActor);
                    childAIActor.CanTargetEnemies   = true;
                    childAIActor.CanTargetPlayers   = false;
                    childAIActor.IgnoreForRoomClear = true;

                    if (childAIActor.gameObject.GetComponent <ObjectVisibilityManager>())
                    {
                        childAIActor.gameObject.GetComponent <ObjectVisibilityManager>().Initialize(CurrentRoom, true);
                    }
                    if (childAIActor.bulletBank)
                    {
                        childAIActor.bulletBank.OnProjectileCreated = (Action <Projectile>)Delegate.Combine(childAIActor.bulletBank.OnProjectileCreated, new Action <Projectile>(HandleCompanionPostProcessProjectile));
                    }
                    if (childAIActor.aiShooter)
                    {
                        childAIActor.aiShooter.PostProcessProjectile = (Action <Projectile>)Delegate.Combine(childAIActor.aiShooter.PostProcessProjectile, new Action <Projectile>(HandleCompanionPostProcessProjectile));
                    }
                    childAIActor.ConfigureOnPlacement(CurrentRoom);
                    childAIActor.gameObject.AddComponent <KillOnRoomClear>();
                    return;
                }
                else
                {
                    if (CurrentRoom != null)
                    {
                        childAIActor.ConfigureOnPlacement(CurrentRoom);
                        childAIActor.gameObject.transform.parent = CurrentRoom.hierarchyParent;
                    }
                    else
                    {
                        childAIActor.gameObject.transform.parent = null;
                    }
                    if (childAIActor.gameObject.GetComponent <ExplodeOnDeath>() && childAIActor.gameObject.GetComponent <ExplodeOnDeath>().explosionData != null)
                    {
                        childAIActor.gameObject.GetComponent <ExplodeOnDeath>().explosionData.ignoreList     = new List <SpeculativeRigidbody>();
                        childAIActor.gameObject.GetComponent <ExplodeOnDeath>().explosionData.damageToPlayer = 0;
                        if (projectile.Owner && (projectile.Owner is PlayerController))
                        {
                            childAIActor.gameObject.GetComponent <ExplodeOnDeath>().explosionData.ignoreList.Add(projectile.Owner.specRigidbody);
                        }
                    }
                    childAIActor.healthHaver.ApplyDamage(10000, Vector2.zero, "Self Destruct", CoreDamageTypes.None, DamageCategory.Unstoppable, true, ignoreDamageCaps: true);
                    return;
                }
            }
        }