// Token: 0x06000041 RID: 65 RVA: 0x00004664 File Offset: 0x00002864 public static bool GetIsBitsSource(ThingDef defSource, bool isSource, Pawn pawn, out ThingDef bitsdef, out int bitsyield) { bitsdef = null; bitsyield = 0; if (MSBitsUtility.GetBitsSource(defSource) || isSource) { bitsdef = DefDatabase <ThingDef> .GetNamed(MSBitsUtility.bitschance.RandomElementByWeight((Pair <string, float> x) => x.Second).First, false); if (bitsdef != null) { bitsyield = MSBitsUtility.GetBitsYield(defSource, bitsdef); if (bitsyield > 0) { return(true); } } } return(false); }
public static void PostFix(ref Mineable __instance, Map map, float yieldChance, bool moteOnWaste, Pawn pawn) { if (pawn == null) { return; } var isSource = false; if (__instance.def.defName == "CollapsedRocks" || __instance.def.defName == "rxCollapsedRoofRocks") { isSource = Controller.Settings.AllowCollapseRocks; } var mineable = __instance; object obj; if (mineable == null) { obj = null; } else { var def = mineable.def; if (def == null) { obj = null; } else { var building = def.building; obj = building?.mineableThing; } } if (obj == null && !isSource) { return; } var mining = 0; var skills = pawn.skills; var b = skills?.GetSkill(SkillDefOf.Mining) != null; if (b) { mining = pawn.skills.GetSkill(SkillDefOf.Mining).Level / 4; } if (Rand.Range(1, 100) > 20 + mining) { return; } var mineable2 = __instance; ThingDef defSource; if (mineable2 == null) { defSource = null; } else { var def2 = mineable2.def; if (def2 == null) { defSource = null; } else { var building2 = def2.building; defSource = building2?.mineableThing; } } if (!MSBitsUtility.GetIsBitsSource(defSource, isSource, pawn, out var bitsdef, out var bitsyield) || bitsdef == null || bitsyield <= 0) { return; } var num = Mathf.Max(1, Mathf.RoundToInt(bitsyield * Find.Storyteller.difficulty.mineYieldFactor)); var thing = ThingMaker.MakeThing(bitsdef); thing.stackCount = num; GenPlace.TryPlaceThing(thing, pawn.Position, map, ThingPlaceMode.Near, out var newbitsthing); if (!pawn.IsColonist && newbitsthing.def.EverHaulable && !newbitsthing.def.designateHaulable) { newbitsthing.SetForbidden(true); } }
public static void PostFix(ref Mineable __instance, Map map, float yieldChance, bool moteOnWaste, Pawn pawn) { if (pawn != null) { bool isSource = false; if (__instance.def.defName == "CollapsedRocks" || __instance.def.defName == "rxCollapsedRoofRocks") { isSource = Controller.Settings.AllowCollapseRocks; } Mineable mineable = __instance; object obj; if (mineable == null) { obj = null; } else { ThingDef def = mineable.def; if (def == null) { obj = null; } else { BuildingProperties building = def.building; obj = (building?.mineableThing); } } if (obj != null || isSource) { int mining = 0; bool flag; if (pawn == null) { flag = (null != null); } else { Pawn_SkillTracker skills = pawn.skills; flag = ((skills?.GetSkill(SkillDefOf.Mining)) != null); } if (flag) { mining = pawn.skills.GetSkill(SkillDefOf.Mining).Level / 4; } if (Rand.Range(1, 100) <= 20 + mining) { Mineable mineable2 = __instance; ThingDef defSource; if (mineable2 == null) { defSource = null; } else { ThingDef def2 = mineable2.def; if (def2 == null) { defSource = null; } else { BuildingProperties building2 = def2.building; defSource = (building2?.mineableThing); } } if (MSBitsUtility.GetIsBitsSource(defSource, isSource, pawn, out ThingDef bitsdef, out int bitsyield) && bitsdef != null && bitsyield > 0) { int num = Mathf.Max(1, Mathf.RoundToInt((float)bitsyield * Find.Storyteller.difficulty.mineYieldFactor)); Thing thing = ThingMaker.MakeThing(bitsdef, null); thing.stackCount = num; GenPlace.TryPlaceThing(thing, pawn.Position, map, ThingPlaceMode.Near, out Thing newbitsthing, null, null, default);