protected override IEnumerable <Toil> MakeNewToils() { this.FailOnDespawnedNullOrForbidden(TargetIndex.A); this.FailOnBurningImmobile(TargetIndex.A); int num = this.pawn.Map.reservationManager.CanReserveStack(this.pawn, this.ShardsUsed, 1, null, false); Toil toil = Toils_Reserve.Reserve(TargetIndex.B, 1, -1, null); yield return(toil); Toil getToHaulTarget = Toils_Goto.GotoThing(TargetIndex.B, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(TargetIndex.B).FailOnSomeonePhysicallyInteracting(TargetIndex.B); yield return(getToHaulTarget); yield return(Toils_Haul.StartCarryThing(TargetIndex.B, false, true, false).FailOnDestroyedNullOrForbidden(TargetIndex.B)); yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell).FailOnDestroyedOrNull(TargetIndex.B)); yield return(Toils_Haul.PlaceHauledThingInCell(TargetIndex.C, null, false, false)); yield return(Toils_General.Wait(600, TargetIndex.None).FailOnDestroyedNullOrForbidden(TargetIndex.B).FailOnDestroyedNullOrForbidden(TargetIndex.A).FailOnCannotTouch(TargetIndex.A, PathEndMode.InteractionCell).WithProgressBarToilDelay(TargetIndex.A, false, -0.5f)); yield return(new Toil { initAction = delegate() { int numShards = this.pawn.CurJob.targetB.Thing.stackCount; ShardApplier.ApplyTechshards(this.TechshardComp.Props.project, this.pawn, numShards); this.Techprint.Destroy(DestroyMode.Vanish); }, defaultCompleteMode = ToilCompleteMode.Instant }); yield return(Toils_Reserve.Release(TargetIndex.A)); yield break; }
private static bool Prefix(ResearchProjectDef proj, Pawn applyingPawn) { ShardApplier.RefundUnlock(proj, applyingPawn, 100); return(true); }
public static void AdvanceShardReq(ResearchProjectDef unlockTarget, int numShards, ResearchProjectDef shardProject) { int weightedShards = Mathf.RoundToInt(Mathf.Max(GetShardRatio(shardProject, unlockTarget) * numShards, 1)); ShardApplier.AddTechshards(unlockTarget, weightedShards); }
public override IEnumerable <FloatMenuOption> CompFloatMenuOptions(Pawn selPawn) { JobFailReason.Clear(); if (selPawn.WorkTypeIsDisabled(WorkTypeDefOf.Research) || selPawn.WorkTagIsDisabled(WorkTags.Intellectual)) { JobFailReason.Is("WillNever".Translate("Research".TranslateSimple().UncapitalizeFirst()), null); } else if (this.Props.project.TechprintRequirementMet && (!TechprintingSettings.enableUnlockedTechPrinting || (ShardApplier.FindBestProjectToAdvance(this.Props.project) == null && ShardApplier.FindBestProjectToUnlock(this.Props.project) == null) ) ) { JobFailReason.Is("NoResearchToApply".Translate(), null); } else if (!selPawn.CanReach(this.parent, PathEndMode.ClosestTouch, Danger.Some, false, TraverseMode.ByPawn)) { JobFailReason.Is("CannotReach".Translate(), null); } else if (!selPawn.CanReserve(this.parent, 1, -1, null, false)) { Pawn pawn = selPawn.Map.reservationManager.FirstRespectedReserver(this.parent, selPawn); if (pawn == null) { pawn = selPawn.Map.physicalInteractionReservationManager.FirstReserverOf(selPawn); } if (pawn != null) { JobFailReason.Is("ReservedBy".Translate(pawn.LabelShort, pawn), null); } else { JobFailReason.Is("Reserved".Translate(), null); } } HaulAIUtility.PawnCanAutomaticallyHaul(selPawn, this.parent, true); Thing thing2 = GenClosest.ClosestThingReachable(selPawn.Position, selPawn.Map, ThingRequest.ForGroup(ThingRequestGroup.ResearchBench), PathEndMode.InteractionCell, TraverseParms.For(selPawn, Danger.Some, TraverseMode.ByPawn, false), 9999f, (Thing thing) => thing is Building_ResearchBench && selPawn.CanReserve(thing, 1, -1, null, false), null, 0, -1, false, RegionType.Set_Passable, false); Job job = null; if (thing2 != null && this.parent.stackCount > 0) { job = JobMaker.MakeJob(Base.DefOf.ApplyTechshards); job.targetA = thing2; job.targetB = this.parent; int count = this.Props.project.techprintCount - Current.Game.researchManager.GetTechprints(this.Props.project); if (count > 0) { job.count = Math.Min(this.parent.stackCount, count); } else { job.count = this.parent.stackCount; } job.targetC = thing2.Position; } if (JobFailReason.HaveReason) { yield return(new FloatMenuOption("CannotGenericWorkCustom".Translate("ApplyTechshard".Translate(this.parent.Label)) + ": " + JobFailReason.Reason.CapitalizeFirst(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); JobFailReason.Clear(); } else { yield return(new FloatMenuOption("ApplyTechshard".Translate(this.parent.Label).CapitalizeFirst(), delegate() { if (job == null) { Messages.Message("MessageNoResearchBenchForTechshard".Translate(), MessageTypeDefOf.RejectInput, true); return; } selPawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, MenuOptionPriority.Default, null, null, 0f, null, null)); } yield break; }