public static GameObject ReinstateBossObjectInfo(GameObject bossobject)
        {   //After removing boss intro, need to reinstate behavior to have it active, awake and have specbody.
            //otherwise they stand there and don't take damage
            //this method also handles specific bosses

            bossobject = ReinstateAIActorObjectInfo(bossobject);
            AIActor bosscomponent = bossobject.GetComponent <AIActor>();

            if (bosscomponent)
            {
                if (bosscomponent.EnemyGuid == "05b8afe0b6cc4fffa9dc6036fa24c8ec" | bosscomponent.EnemyGuid == "465da2bb086a4a88a803f79fe3a27677"
                    | bosscomponent.EnemyGuid == "880bbe4ce1014740ba6b4e2ea521e49d" | bosscomponent.EnemyGuid == "b98b10fca77d469e80fb45f3c5badec5"
                    | bosscomponent.EnemyGuid == "8b913eea3d174184be1af362d441910d" | bosscomponent.EnemyGuid == "8d441ad4e9924d91b6070d5b3438d066"
                    | bosscomponent.EnemyGuid == "dc3cd41623d447aeba77c77c99598426")
                // advancedDragun | dragun | Last Human | Hyperion | Baldy | Frankenstein | InterdimensionalHorror
                {//need this to be able to shoot boss
                    ObjectVisibilityManager objectvisibilitymanager = bosscomponent.GetComponent <ObjectVisibilityManager>();
                    objectvisibilitymanager.SuppressPlayerEnteredRoom = false;
                }

                if (bosscomponent.EnemyGuid == "2ccaa1b7ae10457396a1796decda9cf6") // agunim
                {
                    bosscomponent.healthHaver.OnlyAllowSpecialBossDamage = false;
                }
            }

            return(bossobject);
        }
        public void Awake()
        {
            ObjectVisibilityManager visibilityManager = base.visibilityManager;

            visibilityManager.OnToggleRenderers = (Action)Delegate.Combine(visibilityManager.OnToggleRenderers, new Action(OnToggleRenderers));
            aiActor.IsGone = true;
        }
 protected override void OnDestroy()
 {
     if (base.visibilityManager)
     {
         ObjectVisibilityManager visibilityManager = base.visibilityManager;
         visibilityManager.OnToggleRenderers = (Action)Delegate.Remove(visibilityManager.OnToggleRenderers, new Action(OnToggleRenderers));
     }
     base.OnDestroy();
 }
Esempio n. 4
0
        public static GameObject MainHook(GameObject objectToInstantiate, RoomHandler targetRoom,
                                          IntVector2 location, bool deferConfiguration, AIActor.AwakenAnimationType awakenAnimType = AIActor.AwakenAnimationType.Default, bool autoEngage = false)
        {   //hooks into InstantiateDungeonPlaceable
            GameObject result;

            System.Random rnd = new System.Random();
            int           nu  = 0;
            string        enemyGuid;

            GRandomHook.wasBoss = false;
            bool isbossroom = false;


            if (targetRoom.area.PrototypeRoomCategory == PrototypeDungeonRoom.RoomCategory.BOSS &&
                targetRoom.area.PrototypeRoomBossSubcategory == PrototypeDungeonRoom.RoomBossSubCategory.FLOOR_BOSS)
            {
                isbossroom = true;
            }

            else if (GRandomRoomDatabaseHelper.AllSpecificDeathRooms.Contains(targetRoom.GetRoomName()))
            {
                isbossroom = true;
            }


            try
            {
                if (objectToInstantiate != null)
                {
                    Vector3 vector = location.ToVector3(0f) + targetRoom.area.basePosition.ToVector3();
                    vector.z = vector.y + vector.z;
                    AIActor component   = objectToInstantiate.GetComponent <AIActor>(); //notused
                    AIActor ogcomponent = component;


                    if (component is AIActorDummy)
                    {
                        objectToInstantiate = (component as AIActorDummy).realPrefab;
                        component           = objectToInstantiate.GetComponent <AIActor>();
                    }

                    SpeculativeRigidbody component2 = objectToInstantiate.GetComponent <SpeculativeRigidbody>(); //notused
                    if (component && component2)
                    {
                        if (component.EnemyGuid != null)
                        {
                            //Here gets enemyGuid based on room. Pulls from EnemyDatabase   ///////////////////////
                            if (isbossroom)
                            {
                                if (component.healthHaver.IsBoss)
                                {
                                    GRandomHook.wasBoss = true;
                                    if (component.healthHaver.GetMaxHealth() != 60) //sometimes gets health as regular enemy health, 60
                                    {
                                        GRandomHook.boss_health = component.healthHaver.GetMaxHealth();
                                        //getting boss health to set for replacement boss
                                    }

                                    //replacement for Boss
                                    nu        = rnd.Next(0, GRandomEnemyDataBaseHelper.UsedBossRoomDatabase.Count);
                                    enemyGuid = GRandomEnemyDataBaseHelper.UsedBossRoomDatabase[nu];
                                }


                                else
                                { //normal enemies as bosses is off and the enemy is not a boss; pull from no bosses database for enemy spawnings
                                    nu        = rnd.Next(0, GRandomEnemyDataBaseHelper.BossRoomRegularEnemiesOnly.Count);
                                    enemyGuid = GRandomEnemyDataBaseHelper.BossRoomRegularEnemiesOnly[nu];
                                }
                            }

                            else if (targetRoom.GetRoomName() == "ResourcefulRat_PitEntrance_01" | targetRoom.GetRoomName() == "ResourcefulRat_Entrance")
                            {
                                nu        = rnd.Next(0, GRandomEnemyDataBaseHelper.HarmlessEnemyDatabase.Count);
                                enemyGuid = GRandomEnemyDataBaseHelper.HarmlessEnemyDatabase[nu];
                            }

                            else
                            {
                                nu        = rnd.Next(0, GRandomEnemyDataBaseHelper.UsedRegularRoomDatabase.Count);
                                enemyGuid = GRandomEnemyDataBaseHelper.UsedRegularRoomDatabase[nu];
                            }


                            if (component.EnemyGuid == "479556d05c7c44f3b6abb3b2067fc778") //wallmimic
                            {
                                enemyGuid = "479556d05c7c44f3b6abb3b2067fc778";
                            }

                            //
                            //can add specific Guid here for debugging
                            //


                            if (enemyGuid == "465da2bb086a4a88a803f79fe3a27677") //replace DraGun, can't remove him from database or forge dragunroom breaks
                            {
                                enemyGuid = "05b8afe0b6cc4fffa9dc6036fa24c8ec";
                            }

                            // End getting guid //////////////////////////////

                            //initializing new AIActor, not sure why they do it again below
                            AIActor prefabActor = EnemyDatabase.GetOrLoadByGuid(enemyGuid);


                            objectToInstantiate = prefabActor.gameObject;
                            component           = objectToInstantiate.GetComponent <AIActor>();
                            component2          = objectToInstantiate.GetComponent <SpeculativeRigidbody>();
                            //bool specificdeathdoer = prefabActor.healthHaver.ManualDeathHandling;



                            GenericIntroDoer genericIntroDoer = component.GetComponent <GenericIntroDoer>();

                            //if (genericIntroDoer) // is boss
                            // handles initiated boss settings
                            if (component.healthHaver.IsBoss)
                            {
                                if (isbossroom)
                                {
                                    prefabActor.healthHaver.SetHealthMaximum(GRandomHook.boss_health);
                                    ETGModConsole.Log("Newbosshealth " + prefabActor.healthHaver.GetMaxHealth());
                                }
                                else
                                {
                                    prefabActor.healthHaver.SetHealthMaximum(60f);
                                }

                                objectToInstantiate = RandomHandleEnemyInfo.RemoveBossIntros(objectToInstantiate);
                                objectToInstantiate = RandomHandleEnemyInfo.ReplaceSpecificBossDeathController(objectToInstantiate);
                                objectToInstantiate = RandomHandleEnemyInfo.AttackBehaviorManipulator(objectToInstantiate);

                                DemonWallController dwc = objectToInstantiate.GetComponent <DemonWallController>();
                                if (dwc)
                                {
                                    Destroy(dwc);
                                }
                            }

                            if (!component.IsNormalEnemy)
                            {
                                objectToInstantiate = RandomHandleEnemyInfo.HandleCompanions(objectToInstantiate);
                            }
                        }


                        PixelCollider pixelCollider = component2.GetPixelCollider(ColliderType.Ground);
                        if (pixelCollider.ColliderGenerationMode != PixelCollider.PixelColliderGeneration.Manual)
                        {
                            Debug.LogErrorFormat("Trying to spawn an AIActor who doesn't have a manual ground collider... do we still do this? Name: {0}", new object[]
                            {
                                objectToInstantiate.name
                            });
                        }
                        Vector2 a       = PhysicsEngine.PixelToUnit(new IntVector2(pixelCollider.ManualOffsetX, pixelCollider.ManualOffsetY));
                        Vector2 vector2 = PhysicsEngine.PixelToUnit(new IntVector2(pixelCollider.ManualWidth, pixelCollider.ManualHeight));
                        Vector2 vector3 = new Vector2((float)Mathf.CeilToInt(vector2.x), (float)Mathf.CeilToInt(vector2.y));
                        Vector2 b       = new Vector2((vector3.x - vector2.x) / 2f, 0f).Quantize(0.0625f);



                        if (targetRoom.GetRoomName() == "DraGunRoom01" | targetRoom.GetRoomName() == "LichRoom02" |
                            targetRoom.GetRoomName() == "LichRoom03" | targetRoom.GetRoomName() == "Bullet_End_Room_04" |
                            targetRoom.GetRoomName() == "ResourcefulRatRoom01")
                        {
                            b -= new Vector2(0.0f, 5.0f);
                        }

                        Vector3 v3 = a - b;
                        vector -= v3;
                        //vector -= a - b; //Vector3
                    }

                    if (component)
                    {
                        component.AwakenAnimType = awakenAnimType;
                    }


                    GameObject NewEnemyObject = UnityEngine.Object.Instantiate <GameObject>(objectToInstantiate, vector, Quaternion.identity);


                    if (!deferConfiguration)
                    {
                        Component[] componentsInChildren = NewEnemyObject.GetComponentsInChildren(typeof(IPlaceConfigurable));
                        for (int i = 0; i < componentsInChildren.Length; i++)
                        {
                            IPlaceConfigurable placeConfigurable = componentsInChildren[i] as IPlaceConfigurable;
                            if (placeConfigurable != null)
                            {
                                placeConfigurable.ConfigureOnPlacement(targetRoom);
                            }
                        }
                    }
                    ObjectVisibilityManager component3 = NewEnemyObject.GetComponent <ObjectVisibilityManager>();
                    if (component3 != null)
                    {
                        component3.Initialize(targetRoom, autoEngage);
                    }
                    MinorBreakable componentInChildren = NewEnemyObject.GetComponentInChildren <MinorBreakable>();
                    if (componentInChildren != null)
                    {
                        IntVector2 key      = location + targetRoom.area.basePosition;
                        CellData   cellData = GameManager.Instance.Dungeon.data[key];
                        if (cellData != null)
                        {
                            cellData.cellVisualData.containsObjectSpaceStamp = true;
                        }
                    }
                    PlayerItem component4 = NewEnemyObject.GetComponent <PlayerItem>();
                    if (component4 != null)
                    {
                        component4.ForceAsExtant = true;
                    }


                    //[Randomizer] Add AIActor GameObjectInfo
                    AIActor enemy_component = NewEnemyObject.GetComponent <AIActor>();
                    if (enemy_component)
                    {
                        if (enemy_component.healthHaver.IsBoss)
                        {
                            if (isbossroom)

                            { //Boss Room
                                enemy_component.healthHaver.bossHealthBar = HealthHaver.BossBarType.MainBar;
                            }
                            else
                            {
                                enemy_component.healthHaver.bossHealthBar = HealthHaver.BossBarType.None;
                                autoEngage = true;
                            }
                            NewEnemyObject = RandomHandleEnemyInfo.ReinstateBossObjectInfo(NewEnemyObject); //removes boss status if regular boss, needs hitbox stuff reinstated
                        }


                        if (GRandomEnemyDataBaseHelper.SpecificEnemyDatabase.Contains(enemy_component.EnemyGuid))
                        {
                            NewEnemyObject = RandomHandleEnemyInfo.SpecificEnemyHelper(NewEnemyObject);
                        }

                        NewEnemyObject = UniqueBossRoomDeathHandler.SpecificRoomHandler(targetRoom, NewEnemyObject);
                    }


                    result = NewEnemyObject;
                }

                else
                {
                    result = null;
                    //return null;
                }
            }

            catch (Exception message)
            {
                Debug.Log("[RANDOMIZER ERROR] " + message.ToString());


                result = null;
            }

            return(result);
        }