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

            if (Desk != null)
            {
                if (!CheckJobOnThing(pawn, t, forced) /* && RelevantBills(t).Any()*/)
                {
                    //Log.Message("...no job on desk.");
                    return(false);
                }
                IEnumerable <ResearchProjectDef> advantage = pawn.TryGetComp <CompKnowledge>().expertise.Where(x => !x.Key.IsFinished && x.Value >= 1f).Select(x => x.Key);
                //Log.Message("... advantage is " + advantage.ToStringSafeEnumerable());
                foreach (Bill bill in RelevantBills(Desk, pawn))
                {
                    if (advantage.Intersect(bill.SelectedTech()).Any())
                    {
                        return(true);
                    }
                }
                JobFailReason.Is("NothingToAddToLibrary".Translate(pawn), null);
                return(false);
            }
            //Log.Message("case 4");
            return(false);
        }
        public void DoPasteInto(Building_WorkTable workTable, bool link)
        {
            foreach (var sourceBill in _copiedBills)
            {
                if (sourceBill.DeletedOrDereferenced)
                {
                    continue;
                }

                if (!CanWorkTableDoRecipeNow(workTable, sourceBill.recipe))
                {
                    continue;
                }

                var newBill = (Bill_Production)sourceBill.recipe.MakeNewBill();
                workTable.BillStack.AddBill(newBill);

                Main.Instance.GetExtendedBillDataStorage().MirrorBills(sourceBill, newBill, false);

                if (link)
                {
                    Main.Instance.GetExtendedBillDataStorage().LinkBills(sourceBill, newBill);
                }
            }
        }
        public bool GetTarget(IntVec3 pos, Rot4 rot, bool spawned = false)
        {
            Building_WorkTable new_my_workTable = (Building_WorkTable)(pos + rot.FacingCell).GetThingList(Map)
                                                  .Where(t => t.def.category == ThingCategory.Building)
                                                  .Where(t => t is Building_WorkTable)
                                                  .Where(t => t.InteractionCell == this.Position).FirstOrDefault();
            Building new_drilltypeBuilding = (Building)(pos + rot.FacingCell).GetThingList(Map)
                                             .Where(t => t.def.category == ThingCategory.Building)
                                             .Where(t => t is Building && t.TryGetComp <CompDeepDrill>() != null)
                                             .Where(t => t.InteractionCell == this.Position).FirstOrDefault();
            Building_ResearchBench new_researchBench = (Building_ResearchBench)(pos + rot.FacingCell).GetThingList(Map)
                                                       .Where(t => t.def.category == ThingCategory.Building)
                                                       .Where(t => t is Building_ResearchBench)
                                                       .Where(t => t.InteractionCell == this.Position).FirstOrDefault();

            if (spawned && ((my_workTable != null && new_my_workTable == null) || (researchBench != null && new_researchBench == null) || (drilltypeBuilding != null && new_drilltypeBuilding == null)))
            {
                FreeTarget();
            }
            my_workTable      = new_my_workTable;
            drilltypeBuilding = new_drilltypeBuilding;
            researchBench     = new_researchBench;
            if (spawned && ValidTarget)
            {
                ReserveTraget();
            }


            return(ValidTarget);
        }
        public void DrawRow(Building_WorkTable billgiver, Rect row)
        {
            var labelRect = new Rect(row);

            labelRect.width -= 36f;
            labelRect.xMin  += 6f;
            var iconRect = new Rect(row);

            iconRect.xMin = iconRect.xMax - 24f;

            Text.Font = GameFont.Tiny;
            Widgets.Label(labelRect, billgiver.LabelCap + ", " + billgiver.GetRoom().Role.LabelCap);
            Text.Font = GameFont.Small;
            if (Job.BillGivers.SpecificBillGivers.Contains(billgiver))
            {
                GUI.DrawTexture(iconRect, Widgets.CheckboxOnTex);
                if (Widgets.ButtonInvisible(row))
                {
                    Job.BillGivers.SpecificBillGivers.Remove(billgiver);
                }
            }
            else
            {
                if (Widgets.ButtonInvisible(row))
                {
                    Job.BillGivers.SpecificBillGivers.Add(billgiver);
                }
            }

            if (Mouse.IsOver(row))
            {
                GUI.DrawTexture(row, TexUI.HighlightTex);
                Find.CameraDriver.JumpTo(billgiver.PositionHeld);
            }
        }
        static NewThingReplacement()
        {
            replacements = new List <Replacement>();

            //---------------------------------------------
            //---------------------------------------------
            //Here are valid replacements:
            replacements.Add(new Replacement(d => d.IsWall() || typeof(Building_Door).IsAssignableFrom(d.thingClass)));
            replacements.Add(new Replacement(d => typeof(Building_Cooler).IsAssignableFrom(d.thingClass),
                                             postAction: (n, o) =>
            {
                Building_Cooler newCooler = n as Building_Cooler;
                Building_Cooler oldCooler = o as Building_Cooler;
                //newCooler.compPowerTrader.PowerOn = oldCooler.compPowerTrader.PowerOn;	//should be flickable
                newCooler.compTempControl.targetTemperature = oldCooler.compTempControl.targetTemperature;
            }
                                             ));
            replacements.Add(new Replacement(d => typeof(Building_Bed).IsAssignableFrom(d.thingClass),
                                             preAction: (n, o) =>
            {
                Building_Bed newBed = n as Building_Bed;
                Building_Bed oldBed = o as Building_Bed;
                newBed.ForPrisoners = oldBed.ForPrisoners;
                newBed.Medical      = oldBed.Medical;
                oldBed.OwnersForReading.ListFullCopy().ForEach(p => p.ownership.ClaimBedIfNonMedical(newBed));
            }
                                             ));
            DesignationCategoryDef fencesDef = DefDatabase <DesignationCategoryDef> .GetNamed("Fences", false);

            if (fencesDef != null)
            {
                replacements.Add(new Replacement(d => d.designationCategory == fencesDef));
            }

            Action <Thing, Thing> transferBills = (n, o) =>
            {
                Building_WorkTable newTable = n as Building_WorkTable;
                Building_WorkTable oldTable = o as Building_WorkTable;

                foreach (Bill bill in oldTable.BillStack)
                {
                    newTable.BillStack.AddBill(bill);
                }
            };

            replacements.Add(new Replacement(d => d == NewThingDefOf.ElectricStove, n => n == NewThingDefOf.FueledStove, transferBills));
            replacements.Add(new Replacement(d => d == NewThingDefOf.ElectricTailoringBench, n => n == NewThingDefOf.HandTailoringBench, transferBills));

            replacements.Add(new Replacement(d => d.IsTable));

            replacements.Add(new Replacement(d => d.thingClass == FridgeCompat.fridgeType,
                                             postAction: (n, o) =>
            {
                FridgeCompat.DesiredTempInfo.SetValue(n, FridgeCompat.DesiredTempInfo.GetValue(o));
            }));

            replacements.Add(new Replacement(d => d.building?.isSittable ?? false));
            //---------------------------------------------
            //---------------------------------------------
        }
Exemple #6
0
        private static IEnumerable <Thing> DetachValuableItems(this Pawn corpse, Building_WorkTable table, Pawn butcher)
        {
            float bionicChance = HarvestPartChance(true, table, butcher, corpse);
            float livingChance = HarvestPartChance(false, table, butcher, corpse);
            IEnumerable <BodyPartRecord> parts = corpse.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined);

            foreach (BodyPartRecord record in parts)
            {
                IEnumerable <Hediff> hediffs = from x in corpse.health.hediffSet.hediffs
                                               where x.Part == record
                                               select x;
                if (hediffs.Any())
                {
                    // bionic parts
                    foreach (Hediff hediff in hediffs)
                    {
                        if (hediff.def.spawnThingOnRemoved != null && HarvestPart(livingChance, bionicChance, true))
                        {
                            yield return(ThingMaker.MakeThing(hediff.def.spawnThingOnRemoved, null));
                        }
                    }
                }
                else
                {
                    if (record.def.spawnThingOnRemoved != null)
                    {
                        if (HarvestPart(livingChance, bionicChance, !record.def.alive))
                        {
                            corpse.health.AddHediff(HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, corpse, record), null, null);
                            yield return(ThingMaker.MakeThing(record.def.spawnThingOnRemoved, null));
                        }
                    }
                }
            }
        }
Exemple #7
0
 public static bool Alt_CanBeResearchedAt(this ResearchProjectDef project, Building_WorkTable bench)
 {
     if (project.requiredResearchBuilding != null && bench.def != project.requiredResearchBuilding)
     {
         return(false);
     }
     if (!project.requiredResearchFacilities.NullOrEmpty <ThingDef>())
     {
         CompAffectedByFacilities affectedByFacilities = bench.TryGetComp <CompAffectedByFacilities>();
         if (affectedByFacilities == null)
         {
             return(false);
         }
         List <Thing> linkedFacilitiesListForReading = affectedByFacilities.LinkedFacilitiesListForReading;
         int          j;
         int          i;
         for (i = 0; i < project.requiredResearchFacilities.Count; i = j + 1)
         {
             if (linkedFacilitiesListForReading.Find((Thing x) => x.def == project.requiredResearchFacilities[i] && affectedByFacilities.IsFacilityActive(x)) == null)
             {
                 return(false);
             }
             j = i;
         }
     }
     return(true);
 }
 private static bool CanWorkTableDoRecipeNow(Building_WorkTable workTable, RecipeDef recipe)
 {
     return(workTable.BillStack.Count < 15 &&
            recipe.AvailableNow &&
            workTable.def.AllRecipes != null &&
            workTable.def.AllRecipes.Contains(recipe));
 }
Exemple #9
0
            public static List <FloatMenuOption> RecipeCategoryFloatMenuOptions(Building_WorkTable SelTable, ThingCategoryDef categoryDef, List <ThingCategoryDef> validCategories, Dictionary <ThingCategoryDef, List <RecipeDef> > recipesByCategory, string condensedLabel = "")
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();

                string label = categoryDef.LabelCap;

                if (!string.IsNullOrEmpty(condensedLabel))
                {
                    label = condensedLabel + " > " + label;
                }

                // If this category has no recipes of its own, lets condense it down to save some hassle
                if (!recipesByCategory.ContainsKey(categoryDef))
                {
                    foreach (ThingCategoryDef childCategory in categoryDef.childCategories)
                    {
                        if (validCategories.Contains(childCategory))
                        {
                            options.AddRange(RecipeCategoryFloatMenuOptions(SelTable, childCategory, validCategories, recipesByCategory, label));
                        }
                    }
                }
                else
                {
                    options.Add(new FloatMenuOption(" > " + label, delegate
                    {
                        Find.WindowStack.Add(new FloatMenu(RecipeSubList(SelTable, categoryDef, validCategories, recipesByCategory)));
                    }, MenuOptionPriority.Default, null, null, 29f));
                }

                return(options);
            }
Exemple #10
0
 //public virtual bool UsableNow
 public static void Postfix(ref bool __result, Building_WorkTable __instance)
 {
     if (DisableThing.IsReplacing(__instance))
     {
         __result = false;
         JobFailReason.Is("TD.FailedStuffBeingReplaced".Translate());
     }
 }
 static bool Prefix(Building_WorkTable __instance, ref IEnumerable <IntVec3> __result)
 {
     if (__instance is Building_ForgeRewritten forge)
     {
         __result = MakeNewCells(forge);
         return(false);
     }
     return(true);
 }
Exemple #12
0
        protected IEnumerable <Bill_Production> RelevantBills(Thing thing, Pawn pawn)
        {
            Building_WorkTable desk = thing as Building_WorkTable;

            if (desk != null)
            {
                return(desk.BillStack.Bills.Cast <Bill_Production>().Where(x => x.recipe.defName.StartsWith(def.defName) && x.ShouldDoNow() && x.PawnAllowedToStartAnew(pawn)));
            }
            return(null);
        }
Exemple #13
0
        public static void Postfix(ref IEnumerable <Thing> __result, ref Pawn __instance, Pawn butcher, float efficiency)
        {
            if (butcher.CurJob == null || butcher.CurJob.GetTarget(TargetIndex.A).Thing == null || butcher.CurJob.GetTarget(TargetIndex.A).Thing.def.defName != "TableAutopsy")
            {
                return;
            }
            Building_WorkTable table = butcher.CurJob.GetTarget(TargetIndex.A).Thing as Building_WorkTable;

            __result = __result.CompackedItems(__instance, table, butcher);
        }
        protected IEnumerable <Bill_Production> RelevantBills(Thing thing, Pawn pawn)
        {
            //Log.Warning("DEBUG: looking for relevant bills for workgiver " + def.defName+"...");
            Building_WorkTable desk = thing as Building_WorkTable;

            if (desk != null)
            {
                return(desk.BillStack.Bills.Cast <Bill_Production>().Where(x => x.recipe.defName.StartsWith(def.defName) && x.ShouldDoNow() && x.PawnAllowedToStartAnew(pawn)));
            }
            return(null);
        }
Exemple #15
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            Building_WorkTable desk = t as Building_WorkTable;

            if (desk != null)
            {
                var relevantBills = RelevantBills(desk, pawn);
                if (!CheckJobOnThing(pawn, t, forced) || relevantBills.EnumerableNullOrEmpty())
                {
                    return(false);
                }
                return(JobOnThing(pawn, t, forced) != null);
            }
            return(false);
        }
Exemple #16
0
 public static void Postfix(ref IEnumerable <Thing> __result, ref Pawn __instance, Pawn butcher, float efficiency)
 {
     try
     {
         Building_WorkTable table = butcher.CurJob.GetTarget(TargetIndex.A).Thing as Building_WorkTable;
         if (!(table.def.defName == "TableAutopsy"))
         {
             return;
         }
         __result = __result.CompackedItems(__instance, table, butcher);
     } catch (System.Exception e)
     {
         Log.Error(e.Message);
         Log.Error(e.StackTrace);
     }
 }
Exemple #17
0
        public static bool HasFacility(this Building_WorkTable building, ThingDef facility)
        {
            var comp = building.GetComp <CompAffectedByFacilities>();

            if (comp == null)
            {
                return(false);
            }

            if (comp.LinkedFacilitiesListForReading.Select(f => f.def).Contains(facility))
            {
                return(true);
            }

            return(false);
        }
        static NewThingReplacement()
        {
            replacements = new List <Replacement>();

            //---------------------------------------------
            //---------------------------------------------
            //Here are valid replacements:
            replacements.Add(new Replacement(d => d.thingClass == typeof(Building_Door), n => n.IsWall() || n.thingClass == typeof(Building_Door)));
            replacements.Add(new Replacement(d => d.thingClass == typeof(Building_Cooler), n => n.thingClass == typeof(Building_Cooler),
                                             null,
                                             (n, o) =>
            {
                Building_Cooler newCooler = n as Building_Cooler;
                Building_Cooler oldCooler = o as Building_Cooler;
                //newCooler.compPowerTrader.PowerOn = oldCooler.compPowerTrader.PowerOn;	//should be flickable
                newCooler.compTempControl.targetTemperature = oldCooler.compTempControl.targetTemperature;
            }
                                             ));
            replacements.Add(new Replacement(d => d.thingClass == typeof(Building_Bed), n => n.thingClass == typeof(Building_Bed),
                                             (n, o) =>
            {
                Building_Bed newBed = n as Building_Bed;
                Building_Bed oldBed = o as Building_Bed;
                newBed.ForPrisoners = oldBed.ForPrisoners;
                newBed.Medical      = oldBed.Medical;
                oldBed.owners.ForEach(p => p.ownership.ClaimBedIfNonMedical(newBed));
            }
                                             ));
            replacements.Add(new Replacement(d => d.IsWall(), n => n.IsWall()));

            Action <Thing, Thing> transferBills = (n, o) =>
            {
                Building_WorkTable newTable = n as Building_WorkTable;
                Building_WorkTable oldTable = o as Building_WorkTable;

                foreach (Bill bill in oldTable.BillStack)
                {
                    newTable.BillStack.AddBill(bill);
                }
            };

            replacements.Add(new Replacement(d => d == NewThingDefOf.ElectricStove, n => n == NewThingDefOf.FueledStove, transferBills));
            replacements.Add(new Replacement(d => d == NewThingDefOf.ElectricTailoringBench, n => n == NewThingDefOf.HandTailoringBench, transferBills));
            //---------------------------------------------
            //---------------------------------------------
        }
Exemple #19
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            //Log.Message(pawn + " is looking for a document job...");
            Building_WorkTable Desk = t as Building_WorkTable;

            if (Desk != null)
            {
                var relevantBills = RelevantBills(Desk, pawn);
                if (!CheckJobOnThing(pawn, t, forced) | relevantBills.EnumerableNullOrEmpty())
                {
                    return(false);
                }
                CompKnowledge techComp = pawn.TryGetComp <CompKnowledge>();
                return(techComp.knownTechs.Where(x => !x.IsFinished).Intersect(techComp.homework).Any());
            }
            //Log.Message("case 4");
            return(false);
        }
        public static bool TabUpdate_Prefix()
        {
            Building_WorkTable selTable = (Building_WorkTable)Find.Selector.SingleSelectedThing;

            if (selTable.def != ThingDef.Named("HandTailoringBench") &&
                selTable.def != ThingDef.Named("ElectricTailoringBench"))
            {
                return(true);
            }

            if (_mouseoverBill != null)
            {
                _mouseoverBill.TryDrawIngredientSearchRadiusOnMap(Find.Selector.SingleSelectedThing.Position);
                _mouseoverBill = null;
            }

            return(false);
        }
        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);
                }
                return(pawn.TryGetComp <CompKnowledge>().homework.Where(x => x.IsFinished && x.RequisitesKnownBy(pawn)).Any());
            }
            //Log.Message("case 4");
            return(false);
        }
        public void DoCopy(Building_WorkTable workTable)
        {
            if (workTable.BillStack == null || workTable.BillStack.Count == 0)
            {
                return;
            }

            _copiedBills.Clear();
            foreach (var bill in workTable.BillStack.Bills)
            {
                var billProduction = bill as Bill_Production;
                if (billProduction == null)
                {
                    continue;
                }

                _copiedBills.Add(billProduction);
            }
        }
 public static void Postfix(ResearchProjectDef __instance, ref bool __result)
 {
     if (!__result)
     {
         List <Map> maps = Find.Maps;
         for (int i = 0; i < maps.Count; i++)
         {
             List <Building> allBuildingsColonist = maps[i].listerBuildings.allBuildingsColonist;
             for (int j = 0; j < allBuildingsColonist.Count; j++)
             {
                 Building_WorkTable researchStation = allBuildingsColonist[j] as Building_WorkTable;
                 if (researchStation != null && __instance.Alt_CanBeResearchedAt(researchStation))
                 {
                     __result = true;
                 }
             }
         }
     }
 }
Exemple #24
0
 public static FloatMenuOption RecipeFloatMenuOption(Building_WorkTable SelTable, RecipeDef recipe)
 {
     return(new FloatMenuOption(recipe.LabelCap, delegate
     {
         if (!SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
         {
             Bill.CreateNoPawnsWithSkillDialog(recipe);
         }
         Bill bill2 = recipe.MakeNewBill();
         SelTable.billStack.AddBill(bill2);
         if (recipe.conceptLearned != null)
         {
             PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
         }
         if (TutorSystem.TutorialMode)
         {
             TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap.Resolve());
         }
     }, recipe.UIIconThing, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, recipe)));
 }
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            //Log.Message(pawn + " is looking for a training job...");
            Building_WorkTable Target = t as Building_WorkTable;

            if (Target != null)
            {
                if (!CheckJobOnThing(pawn, t, forced) && RelevantBills(t, pawn).Any())
                {
                    //Log.Message("...no job on target.");
                    return(false);
                }
                foreach (Bill bill in RelevantBills(Target, pawn))
                {
                    return(ValidateChosenWeapons(bill, pawn, t as IBillGiver));
                }
                return(false);
            }
            return(false);
        }
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            //Log.Message(pawn + " is looking for a practice job...");
            Building_WorkTable Target = t as Building_WorkTable;

            if (Target != null)
            {
                if (!CheckJobOnThing(pawn, t, forced))
                {
                    return(false);
                }
                foreach (Bill bill in RelevantBills(Target, pawn))
                {
                    return(ValidateChosenWeapons(bill, pawn));
                }
                return(false);
            }
            //Log.Message("case 4");
            return(false);
        }
Exemple #27
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);
        }
Exemple #28
0
        public static void Prefix(ref Func <List <FloatMenuOption> > recipeOptionsMaker, ITab_Bills __instance)
        {
            Func <List <FloatMenuOption> > bill_source = recipeOptionsMaker;
            Building_WorkTable             selThing    = (Building_WorkTable)Find.Selector.SingleSelectedThing;
            List <RecipeDef> rdef = selThing.def.AllRecipes;

            recipeOptionsMaker = () =>
            {
                List <FloatMenuOption> optList = bill_source();
                int ii = 0;

                foreach (FloatMenuOption opt in optList)
                {
                    int       iii   = ii;
                    RecipeDef _rdef = rdef[ii];
                    opt.action = () => { Utilities.RimLog.Message("recipe option clicked for recipe " + _rdef); MakeNewBillAt(selThing, _rdef); };
                    ii++;
                }

                return(optList);
            };
        }
Exemple #29
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);
        }
Exemple #30
0
        public override bool HasJobOnThing(Pawn pawn, Thing t, bool forced = false)
        {
            //Log.Message(pawn + " is looking for a document job...");
            Building_WorkTable Desk = t as Building_WorkTable;

            if (Desk != null && ModBaseHumanResources.unlocked.libraryFreeSpace > 0)
            {
                var relevantBills = RelevantBills(Desk, pawn);
                if (!CheckJobOnThing(pawn, t, forced) | relevantBills.EnumerableNullOrEmpty())
                {
                    //Log.Message("... no job on thing");
                    return(false);
                }
                CompKnowledge techComp = pawn.TryGetComp <CompKnowledge>();
                return(techComp.knownTechs.Where(x => !x.IsFinished).Intersect(techComp.homework).Any());
            }
            //Log.Message("... no free space");
            if (ModBaseHumanResources.unlocked.libraryFreeSpace <= 0)
            {
                JobFailReason.Is("NoSpaceInLibrary".Translate());
            }
            return(false);
        }
        public void DrawRow( Building_WorkTable billgiver, Rect row )
        {
            Rect labelRect = new Rect( row );
            labelRect.width -= 36f;
            labelRect.xMin += 6f;
            Rect iconRect = new Rect( row );
            iconRect.xMin = iconRect.xMax - 24f;

            Text.Font = GameFont.Tiny;
            Widgets.Label( labelRect, billgiver.LabelCap + ", " + billgiver.GetRoom().Role.LabelCap );
            Text.Font = GameFont.Small;
            if ( Job.BillGivers.SpecificBillGivers.Contains( billgiver ) )
            {
                GUI.DrawTexture( iconRect, Widgets.CheckboxOnTex );
                if ( Widgets.ButtonInvisible( row ) )
                {
                    Job.BillGivers.SpecificBillGivers.Remove( billgiver );
                }
            }
            else
            {
                if ( Widgets.ButtonInvisible( row ) )
                {
                    Job.BillGivers.SpecificBillGivers.Add( billgiver );
                }
            }

            if ( Mouse.IsOver( row ) )
            {
                GUI.DrawTexture( row, TexUI.HighlightTex );
                Find.CameraDriver.JumpTo( billgiver.PositionHeld );
            }
        }
 public BillTablePriority( Bill_Production bill, Building_WorkTable table, int priority )
 {
     this.bill = bill;
     this.table = table;
     this.priority = priority;
 }