Beispiel #1
0
        public static List <FloatMenuOption> GetRecipeFloatsFor(Building_MechanicusMedTable medTable)
        {
            Pawn patient = medTable.patient;
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            foreach (RecipeDef current in patient.def.AllRecipes)
            {
                if (current.AvailableNow)
                {
                    IEnumerable <ThingDef> enumerable = current.PotentiallyMissingIngredients(null, medTable.patient.Map);
                    if (!enumerable.Any((ThingDef x) => x.isBodyPartOrImplant))
                    {
                        if (!enumerable.Any((ThingDef x) => x.IsDrug))
                        {
                            if (current.targetsBodyPart)
                            {
                                foreach (BodyPartRecord current2 in current.Worker.GetPartsToApplyOn(patient, current))
                                {
                                    list.Add(Building_MechanicusMedTable.GenerateSurgeryOptionMedTable(patient, medTable, current, enumerable, current2));
                                }
                            }
                            else
                            {
                                list.Add(Building_MechanicusMedTable.GenerateSurgeryOptionMedTable(patient, medTable, current, enumerable, null));
                            }
                        }
                    }
                }
            }
            return(list);
        }
Beispiel #2
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1));

            yield return(Toils_Goto.GotoCell(TargetIndex.A, PathEndMode.InteractionCell).FailOn(delegate(Toil to)
            {
                Building_MechanicusMedTable building_CommsConsole = (Building_MechanicusMedTable)to.actor.jobs.curJob.GetTarget(TargetIndex.A).Thing;
                CompPowerTrader power = building_CommsConsole.GetComp <CompPowerTrader>();

                return !power.PowerOn;
            }));

            yield return(new Toil
            {
                initAction = delegate
                {
                    Pawn actor = this.GetActor();
                    Building_CommsConsole building_CommsConsole = (Building_CommsConsole)actor.jobs.curJob.GetTarget(TargetIndex.A).Thing;
                    if (building_CommsConsole.CanUseCommsNow)
                    {
                        actor.jobs.curJob.commTarget.TryOpenComms(actor);
                    }
                }
            });

            yield break;
        }
Beispiel #3
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            yield return(Toils_Reserve.Reserve(TargetIndex.A, 1));

            yield return(Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.InteractionCell));

            Toil toil = new Toil();

            toil.defaultCompleteMode = ToilCompleteMode.Delay;
            toil.defaultDuration     = 500;
            toil.WithProgressBarToilDelay(TargetIndex.A, false, -0.5f);
            yield return(toil);

            yield return(new Toil
            {
                initAction = delegate
                {
                    Pawn actor = this.GetActor();
                    Building_MechanicusMedTable pod = (Building_MechanicusMedTable)actor.CurJob.targetA.Thing;
                    Action action = delegate
                    {
                        pod.TryAcceptThing(actor, true);
                    };
                    if (!pod.def.building.isPlayerEjectable)
                    {
                        int freeColonistsSpawnedOrInPlayerEjectablePodsCount = actor.Map.mapPawns.FreeColonistsSpawnedOrInPlayerEjectablePodsCount;
                        if (freeColonistsSpawnedOrInPlayerEjectablePodsCount <= 1)
                        {
                            Find.WindowStack.Add(Dialog_MessageBox.CreateConfirmation("CasketWarning".Translate().AdjustedFor(actor), action, false, null));
                        }
                        else
                        {
                            action();
                        }
                    }
                    else
                    {
                        action();
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Instant
            });

            yield break;
        }
Beispiel #4
0
        public static FloatMenuOption GenerateSurgeryOptionMedTable(Pawn pawn, Building_MechanicusMedTable medTable, RecipeDef recipe, IEnumerable <ThingDef> missingIngredients, BodyPartRecord part = null)
        {
            string text = recipe.Worker.GetLabelWhenUsedOn(pawn, part);

            if (part != null && !recipe.hideBodyPartNames)
            {
                text = text + " (" + part.def.label + ")";
            }
            if (missingIngredients.Any <ThingDef>())
            {
                text += " (";
                bool flag = true;
                foreach (ThingDef current in missingIngredients)
                {
                    if (!flag)
                    {
                        text += ", ";
                    }
                    flag  = false;
                    text += "MissingMedicalBillIngredient".Translate(new object[]
                    {
                        current.label
                    });
                }
                text += ")";
                return(new FloatMenuOption(text, null, MenuOptionPriority.Default, null, null, 0f, null, null));
            }
            Action action = delegate
            {
                if (medTable == null)
                {
                    return;
                }
                recipe.effectWorking = EffecterDefOf.ConstructMetal;
                Bill_MedicalTable bill_Medical = new Bill_MedicalTable(recipe);
                medTable.medOpStack.AddBill(bill_Medical);
                bill_Medical.Part = part;
                if (recipe.conceptLearned != null)
                {
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                }
                Map map = medTable.Map;
                if (!map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                {
                    Bill.CreateNoPawnsWithSkillDialog(recipe);
                }
                if (medTable.patient.Faction != null && !medTable.patient.Faction.HostileTo(Faction.OfPlayer) && recipe.Worker.IsViolationOnPawn(medTable.patient, part, Faction.OfPlayer))
                {
                    Messages.Message("MessageMedicalOperationWillAngerFaction".Translate(new object[]
                    {
                        medTable.Faction
                    }), medTable, MessageSound.Negative);
                }
                MethodInfo info = typeof(HealthCardUtility).GetMethod("GetMinRequiredMedicine", BindingFlags.Static | BindingFlags.NonPublic);
                if (info == null)
                {
                    Log.Message("NoInfo");
                }
                Log.Message("tryingToInvoke");
                ThingDef minRequiredMedicine = (ThingDef)info.Invoke(null, new object[] { recipe });
                if (minRequiredMedicine != null && medTable.patient.playerSettings != null && !medTable.patient.playerSettings.medCare.AllowsMedicine(minRequiredMedicine))
                {
                    Messages.Message("MessageTooLowMedCare".Translate(new object[]
                    {
                        minRequiredMedicine.label,
                        medTable.LabelShort,
                        medTable.patient.playerSettings.medCare.GetLabel()
                    }), medTable, MessageSound.Negative);
                }
                //          Log.Message("C3");
            };

            return(new FloatMenuOption(text, action, MenuOptionPriority.Default, null, null, 0f, null, null));
        }
Beispiel #5
0
        private static float DrawMedTableOperationsTab(Rect rect, Pawn patient, Thing thingForMedBills, float curY, Building_MechanicusMedTable medTable)
        {
            curY += 2f;
            Func <List <FloatMenuOption> > recipeOptionsMakerStandard = delegate
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (RecipeDef current in thingForMedBills.def.AllRecipes)
                {
                    if (current.AvailableNow)
                    {
                        IEnumerable <ThingDef> enumerable = current.PotentiallyMissingIngredients(null, medTable.Map);

                        if (enumerable != null && !enumerable.Any((ThingDef x) => x.isBodyPartOrImplant))
                        {
                            if (!enumerable.Any((ThingDef x) => x.IsDrug))
                            {
                                if (current.targetsBodyPart)
                                {
                                    foreach (BodyPartRecord current2 in current.Worker.GetPartsToApplyOn(patient, current))
                                    {
                                        list.Add(Building_MechanicusMedTable.GenerateSurgeryOptionMedTable(patient, medTable, current, enumerable, current2));
                                    }
                                }
                                else
                                {
                                    list.Add(Building_MechanicusMedTable.GenerateSurgeryOptionMedTable(patient, medTable, current, enumerable, null));
                                }
                            }
                        }
                    }
                }
                return(list);
            };

            Func <List <FloatMenuOption> > recipeOptionsMakerAdvanced = delegate
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();

                List <RecipeDef> advancedRecipes = DefDatabase <RecipeDef> .AllDefsListForReading.FindAll(x => x.defName.Contains("_MSU") || x.defName == "Euthanize");

                advancedRecipes.AddRange(DefDatabase <RecipeDef> .AllDefsListForReading.FindAll(x => x is Astartes.RecipeDef_AstartesImplant));

                foreach (RecipeDef current in advancedRecipes)
                {
                    if (current.AvailableNow && CheckAstartesRecipeDef(current, patient))
                    {
                        IEnumerable <ThingDef> enumerable = current.PotentiallyMissingIngredients(null, medTable.Map);
                        if (enumerable != null && !enumerable.Any((ThingDef x) => x.isBodyPartOrImplant))
                        {
                            if (!enumerable.Any((ThingDef x) => x.IsDrug))
                            {
                                if (current.targetsBodyPart)
                                {
                                    foreach (BodyPartRecord current2 in current.Worker.GetPartsToApplyOn(patient, current))
                                    {
                                        list.Add(Building_MechanicusMedTable.GenerateSurgeryOptionMedTable(patient, medTable, current, enumerable, current2));
                                    }
                                }
                                else
                                {
                                    list.Add(Building_MechanicusMedTable.GenerateSurgeryOptionMedTable(patient, medTable, current, enumerable, null));
                                }
                            }
                        }
                    }
                }

                return(list);
            };
            Rect rect2 = new Rect(rect.x + 20f, 40f, rect.width, rect.height - curY - 20f);

            ITab_MSUOperation.DoBillListingSMU(medTable.BillStack, rect2, recipeOptionsMakerStandard, recipeOptionsMakerAdvanced, ref ITab_MSUOperation.billsScrollPosition, ref ITab_MSUOperation.billsScrollHeight);
            return(curY);
        }