private Thing RandomMeals(TechLevel techLevel) { ThingDef thingDef; if (techLevel.IsNeolithicOrWorse()) { thingDef = ThingDefOf.Pemmican; } else { float value = Rand.Value; if (value < 0.5f) { thingDef = ThingDefOf.MealSimple; } else if ((double)value < 0.75) { thingDef = ThingDefOf.MealFine; } else { thingDef = ThingDefOf.MealSurvivalPack; } } Thing thing = ThingMaker.MakeThing(thingDef, null); int num = Mathf.Min(thingDef.stackLimit, 10); thing.stackCount = Rand.RangeInclusive(num / 2, num); return(thing); }
public float BaseGenerationChanceFactor(Pawn generated, Pawn other, PawnGenerationRequest request) { float num = 1f; if (generated.Faction != other.Faction) { num *= 0.65f; } if (generated.HostileTo(other)) { num *= 0.7f; } if (other.Faction != null && other.Faction.IsPlayer) { num *= request.ColonistRelationChanceFactor; } TechLevel techLevel = (generated.Faction == null) ? TechLevel.Undefined : generated.Faction.def.techLevel; TechLevel techLevel2 = (other.Faction == null) ? TechLevel.Undefined : other.Faction.def.techLevel; if (techLevel != TechLevel.Undefined && techLevel2 != TechLevel.Undefined && techLevel != techLevel2) { num *= 0.85f; } if ((techLevel.IsNeolithicOrWorse() && !techLevel2.IsNeolithicOrWorse()) || (!techLevel.IsNeolithicOrWorse() && techLevel2.IsNeolithicOrWorse())) { num *= 0.03f; } return(num); }
private Thing RandomMedicine(TechLevel techLevel) { ThingDef result; if (Rand.Value < 0.75f && (int)techLevel >= (int)ThingDefOf.MedicineHerbal.techLevel) { result = (from x in ThingSetMakerUtility.allGeneratableItems where x.IsMedicine && (int)x.techLevel <= (int)techLevel select x).MaxBy((ThingDef x) => x.GetStatValueAbstract(StatDefOf.MedicalPotency)); } else if (!(from x in ThingSetMakerUtility.allGeneratableItems where x.IsMedicine select x).TryRandomElement(out result)) { return(null); } if (techLevel.IsNeolithicOrWorse()) { result = ThingDefOf.MedicineHerbal; } Thing thing = ThingMaker.MakeThing(result); int max = Mathf.Min(result.stackLimit, 20); thing.stackCount = Rand.RangeInclusive(1, max); return(thing); }
private Thing RandomMedicine(TechLevel techLevel) { bool flag = Rand.Value < 0.75f && techLevel >= ThingDefOf.MedicineHerbal.techLevel; ThingDef thingDef; if (flag) { thingDef = (from x in ThingSetMakerUtility.allGeneratableItems where x.IsMedicine && x.techLevel <= techLevel select x).MaxBy((ThingDef x) => x.GetStatValueAbstract(StatDefOf.MedicalPotency, null)); } else if (!(from x in ThingSetMakerUtility.allGeneratableItems where x.IsMedicine select x).TryRandomElement(out thingDef)) { return(null); } if (techLevel.IsNeolithicOrWorse()) { thingDef = ThingDefOf.MedicineHerbal; } Thing thing = ThingMaker.MakeThing(thingDef, null); int max = Mathf.Min(thingDef.stackLimit, 20); thing.stackCount = Rand.RangeInclusive(1, max); return(thing); }
private Thing RandomMedicine(TechLevel techLevel) { ThingDef thingDef = default(ThingDef); if (Rand.Value < 0.75 && (int)techLevel >= (int)ThingDefOf.HerbalMedicine.techLevel) { thingDef = (from x in ItemCollectionGeneratorUtility.allGeneratableItems where x.IsMedicine && (int)x.techLevel <= (int)techLevel select x).MaxBy((ThingDef x) => x.GetStatValueAbstract(StatDefOf.MedicalPotency, null)); } else if (!(from x in ItemCollectionGeneratorUtility.allGeneratableItems where x.IsMedicine select x).TryRandomElement <ThingDef>(out thingDef)) { throw new Exception(); } if (techLevel.IsNeolithicOrWorse()) { thingDef = ThingDefOf.HerbalMedicine; } Thing thing = ThingMaker.MakeThing(thingDef, null); int max = Mathf.Min(thingDef.stackLimit, 20); thing.stackCount = Rand.RangeInclusive(1, max); return(thing); }
public static ThingDef RandomCheapWallStuff(TechLevel techLevel, bool notVeryFlammable = false) { if (techLevel.IsNeolithicOrWorse()) { return(ThingDefOf.WoodLog); } return(DefDatabase <ThingDef> .AllDefsListForReading.Where((ThingDef d) => IsCheapWallStuff(d) && (!notVeryFlammable || d.BaseFlammability < 0.5f)).RandomElement()); }
public static ThingDef RandomCheapWallStuff(TechLevel techLevel, bool notVeryFlammable = false) { if (techLevel.IsNeolithicOrWorse()) { return(ThingDefOf.WoodLog); } return((from d in DefDatabase <ThingDef> .AllDefsListForReading where BaseGenUtility.IsCheapWallStuff(d) && (!notVeryFlammable || d.BaseFlammability < 0.5f) select d).RandomElement <ThingDef>()); }
protected override IEnumerable <ThingDef> AllGeneratableThingsDebugSub(ThingSetMakerParams parms) { TechLevel techLevel = parms.techLevel ?? TechLevel.Undefined; if (techLevel.IsNeolithicOrWorse()) { yield return(ThingDefOf.Pemmican); } else { yield return(ThingDefOf.MealSimple); yield return(ThingDefOf.MealFine); yield return(ThingDefOf.MealSurvivalPack); } foreach (ThingDef item in PossibleRawFood(techLevel)) { yield return(item); } foreach (ThingDef item2 in ThingSetMakerUtility.allGeneratableItems.Where((ThingDef x) => x.IsMedicine)) { yield return(item2); } foreach (ThingDef item3 in ThingSetMakerUtility.allGeneratableItems.Where((ThingDef x) => x.IsDrug && (int)x.techLevel <= (int)techLevel)) { yield return(item3); } if (techLevel.IsNeolithicOrWorse()) { yield return(ThingDefOf.WoodLog); } else { foreach (ThingDef item4 in DefDatabase <ThingDef> .AllDefsListForReading.Where((ThingDef d) => BaseGenUtility.IsCheapWallStuff(d))) { yield return(item4); } } }
public float BaseGenerationChanceFactor(Pawn generated, Pawn other, PawnGenerationRequest request) { float num = 1f; if (generated.Faction != other.Faction) { num = (float)(num * 0.64999997615814209); } if (generated.HostileTo(other)) { num = (float)(num * 0.699999988079071); } if (other.Faction != null && other.Faction.IsPlayer) { num *= request.ColonistRelationChanceFactor; } TechLevel techLevel = (generated.Faction != null) ? generated.Faction.def.techLevel : TechLevel.Undefined; TechLevel techLevel2 = (other.Faction != null) ? other.Faction.def.techLevel : TechLevel.Undefined; if (techLevel != 0 && techLevel2 != 0 && techLevel != techLevel2) { num = (float)(num * 0.85000002384185791); } if (techLevel.IsNeolithicOrWorse() && !techLevel2.IsNeolithicOrWorse()) { goto IL_00e3; } if (!techLevel.IsNeolithicOrWorse() && techLevel2.IsNeolithicOrWorse()) { goto IL_00e3; } goto IL_00eb; IL_00eb: return(num); IL_00e3: num = (float)(num * 0.029999999329447746); goto IL_00eb; }
protected override IEnumerable <ThingDef> AllGeneratableThingsDebugSub(ThingSetMakerParams parms) { _003CAllGeneratableThingsDebugSub_003Ec__Iterator0 _003CAllGeneratableThingsDebugSub_003Ec__Iterator = (_003CAllGeneratableThingsDebugSub_003Ec__Iterator0) /*Error near IL_0054: stateMachine*/; TechLevel?techLevel2 = parms.techLevel; TechLevel techLevel = techLevel2.HasValue ? techLevel2.Value : TechLevel.Undefined; if (!techLevel.IsNeolithicOrWorse()) { yield return(ThingDefOf.MealSimple); /*Error: Unable to find new state assignment for yield return*/; } yield return(ThingDefOf.Pemmican); /*Error: Unable to find new state assignment for yield return*/; }
public float BaseGenerationChanceFactor(Pawn generated, Pawn other, PawnGenerationRequest request) { float num = 1f; if (generated.Faction != other.Faction) { num *= 0.65f; } if (generated.HostileTo(other)) { num *= 0.7f; } if (other.Faction != null && other.Faction.IsPlayer && (generated.Faction == null || !generated.Faction.IsPlayer)) { num *= 0.5f; } if (other.Faction != null && other.Faction.IsPlayer) { num *= request.ColonistRelationChanceFactor; } if (other == request.ExtraPawnForExtraRelationChance) { num *= request.RelationWithExtraPawnChanceFactor; } TechLevel techLevel = ((generated.Faction != null) ? generated.Faction.def.techLevel : TechLevel.Undefined); TechLevel techLevel2 = ((other.Faction != null) ? other.Faction.def.techLevel : TechLevel.Undefined); if (techLevel != 0 && techLevel2 != 0 && techLevel != techLevel2) { num *= 0.85f; } if ((techLevel.IsNeolithicOrWorse() && !techLevel2.IsNeolithicOrWorse()) || (!techLevel.IsNeolithicOrWorse() && techLevel2.IsNeolithicOrWorse())) { num *= 0.03f; } return(num); }