Exemplo n.º 1
0
        protected void SelectPreviousTrait(CustomPawn customPawn, int traitIndex)
        {
            Trait currentTrait = customPawn.GetTrait(traitIndex);

            ComputeDisallowedTraits(customPawn, currentTrait);
            int index = -1;

            if (currentTrait != null)
            {
                index = providerTraits.Traits.FindIndex((Trait t) => {
                    return(t.Label.Equals(currentTrait.Label));
                });
            }
            int count = 0;

            do
            {
                index--;
                if (index < 0)
                {
                    index = providerTraits.Traits.Count - 1;
                }
                if (++count > providerTraits.Traits.Count + 1)
                {
                    index = -1;
                    break;
                }
            }while (index != -1 && (customPawn.HasTrait(providerTraits.Traits[index]) || disallowedTraitDefs.Contains(providerTraits.Traits[index].def)));

            Trait newTrait = null;

            if (index > -1)
            {
                newTrait = providerTraits.Traits[index];
            }
            TraitUpdated(traitIndex, newTrait);
        }