// Token: 0x0600007D RID: 125 RVA: 0x00006F64 File Offset: 0x00005164 public static void DoCaravanPainReliefResponse(Caravan car, Pawn pawn) { if (MSPainlessData.GetLastPainReliefTick(pawn) + 2500 * DRSettings.PainReliefWaitPeriod > Find.TickManager.TicksGame) { return; } ThingDef painDrugDef = MSPainUtility.NeedsPainReliefNow(pawn, out bool highpain); if (painDrugDef != null && MSDrugUtility.IsOKtoAdmin(pawn, null, painDrugDef) && !MSDrugUtility.IsViolation(pawn, painDrugDef) && MSCaravanUtility.CaravanHasDrug(car, painDrugDef, out Thing drug, out Pawn owner)) { MSPainlessData.MSPainlessDataTickSet(pawn); MSCaravanUtility.PawnOnCaravanTakeDrug(car, pawn, drug, owner); if (DRSettings.ShowReliefMsg) { Messages.Message(TranslatorFormattedStringExtensions.Translate("MSPainless.ReliefMsg", GenText.CapitalizeFirst(pawn.LabelShort), GenText.CapitalizeFirst(drug.def.label)), pawn, MessageTypeDefOf.NeutralEvent, false); } } }
// Token: 0x0600007E RID: 126 RVA: 0x00007018 File Offset: 0x00005218 public static Job DoPainReliefResponse(Pawn pawn) { if ((pawn?.CurJob) != null && pawn.CurJob.def == JobDefOf.Ingest) { return(null); } if (MSPainlessData.GetLastPainReliefTick(pawn) + 2500 * DRSettings.PainReliefWaitPeriod > Find.TickManager.TicksGame) { return(null); } ThingDef painDrugDef = MSPainUtility.NeedsPainReliefNow(pawn, out bool highpain); if (painDrugDef != null && MSDrugUtility.IsOKtoAdmin(pawn, null, painDrugDef) && !MSDrugUtility.IsViolation(pawn, painDrugDef)) { Thing drug = MSDrugUtility.FindDrugFor(pawn, painDrugDef); if (drug != null) { if (DRSettings.ShowReliefMsg) { Messages.Message(TranslatorFormattedStringExtensions.Translate("MSPainless.ReliefMsg", GenText.CapitalizeFirst(pawn.LabelShort), GenText.CapitalizeFirst(drug.def.label)), pawn, MessageTypeDefOf.NeutralEvent, false); } Job job = new Job(JobDefOf.Ingest, drug) { count = Mathf.Min(new int[] { drug.stackCount, drug.def.ingestible.maxNumToIngestAtOnce, 1 }) }; if (drug.Spawned && pawn.drugs != null && !pawn.inventory.innerContainer.Contains(drug.def)) { DrugPolicyEntry drugPolicyEntry = pawn.drugs.CurrentPolicy[drug.def]; if (drugPolicyEntry.takeToInventory > 0) { job.takeExtraIngestibles = drugPolicyEntry.takeToInventory; } } if (MSPainResponse.IsUsingPainJob(pawn, highpain) && !pawn.IsPrisoner) { MSPainlessData.MSPainlessDataTickSet(pawn); return(job); } if (MSAddDrugBill.GenDrugResponse(false, pawn, null, painDrugDef, null, null, 1)) { MSPainlessData.MSPainlessDataTickSet(pawn); return(null); } } } return(null); }
public static StatDrawEntry AffectedBodyPartsStat(RecipeDef surgery) { var bodyParts = new List <BodyPartDef> { }; string reportText = ""; string title = ""; if (surgery.targetsBodyPart) { bodyParts = surgery.appliedOnFixedBodyParts.ListFullCopy(); reportText = "Stat_Recipe_Surgery_AffectedBodyParts_Desc".Translate(); var sBPG = surgery.appliedOnFixedBodyPartGroups; if (!surgery.appliedOnFixedBodyPartGroups.NullOrEmpty()) { bodyParts.AddRange( DefDatabase <BodyDef> .AllDefs. SelectMany(bd => bd.AllParts).Distinct(). Where(bpr => sBPG.Any(bpgd => bpr.groups.Contains(bpgd))). Select(bpr => bpr.def) ); } } // Remove duplicates. No, really... bodyParts.RemoveDuplicates(); bodyParts = bodyParts.OrderBy(bpd => bpd.LabelShort).ToList(); // Use SimplifyBodyPartLabel to remove dupes, but it's not really suitable for display text, because // of certain spelling errors. So, we'll use the shortest string in each group for that. List <string> bodyPartLabels = bodyParts. Select(bpd => GenText.CapitalizeFirst(bpd.LabelShort)). // order first to make sure distinct picks the shortest one OrderBy(s => s.Length). ThenBy(s => s). Distinct(BodyPartMatcher.StringEqualityComparer). ToList() ; if (bodyPartLabels.Count == 0) { if (surgery.targetsBodyPart) { title = "Any".Translate(); reportText = "Stat_Recipe_Surgery_AffectedBodyParts_Desc_Any".Translate(); } else { title = "None".Translate(); reportText = "Stat_Recipe_Surgery_AffectedBodyParts_Desc_None".Translate(); } } else if (bodyPartLabels.Count <= 5) { title = string.Join("\n", bodyPartLabels); } else if (surgery.appliedOnFixedBodyPartGroups.Count > 0 && surgery.appliedOnFixedBodyPartGroups.Count <= 5) { title = string.Join("\n", surgery.appliedOnFixedBodyPartGroups.Select(bpd => bpd.LabelShortCap)); } else if (surgery.appliedOnFixedBodyParts.Count > 0 && surgery.appliedOnFixedBodyParts.Count <= 5) { title = string.Join("\n", surgery.appliedOnFixedBodyParts.Select(bpd => bpd.LabelShortCap)); } else { title = "VariousLabel".Translate(); } var sde = new StatDrawEntry( category: category, label: "Stat_Recipe_Surgery_AffectedBodyParts_Name".Translate(), reportText: reportText, valueString: title, hyperlinks: bodyParts.Select(bpd => new Dialog_InfoCard.Hyperlink(bpd)), displayPriorityWithinCategory: 4875 ); return(sde); }
// Token: 0x0600003C RID: 60 RVA: 0x000038A6 File Offset: 0x00001AA6 protected override IEnumerable <Toil> MakeNewToils() { Pawn actor = base.GetActor(); ToilFailConditions.FailOnDespawnedNullOrForbidden <JobDriver_JPRefuel>(this, TargetIndex.A); yield return(Toils_Reserve.Reserve(TargetIndex.A, 1, -1, null)); yield return(ToilFailConditions.FailOnDespawnedNullOrForbidden <Toil>(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch), TargetIndex.A)); Toil refuel = Toils_General.Wait(180, 0); ToilFailConditions.FailOnDespawnedNullOrForbidden <Toil>(refuel, TargetIndex.A); ToilFailConditions.FailOnCannotTouch <Toil>(refuel, TargetIndex.A, PathEndMode.Touch); ToilEffects.WithProgressBarToilDelay(refuel, TargetIndex.A, false, -0.5f); yield return(refuel); yield return(new Toil { initAction = delegate() { int JPFuel = 0; int JPMax = 0; Pawn obj = actor; if (obj != null && obj.apparel.WornApparelCount == 0) { //Log.Message("True: obj != null && obj.apparel.WornApparelCount == 0"); this.EndJobWith(JobCondition.Incompletable); return; } Apparel JetPack = null; List <Apparel> list = actor.apparel.WornApparel; for (int i = 0; i < list.Count; i++) { if (list[i] is JetPackApparel) { JetPack = list[i]; break; } } if (JetPack == null) { this.EndJobWith(JobCondition.Incompletable); return; } if (JetPack is JetPackApparel) { //Log.Message("True: JetPack is JetPackApparel"); JPFuel = (JetPack as JetPackApparel).JPFuelAmount; JPMax = (JetPack as JetPackApparel).JPFuelMax; } if (JPMax - JPFuel <= 0) { //Log.Message("True: JPMax - JPFuel <= 0"); this.EndJobWith(JobCondition.Incompletable); return; } if (this.TargetThingA.stackCount > JPMax - JPFuel) { //Log.Message("True: this.TargetThingA.stackCount > JPMax - JPFuel"); (JetPack as JetPackApparel).JPFuelAmount = JPMax; this.TargetThingA.stackCount -= JPMax - JPFuel; Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.FullyRefueled", actor.LabelShort), actor, MessageTypeDefOf.NeutralEvent, false); this.EndJobWith(JobCondition.Succeeded); return; } //Log.Message("False"); (JetPack as JetPackApparel).JPFuelAmount = JPFuel + this.TargetThingA.stackCount; Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.Refueled", GenText.CapitalizeFirst(actor.LabelShort), this.TargetThingA.stackCount.ToString(), (this.TargetThingA.stackCount > 1) ? "s" : ""), actor, MessageTypeDefOf.NeutralEvent, false); this.TargetThingA.Destroy(0); this.EndJobWith(JobCondition.Succeeded); } }); yield break; }
// Token: 0x0600002C RID: 44 RVA: 0x000031D8 File Offset: 0x000013D8 public void RefuelJP(Pawn pilot, Thing JP, bool Using) { if (Using) { if (this.JPComposMentis(pilot, JP, out string Reason)) { if (this.JPFuelAmount >= this.JPFuelMax) { Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.FullyFueled", GenText.CapitalizeFirst(JP.Label)), pilot, MessageTypeDefOf.NeutralEvent, false); SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null); return; } JobDef JPRefuel = DefDatabase <JobDef> .GetNamed("JPRefuel", true); this.FindBestJPFuel(pilot, out Thing targ); if (targ != null) { Job job = new Job(JPRefuel, targ); pilot.jobs.TryTakeOrderedJob(job, 0); return; } Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.NoFuelFound", GenText.CapitalizeFirst(this.JPFuelItem.label)), pilot, MessageTypeDefOf.NeutralEvent, false); SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null); return; } else { Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.CantDo", pilot, Reason), pilot, MessageTypeDefOf.NeutralEvent, false); SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null); } } }
// Token: 0x06000031 RID: 49 RVA: 0x00003520 File Offset: 0x00001720 internal bool FlightChecksOK(Pawn pilot, Thing JP, out string checksReason) { checksReason = ""; if ((pilot?.Map) == null) { checksReason = Translator.Translate("JetPack.ChecksLocation"); return(false); } if (GridsUtility.Roofed(pilot.Position, pilot.Map)) { if (!Settings.RoofPunch) { checksReason = Translator.Translate("JetPack.ChecksRoofed"); return(false); } ThingDef chkSKF = DefDatabase <ThingDef> .GetNamed(this.JPSkyFallType, false); if (chkSKF == null || !chkSKF.skyfaller.hitRoof) { checksReason = TranslatorFormattedStringExtensions.Translate("JetPack.ChecksSFNotRPunch", (chkSKF != null) ? GenText.CapitalizeFirst(chkSKF.label) : null); return(false); } } if (this.JPFuelAmount < this.JPFuelMin) { checksReason = Translator.Translate("JetPack.ChecksRefuel") + GenText.CapitalizeFirst(JP.Label); return(false); } return(true); }
// Token: 0x0600002B RID: 43 RVA: 0x0000302C File Offset: 0x0000122C internal void RefuelJetPack(Pawn pilot, ThingWithComps thing) { List <FloatMenuOption> list = new List <FloatMenuOption>(); string text = Translator.Translate("JetPack.JPDoNothing"); list.Add(new FloatMenuOption(text, delegate() { this.RefuelJP(pilot, thing, false); }, MenuOptionPriority.Default, null, null, 29f, null, null)); if (this.JPFuelAmount < this.JPFuelMax) { text = Translator.Translate("JetPack.JPDoRefuel"); list.Add(new FloatMenuOption(text, delegate() { this.RefuelJP(pilot, thing, true); }, MenuOptionPriority.Default, null, null, 29f, null, null)); } if (this.JPFuelAmount > 0) { text = Translator.Translate("JetPack.JPDropFuel"); list.Add(new FloatMenuOption(text, delegate() { this.DropFuelJP(pilot, thing); }, MenuOptionPriority.Default, null, null, 29f, null, null)); } List <string> fuels = JPUtility.ListFuelTypes(this.def); if (fuels.Count > 0) { for (int i = 0; i < fuels.Count; i++) { ThingDef fuelref = DefDatabase <ThingDef> .GetNamed(fuels[i], true); if (fuelref != (thing as JetPackApparel).JPFuelItem) { text = TranslatorFormattedStringExtensions.Translate("JetPack.JPDoChangeFuel", GenText.CapitalizeFirst(fuelref.label)); list.Add(new FloatMenuOption(text, delegate() { this.ChangeFuelJP(pilot, thing, fuelref, this.JPJumpRangeMin); }, MenuOptionPriority.Default, null, null, 29f, null, null)); } } } Find.WindowStack.Add(new FloatMenu(list)); }
// Token: 0x0600002A RID: 42 RVA: 0x00002E28 File Offset: 0x00001028 internal bool FlightCellCheck(Pawn pilot, IntVec3 tCell, int fuel, float fRate, float minJump, float maxJump, out string cantReason) { cantReason = ""; if (!GenGrid.InBounds(tCell, pilot.Map)) { cantReason = Translator.Translate("JetPack.JumpReasonInvalid"); return(false); } if (this.JPOnCooldown) { cantReason = Translator.Translate("JetPack.JumpReasonOnCooldown"); return(false); } if (!ReservationUtility.CanReserve(pilot, tCell, 1, -1, null, false)) { cantReason = Translator.Translate("JetPack.JumpReasonReserved"); return(false); } if (GridsUtility.Roofed(tCell, pilot.Map)) { if (!Settings.RoofPunch) { cantReason = Translator.Translate("JetPack.JumpReasonRoofed"); return(false); } ThingDef chkSKF = DefDatabase <ThingDef> .GetNamed(this.JPSkyFallType, false); if (chkSKF == null || !chkSKF.skyfaller.hitRoof) { cantReason = TranslatorFormattedStringExtensions.Translate("JetPack.JumpReasonSFNotRPunch", (chkSKF != null) ? GenText.CapitalizeFirst(chkSKF.label) : null); return(false); } } if (!GenGrid.Walkable(tCell, pilot.Map)) { cantReason = Translator.Translate("JetPack.JumpReasonNotWalk"); return(false); } if (DangerUtility.GetDangerFor(tCell, pilot, pilot.Map) == Danger.Deadly) { cantReason = Translator.Translate("JetPack.JumpReasonDeadly"); return(false); } float distance = IntVec3Utility.DistanceTo(pilot.Position, tCell); if (distance < minJump) { cantReason = TranslatorFormattedStringExtensions.Translate("JetPack.JumpReasonMinRange", ((int)minJump).ToString()); return(false); } if (distance > maxJump) { cantReason = TranslatorFormattedStringExtensions.Translate("JetPack.JumpReasonMaxRange", ((int)maxJump).ToString()); return(false); } if (fRate <= 0f) { cantReason = TranslatorFormattedStringExtensions.Translate("JetPack.JumpFuelRateInvalid", fRate.ToString()); return(false); } float distCanJump; if (Settings.UseCarry) { distCanJump = (float)fuel / fRate * JPWeightUtility.JPCarryFactor(pilot, this.def, this.JPFuelItem); } else { distCanJump = (float)fuel / fRate; } if (distCanJump > maxJump) { distCanJump = maxJump; } if (distCanJump < distance) { cantReason = Translator.Translate("JetPack.JumpNotEnoughfuel"); return(false); } return(true); }
// Token: 0x06000027 RID: 39 RVA: 0x00002B44 File Offset: 0x00000D44 public void UseJetPack(Pawn pilot, Thing JP, IntVec3 targCell) { if (!this.JPComposMentis(pilot, JP, out string Reason)) { Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.CantDo", pilot, Reason), pilot, MessageTypeDefOf.NeutralEvent, false); SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null); return; } if (!this.FlightChecksOK(pilot, JP, out string ChecksReason)) { Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.ChecksReason", GenText.CapitalizeFirst(pilot.LabelShort), ChecksReason), pilot, MessageTypeDefOf.NeutralEvent, false); SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null); return; } if (JPUtility.ChkForDissallowed(pilot, out string DAllowReason)) { Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.DAllowReason", GenText.CapitalizeFirst(pilot.LabelShort), DAllowReason), pilot, MessageTypeDefOf.NeutralEvent, false); SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null); return; } if (!this.FlightCellCheck(pilot, targCell, this.JPFuelAmount, this.JPFuelRate, this.JPJumpRangeMin, this.JPJumpRangeMax, out string JumpReason)) { Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.JumpReason", JumpReason), pilot, MessageTypeDefOf.NeutralEvent, false); SoundStarter.PlayOneShotOnCamera(SoundDefOf.ClickReject, null); return; } if (!JPInjury.CheckForExplosion(this)) { this.DoJumpJet(pilot, targCell); return; } JPInjury.DoJPExplosion(pilot, this.JPFuelAmount, this.JPFuelItem); this.JPFuelAmount = 0; }
// Token: 0x06000025 RID: 37 RVA: 0x00002B27 File Offset: 0x00000D27 public override IEnumerable <Gizmo> GetWornGizmos() { Texture2D fuelicon = this.JPFuelItem.uiIcon; if (fuelicon == null) { ThingDef chkFuelItem = null; if (this.JPFuelItem == null) { chkFuelItem = DefDatabase <ThingDef> .GetNamed(base.GetComp <CompJetPack>().Props.JPFuel, false); } if (chkFuelItem != null && chkFuelItem != this.JPFuelItem) { this.JPFuelItem = chkFuelItem; int chkFuelMax = base.GetComp <CompJetPack>().Props.JPFuelMaximum; if (chkFuelMax != this.JPFuelMax) { this.JPFuelMax = chkFuelMax; if (this.JPFuelAmount > this.JPFuelMax) { this.JPFuelAmount = this.JPFuelMax; } } } fuelicon = this.JPFuelItem.uiIcon; if (fuelicon == null) { this.JPFuelItem = ThingDefOf.Chemfuel; fuelicon = this.JPFuelItem.uiIcon; if (fuelicon == null) { fuelicon = this.def.uiIcon; Log.Message("Error: Jet Pack fuel definition not found.", false); } } } string chkSkyFallType = base.GetComp <CompJetPack>().Props.JPSKType; if (chkSkyFallType == null || chkSkyFallType == "") { this.JPSkyFallType = "SFJetPack"; } else if (chkSkyFallType != this.JPSkyFallType) { this.JPSkyFallType = chkSkyFallType; } Pawn pilot = base.Wearer; this.JPJumpRangeMax = (float)JPUtility.GetJumpRange(pilot, this.def, this.JPFuelItem, this.JPJumpRangeMin); this.JPFuelRate = JPUtility.GetFuelRate(this.JPFuelItem); if (base.Wearer != null && base.Wearer.IsColonistPlayerControlled) { Pawn wearer = base.Wearer; if ((wearer?.Map) != null && !base.Wearer.Downed && base.Wearer.Spawned && !JPUtility.IsInMeleeWithJP(base.Wearer)) { if (Find.Selector.SingleSelectedThing == base.Wearer) { string text; if (this.JPOnCooldown) { text = TranslatorFormattedStringExtensions.Translate("JetPack.CooldownTicks", this.JPCooldownTicks.ToString()); } else { text = Translator.Translate("JetPack.JPJump"); } string desc = TranslatorFormattedStringExtensions.Translate("JetPack.JPDesc", GenText.CapitalizeFirst(this.def.label)); yield return(new Command_JetPack { defaultLabel = text, defaultDesc = desc, icon = this.def.uiIcon, Pilot = base.Wearer, JPFuel = this.JPFuelAmount, JPFRate = this.JPFuelRate, JPMaxJump = this.JPJumpRangeMax, JPMinJump = this.JPJumpRangeMin, JPSKFStr = this.JPSkyFallType, action = delegate(IntVec3 cell) { SoundStarter.PlayOneShotOnCamera(SoundDefOf.Click, null); this.UseJetPack(base.Wearer, this, cell); } }); if (Settings.AllowSlowBurn) { text = Translator.Translate("JetPack.JPSBSet"); desc = Translator.Translate("JetPack.JPSBDesc"); yield return(new Command_Toggle { icon = ContentFinder <Texture2D> .Get(this.JPSBTexPath, true), defaultLabel = text, defaultDesc = desc, isActive = (() => this.JPSlowBurn), toggleAction = delegate() { this.ToggleSlowBurn(this.JPSlowBurn); } }); } text = TranslatorFormattedStringExtensions.Translate("JetPack.JPLabel", GenText.CapitalizeFirst(this.def.label), this.JPFuelAmount.ToString(), this.JPFuelMax.ToString()); desc = TranslatorFormattedStringExtensions.Translate("JetPack.JPDesc", GenText.CapitalizeFirst(this.def.label)); yield return(new Command_Action { defaultLabel = text, defaultDesc = desc, icon = fuelicon, action = delegate() { SoundStarter.PlayOneShotOnCamera(SoundDefOf.Click, null); this.RefuelJetPack(base.Wearer, this); } }); if (Prefs.DevMode) { yield return(new Command_Action { defaultLabel = "Debug Settings", defaultDesc = "Debug Commands", icon = fuelicon, action = delegate() { SoundStarter.PlayOneShotOnCamera(SoundDefOf.Click, null); this.DoJetPackDebug(base.Wearer, this); } }); } } yield break; } } yield break; }
// Token: 0x06000023 RID: 35 RVA: 0x000029F0 File Offset: 0x00000BF0 public override void Tick() { base.Tick(); if (this.JPCooldownTicks > 0) { this.JPCooldownTicks--; } if (Settings.AllowSlowBurn) { if (base.Wearer == null) { this.JPSlowBurn = false; return; } if (this.JPSlowBurn && base.Wearer.Spawned && PawnUtility.GetPosture(base.Wearer) != PawnPosture.LayingInBed && PawnUtility.GetPosture(base.Wearer) != PawnPosture.LayingOnGroundFaceUp && PawnUtility.GetPosture(base.Wearer) != PawnPosture.LayingOnGroundNormal) { if (this.JPSlowBurnTicks > 0) { this.JPSlowBurnTicks--; return; } if (this.JPFuelAmount > 0) { this.JPFuelAmount--; this.JPSlowBurnTicks = JPUtility.GetSlowBurnTicks(this.JPFuelItem); return; } this.JPSlowBurn = false; Messages.Message(TranslatorFormattedStringExtensions.Translate("JetPack.SBOutOfFuel", GenText.CapitalizeFirst(base.Wearer.LabelShort), GenText.CapitalizeFirst(this.Label)), base.Wearer, MessageTypeDefOf.NeutralEvent, false); return; } } else { this.JPSlowBurn = false; } }