コード例 #1
0
        protected void ShowBodyTypeDialog(CustomPawn customPawn)
        {
            ProviderBodyTypes         provider  = PrepareCarefully.Instance.Providers.BodyTypes;
            List <BodyType>           bodyTypes = provider.GetBodyTypesForPawn(customPawn);
            Dialog_Options <BodyType> dialog    = new Dialog_Options <BodyType>(bodyTypes)
            {
                NameFunc = (BodyType bodyType) => {
                    return(provider.GetBodyTypeLabel(bodyType));
                },
                SelectedFunc = (BodyType bodyType) => {
                    return(customPawn.BodyType == bodyType);
                },
                SelectAction = (BodyType bodyType) => {
                    customPawn.BodyType = bodyType;
                    this.pawnLayerLabel = provider.GetBodyTypeLabel(bodyType);
                },
                CloseAction = () => { }
            };

            Find.WindowStack.Add(dialog);
        }
コード例 #2
0
        protected void SelectNextBodyType(CustomPawn customPawn, int direction)
        {
            ProviderBodyTypes provider  = PrepareCarefully.Instance.Providers.BodyTypes;
            List <BodyType>   bodyTypes = provider.GetBodyTypesForPawn(customPawn);
            int index = bodyTypes.IndexOf(customPawn.BodyType);

            if (index == -1)
            {
                Log.Warning("Could not find the current pawn's body type in list of available options: " + customPawn.BodyType);
                return;
            }
            index += direction;
            if (index < 0)
            {
                index = bodyTypes.Count - 1;
            }
            else if (index >= bodyTypes.Count)
            {
                index = 0;
            }
            customPawn.BodyType = bodyTypes[index];
            this.pawnLayerLabel = provider.GetBodyTypeLabel(customPawn.BodyType);
        }