public override Verse.AI.Job JobOnThing(Pawn pawn, Thing thing, bool forced = false)
        {
            var patient = thing as Pawn;

            if (patient == null)
            {
                return(null);
            }

            JobDef jobDef;

            if (PartUtility.PartsNeedingBreakdownRepair(patient).Any())
            {
                jobDef = CyberizationDefOf.Cyberization_FixBreakdown;
            }
            else if (PartUtility.PartsNeedingDamageRepair(patient).Any())
            {
                jobDef = CyberizationDefOf.Cyberization_RepairPartDamage;
            }
            else if (PartUtility.PartsNeedingRoutineMaintenance(patient).Any())
            {
                jobDef = CyberizationDefOf.Cyberization_RoutinePartMaintenance;
            }
            else
            {
                return(null);
            }

            return(new Verse.AI.Job(jobDef)
            {
                targetA = patient
            });
        }
Example #2
0
        protected override Toil Repair()
        {
            _part = PartUtility.PartsNeedingDamageRepair(Patient).First();
            var workSpeed = pawn.GetStatValue(StatDefOf.WorkSpeedGlobal);
            var repair    = new Toil()
                            .WithProgressBar(TargetIndex.A, () => 1f - _part.HealthPercent);

            repair.defaultCompleteMode = ToilCompleteMode.Never;
            repair.tickAction          = delegate
            {
                try
                {
                    PartUtility.GetHediffsForPart(_part.parent).OfType <Hediff_Injury>().First().Heal(workSpeed * baseRate);
                    pawn.skills.Learn(SkillDefOf.Crafting, 0.125f * workSpeed);
                }
                catch (InvalidOperationException)
                {
                }
            };
            return(repair);
        }