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); }
private void RemoveNeed(NeedDef nd) { Need item = this.TryGetNeed(nd); this.needs.Remove(item); this.BindDirectNeedFields(); }
private void RemoveNeed(NeedDef nd) { Need item = TryGetNeed(nd); needs.Remove(item); BindDirectNeedFields(); }
private Action <DoEditInterface> m__1(NeedDef n) { return(delegate() { this.need = n; }); }
public override void Randomize() { base.Randomize(); need = PossibleNeeds().RandomElement(); levelRange.max = Rand.Range(0f, 1f); levelRange.min = levelRange.max * Rand.Range(0f, 0.95f); }
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); } } }
private void AddNeed(NeedDef nd) { Need need = (Need)Activator.CreateInstance(nd.needClass, pawn); need.def = nd; needs.Add(need); need.SetInitialLevel(); BindDirectNeedFields(); }
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); }
public override void AssignDebugData() { base.AssignDebugData(); need = NeedDefOf.Food; offset = 0.5f; if (Find.AnyPlayerHomeMap != null) { Find.RandomPlayerHomeMap.mapPawns.FreeColonists.FirstOrDefault(); } }
public Need TryGetNeed(NeedDef def) { for (int i = 0; i < needs.Count; i++) { if (needs[i].def == def) { return(needs[i]); } } return(null); }
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(); }
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); }
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); } } }
private static string <DoEditInterface> m__0(NeedDef hd) { return(hd.LabelCap); }
private static bool <PossibleNeeds> m__2(NeedDef x) { return(x.major); }
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); }