BetterAnimalsTab.Widgets_PetFollow.ToggleAllFollowsHunter C# (CSharp) Méthode

ToggleAllFollowsHunter() public static méthode

public static ToggleAllFollowsHunter ( List animals ) : void
animals List
Résultat void
        public static void ToggleAllFollowsHunter( List<Pawn> animals )
        {
            int count = animals.Count();
            bool[] following = animals.Select( a => a.FollowsHunter() ).ToArray();
            bool[] canFollow = animals.Select( a => a.CanFollow() ).ToArray();
            bool anyCanFollow = false;
            bool anyFollowing = false;
            bool all = true;

            for ( int i = 0; i < count; i++ )
            {
                if ( !anyCanFollow && canFollow[i] )
                    anyCanFollow = true;
                if ( !anyFollowing && following[i] )
                    anyFollowing = true;
                if ( all && !following[i] )
                    all = false;
            }

            if ( anyCanFollow )
            {
                for ( int i = 0; i < count; i++ )
                {
                    if ( canFollow[i] && !all && !following[i] )
                        animals[i].FollowsHunter( true );
                    if ( canFollow[i] && all )
                        animals[i].FollowsHunter( false );
                }
                if ( all )
                    SoundDefOf.CheckboxTurnedOff.PlayOneShotOnCamera();
                else
                    SoundDefOf.CheckboxTurnedOn.PlayOneShotOnCamera();
            }
        }