// Token: 0x06002709 RID: 9993 RVA: 0x000E7EBC File Offset: 0x000E62BC
        private void respawnAnimals()
        {
            if ((int)AnimalManager.respawnPackIndex >= AnimalManager.packs.Count)
            {
                AnimalManager.respawnPackIndex = (ushort)(AnimalManager.packs.Count - 1);
            }
            PackInfo packInfo = AnimalManager.packs[(int)AnimalManager.respawnPackIndex];

            AnimalManager.respawnPackIndex += 1;
            if ((int)AnimalManager.respawnPackIndex >= AnimalManager.packs.Count)
            {
                AnimalManager.respawnPackIndex = 0;
            }
            if (packInfo == null)
            {
                return;
            }
            for (int i = 0; i < packInfo.animals.Count; i++)
            {
                Animal animal = packInfo.animals[i];
                if (animal == null || !animal.isDead || Time.realtimeSinceStartup - animal.lastDead < Provider.modeConfigData.Animals.Respawn_Time)
                {
                    return;
                }
            }
            List <AnimalSpawnpoint> list = new List <AnimalSpawnpoint>();

            for (int j = 0; j < packInfo.spawns.Count; j++)
            {
                list.Add(packInfo.spawns[j]);
            }
            for (int k = 0; k < packInfo.animals.Count; k++)
            {
                Animal animal2 = packInfo.animals[k];
                if (!(animal2 == null))
                {
                    int index = UnityEngine.Random.Range(0, list.Count);
                    AnimalSpawnpoint animalSpawnpoint = list[index];
                    list.RemoveAt(index);
                    Vector3 point = animalSpawnpoint.point;
                    point.y += 0.1f;
                    animal2.sendRevive(point, UnityEngine.Random.Range(0f, 360f));
                }
            }
        }
        // Token: 0x060026F5 RID: 9973 RVA: 0x000E76A8 File Offset: 0x000E5AA8
        public static void spawnAnimal(ushort id, Vector3 point, Quaternion angle)
        {
            AnimalAsset animalAsset = (AnimalAsset)Assets.find(EAssetType.ANIMAL, id);

            if (animalAsset != null)
            {
                Animal           animal   = AnimalManager.manager.addAnimal(id, point, angle.eulerAngles.y, false);
                AnimalSpawnpoint item     = new AnimalSpawnpoint(0, point);
                PackInfo         packInfo = new PackInfo();
                animal.pack = packInfo;
                packInfo.animals.Add(animal);
                packInfo.spawns.Add(item);
                AnimalManager.packs.Add(packInfo);
                AnimalManager.manager.channel.openWrite();
                AnimalManager.manager.sendAnimal(animal);
                AnimalManager.manager.channel.closeWrite("tellAnimal", ESteamCall.OTHERS, ESteamPacket.UPDATE_RELIABLE_CHUNK_BUFFER);
            }
        }
 // Token: 0x0600270C RID: 9996 RVA: 0x000E8428 File Offset: 0x000E6828
 private void OnDrawGizmos()
 {
     if (AnimalManager.packs == null)
     {
         return;
     }
     for (int i = 0; i < AnimalManager.packs.Count; i++)
     {
         PackInfo packInfo = AnimalManager.packs[i];
         if (packInfo != null && packInfo.spawns != null && packInfo.animals != null)
         {
             Vector3 averageSpawnPoint  = packInfo.getAverageSpawnPoint();
             Vector3 averageAnimalPoint = packInfo.getAverageAnimalPoint();
             Vector3 wanderDirection    = packInfo.getWanderDirection();
             Gizmos.color = Color.gray;
             for (int j = 0; j < packInfo.spawns.Count; j++)
             {
                 AnimalSpawnpoint animalSpawnpoint = packInfo.spawns[j];
                 if (animalSpawnpoint != null)
                 {
                     Gizmos.DrawLine(averageSpawnPoint, animalSpawnpoint.point);
                 }
             }
             Gizmos.color = Color.yellow;
             Gizmos.DrawLine(averageSpawnPoint, averageAnimalPoint);
             for (int k = 0; k < packInfo.animals.Count; k++)
             {
                 Animal animal = packInfo.animals[k];
                 if (!(animal == null))
                 {
                     Gizmos.color = ((!animal.isDead) ? Color.green : Color.red);
                     Gizmos.DrawLine(averageAnimalPoint, animal.transform.position);
                     if (!animal.isDead)
                     {
                         Gizmos.color = Color.magenta;
                         Gizmos.DrawLine(animal.transform.position, animal.target);
                     }
                 }
             }
             Gizmos.color = Color.cyan;
             Gizmos.DrawLine(averageAnimalPoint, averageAnimalPoint + wanderDirection * 4f);
         }
     }
 }
 // Token: 0x0600270A RID: 9994 RVA: 0x000E805C File Offset: 0x000E645C
 private void onLevelLoaded(int level)
 {
     if (level > Level.SETUP)
     {
         this.seq = 0u;
         AnimalManager._animals        = new List <Animal>();
         AnimalManager._packs          = null;
         AnimalManager.updates         = 0;
         AnimalManager.tickIndex       = 0;
         AnimalManager._tickingAnimals = new List <Animal>();
         if (Provider.isServer)
         {
             AnimalManager._packs = new List <PackInfo>();
             if (LevelAnimals.spawns.Count > 0)
             {
                 for (int i = 0; i < LevelAnimals.spawns.Count; i++)
                 {
                     AnimalSpawnpoint animalSpawnpoint = LevelAnimals.spawns[i];
                     int num = -1;
                     for (int j = AnimalManager.packs.Count - 1; j >= 0; j--)
                     {
                         List <AnimalSpawnpoint> spawns = AnimalManager.packs[j].spawns;
                         for (int k = 0; k < spawns.Count; k++)
                         {
                             AnimalSpawnpoint animalSpawnpoint2 = spawns[k];
                             if ((animalSpawnpoint2.point - animalSpawnpoint.point).sqrMagnitude < 256f)
                             {
                                 if (num == -1)
                                 {
                                     spawns.Add(animalSpawnpoint);
                                 }
                                 else
                                 {
                                     List <AnimalSpawnpoint> spawns2 = AnimalManager.packs[num].spawns;
                                     for (int l = 0; l < spawns2.Count; l++)
                                     {
                                         spawns.Add(spawns2[l]);
                                     }
                                     AnimalManager.packs.RemoveAtFast(num);
                                 }
                                 num = j;
                                 break;
                             }
                         }
                     }
                     if (num == -1)
                     {
                         PackInfo packInfo = new PackInfo();
                         packInfo.spawns.Add(animalSpawnpoint);
                         AnimalManager.packs.Add(packInfo);
                     }
                 }
                 List <AnimalManager.ValidAnimalSpawnsInfo> list = new List <AnimalManager.ValidAnimalSpawnsInfo>();
                 for (int m = 0; m < AnimalManager.packs.Count; m++)
                 {
                     PackInfo packInfo2            = AnimalManager.packs[m];
                     List <AnimalSpawnpoint> list2 = new List <AnimalSpawnpoint>();
                     for (int n = 0; n < packInfo2.spawns.Count; n++)
                     {
                         list2.Add(packInfo2.spawns[n]);
                     }
                     list.Add(new AnimalManager.ValidAnimalSpawnsInfo
                     {
                         spawns = list2,
                         pack   = packInfo2
                     });
                 }
                 while ((long)AnimalManager.animals.Count < (long)((ulong)AnimalManager.maxInstances) && list.Count > 0)
                 {
                     int index = UnityEngine.Random.Range(0, list.Count);
                     AnimalManager.ValidAnimalSpawnsInfo validAnimalSpawnsInfo = list[index];
                     int index2 = UnityEngine.Random.Range(0, validAnimalSpawnsInfo.spawns.Count);
                     AnimalSpawnpoint animalSpawnpoint3 = validAnimalSpawnsInfo.spawns[index2];
                     validAnimalSpawnsInfo.spawns.RemoveAt(index2);
                     if (validAnimalSpawnsInfo.spawns.Count == 0)
                     {
                         list.RemoveAt(index);
                     }
                     Vector3 point = animalSpawnpoint3.point;
                     point.y += 0.1f;
                     ushort id;
                     if (validAnimalSpawnsInfo.pack.animals.Count > 0)
                     {
                         id = validAnimalSpawnsInfo.pack.animals[0].id;
                     }
                     else
                     {
                         id = LevelAnimals.getAnimal(animalSpawnpoint3);
                     }
                     Animal animal = this.addAnimal(id, point, UnityEngine.Random.Range(0f, 360f), false);
                     if (animal != null)
                     {
                         animal.pack = validAnimalSpawnsInfo.pack;
                         validAnimalSpawnsInfo.pack.animals.Add(animal);
                     }
                 }
                 for (int num2 = AnimalManager.packs.Count - 1; num2 >= 0; num2--)
                 {
                     PackInfo packInfo3 = AnimalManager.packs[num2];
                     if (packInfo3.animals.Count <= 0)
                     {
                         AnimalManager.packs.RemoveAt(num2);
                     }
                 }
             }
         }
     }
 }