private List <FloatMenuOption> < FillTab > m__0() { List <FloatMenuOption> list = new List <FloatMenuOption>(); for (int i = 0; i < this.SelTable.def.AllRecipes.Count; i++) { if (this.SelTable.def.AllRecipes[i].AvailableNow) { RecipeDef recipe = this.SelTable.def.AllRecipes[i]; list.Add(new FloatMenuOption(recipe.LabelCap, delegate() { if (!this.SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col))) { Bill.CreateNoPawnsWithSkillDialog(recipe); } Bill bill = recipe.MakeNewBill(); this.SelTable.billStack.AddBill(bill); if (recipe.conceptLearned != null) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total); } if (TutorSystem.TutorialMode) { TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap); } }, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, recipe), null)); } } if (!list.Any <FloatMenuOption>()) { list.Add(new FloatMenuOption("NoneBrackets".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } return(list); }
internal void <> m__0() { if (!this.$this.SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => this.recipe.PawnSatisfiesSkillRequirements(col))) { Bill.CreateNoPawnsWithSkillDialog(this.recipe); } Bill bill = this.recipe.MakeNewBill(); this.$this.SelTable.billStack.AddBill(bill); if (this.recipe.conceptLearned != null) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(this.recipe.conceptLearned, KnowledgeAmount.Total); } if (TutorSystem.TutorialMode) { TutorSystem.Notify_Event("AddBill-" + this.recipe.LabelCap); } }
protected override void FillTab() { PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed); Vector2 winSize = ITab_Bills.WinSize; float x = winSize.x; Vector2 winSize2 = ITab_Bills.WinSize; Rect rect2 = new Rect(0f, 0f, x, winSize2.y).ContractedBy(10f); Func <List <FloatMenuOption> > recipeOptionsMaker = delegate { List <FloatMenuOption> list = new List <FloatMenuOption>(); for (int i = 0; i < this.SelTable.def.AllRecipes.Count; i++) { ITab_Bills tab_Bills = this; if (this.SelTable.def.AllRecipes[i].AvailableNow) { RecipeDef recipe = this.SelTable.def.AllRecipes[i]; list.Add(new FloatMenuOption(recipe.LabelCap, delegate { if (!tab_Bills.SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col))) { Bill.CreateNoPawnsWithSkillDialog(recipe); } Bill bill = recipe.MakeNewBill(); tab_Bills.SelTable.billStack.AddBill(bill); if (recipe.conceptLearned != null) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total); } if (TutorSystem.TutorialMode) { TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap); } }, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton((float)(rect.x + 5.0), (float)(rect.y + (rect.height - 24.0) / 2.0), recipe), null)); } } if (!list.Any()) { list.Add(new FloatMenuOption("NoneBrackets".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } return(list); }; this.mouseoverBill = this.SelTable.billStack.DoListing(rect2, recipeOptionsMaker, ref this.scrollPosition, ref this.viewHeight); }
private static void CreateSurgeryBill(Pawn medPawn, RecipeDef recipe, BodyPartRecord part) { Bill_Medical bill_Medical = new Bill_Medical(recipe); medPawn.BillStack.AddBill(bill_Medical); bill_Medical.Part = part; if (recipe.conceptLearned != null) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total); } Map map = medPawn.Map; if (!map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col))) { Bill.CreateNoPawnsWithSkillDialog(recipe); } if (!medPawn.InBed() && medPawn.RaceProps.IsFlesh) { if (medPawn.RaceProps.Humanlike) { if (!map.listerBuildings.allBuildingsColonist.Any((Building x) => x is Building_Bed && RestUtility.CanUseBedEver(medPawn, x.def) && ((Building_Bed)x).Medical)) { Messages.Message("MessageNoMedicalBeds".Translate(), medPawn, MessageTypeDefOf.CautionInput, historical: false); } } else if (!map.listerBuildings.allBuildingsColonist.Any((Building x) => x is Building_Bed && RestUtility.CanUseBedEver(medPawn, x.def))) { Messages.Message("MessageNoAnimalBeds".Translate(), medPawn, MessageTypeDefOf.CautionInput, historical: false); } } if (medPawn.Faction != null && !medPawn.Faction.Hidden && !medPawn.Faction.HostileTo(Faction.OfPlayer) && recipe.Worker.IsViolationOnPawn(medPawn, part, Faction.OfPlayer)) { Messages.Message("MessageMedicalOperationWillAngerFaction".Translate(medPawn.FactionOrExtraMiniOrHomeFaction), medPawn, MessageTypeDefOf.CautionInput, historical: false); } ThingDef minRequiredMedicine = GetMinRequiredMedicine(recipe); if (minRequiredMedicine != null && medPawn.playerSettings != null && !medPawn.playerSettings.medCare.AllowsMedicine(minRequiredMedicine)) { Messages.Message("MessageTooLowMedCare".Translate(minRequiredMedicine.label, medPawn.LabelShort, medPawn.playerSettings.medCare.GetLabel(), medPawn.Named("PAWN")), medPawn, MessageTypeDefOf.CautionInput, historical: false); } recipe.Worker.CheckForWarnings(medPawn); }
protected override void FillTab() { PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed); Rect rect2 = new Rect(WinSize.x - PasteX, PasteY, PasteSize, PasteSize); if (BillUtility.Clipboard == null) { GUI.color = Color.gray; Widgets.DrawTextureFitted(rect2, TexButton.Paste, 1f); GUI.color = Color.white; TooltipHandler.TipRegionByKey(rect2, "PasteBillTip"); } else if (!SelTable.def.AllRecipes.Contains(BillUtility.Clipboard.recipe) || !BillUtility.Clipboard.recipe.AvailableNow || !BillUtility.Clipboard.recipe.AvailableOnNow(SelTable)) { GUI.color = Color.gray; Widgets.DrawTextureFitted(rect2, TexButton.Paste, 1f); GUI.color = Color.white; TooltipHandler.TipRegionByKey(rect2, "ClipboardBillNotAvailableHere"); } else if (SelTable.billStack.Count >= 15) { GUI.color = Color.gray; Widgets.DrawTextureFitted(rect2, TexButton.Paste, 1f); GUI.color = Color.white; if (Mouse.IsOver(rect2)) { TooltipHandler.TipRegion(rect2, "PasteBillTip".Translate() + " (" + "PasteBillTip_LimitReached".Translate() + ")"); } } else { if (Widgets.ButtonImageFitted(rect2, TexButton.Paste, Color.white)) { Bill bill = BillUtility.Clipboard.Clone(); bill.InitializeAfterClone(); SelTable.billStack.AddBill(bill); SoundDefOf.Tick_Low.PlayOneShotOnCamera(); } TooltipHandler.TipRegionByKey(rect2, "PasteBillTip"); } Rect rect3 = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f); Func <List <FloatMenuOption> > recipeOptionsMaker = delegate { List <FloatMenuOption> list = new List <FloatMenuOption>(); ITab_Bills tab_Bills = default(ITab_Bills); RecipeDef recipe = default(RecipeDef); for (int i = 0; i < SelTable.def.AllRecipes.Count; i++) { tab_Bills = this; if (SelTable.def.AllRecipes[i].AvailableNow && SelTable.def.AllRecipes[i].AvailableOnNow(SelTable)) { recipe = SelTable.def.AllRecipes[i]; list.Add(new FloatMenuOption(recipe.LabelCap, delegate { if (!tab_Bills.SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col))) { Bill.CreateNoPawnsWithSkillDialog(recipe); } Bill bill2 = recipe.MakeNewBill(); tab_Bills.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.ProducedThingDef, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, recipe))); } } if (!list.Any()) { list.Add(new FloatMenuOption("NoneBrackets".Translate(), null)); } return(list); }; mouseoverBill = SelTable.billStack.DoListing(rect3, recipeOptionsMaker, ref scrollPosition, ref viewHeight); }
private static FloatMenuOption GenerateSurgeryOption(Pawn pawn, Thing thingForMedBills, 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 + ")"; } FloatMenuOption floatMenuOption; if (missingIngredients.Any()) { text += " ("; bool flag = true; foreach (ThingDef missingIngredient in missingIngredients) { if (!flag) { text += ", "; } flag = false; text += "MissingMedicalBillIngredient".Translate(missingIngredient.label); } text += ")"; floatMenuOption = new FloatMenuOption(text, null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { Action action = delegate { Pawn pawn2 = thingForMedBills as Pawn; if (pawn2 != null) { Bill_Medical bill_Medical = new Bill_Medical(recipe); pawn2.BillStack.AddBill(bill_Medical); bill_Medical.Part = part; if (recipe.conceptLearned != null) { PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total); } Map map = thingForMedBills.Map; if (!map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col))) { Bill.CreateNoPawnsWithSkillDialog(recipe); } if (!pawn2.InBed() && pawn2.RaceProps.IsFlesh) { if (pawn2.RaceProps.Humanlike) { if (!map.listerBuildings.allBuildingsColonist.Any((Building x) => x is Building_Bed && RestUtility.CanUseBedEver(pawn, x.def) && ((Building_Bed)x).Medical)) { Messages.Message("MessageNoMedicalBeds".Translate(), pawn2, MessageTypeDefOf.CautionInput); } } else if (!map.listerBuildings.allBuildingsColonist.Any((Building x) => x is Building_Bed && RestUtility.CanUseBedEver(pawn, x.def))) { Messages.Message("MessageNoAnimalBeds".Translate(), pawn2, MessageTypeDefOf.CautionInput); } } if (pawn2.Faction != null && !pawn2.Faction.def.hidden && !pawn2.Faction.HostileTo(Faction.OfPlayer) && recipe.Worker.IsViolationOnPawn(pawn2, part, Faction.OfPlayer)) { Messages.Message("MessageMedicalOperationWillAngerFaction".Translate(pawn2.Faction), pawn2, MessageTypeDefOf.CautionInput); } ThingDef minRequiredMedicine = HealthCardUtility.GetMinRequiredMedicine(recipe); if (minRequiredMedicine != null && pawn2.playerSettings != null && !pawn2.playerSettings.medCare.AllowsMedicine(minRequiredMedicine)) { Messages.Message("MessageTooLowMedCare".Translate(minRequiredMedicine.label, pawn2.LabelShort, pawn2.playerSettings.medCare.GetLabel()), pawn2, MessageTypeDefOf.CautionInput); } } }; floatMenuOption = new FloatMenuOption(text, action, MenuOptionPriority.Default, null, null, 0f, null, null); } floatMenuOption.extraPartWidth = 29f; floatMenuOption.extraPartOnGUI = ((Rect rect) => Widgets.InfoCardButton((float)(rect.x + 5.0), (float)(rect.y + (rect.height - 24.0) / 2.0), recipe)); return(floatMenuOption); }