Пример #1
0
        // This function doesn't null check orLoadByGuid. If non fake prefab custom enemies are spawned (like the special rats on Hollow), then this would cause exception.
        // Added fall back GUIDs and use one of those for AIActor instead if this happens.
        public void AddSpecificEnemyToRoomProcedurallyFixed(RoomHandler room, string enemyGuid, bool reinforcementSpawn = false, Vector2?goalPosition = null)
        {
            AIActor orLoadByGuid = EnemyDatabase.GetOrLoadByGuid(enemyGuid);

            if (!orLoadByGuid)
            {
                List <string> FallbackGUIDs = new List <string>()
                {
                    ExpandCustomEnemyDatabase.BootlegBullatGUID,
                    ExpandCustomEnemyDatabase.BootlegBulletManGUID,
                    ExpandCustomEnemyDatabase.BootlegBulletManBandanaGUID,
                    ExpandCustomEnemyDatabase.BootlegShotgunManBlueGUID,
                    ExpandCustomEnemyDatabase.BootlegShotgunManRedGUID
                };
                FallbackGUIDs = FallbackGUIDs.Shuffle();
                orLoadByGuid  = EnemyDatabase.GetOrLoadByGuid(BraveUtility.RandomElement(FallbackGUIDs));
            }
            IntVector2    clearance     = orLoadByGuid.specRigidbody.UnitDimensions.ToIntVector2(VectorConversions.Ceil);
            CellValidator cellValidator = delegate(IntVector2 c) {
                for (int i = 0; i < clearance.x; i++)
                {
                    int x = c.x + i;
                    for (int j = 0; j < clearance.y; j++)
                    {
                        int y = c.y + j;
                        if (GameManager.Instance.Dungeon.data.isTopWall(x, y))
                        {
                            return(false);
                        }
                    }
                }
                return(true);
            };
            IntVector2?intVector;

            if (goalPosition != null)
            {
                intVector = room.GetNearestAvailableCell(goalPosition.Value, new IntVector2?(clearance), new CellTypes?(CellTypes.FLOOR), false, cellValidator);
            }
            else
            {
                intVector = room.GetRandomAvailableCell(new IntVector2?(clearance), new CellTypes?(CellTypes.FLOOR), false, cellValidator);
            }
            if (intVector != null)
            {
                AIActor aiactor = AIActor.Spawn(orLoadByGuid, intVector.Value, room, true, AIActor.AwakenAnimationType.Spawn, false);
                if (aiactor && reinforcementSpawn)
                {
                    if (aiactor.specRigidbody)
                    {
                        aiactor.specRigidbody.CollideWithOthers = false;
                    }
                    aiactor.HandleReinforcementFallIntoRoom(0f);
                }
            }
            else
            {
                Debug.LogError("failed placement");
            }
        }
Пример #2
0
        /// <summary>
        /// Generates the output
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public string GenerateOutput(string input)
        {
            List <Minefield> minefields = new List <Minefield>();
            Minefield        minefield  = null;
            StringBuilder    output     = new StringBuilder();

            string[] delimiter = { Environment.NewLine };
            string[] words     = input.Split(delimiter, StringSplitOptions.None);

            foreach (string s in words)
            {
                if (MinefieldValidator.IsHeader(s))
                {
                    minefield = MinefieldFactory.Create(minefields.Count + 1, s);
                    minefields.Add(minefield);
                }
                else if (MinefieldValidator.isFooter(s))
                {
                    break;
                }
                else
                {
                    foreach (char c in s.ToCharArray())
                    {
                        if (CellValidator.isMineOrSafe(c.ToString()))
                        {
                            minefield.Cells.Add(CellFactory.Create(c));
                        }
                        else
                        {
                            ErroMessage = "Your input data is not valid.";
                            return(output.ToString());
                        }
                    }
                }
            }
            try
            {
                foreach (Minefield field in minefields)
                {
                    MinesweeperConverter converter = new MinesweeperConverter();
                    converter.ConvertMinefield(field);
                    //header
                    output.Append(String.Format(MinefieldValidator.headerOutput, field.Id));
                    output.Append(Environment.NewLine);
                    //result
                    output.Append(converter.output);
                    output.Append(Environment.NewLine);
                }
            }
            catch
            {
                ErroMessage = "Your input data is not valid.";
                return(output.ToString());
            }

            return(output.ToString());
        }
Пример #3
0
        static void Main()
        {
            var cooker = new Cooker();
            var potato = new Potato();

            cooker.CheckIfPotatoIsReadyForCooking(potato);

            var cellValidator = new CellValidator();

            cellValidator.VisitedCell();
        }
    // Token: 0x0600487A RID: 18554 RVA: 0x001A4998 File Offset: 0x001A2B98
    private void DoTeleport()
    {
        Vector2 playerLowerLeft       = Vector2.zero;
        Vector2 playerUpperRight      = Vector2.zero;
        bool    hasOtherPlayer        = false;
        Vector2 otherPlayerLowerLeft  = Vector2.zero;
        Vector2 otherPlayerUpperRight = Vector2.zero;

        IntVector2    bottomLeft    = IntVector2.Zero;
        IntVector2    topRight      = IntVector2.Zero;
        CellValidator cellValidator = delegate(IntVector2 c)
        {
            for (int i = 0; i < this.m_aiActor.Clearance.x; i++)
            {
                int num = c.x + i;
                for (int j = 0; j < this.m_aiActor.Clearance.y; j++)
                {
                    int num2 = c.y + j;
                    if (GameManager.Instance.Dungeon.data.isTopWall(num, num2))
                    {
                        return(false);
                    }
                    if (this.ManuallyDefineRoom && ((float)num < this.roomMin.x || (float)num > this.roomMax.x || (float)num2 < this.roomMin.y || (float)num2 > this.roomMax.y))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        };
        Vector2           b                   = this.m_aiActor.specRigidbody.UnitBottomCenter - this.m_aiActor.transform.position.XY();
        IntVector2?       intVector           = null;
        List <IntVector2> randomAvailableCell = new List <IntVector2>()
        {
            this.m_aiActor.ParentRoom.area.UnitCenter.ToIntVector2() + new IntVector2(0, 5),
            this.m_aiActor.ParentRoom.area.UnitCenter.ToIntVector2() + new IntVector2(-5, 0),
            this.m_aiActor.ParentRoom.area.UnitCenter.ToIntVector2() + new IntVector2(5, 0),
        };

        ;    //this.m_aiActor.ParentRoom.GetRandomAvailableCell(new IntVector2?(this.m_aiActor.Clearance), new CellTypes?(this.m_aiActor.PathableTiles), false, cellValidator);
        if (randomAvailableCell != null)
        {
            IntVector2 id = BraveUtility.RandomElement <IntVector2>(randomAvailableCell);
            this.m_aiActor.transform.position = Pathfinder.GetClearanceOffset(id, this.m_aiActor.Clearance).WithY((float)id.y) - b;
            this.m_aiActor.specRigidbody.Reinitialize();
        }
        else
        {
            ETGModConsole.Log("TELEPORT FAILED!", this.m_aiActor);
        }
    }
Пример #5
0
 /// <summary>
 /// Filling the minefield with cells.
 /// </summary>
 /// <param name="minefield">The minefield.</param>
 /// <param name="input">The input.</param>
 private void CreateCells(Minefield minefield, string input)
 {
     foreach (char c in input.ToCharArray())
     {
         if (CellValidator.isMineOrSafe(c.ToString()))
         {
             minefield.Cells.Add(CellFactory.Create(c));
         }
         else
         {
             //invalid input
             this.Renderer.ClearCurrentLine();
             break;
         }
     }
 }
Пример #6
0
        private void Start()
        {
            RoomHandler currentRoom = GameManager.Instance.PrimaryPlayer.CurrentRoom;
            int         num         = MinBoxes;
            int         i           = currentRoom.Cells.Count;

            for (i -= ExtraBoxAboveArea; i > 0; i -= ExtraBoxEveryArea)
            {
                num++;
            }
            num           = Mathf.Clamp(num, MinBoxes, 11);
            m_instanceBox = new FlippableCover[num];
            CellValidator cellValidator = delegate(IntVector2 c) {
                CellData cellData = GameManager.Instance.Dungeon.data[c];
                if (cellData == null || cellData.containsTrap || cellData.isOccupied)
                {
                    return(false);
                }
                for (int k = 0; k < m_instanceBox.Length; k++)
                {
                    if (m_instanceBox[k] != null && Vector2.Distance(m_instanceBox[k].specRigidbody.UnitCenter, c.ToCenterVector2()) < 5f)
                    {
                        return(false);
                    }
                }
                return(true);
            };

            for (int j = 0; j < num; j++)
            {
                IntVector2?randomAvailableCell = currentRoom.GetRandomAvailableCell(new IntVector2?(new IntVector2(4, 4)), new CellTypes?(CellTypes.FLOOR), false, cellValidator);
                if (randomAvailableCell != null)
                {
                    GameObject gameObject = BoxPlaceable.InstantiateObject(currentRoom, randomAvailableCell.Value + IntVector2.One - currentRoom.area.basePosition, false, false);
                    m_instanceBox[j] = gameObject.GetComponent <FlippableCover>();
                    m_instanceBox[j].GetComponentInChildren <tk2dSpriteAnimator>().Play("moving_box_in");
                    PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(m_instanceBox[j].specRigidbody, null, false);
                }
            }
        }
Пример #7
0
        private IntVector2?FindRandomDropLocation(RoomHandler currentRoom, IntVector2 Clearance, float maxDistanceFromPlayer = 20f, bool markLocationAsOccupied = false)
        {
            CellValidator cellValidator = delegate(IntVector2 pos) {
                for (int j = 0; j < GameManager.Instance.AllPlayers.Length; j++)
                {
                    if (Vector2.Distance(GameManager.Instance.AllPlayers[j].CenterPosition, pos.ToCenterVector2()) < maxDistanceFromPlayer)
                    {
                        return(false);
                    }
                }
                return(true);
            };

            IntVector2?randomAvailableCell = currentRoom.GetRandomAvailableCell(new IntVector2?(Clearance), new CellTypes?(CellTypes.FLOOR), false, cellValidator);

            if (randomAvailableCell.HasValue)
            {
                CellData cellData = GameManager.Instance.Dungeon.data[randomAvailableCell.Value];
                if (cellData.parentRoom == currentRoom && cellData.type == CellType.FLOOR && !cellData.isOccupied && !cellData.containsTrap && !cellData.isOccludedByTopWall)
                {
                    if (markLocationAsOccupied)
                    {
                        cellData.isOccupied = true;
                    }
                    return(randomAvailableCell);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Пример #8
0
        private IEnumerator LaunchChestSpawns()
        {
            while (Dungeon.IsGenerating)
            {
                yield return(null);
            }
            yield return(null);

            List <CachedChestData> failedList = new List <CachedChestData>();

            for (int i = 0; i < this.m_chestos.Count; i++)
            {
                CachedChestData cachedChestData = this.m_chestos[i];
                RoomHandler     entrance        = GameManager.Instance.Dungeon.data.Entrance;
                RoomHandler     roomHandler     = entrance;
                cachedChestData.Upgrade();

                CellValidator cellValidator = delegate(IntVector2 c)
                {
                    for (int n = 0; n < 5; n++)
                    {
                        for (int num2 = 0; num2 < 5; num2++)
                        {
                            if (!GameManager.Instance.Dungeon.data.CheckInBoundsAndValid(c.x + n, c.y + num2) || GameManager.Instance.Dungeon.data[c.x + n, c.y + num2].type == CellType.PIT || GameManager.Instance.Dungeon.data[c.x + n, c.y + num2].isOccupied)
                            {
                                return(false);
                            }
                        }
                    }
                    return(true);
                };
                IntVector2?randomAvailableCell = roomHandler.GetRandomAvailableCell(new IntVector2?(IntVector2.One * 5), new CellTypes?(CellTypes.FLOOR), false, cellValidator);
                IntVector2?intVector           = (randomAvailableCell == null) ? null : new IntVector2?(randomAvailableCell.GetValueOrDefault() + IntVector2.One);
                if (intVector != null)
                {
                    cachedChestData.SpawnChest(intVector.Value);
                    for (int j = 0; j < 3; j++)
                    {
                        for (int k = 0; k < 3; k++)
                        {
                            IntVector2 key = intVector.Value + IntVector2.One + new IntVector2(j, k);
                            GameManager.Instance.Dungeon.data[key].isOccupied = true;
                        }
                    }
                }
                else
                {
                    roomHandler = ((roomHandler != entrance) ? entrance : ChestTeleporterItem.FindBossFoyer());
                    if (roomHandler == null)
                    {
                        roomHandler = entrance;
                    }
                    IntVector2?randomAvailableCell2 = roomHandler.GetRandomAvailableCell(new IntVector2?(IntVector2.One * 5), new CellTypes?(CellTypes.FLOOR), false, cellValidator);
                    intVector = ((randomAvailableCell2 == null) ? null : new IntVector2?(randomAvailableCell2.GetValueOrDefault() + IntVector2.One));
                    if (intVector != null)
                    {
                        cachedChestData.SpawnChest(intVector.Value);
                        for (int l = 0; l < 3; l++)
                        {
                            for (int m = 0; m < 3; m++)
                            {
                                IntVector2 key2 = intVector.Value + IntVector2.One + new IntVector2(l, m);
                                GameManager.Instance.Dungeon.data[key2].isOccupied = true;
                            }
                        }
                    }
                    else
                    {
                        failedList.Add(cachedChestData);
                    }
                }
            }
            this.m_chestos.Clear();
            this.m_chestos.AddRange(failedList);
            yield break;
        }
Пример #9
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);
     }
 }