// Token: 0x0600007F RID: 127 RVA: 0x000069CC File Offset: 0x00004BCC
 public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List <Thing> ingredients, Bill bill)
 {
     foreach (Thing item in ingredients)
     {
         if (item != ingredients[0])
         {
             if (item.def.IsDrug && item.def.IsIngestible)
             {
                 IngestibleProperties        ingestible = item.def.ingestible;
                 List <IngestionOutcomeDoer> listIOD    = ingestible?.outcomeDoers;
                 if (listIOD.Count > 0)
                 {
                     foreach (IngestionOutcomeDoer ingestionOutcomeDoer in listIOD)
                     {
                         ingestionOutcomeDoer.DoIngestionOutcome(pawn, item);
                     }
                 }
             }
             if (!item.DestroyedOrNull())
             {
                 item.Destroy(DestroyMode.Vanish);
             }
         }
     }
     ingredients[0].TryGetComp <CompUsable>().UsedBy(pawn);
 }
示例#2
0
 public void ApplyStats(IngestibleProperties to)
 {
     to.maxNumToIngestAtOnce = this.maxNumToIngestAtOnce;
     to.baseIngestTicks      = this.baseIngestTicks;
     to.chairSearchRadius    = this.chairSearchRadius;
     to.useEatingSpeedStat   = this.useEatingSpeedStat;
     to.ingestHoldUsesTable  = this.ingestHoldUsesTable;
     to.foodType             = this.foodType;
     to.joy           = this.joy;
     to.preferability = this.preferability;
     to.nurseable     = this.nurseable;
     to.optimalityOffsetHumanlikes     = this.optimalityOffsetHumanlikes;
     to.optimalityOffsetFeedingAnimals = this.optimalityOffsetFeedingAnimals;
     to.drugCategory = this.drugCategory;
     if (this.ingestHoldOffsetStanding != null)
     {
         if (to.ingestHoldOffsetStanding == null)
         {
             to.ingestHoldOffsetStanding = new HoldOffsetSet();
         }
         this.ingestHoldOffsetStanding.ApplyStats(to.ingestHoldOffsetStanding);
     }
     //Util.AssignDef(this.parent, out v.parent);
     Util.AssignDef(this.joyKind, out to.joyKind);
     Util.AssignDef(this.sourceDef, out to.sourceDef);
     Util.AssignDef(this.tasteThought, out to.tasteThought);
     Util.AssignDef(this.specialThoughtDirect, out to.specialThoughtDirect);
     Util.AssignDef(this.specialThoughtAsIngredient, out to.specialThoughtAsIngredient);
     Util.AssignDef(this.ingestEffect, out to.ingestEffect);
     Util.AssignDef(this.ingestEffectEat, out to.ingestEffectEat);
     Util.AssignDef(this.ingestSound, out to.ingestSound);
     ResetCache(to);
 }
示例#3
0
        public IngestiblePropertiesStats(IngestibleProperties p)
        {
            this.maxNumToIngestAtOnce = p.maxNumToIngestAtOnce;
            this.baseIngestTicks      = p.baseIngestTicks;
            this.chairSearchRadius    = p.chairSearchRadius;
            this.useEatingSpeedStat   = p.useEatingSpeedStat;
            //this.ingestCommandString = p.ingestCommandString;
            //this.ingestReportString = p.ingestReportString;
            //this.ingestReportStringEat = p.ingestReportStringEat;
            this.ingestHoldUsesTable = p.ingestHoldUsesTable;
            this.foodType            = p.foodType;
            this.joy           = p.joy;
            this.preferability = p.preferability;
            this.nurseable     = p.nurseable;
            this.optimalityOffsetHumanlikes     = p.optimalityOffsetHumanlikes;
            this.optimalityOffsetFeedingAnimals = p.optimalityOffsetFeedingAnimals;
            this.drugCategory = p.drugCategory;

            if (p.ingestHoldOffsetStanding != null)
            {
                this.ingestHoldOffsetStanding = new HoldOffsetSetStats(p.ingestHoldOffsetStanding);
            }

            //Util.AssignDefStat(p.parent, out this.parent);
            Util.AssignDefStat(p.joyKind, out this.joyKind);
            Util.AssignDefStat(p.sourceDef, out this.sourceDef);
            Util.AssignDefStat(p.tasteThought, out this.tasteThought);
            Util.AssignDefStat(p.specialThoughtDirect, out this.specialThoughtDirect);
            Util.AssignDefStat(p.specialThoughtAsIngredient, out this.specialThoughtAsIngredient);
            Util.AssignDefStat(p.ingestEffect, out this.ingestEffect);
            Util.AssignDefStat(p.ingestEffectEat, out this.ingestEffectEat);
            Util.AssignDefStat(p.ingestSound, out this.ingestSound);
        }
示例#4
0
        public IngestiblePropertiesWidget(IngestibleProperties props)
        {
            this.Parent       = props;
            this.inputWidgets = new List <IInputWidget>()
            {
                new IntInputWidget <IngestibleProperties>(this.Parent, "Max Number Ingest At Once", p => p.maxNumToIngestAtOnce, (p, v) => p.maxNumToIngestAtOnce = v),
                new IntInputWidget <IngestibleProperties>(this.Parent, "Base Ingest Ticks", p => p.baseIngestTicks, (p, v) => p.baseIngestTicks               = v),
                new FloatInputWidget <IngestibleProperties>(this.Parent, "Chair Search Radius", p => p.chairSearchRadius, (p, v) => p.chairSearchRadius       = v),
                new BoolInputWidget <IngestibleProperties>(this.Parent, "Use Eating Speed Stat", p => p.useEatingSpeedStat, (p, v) => p.useEatingSpeedStat    = v),
                new BoolInputWidget <IngestibleProperties>(this.Parent, "Ingest Hold Uses Table", p => p.ingestHoldUsesTable, (p, v) => p.ingestHoldUsesTable = v),
                new FloatInputWidget <IngestibleProperties>(this.Parent, "Joy", p => p.joy, (p, v) => p.joy = v),
                new EnumInputWidget <IngestibleProperties, FoodPreferability>(this.Parent, "Preferability", 200, p => p.preferability, (p, v) => p.preferability = v),
                new BoolInputWidget <IngestibleProperties>(this.Parent, "Nurseable", p => p.nurseable, (p, v) => p.nurseable = v),
                new FloatInputWidget <IngestibleProperties>(this.Parent, "Optimality Offset Humanlikes", p => p.optimalityOffsetHumanlikes, (p, v) => p.optimalityOffsetHumanlikes = v),
                new FloatInputWidget <IngestibleProperties>(this.Parent, "Optimality Offset Feeding Animals", p => p.optimalityOffsetFeedingAnimals, (p, v) => p.optimalityOffsetFeedingAnimals = v),
                new EnumInputWidget <IngestibleProperties, DrugCategory>(this.Parent, "DrugCategory", 200, p => p.drugCategory, (p, v) => p.drugCategory = v),
                //new DefInputWidget<IngestibleProperties, ThingDef>(this.Parent, "Parent", 200, p => p.parent, (p, v) => { p.parent = v; IngestiblePropertiesStats.ResetCache(p); }, true),
                new DefInputWidget <IngestibleProperties, JoyKindDef>(this.Parent, "Joy Kind", 200, p => p.joyKind, (p, v) => p.joyKind                = v, true),
                new DefInputWidget <IngestibleProperties, ThingDef>(this.Parent, "Source Def", 200, p => p.sourceDef, (p, v) => p.sourceDef            = v, true),
                new DefInputWidget <IngestibleProperties, ThoughtDef>(this.Parent, "Taste Thought", 200, p => p.tasteThought, (p, v) => p.tasteThought = v, true),
                new DefInputWidget <IngestibleProperties, ThoughtDef>(this.Parent, "Special Thought Direct", 200, p => p.specialThoughtDirect, (p, v) => p.specialThoughtDirect = v, true),
                new DefInputWidget <IngestibleProperties, ThoughtDef>(this.Parent, "Special Thought As Ingredient", 200, p => p.specialThoughtAsIngredient, (p, v) => p.specialThoughtAsIngredient = v, true),
                new DefInputWidget <IngestibleProperties, EffecterDef>(this.Parent, "Ingest Effect", 200, p => p.ingestEffect, (p, v) => p.ingestEffect           = v, true),
                new DefInputWidget <IngestibleProperties, EffecterDef>(this.Parent, "Ingest Effect Eat", 200, p => p.ingestEffectEat, (p, v) => p.ingestEffectEat = v, true),
                new DefInputWidget <IngestibleProperties, SoundDef>(this.Parent, "Sound Def", 200, p => p.ingestSound, (p, v) => p.ingestSound = v, true),
            };

            var dic = new SortedDictionary <string, FoodTypeFlags>();

            foreach (var v in Enum.GetValues(typeof(FoodTypeFlags)).Cast <FoodTypeFlags>())
            {
                dic.Add(v.ToString(), v);
            }
            this.foodTypeSortedFlags = new List <FoodTypeFlags>(dic.Values);
            dic.Clear();
            dic = null;

            this.foodTypePlusMinus = new PlusMinusArgs <FoodTypeFlags>()
            {
                allItems       = this.foodTypeSortedFlags,
                isBeingUsed    = v => (this.Parent.foodType & v) == v,
                onAdd          = v => this.Parent.foodType |= v,
                onRemove       = v => this.Parent.foodType &= ~v,
                getDisplayName = v => v.ToString()
            };
        }
示例#5
0
        // Token: 0x06000055 RID: 85 RVA: 0x000058A0 File Offset: 0x00003AA0
        public static List <ThingDef> MaladyDrugs()
        {
            List <RecipeDef> recipelist = DefDatabase <RecipeDef> .AllDefsListForReading;

            if (Current.ProgramState != ProgramState.Playing && DRSettings.ShowResearched)
            {
                Messages.Message(Translator.Translate("MSPainless.Warning"), LookTargets.Invalid, MessageTypeDefOf.CautionInput, false);
            }
            List <ThingDef> list    = new List <ThingDef>();
            List <ThingDef> chkList = DefDatabase <ThingDef> .AllDefsListForReading;

            if (chkList.Count > 0)
            {
                foreach (ThingDef chkDef in chkList)
                {
                    if (chkDef.IsIngestible && chkDef != null)
                    {
                        IngestibleProperties ingestible    = chkDef.ingestible;
                        DrugCategory?        drugCategory  = (ingestible != null) ? new DrugCategory?(ingestible.drugCategory) : null;
                        DrugCategory         drugCategory2 = DrugCategory.Medical;
                        if (drugCategory.GetValueOrDefault() == drugCategory2 & drugCategory != null)
                        {
                            if (DRSettings.ShowResearched)
                            {
                                if (MSPainDrug.IsResearchCompleted(chkDef, recipelist))
                                {
                                    GenCollection.AddDistinct <ThingDef>(list, chkDef);
                                }
                            }
                            else
                            {
                                GenCollection.AddDistinct <ThingDef>(list, chkDef);
                            }
                        }
                    }
                }
            }
            return((from td in list
                    orderby td.label
                    select td).ToList <ThingDef>());
        }
示例#6
0
        public static bool GetMeatSourceCategory(ref MeatSourceCategory __result, ThingDef source)
        {
            IngestibleProperties ingestible = source.ingestible;

            if (ingestible == null)
            {
                __result = MeatSourceCategory.Undefined;
                return(false);
            }
            if ((ingestible.foodType & FoodTypeFlags.Meat) != FoodTypeFlags.Meat)
            {
                __result = MeatSourceCategory.NotMeat;
                return(false);
            }
            if (ingestible.sourceDef != null && ingestible.sourceDef.race != null && ingestible.sourceDef.race.Humanlike)
            {
                __result = MeatSourceCategory.Humanlike;
                return(false);
            }
            __result = ingestible.sourceDef != null && ingestible.sourceDef.race.FleshType != null && ingestible.sourceDef.race.FleshType == FleshTypeDefOf.Insectoid ? MeatSourceCategory.Insect : MeatSourceCategory.Undefined;
            return(false);
        }
示例#7
0
 public static void ResetCache(IngestibleProperties p)
 {
     typeof(IngestibleProperties).GetField("cachedNutrition", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(p, -1);
 }