// Before an orbital trade static void Postfix(ref IEnumerable <Thing> __result, Pawn playerNegotiator) { if (playerNegotiator != null && playerNegotiator.Map != null) { foreach (Thing thing in playerNegotiator.Map.listerThings.AllThings) { if (thing != null && ThingCompUtility.TryGetComp <CompRefrigerator>(thing) != null && thing.def.passability == Traversability.Impassable && thing is Building_Storage storage) { foreach (IntVec3 cell in storage.AllSlotCells()) { foreach (Thing refrigeratedItem in playerNegotiator.Map.thingGrid.ThingsAt(cell)) { if (storage.settings.AllowedToAccept(refrigeratedItem)) { if (__result == null) { __result = new List <Thing>(__result); } __result.AddItem(refrigeratedItem); break; } } } } } } }
public static void PostFix(Thing t, Color newColor, bool reportFailure = true) { if (t.def.IsApparel && t.def.defName.StartsWith("CASFlak")) { CompColorable compColorable = ThingCompUtility.TryGetComp <CompColorable>(t); if (compColorable != null) { ThingDef def = t.def; bool flag; if (def == null) { flag = false; } else { GraphicData graphicData = def.graphicData; Color? color = (graphicData != null) ? new Color?(graphicData.color) : null; flag = (color != null); } if (flag) { Color color2 = t.def.graphicData.color; compColorable.Color = color2; } } } }
// Token: 0x06000018 RID: 24 RVA: 0x00002C58 File Offset: 0x00000E58 public static bool TryGetCamoHidValue(Pawn seer, Pawn target, out bool hid) { hid = false; if (seer != null) { PawnCamoData pawnCamoData = ThingCompUtility.TryGetComp <PawnCamoData>(seer); if (pawnCamoData != null) { int ticksGame = Find.TickManager.TicksGame; List <string> list = pawnCamoData?.PawnHidTickList; if (list != null && list.Count > 0) { foreach (string valuesStr in list) { if (CamoGearUtility.GetIntValue(valuesStr, 1) + CamoUtility.TickElapse >= ticksGame) { int intValue = CamoGearUtility.GetIntValue(valuesStr, 0); if (target != null && target != null) { int thingIDNumber = target.thingIDNumber; if (intValue == target.thingIDNumber) { string strValue = CamoGearUtility.GetStrValue(valuesStr, 2); hid = (strValue == "1"); return(true); } } } } return(false); } } } return(false); }
public static void Patch_VerbTracker_GetVerbsCommands_Postfix( ref VerbTracker __instance, ref IEnumerable <Command> __result, ref KeyCode hotKey) { CompEquippable directOwner = __instance.directOwner as CompEquippable; MultiVerbComp multiVerb = (MultiVerbComp)null; if (directOwner == null || (M0)(multiVerb = (MultiVerbComp)ThingCompUtility.TryGetComp <MultiVerbComp>((Thing)((ThingComp)directOwner).parent)) == null) { return; } List <Command> commandList = new List <Command>(); int index = 0; commandList.AddRange(__result); using (List <Verb> .Enumerator enumerator = __instance.get_AllVerbs().GetEnumerator()) { while (enumerator.MoveNext()) { MechaniteForgeHarmonyPatches.Command_MultiVerb commandMultiVerb = new MechaniteForgeHarmonyPatches.Command_MultiVerb(enumerator.Current, multiVerb, index); commandList.Add((Command)commandMultiVerb); ++index; } } __result = (IEnumerable <Command>)commandList; }
// Token: 0x0600003C RID: 60 RVA: 0x00002F10 File Offset: 0x00001110 public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false) { CompUniversalFermenter compUniversalFermenter = ThingCompUtility.TryGetComp <CompUniversalFermenter>(t); if (compUniversalFermenter == null || compUniversalFermenter.Fermented || compUniversalFermenter.SpaceLeftForIngredient <= 0) { return(false); } float ambientTemperature = compUniversalFermenter.parent.AmbientTemperature; if (ambientTemperature < compUniversalFermenter.Product.temperatureSafe.min + 2f || ambientTemperature > compUniversalFermenter.Product.temperatureSafe.max - 2f) { JobFailReason.Is(WorkGiver_FillUniversalFermenter.TemperatureTrans, null); return(false); } if (ForbidUtility.IsForbidden(t, pawn) || !ReservationUtility.CanReserveAndReach(pawn, t, (PathEndMode)2, DangerUtility.NormalMaxDanger(pawn), 1, -1, null, forced)) { return(false); } if (pawn.Map.designationManager.DesignationOn(t, DesignationDefOf.Deconstruct) != null) { return(false); } if (this.FindIngredient(pawn, t) == null) { JobFailReason.Is(WorkGiver_FillUniversalFermenter.NoIngredientTrans, null); return(false); } return(!FireUtility.IsBurning(t)); }
public override void CompTickRare() { base.CompTickRare(); float num = 15f; if (parent.MapHeld != null) { num = GridsUtility.GetTemperature(parent.PositionHeld, parent.MapHeld); } CompEquippable comp = parent.GetComp <CompEquippable>(); if (comp != null) { Pawn casterPawn = comp.PrimaryVerb.CasterPawn; if (casterPawn != null) { num = GridsUtility.GetTemperature(casterPawn.PositionHeld, casterPawn.MapHeld); } } if (parent.Spawned) { List <Thing> thingList = GridsUtility.GetThingList(parent.PositionHeld, parent.MapHeld); for (int i = 0; i < thingList.Count; i++) { CompRefrigerator fridge = ThingCompUtility.TryGetComp <CompRefrigerator>(thingList[i]); if (fridge != null) { num = fridge.currentTemp; break; } } } temperature += (num - temperature) * 0.05f; }
// Token: 0x06000011 RID: 17 RVA: 0x00002740 File Offset: 0x00000940 public static void DrawCamoOverlay(Pawn pawn) { bool flag = false; string text = ""; if (CamoUtility.IsCamoActive(pawn, out Apparel apparel) && apparel != null) { float activeCamoEff = ThingCompUtility.TryGetComp <CompGearCamo>(apparel).Props.ActiveCamoEff; if (ThingCompUtility.TryGetComp <CompGearCamo>(apparel).Props.StealthCamoChance > 0 && activeCamoEff > 0f) { text = "Mote_CASStealth"; flag = true; } else if (activeCamoEff > 0f) { text = CamoDrawTools.GetMoteToUse(activeCamoEff); flag = true; } } if (!flag && CamoGearUtility.GetCurCamoEff(pawn, out string text2, out float num) && num > 0f) { text = CamoDrawTools.GetMoteToUse(num); flag = true; } if (flag && text != "") { CamoDrawTools.DoCamoOverlay(pawn, text); } }
// Token: 0x0600003D RID: 61 RVA: 0x000046D8 File Offset: 0x000028D8 internal static float GetApparelCamoEff(Pawn pawn, Apparel apparel, string camoType) { float num = 0f; if (pawn != null && (pawn?.Map) != null && camoType != null) { if (ThingCompUtility.TryGetComp <CompGearCamo>(apparel) != null) { if (camoType == "notDefined") { num += CamoPresets.GetCamoPresetEff(apparel, "Arctic"); num += CamoPresets.GetCamoPresetEff(apparel, "Desert"); num += CamoPresets.GetCamoPresetEff(apparel, "Jungle"); num += CamoPresets.GetCamoPresetEff(apparel, "Stone"); num += CamoPresets.GetCamoPresetEff(apparel, "Woodland"); num += CamoPresets.GetCamoPresetEff(apparel, "Urban"); num = num / 6f * 0.75f; } else { num = CamoPresets.GetCamoPresetEff(apparel, camoType); } } else { num = CamoPresets.GetCamoPresetEff(apparel, camoType); } } return(num); }
// Token: 0x06000187 RID: 391 RVA: 0x0000EA24 File Offset: 0x0000CC24 public override void Resolve(ResolveParams rp) { Map map = BaseGen.globalSettings.map; Rand.PushState(); for (int i = 0; i < Rand.RangeInclusive(10, 25); i++) { IntVec3 randomCell = rp.rect.RandomCell; if (GenGrid.Standable(randomCell, map) && GridsUtility.GetFirstItem(randomCell, map) == null && GridsUtility.GetFirstPawn(randomCell, map) == null && GridsUtility.GetFirstBuilding(randomCell, map) == null) { Pawn val = PawnGenerator.GeneratePawn(PawnKindDefOf.Villager, Find.FactionManager.RandomEnemyFaction(false, false, false, (TechLevel)0)); ((Thing)val).Kill((DamageInfo?)new DamageInfo(DamageDefOf.Cut, 9999f, 0f, -1f, (Thing)null, (BodyPartRecord)null, (ThingDef)null, (SourceCategory)0, (Thing)null), (Hediff)null); Corpse corpse = val.Corpse; corpse.timeOfDeath = 10000; ThingCompUtility.TryGetComp <CompRottable>((Thing)(object)corpse).RotImmediately(); GenSpawn.Spawn((Thing)(object)corpse, randomCell, map, (WipeMode)0); for (int j = 0; j < 5; j++) { IntVec3 val2 = default(IntVec3); RCellFinder.TryFindRandomCellNearWith(randomCell, (Predicate <IntVec3>)((IntVec3 ni) => GenGrid.Walkable(ni, map)), map, out val2, 1, 3); GenSpawn.Spawn(RimWorld.ThingDefOf.Filth_CorpseBile, val2, map, (WipeMode)0); } } } Rand.PopState(); }
// Token: 0x06000002 RID: 2 RVA: 0x00002090 File Offset: 0x00000290 private static void MakeButcherProducts_PostFix(Thing __instance, ref IEnumerable <Thing> __result, Pawn butcher, float efficiency) { CompSpecialButcherChance compSpecialButcherChance; if ((compSpecialButcherChance = ThingCompUtility.TryGetComp <CompSpecialButcherChance>(__instance)) != null) { if (GenList.NullOrEmpty <ThingDefCountWithChanceClass>(compSpecialButcherChance.Props.butcherProducts)) { return; } foreach (ThingDefCountWithChanceClass thingDefCountWithChanceClass in compSpecialButcherChance.Props.butcherProducts) { if (Rand.Chance(thingDefCountWithChanceClass.chance)) { ThingDefCountWithChanceClass thingDefCountWithChanceClass2 = new ThingDefCountWithChanceClass { thingDef = thingDefCountWithChanceClass.thingDef, count = thingDefCountWithChanceClass.count }; int num = GenMath.RoundRandom((float)thingDefCountWithChanceClass2.count * efficiency); if (num > 0) { Thing thing = ThingMaker.MakeThing(thingDefCountWithChanceClass2.thingDef, null); thing.stackCount = num; __result = __result.Add(thing); } } } } }
static void Prefix(Building_TurretGunCE __instance) { if (__instance.GetType().GetField("mannableComp", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(__instance) is CompMannable mannable && __instance.CompAmmo.UseAmmo) { CompInventory inv = ThingCompUtility.TryGetComp <CompInventory>(mannable.ManningPawn); if (mannable.ManningPawn.IsColonist && inv != null) { Thing thing = inv.container.FirstOrDefault((Thing x) => x.def == __instance.CompAmmo.SelectedAmmo); if (thing == null) { AmmoDef ammoDef = __instance.CompAmmo.SelectedAmmo; if (ammoDef != null && CombatExtendedUtil.HasAmmo(ammoDef)) { int magazineSize = __instance.CompAmmo.Props.magazineSize; if (CombatExtendedUtil.TryRemoveAmmo(ammoDef, magazineSize, out Thing ammo)) { inv.UpdateInventory(); if (!inv.container.TryAdd(ammo as ThingWithComps)) { Log.Error("Failed to add ammo to pawn inventory"); CombatExtendedUtil.AddAmmo(ammo); } } } } } } }
// Token: 0x0600000C RID: 12 RVA: 0x00002524 File Offset: 0x00000724 public static void CorrectJob(Pawn seer, Pawn target) { if (seer != null && target != null && (seer?.Map) != null && (target?.Map) != null && seer.Map == target.Map) { bool flag; if (seer == null) { flag = (null != null); } else { Pawn_MindState mindState = seer.mindState; flag = ((mindState?.meleeThreat) != null); } if (!flag && ThingCompUtility.TryGetComp <PawnCamoData>(seer).LastCamoCorrectTick + 120 <= Find.TickManager.TicksGame && seer.Spawned && target.Spawned) { bool flag2; if (seer == null) { flag2 = (null != null); } else { Pawn_JobTracker jobs = seer.jobs; flag2 = ((jobs?.curJob) != null); } if (flag2 && seer.jobs.curJob.def != CamoAIUtility.CamoPauseJobDef() && seer.jobs.curJob.AnyTargetIs(target)) { ThingCompUtility.TryGetComp <PawnCamoData>(seer).LastCamoCorrectTick = Find.TickManager.TicksGame; CamoAIUtility.RemoveTarget(seer, target); } } } }
public static void Postfix(Pawn pawn, Building_Turret tube, ref Thing __result) { if (__result != null) { return; } var turret = tube as Building_ShipTurret; StorageSettings allowedShellsSettings = ThingCompUtility.TryGetComp <CompChangeableProjectilePlural>(turret.gun).allowedShellsSettings; Predicate <Thing> pred = (Thing x) => { if (ForbidUtility.IsForbidden(x, pawn) || !ReservationUtility.CanReserve(pawn, x, 1, -1, (ReservationLayerDef)null, false)) { return(false); } else { return(allowedShellsSettings?.AllowedToAccept(x) ?? true); } }; foreach (String defName in shellDefNames) { var val = ThingDef.Named(defName); __result = GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, ThingRequest.ForDef(val), PathEndMode.ClosestTouch, TraverseParms.For(pawn), 9999f, pred); if (__result != null) { return; } } }
public static Courier GetCourierComponent(this Pawn pawn) { if (ThingCompUtility.TryGetComp <Courier>(pawn) != null) { return(ThingCompUtility.TryGetComp <Courier>(pawn)); } return(null); }
public static MailBox GetMailBoxComponent(this Thing thing) { if (ThingCompUtility.TryGetComp <MailBox>(thing) != null) { return(ThingCompUtility.TryGetComp <MailBox>(thing)); } return(null); }
// Token: 0x0600003E RID: 62 RVA: 0x00003028 File Offset: 0x00001228 private Thing FindIngredient(Pawn pawn, Thing fermenter) { ThingFilter filter = ThingCompUtility.TryGetComp <CompUniversalFermenter>(fermenter).Product.ingredientFilter; Predicate <Thing> predicate = (Thing x) => !ForbidUtility.IsForbidden(x, pawn) && ReservationUtility.CanReserve(pawn, x, 1, -1, null, false) && filter.Allows(x); Predicate <Thing> predicate2 = predicate; return(GenClosest.ClosestThingReachable(pawn.Position, pawn.Map, filter.BestThingRequest, (PathEndMode)3, TraverseParms.For(pawn, (Danger)3, 0, false), 9999f, predicate2, null, 0, -1, false, (RegionType)6, false)); }
public static Tenant GetTenantComponent(this Pawn pawn) { if (ThingCompUtility.TryGetComp <Tenant>(pawn) != null) { return(ThingCompUtility.TryGetComp <Tenant>(pawn)); } return(null); }
public static void SetAlienHead(Pawn pawn, string head) { var alienComp = ThingCompUtility.TryGetComp <AlienRace.AlienPartGenerator.AlienComp>(pawn); if (alienComp != null) { alienComp.crownType = head; } }
// Token: 0x0600003D RID: 61 RVA: 0x00002FE4 File Offset: 0x000011E4 public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false) { Thing thing = this.FindIngredient(pawn, t); return(new Job(DefDatabase <JobDef> .GetNamed("VG_FillUniversalFermenter", true), t, thing) { count = ThingCompUtility.TryGetComp <CompUniversalFermenter>(t).SpaceLeftForIngredient }); }
public static void SetSyrTraitsRomanceFactor(Pawn pawn, float romanceFactor) { var comp = ThingCompUtility.TryGetComp <SyrTraits.CompIndividuality>(pawn); if (comp != null) { comp.RomanceFactor = romanceFactor; } }
public static void SetSyrTraitsSexuality(Pawn pawn, int sexuality) { var comp = ThingCompUtility.TryGetComp <SyrTraits.CompIndividuality>(pawn); if (comp != null) { comp.sexuality = (SyrTraits.CompIndividuality.Sexuality)sexuality; } }
// Token: 0x06000004 RID: 4 RVA: 0x00002160 File Offset: 0x00000360 private List <Thing> CreateLoot() { List <Thing> list = new List <Thing>(); int ItemCount; if (PropsResourceBox.spawnAll) { ItemCount = PropsResourceBox.possibleItems.Count; } else { ItemCount = Rand.RangeInclusive(PropsResourceBox.minItems, PropsResourceBox.maxItems); } for (int i = 0; i < ItemCount; i++) { ThingDef named = null; int PerItemCount; int j = 0; if (PropsResourceBox.PerItemCount != 0) { PerItemCount = PropsResourceBox.PerItemCount; } else { PerItemCount = Rand.RangeInclusive(PropsResourceBox.minPerItem, PropsResourceBox.maxPerItem); } if (!PropsResourceBox.possibleItems.NullOrEmpty()) { if (PropsResourceBox.spawnAll) { named = PropsResourceBox.possibleItems[i]; } else { named = PropsResourceBox.possibleItems.RandomElement(); } } if (named != null) { Thing thing = ThingMaker.MakeThing(named, GenStuff.RandomStuffFor(named)); thing.stackCount = PerItemCount; CompQuality compQuality = ThingCompUtility.TryGetComp <CompQuality>(thing); if (compQuality != null) { QualityCategory qualityCategory = QualityUtility.GenerateQualityCreatedByPawn(Rand.RangeInclusive(0, 19), false); compQuality.SetQuality(qualityCategory, 0); } CompArt compArt = ThingCompUtility.TryGetComp <CompArt>(thing); if (compArt != null) { compArt.InitializeArt(0); } list.Add(thing); } } return(list); }
public static void SetSkinColor(Pawn pawn, Color color) { var alienComp = ThingCompUtility.TryGetComp <AlienRace.AlienPartGenerator.AlienComp>(pawn); if (alienComp != null) { alienComp.GetChannel("skin").first = color; } }
public static int GetSyrTraitsSexuality(Pawn pawn) { var comp = ThingCompUtility.TryGetComp <SyrTraits.CompIndividuality>(pawn); if (comp != null) { return((int)comp.sexuality); } return(-1); }
public static float GetSyrTraitsRomanceFactor(Pawn pawn) { var comp = ThingCompUtility.TryGetComp <SyrTraits.CompIndividuality>(pawn); if (comp != null) { return(comp.RomanceFactor); } return(-1f); }
// Token: 0x06000072 RID: 114 RVA: 0x00006B74 File Offset: 0x00004D74 public static int GetLastPainReliefTick(Pawn pawn) { ThingComp PComp = (pawn != null) ? ThingCompUtility.TryGetComp <MSPainlessData>(pawn) : null; if (PComp != null) { return((PComp as MSPainlessData).LastPainReliefTick); } return(0); }
public override void TickRare() { if (this.CurrentTemp < -2000f) { this.CurrentTemp = GridsUtility.GetTemperature(base.Position, base.Map); } foreach (IntVec3 cell in this.AllSlotCells()) { foreach (Thing thing in GridsUtility.GetThingList(cell, base.Map)) { CompRottable rottable = ThingCompUtility.TryGetComp <CompRottable>(thing); if (rottable != null && !(rottable is CompBetterRottable)) { ThingWithComps thingWithComps = thing as ThingWithComps; CompBetterRottable compBetterRottable = new CompBetterRottable(); thingWithComps.AllComps.Remove(rottable); thingWithComps.AllComps.Add(compBetterRottable); compBetterRottable.props = rottable.props; compBetterRottable.parent = thingWithComps; compBetterRottable.RotProgress = rottable.RotProgress; } if (ThingCompUtility.TryGetComp <CompFrosty>(thing) == null && thing.def.defName == "Beer") { ThingWithComps thingWithComps = thing as ThingWithComps; CompFrosty compFrosty = new CompFrosty(); thingWithComps.AllComps.Add(compFrosty); compFrosty.props = CompProperties_Frosty.Beer; compFrosty.parent = thingWithComps; ((TickList)typeof(TickManager).GetField("tickListRare", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(Find.TickManager)).RegisterThing(thingWithComps); } } } float roomTemperature = GridsUtility.GetTemperature(base.Position, base.Map); float changetemperature = (roomTemperature - this.CurrentTemp) * 0.01f; float changeEnergy = -changetemperature; float powerMultiplier = 0f; if (this.CurrentTemp + changetemperature > this.DesiredTemp) { float change = Mathf.Max(this.DesiredTemp - (this.CurrentTemp + changetemperature), -1f); if (this.powerComp != null && this.powerComp.PowerOn) { changetemperature += change; changeEnergy -= change * 1.25f; } powerMultiplier = change * -1f; } this.CurrentTemp += changetemperature; IntVec3 pos = base.Position + IntVec3.North.RotatedBy(base.Rotation); GenTemperature.PushHeat(pos, base.Map, changeEnergy * 1.25f); this.powerComp.PowerOutput = -((CompProperties_Power)this.powerComp.props).basePowerConsumption * (powerMultiplier * 0.9f + 0.1f); }
// Token: 0x06000038 RID: 56 RVA: 0x00003F58 File Offset: 0x00002158 internal static bool GetCurCamoEff(Pawn pawn, out string type, out float CamoEff) { CamoEff = 0f; type = CamoGearUtility.GetCamoType(pawn); PawnCamoData pawnCamoData = ThingCompUtility.TryGetComp <PawnCamoData>(pawn); if (pawnCamoData != null) { string a = type; if (!(a == "Arctic")) { if (!(a == "Desert")) { if (!(a == "Jungle")) { if (!(a == "Stone")) { if (!(a == "Woodland")) { if (!(a == "Urban")) { CamoEff = pawnCamoData.PawnnotDefinedCamo; } else { CamoEff = pawnCamoData.PawnUrbanCamo; } } else { CamoEff = pawnCamoData.PawnWoodlandCamo; } } else { CamoEff = pawnCamoData.PawnStoneCamo; } } else { CamoEff = pawnCamoData.PawnJungleCamo; } } else { CamoEff = pawnCamoData.PawnDesertCamo; } } else { CamoEff = pawnCamoData.PawnArcticCamo; } } return(CamoEff > 0f); }
// Token: 0x06000006 RID: 6 RVA: 0x000021CC File Offset: 0x000003CC private static void GiveWaitJob(Pawn pawn, int period) { ThingCompUtility.TryGetComp <PawnCamoData>(pawn).LastCamoCorrectTick = Find.TickManager.TicksGame; Job job = new Job(CamoAIUtility.CamoPauseJobDef()) { expiryInterval = period, checkOverrideOnExpire = true }; pawn.jobs.jobQueue.EnqueueFirst(job, null); }
// Token: 0x06000073 RID: 115 RVA: 0x00006BA0 File Offset: 0x00004DA0 public static void MSPainlessDataTickSet(Pawn pawn) { ThingComp PComp = (pawn != null) ? ThingCompUtility.TryGetComp <MSPainlessData>(pawn) : null; if (PComp != null) { if (PComp is MSPainlessData PData) { PData.LastPainReliefTick = Find.TickManager.TicksGame; } } }