public static void CilleSpawningScripts()
        {
            const byte CheckDelayTime = 150;
            const int  CilleID        = GuardianBase.Cille;

            CilleSpawnCheckDelay++;
            if (CilleSpawnCheckDelay < CheckDelayTime)
            {
                return;
            }
            CilleSpawnCheckDelay -= CheckDelayTime;
            if (Main.rand.Next(7) > 0)
            {
                return;
            }
            if (!NpcMod.HasMetGuardian(CilleID) || NPC.AnyNPCs(ModContent.NPCType <Npcs.CilleNPC>()))
            {
                return;
            }
            if (NpcMod.HasGuardianNPC(CilleID))
            {
                TerraGuardian tg = NpcMod.GetGuardianNPCCharacter(CilleID);
                if (tg.FriendshipLevel >= tg.Base.MoveInLevel)
                {
                    return;
                }
                for (int i = 0; i < 255; i++)
                {
                    if (Main.player[i].active && Math.Abs(tg.Position.X - Main.player[i].Center.X) < 2000 && Math.Abs(tg.Position.Y - Main.player[i].Center.Y) < 1600)
                    {
                        return;
                    }
                }
            }
            if (CilleShelterX == -1 && CilleShelterY == -1)
            {
                int Left = (int)(Main.leftWorld * (1f / 16) + 130), Right = (int)(Main.rightWorld * (1f / 16) - 130);
                int Top = (int)(Main.worldSurface * 0.35f), Bottom = (int)(Main.worldSurface);
                int PositionX = Main.rand.Next(Left, Right),
                    PositionY = Main.rand.Next(Top, Bottom);
                Tile tile     = Framing.GetTileSafely(PositionX, PositionY);
                if (tile == null || (tile.active() && Main.tileSolid[tile.type]) || tile.wall > 0)
                {
                    return;
                }
                {
                    byte Counter = 0;
                    while (!tile.active() || !Main.tileSolid[tile.type])
                    {
                        PositionY++;
                        tile = Framing.GetTileSafely(PositionX, PositionY);
                        if (Counter++ >= 250)
                        {
                            return;
                        }
                    }
                }
                tile = Framing.GetTileSafely(PositionX, PositionY);
                switch (tile.type)
                {
                case Terraria.ID.TileID.CorruptGrass:
                case Terraria.ID.TileID.Ebonstone:
                case Terraria.ID.TileID.Ebonsand:
                case Terraria.ID.TileID.FleshGrass:
                case Terraria.ID.TileID.Crimtane:
                case Terraria.ID.TileID.Crimsand:
                case Terraria.ID.TileID.LeafBlock:
                case Terraria.ID.TileID.LivingWood:
                case Terraria.ID.TileID.BlueDungeonBrick:
                case Terraria.ID.TileID.GreenDungeonBrick:
                case Terraria.ID.TileID.PinkDungeonBrick:
                    return;
                }
                PositionY--;
                tile = Framing.GetTileSafely(PositionX, PositionY);
                if (tile.wall > 0)
                {
                    return;
                }
                for (int i = 0; i < 255; i++)
                {
                    if (Main.player[i].active)
                    {
                        if (Math.Abs(Main.player[i].Center.X - PositionX * 16) < 1000 && Math.Abs(Main.player[i].Center.Y - PositionY * 16) < 1000)
                        {
                            return;
                        }
                    }
                    if (i < 200 && Main.npc[i].active)
                    {
                        if (Math.Abs(Main.npc[i].Center.X - PositionX * 16) < 1000 && Math.Abs(Main.npc[i].Center.Y - PositionY * 16) < 800)
                        {
                            return;
                        }
                    }
                }
                int HouseBottom;
                if (!TryPlacingCilleHouse(PositionX, PositionY, out HouseBottom))
                {
                    return;
                }
                CilleShelterX = PositionX;
                CilleShelterY = HouseBottom;

                /*if (!NpcMod.HasGuardianNPC(CilleID))
                 * {
                 *  NpcMod.SpawnGuardianNPC(PositionX * 16, PositionY * 16, CilleID);
                 * }
                 * else
                 * {
                 *  TerraGuardian Cille = NpcMod.GetGuardianNPCCharacter(CilleID);
                 *  Cille.Position.X = PositionX * 16;
                 *  Cille.Position.Y = PositionY * 16;
                 *  Cille.SetFallStart();
                 * }*/
                WorldMod.TrySpawningOrMovingGuardianNPC(CilleID, "", CilleShelterX, CilleShelterY, true, true);
            }
            else
            {
                if (!NpcMod.HasGuardianNPC(CilleID))
                {
                    if (!WorldMod.CanGuardianNPCSpawnInTheWorld(CilleID))
                    {
                        if (Main.dayTime && Main.moonPhase != 4)
                        {
                            List <WorldMod.GuardianTownNpcState> TownNpcsAtThisHouse = WorldMod.GetGuardianLivingHere(CilleShelterX, CilleShelterY);
                            foreach (WorldMod.GuardianTownNpcState tg in TownNpcsAtThisHouse)
                            {
                                if (!tg.CharID.IsSameID(CilleID))
                                {
                                    tg.Homeless = true;
                                    tg.HomeX    = tg.HomeY = -1;
                                }
                            }
                            if (WorldMod.TrySpawningOrMovingGuardianNPC(CilleID, "", CilleShelterX, CilleShelterY, true, true))
                            {
                                //NpcMod.SpawnGuardianNPC(CilleShelterX * 16, CilleShelterY * 16, CilleID);
                            }
                            else
                            {
                                CilleShelterX = CilleShelterY = -1;
                            }
                        }
                    }
                }
                else
                {
                    /*if (!Main.dayTime && !WorldMod.CanGuardianNPCSpawnInTheWorld(CilleID))
                     * {
                     *  WorldMod.GuardianTownNpcState townnpc = CilleGuardian.GetTownNpcInfo;
                     *  if (townnpc != null)
                     *  {
                     *      townnpc.Homeless = true;
                     *  }
                     * }*/
                }
            }
        }