Esempio n. 1
0
 private bool ShouldHaveNeed(NeedDef nd)
 {
     if ((int)pawn.RaceProps.intelligence < (int)nd.minIntelligence)
     {
         return(false);
     }
     if (nd.colonistsOnly && (pawn.Faction == null || !pawn.Faction.IsPlayer))
     {
         return(false);
     }
     if (nd.colonistAndPrisonersOnly && (pawn.Faction == null || !pawn.Faction.IsPlayer) && (pawn.HostFaction == null || pawn.HostFaction != Faction.OfPlayer))
     {
         return(false);
     }
     if (nd.onlyIfCausedByHediff && !pawn.health.hediffSet.hediffs.Any((Hediff x) => x.def.causesNeed == nd))
     {
         return(false);
     }
     if (nd.neverOnPrisoner && pawn.IsPrisoner)
     {
         return(false);
     }
     if (nd == NeedDefOf.Food)
     {
         return(pawn.RaceProps.EatsFood);
     }
     if (nd == NeedDefOf.Rest)
     {
         return(pawn.RaceProps.needsRest);
     }
     return(true);
 }
Esempio n. 2
0
        private void RemoveNeed(NeedDef nd)
        {
            Need item = this.TryGetNeed(nd);

            this.needs.Remove(item);
            this.BindDirectNeedFields();
        }
Esempio n. 3
0
        private void RemoveNeed(NeedDef nd)
        {
            Need item = TryGetNeed(nd);

            needs.Remove(item);
            BindDirectNeedFields();
        }
Esempio n. 4
0
 private Action <DoEditInterface> m__1(NeedDef n)
 {
     return(delegate()
     {
         this.need = n;
     });
 }
Esempio n. 5
0
 public override void Randomize()
 {
     base.Randomize();
     need           = PossibleNeeds().RandomElement();
     levelRange.max = Rand.Range(0f, 1f);
     levelRange.min = levelRange.max * Rand.Range(0f, 0.95f);
 }
Esempio n. 6
0
 public override void Randomize()
 {
     base.Randomize();
     this.need           = this.PossibleNeeds().RandomElement <NeedDef>();
     this.levelRange.max = Rand.Range(0f, 1f);
     this.levelRange.min = this.levelRange.max * Rand.Range(0f, 0.95f);
 }
        public void AddOrRemoveNeedsAsAppropriate()
        {
            List <NeedDef> allDefsListForReading = DefDatabase <NeedDef> .AllDefsListForReading;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                try
                {
                    NeedDef needDef = allDefsListForReading[i];
                    if (ShouldHaveNeed(needDef))
                    {
                        if (TryGetNeed(needDef) == null)
                        {
                            AddNeed(needDef);
                        }
                    }
                    else if (TryGetNeed(needDef) != null)
                    {
                        RemoveNeed(needDef);
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("Error while determining if " + pawn.ToStringSafe() + " should have Need " + allDefsListForReading[i].ToStringSafe() + ": " + ex);
                }
            }
        }
Esempio n. 8
0
        private void AddNeed(NeedDef nd)
        {
            Need need = (Need)Activator.CreateInstance(nd.needClass, pawn);

            need.def = nd;
            needs.Add(need);
            need.SetInitialLevel();
            BindDirectNeedFields();
        }
Esempio n. 9
0
        public static float GetAddictionNeedCostPerDay(ThingDef d)
        {
            NeedDef need = GetNeed(d);

            if (need != null)
            {
                return(d.BaseMarketValue * need.fallPerDay * (1f + (1f - GetDrugComp(d).needLevelOffset)));
            }
            return(0f);
        }
Esempio n. 10
0
 public override void AssignDebugData()
 {
     base.AssignDebugData();
     need   = NeedDefOf.Food;
     offset = 0.5f;
     if (Find.AnyPlayerHomeMap != null)
     {
         Find.RandomPlayerHomeMap.mapPawns.FreeColonists.FirstOrDefault();
     }
 }
Esempio n. 11
0
 public Need TryGetNeed(NeedDef def)
 {
     for (int i = 0; i < needs.Count; i++)
     {
         if (needs[i].def == def)
         {
             return(needs[i]);
         }
     }
     return(null);
 }
Esempio n. 12
0
        private void AddNeed(NeedDef nd)
        {
            Need need = (Need)Activator.CreateInstance(nd.needClass, new object[]
            {
                this.pawn
            });

            need.def = nd;
            this.needs.Add(need);
            need.SetInitialLevel();
            this.BindDirectNeedFields();
        }
Esempio n. 13
0
        public override void DoEditInterface(Listing_ScenEdit listing)
        {
            Rect scenPartRect = listing.GetScenPartRect(this, ScenPart.RowHeight * 3f + 31f);

            if (Widgets.ButtonText(scenPartRect.TopPartPixels(ScenPart.RowHeight), this.need.LabelCap, true, false, true))
            {
                FloatMenuUtility.MakeMenu <NeedDef>(this.PossibleNeeds(), (NeedDef hd) => hd.LabelCap, (NeedDef n) => delegate
                {
                    this.need = n;
                });
            }
            Widgets.FloatRange(new Rect(scenPartRect.x, scenPartRect.y + ScenPart.RowHeight, scenPartRect.width, 31f), listing.CurHeight.GetHashCode(), ref this.levelRange, 0f, 1f, "ConfigurableLevel", ToStringStyle.FloatTwo);
            base.DoPawnModifierEditInterface(scenPartRect.BottomPartPixels(ScenPart.RowHeight * 2f));
        }
        private bool ShouldHaveNeed(NeedDef nd)
        {
            bool result;

            if (this.pawn.RaceProps.intelligence < nd.minIntelligence)
            {
                result = false;
            }
            else
            {
                if (nd.colonistsOnly)
                {
                    if (this.pawn.Faction == null || !this.pawn.Faction.IsPlayer)
                    {
                        return(false);
                    }
                }
                if (nd.colonistAndPrisonersOnly)
                {
                    if ((this.pawn.Faction == null || !this.pawn.Faction.IsPlayer) && (this.pawn.HostFaction == null || this.pawn.HostFaction != Faction.OfPlayer))
                    {
                        return(false);
                    }
                }
                if (nd.onlyIfCausedByHediff)
                {
                    if (!this.pawn.health.hediffSet.hediffs.Any((Hediff x) => x.def.causesNeed == nd))
                    {
                        return(false);
                    }
                }
                if (nd.neverOnPrisoner && this.pawn.IsPrisoner)
                {
                    result = false;
                }
                else if (nd == NeedDefOf.Food)
                {
                    result = this.pawn.RaceProps.EatsFood;
                }
                else
                {
                    result = (nd != NeedDefOf.Rest || this.pawn.RaceProps.needsRest);
                }
            }
            return(result);
        }
Esempio n. 15
0
        public void AddOrRemoveNeedsAsAppropriate()
        {
            List <NeedDef> allDefsListForReading = DefDatabase <NeedDef> .AllDefsListForReading;

            for (int i = 0; i < allDefsListForReading.Count; i++)
            {
                NeedDef needDef = allDefsListForReading[i];
                if (ShouldHaveNeed(needDef))
                {
                    if (TryGetNeed(needDef) == null)
                    {
                        AddNeed(needDef);
                    }
                }
                else if (TryGetNeed(needDef) != null)
                {
                    RemoveNeed(needDef);
                }
            }
        }
Esempio n. 16
0
 private static string <DoEditInterface> m__0(NeedDef hd)
 {
     return(hd.LabelCap);
 }
Esempio n. 17
0
 private static bool <PossibleNeeds> m__2(NeedDef x)
 {
     return(x.major);
 }
Esempio n. 18
0
 internal void <> m__0()
 {
     this.$this.need = this.n;
 }
 private bool ShouldHaveNeed(NeedDef nd)
 {
     if ((int)pawn.RaceProps.intelligence < (int)nd.minIntelligence)
     {
         return(false);
     }
     if (nd.colonistsOnly && (pawn.Faction == null || !pawn.Faction.IsPlayer))
     {
         return(false);
     }
     if (nd.colonistAndPrisonersOnly && (pawn.Faction == null || !pawn.Faction.IsPlayer) && (pawn.HostFaction == null || pawn.HostFaction != Faction.OfPlayer))
     {
         return(false);
     }
     if (pawn.health.hediffSet.hediffs.Any((Hediff x) => x.def.disablesNeed == nd))
     {
         return(false);
     }
     if (nd.onlyIfCausedByHediff && !pawn.health.hediffSet.hediffs.Any((Hediff x) => x.def.causesNeed == nd))
     {
         return(false);
     }
     if (nd.neverOnPrisoner && pawn.IsPrisoner)
     {
         return(false);
     }
     if (nd.titleRequiredAny != null)
     {
         if (pawn.royalty == null)
         {
             return(false);
         }
         bool flag = false;
         foreach (RoyalTitle item in pawn.royalty.AllTitlesInEffectForReading)
         {
             if (nd.titleRequiredAny.Contains(item.def))
             {
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             return(false);
         }
     }
     if (nd.hediffRequiredAny != null)
     {
         bool flag2 = false;
         foreach (HediffDef item2 in nd.hediffRequiredAny)
         {
             if (pawn.health.hediffSet.HasHediff(item2))
             {
                 flag2 = true;
             }
         }
         if (!flag2)
         {
             return(false);
         }
     }
     if (nd.defName == "Authority")
     {
         return(false);
     }
     if (nd == NeedDefOf.Food)
     {
         return(pawn.RaceProps.EatsFood);
     }
     if (nd == NeedDefOf.Rest)
     {
         return(pawn.RaceProps.needsRest);
     }
     return(true);
 }