Ejemplo n.º 1
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            //Log.Message(pawn + " is looking for a research job...");
            Building_WorkTable Desk = t as Building_WorkTable;

            if (Desk != null)
            {
                var relevantBills = RelevantBills(Desk, pawn);
                if (!CheckJobOnThing(pawn, t, forced) | relevantBills.EnumerableNullOrEmpty())
                {
                    //Log.Message("...no job on desk.");
                    return(false);
                }
                List <ResearchProjectDef> studyMaterial = new List <ResearchProjectDef>();
                //Log.Message("...relevant bills: " + RelevantBills(Desk, pawn).Count);
                foreach (Bill bill in relevantBills)
                {
                    //Log.Message("...checking recipe: " + bill.recipe+", on bill "+bill.GetType());
                    //Log.Message("...selected techs count: " + bill.SelectedTech().ToList().Count());
                    studyMaterial.AddRange(bill.SelectedTech().Where(x => !x.IsFinished && x.TechprintRequirementMet && (x.requiredResearchBuilding == null || (bool)AccessTools.Property(typeof(ResearchProjectDef), "PlayerHasAnyAppropriateResearchBench").GetValue(x))));
                }
                availableTechs = studyMaterial;
                //Log.Message("...studyMaterial count is " + studyMaterial.Count());
                CompKnowledge techComp = pawn.TryGetComp <CompKnowledge>();
                techComp.AssignHomework(studyMaterial);
                //Log.Message("...homework count is " + techComp.HomeWork.Count());
                //if (techComp.HomeWork.Count() > 0) return true;
                if (studyMaterial.Intersect(techComp.HomeWork).Any())
                {
                    return(true);
                }
                if (!JobFailReason.HaveReason)
                {
                    JobFailReason.Is("AlreadyKnowsThoseProjects".Translate(pawn), null);
                }
                return(false);
            }
            //Log.Message("case 4");
            return(false);
        }
Ejemplo n.º 2
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            //Log.Message(pawn + " is looking for a study job...");
            Building_WorkTable Desk = t as Building_WorkTable;

            if (Desk != null)
            {
                var relevantBills = RelevantBills(Desk, pawn);
                if (!CheckJobOnThing(pawn, t, forced) | relevantBills.EnumerableNullOrEmpty())
                {
                    //Log.Message("...no job on desk.");
                    return(false);
                }
                List <ResearchProjectDef> studyMaterial = new List <ResearchProjectDef>();
                foreach (Bill bill in relevantBills)
                {
                    //Log.Message("...checking recipe: " + bill.recipe + ", on bill " + bill.GetType());
                    //Log.Message("...selected techs count: " + bill.SelectedTech().ToList().Count());
                    studyMaterial.AddRange(bill.SelectedTech().Where(x => x.IsFinished));
                }
                availableTechs = studyMaterial;
                //Log.Message("...studyMaterial count is " + studyMaterial.Count());
                CompKnowledge techComp = pawn.TryGetComp <CompKnowledge>();
                techComp.AssignHomework(studyMaterial);
                //Log.Message("...homework count is " + techComp.HomeWork.Count());
                if (techComp.HomeWork.Count() > 0)
                {
                    return(true);
                }
                if (studyMaterial.Intersect(techComp.HomeWork).Any())
                {
                    return(true);
                }
                return(false);
            }
            Log.Message("case 4");
            return(false);
        }