/// <summary>
 /// Clean all animal related links if animal is dead
 /// </summary>
 private static void CleanDeadAnimals(List <Pawn> pawns)
 {
     for (int i = 0; i < AnimalManager.links.Count; i++)
     {
         AnimalLink pawn = AnimalManager.links[i];
         if (!pawns.Contains(pawn.animal))
         {
             if (pawn.animal == null || pawn.animal.Dead)
             {
                 AnimalManager.links.Remove(pawn);
             }
         }
     }
 }
        private static void SaveCurrentState(List <Pawn> pawns)
        {
            int currentMap = Find.VisibleMap.uniqueID;

            //Save current state
            foreach (Pawn p in pawns)
            {
                //find animal on the current zone
                AnimalLink animalLink =
                    AnimalManager.links.Find(
                        x => x.animal.Equals(p) &&
                        x.zone == AnimalManager.GetActivePolicy().id&&
                        x.mapId == currentMap);

                if (animalLink != null)
                {
                    //animal found! save master and area
                    animalLink.master =
                        p.playerSettings.master;
                    animalLink.area =
                        p.playerSettings.AreaRestriction;
                    animalLink.followDrafted =
                        p.playerSettings.followDrafted;
                    animalLink.followFieldwork =
                        p.playerSettings.followFieldwork;
                }
                else
                {
                    //animal not found. So add it to the AnimalLink list
                    AnimalManager.links.Add(new AnimalLink(
                                                AnimalManager.GetActivePolicy().id,
                                                p,
                                                p.playerSettings.master,
                                                p.playerSettings.AreaRestriction,
                                                p.playerSettings.followDrafted,
                                                p.playerSettings.followFieldwork,
                                                currentMap));
                }
            }
        }