public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan) { //using (IEnumerator<FloatMenuOption> enumerator = base.GetFloatMenuOptions(caravan).GetEnumerator()) //{ // if (enumerator.MoveNext()) // { // FloatMenuOption o = enumerator.Current; // yield return o; // } //} using (IEnumerator <FloatMenuOption> enumerator2 = CaravanArrivalAction_AttackWarObject.GetFloatMenuOptions(caravan, this).GetEnumerator()) { if (enumerator2.MoveNext()) { FloatMenuOption f2 = enumerator2.Current; yield return(f2); } } using (IEnumerator <FloatMenuOption> enumerator3 = CaravanArrivalAction_EngageWarObject.GetFloatMenuOptions(caravan, this).GetEnumerator()) { if (enumerator3.MoveNext()) { FloatMenuOption f3 = enumerator3.Current; yield return(f3); } } yield break; }
public static void MakeConfigFloatMenu(Bill_Production bill) { List <FloatMenuOption> list = new List <FloatMenuOption>(); list.Add(new FloatMenuOption(BillRepeatModeDefOf.RepeatCount.LabelCap, delegate { bill.repeatMode = BillRepeatModeDefOf.RepeatCount; }, MenuOptionPriority.Default, null, null, 0f, null, null)); FloatMenuOption item = new FloatMenuOption(BillRepeatModeDefOf.TargetCount.LabelCap, delegate { if (!bill.recipe.WorkerCounter.CanCountProducts(bill)) { Messages.Message("RecipeCannotHaveTargetCount".Translate(), MessageTypeDefOf.RejectInput, false); } else { bill.repeatMode = BillRepeatModeDefOf.TargetCount; } }, MenuOptionPriority.Default, null, null, 0f, null, null); list.Add(item); list.Add(new FloatMenuOption(BillRepeatModeDefOf.Forever.LabelCap, delegate { bill.repeatMode = BillRepeatModeDefOf.Forever; }, MenuOptionPriority.Default, null, null, 0f, null, null)); Find.WindowStack.Add(new FloatMenu(list)); }
private void DrawHillinessTypeSelection() { DrawEntryHeader("Terrain Types", backgroundColor: ColorLibrary.RoyalPurple); if (ListingStandard.ButtonText("Select Terrain")) { var floatMenuOptions = new List <FloatMenuOption>(); foreach (var hillinessValue in _gameData.DefData.HillinessCollection) { var label = "Any"; if (hillinessValue != Hilliness.Undefined) { label = hillinessValue.GetLabelCap(); } var menuOption = new FloatMenuOption(label, delegate { _gameData.GodModeData.Hilliness = hillinessValue; }); floatMenuOptions.Add(menuOption); } var floatMenu = new FloatMenu(floatMenuOptions, "Select terrain"); Find.WindowStack.Add(floatMenu); } // note: RimWorld logs an error when .GetLabelCap() is used on Hilliness.Undefined var rightLabel = _gameData.GodModeData.Hilliness != Hilliness.Undefined ? _gameData.GodModeData.Hilliness.GetLabelCap() : "Any"; ListingStandard.LabelDouble($"{"Terrain".Translate()}:", rightLabel); }
public static void AddMechPartsOption(WindowStack instance, FloatMenu menu) { List <FloatMenuOption> options = Traverse.Create(menu).Field("options").GetValue <List <FloatMenuOption> >(); //options.Add(new FloatMenuOption()); bool researchComplete = DefDatabase <ResearchProjectDef> .AllDefs.FirstOrDefault((ResearchProjectDef rp) => rp == WTH_DefOf.WTH_LRMSTuning && rp.IsFinished) != null; ThingDef mechanoidParts = WTH_DefOf.WTH_MineableMechanoidParts; if (researchComplete) { FloatMenuOption item = new FloatMenuOption("WTH_MechanoidParts_LabelShort".Translate(), delegate { foreach (object selectedObject in Find.Selector.SelectedObjects) { Thing selection = selectedObject as Thing; if (selection != null) { CompLongRangeMineralScanner compLongRangeMineralScanner = selection.TryGetComp <CompLongRangeMineralScanner>(); if (compLongRangeMineralScanner != null) { Traverse.Create(compLongRangeMineralScanner).Field("targetMineable").SetValue(mechanoidParts); } } } }, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2, mechanoidParts.GetConcreteExample()), null); options.Add(item); } Traverse.Create(menu).Field("options").SetValue(options); instance.Add(menu); }
public static void MakeAllowedAreaListFloatMenu(Action <Area> selAction, bool addNullAreaOption, bool addManageOption, Map map) { List <FloatMenuOption> list = new List <FloatMenuOption>(); if (addNullAreaOption) { list.Add(new FloatMenuOption("NoAreaAllowed".Translate(), delegate() { selAction(null); }, MenuOptionPriority.High, null, null, 0f, null, null)); } foreach (Area localArea2 in from a in map.areaManager.AllAreas where a.AssignableAsAllowed() select a) { Area localArea = localArea2; FloatMenuOption item = new FloatMenuOption(localArea.Label, delegate() { selAction(localArea); }, MenuOptionPriority.Default, delegate(Rect rect) { localArea.MarkForDraw(); }, null, 0f, null, null); list.Add(item); } Find.WindowStack.Add(new FloatMenu(list)); }
public static void GenerateMemoryReclaimOptions() { List <FloatMenuOption> list = new List <FloatMenuOption>(); FloatMenuOption option; option = new FloatMenuOption("FloatACModMetaData".Translate(), ModMetaDataCleaner.CleanModMetaData); if (ModMetaDataCleaner.Cleaned) { option.Label = "FloatACModMetaDataCleared".Translate(); option.Disabled = true; } list.Add(option); option = new FloatMenuOption("FloatACLanguageData".Translate(), LanguageDataCleaner.CleanLanguageData); if (LanguageDataCleaner.Cleaned) { option.Label = "FloatACLanguageDataCleared".Translate(); option.Disabled = true; } list.Add(option); option = new FloatMenuOption("FloatACDefPackage".Translate(), DefPackageCleaner.CleanDefPackage); if (DefPackageCleaner.Cleaned) { option.Label = "FloatACDefPackageCleared".Translate(); option.Disabled = true; } list.Add(option); Find.WindowStack.Add(new FloatMenu(list)); }
public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn selPawn) { IEnumerator <FloatMenuOption> enumerator = base.GetFloatMenuOptions(selPawn).GetEnumerator(); while (enumerator.MoveNext()) { FloatMenuOption current = enumerator.Current; yield return(current); } Action action = delegate { if (selPawn.CanReach(this, PathEndMode.ClosestTouch, Danger.Deadly)) { Job job = new Job(ShipNamespaceDefOfs.EnterShip, this); selPawn.jobs.TryTakeOrderedJob(job); } }; if (DropShipUtility.AllPawnsInShip(this).Count < this.compShip.sProps.maxPassengers + 1) { yield return(new FloatMenuOption("EnterShip".Translate(), action, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { yield return(new FloatMenuOption("ShipPassengersFull".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null)); } }
// this allow the work giver to be present in both drafted and undrafted float menus public static FloatMenuOption InjectThingFloatOptionIfNeeded(Thing target, Pawn selPawn) { if (Designator_FinishOff.IsValidDesignationTarget(target)) { if (WorkGiverEnabled) { JobFailReason.Clear(); var giver = CreateInstance(); var job = giver.JobOnThing(selPawn, target, true); var opt = new FloatMenuOption("Finish_off_floatMenu".Translate(target.LabelShort), () => { selPawn.jobs.TryTakeOrderedJobPrioritizedWork(job, giver, target.Position); }); opt = FloatMenuUtility.DecoratePrioritizedTask(opt, selPawn, target); if (job == null) { opt.Disabled = true; if (JobFailReason.HaveReason) { opt.Label = "CannotGenericWork".Translate(giver.def.verb, target.LabelShort, target) + " (" + JobFailReason.Reason + ")"; } } return(opt); } } return(null); }
// ReSharper disable once InconsistentNaming public static void Postfix(ref FloatMenuOption __result, Thing thingForMedBills, RecipeDef recipe) { var pawn = thingForMedBills as Pawn; if (!(pawn?.story?.traits?.HasTrait(TraitDefOf.Brawler) ?? false)) { return; } if (recipe?.addsHediff == null) { return; } var hediff = recipe.addsHediff; if (!hediff.HasComp(typeof(HediffComp_VerbGiver))) { return; } var comp = hediff.CompPropsFor(typeof(HediffComp_VerbGiver)) as HediffCompProperties_VerbGiver; var verbs = comp?.verbs; if (verbs == null) { return; } if (!verbs.Any(verb => !verb.IsMeleeAttack)) { return; } __result.Label = __result.Label + " " + "EquipWarningBrawler".Translate(); }
static void Postfix(Vector3 clickPos, Pawn pawn, ref List <FloatMenuOption> opts) { IntVec3 c = IntVec3.FromVector3(clickPos); foreach (LocalTargetInfo current in GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn), true)) { if (pawn.equipment.TryGetOffHandEquipment(out ThingWithComps eq)) { FloatMenuOption unequipOffHandOption = new FloatMenuOption("DW_DropOffHand".Translate(eq.LabelShort), new Action(delegate { pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.DropEquipment, eq)); })); //TODO translation opts.Add(unequipOffHandOption); } } if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { if (pawn.equipment != null) { ThingWithComps equipment = null; List <Thing> thingList = c.GetThingList(pawn.Map); for (int i = 0; i < thingList.Count; i++) { if (thingList[i].TryGetComp <CompEquippable>() != null) { equipment = (ThingWithComps)thingList[i]; FloatMenuOption equipOffHandOption = GetEquipOffHandOption(pawn, equipment); opts.Add(equipOffHandOption); } } } } }
public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { ///This code returns all the other float menu options first! IEnumerator <FloatMenuOption> enumerator = base.GetFloatMenuOptions(myPawn).GetEnumerator(); while (enumerator.MoveNext()) { FloatMenuOption current = enumerator.Current; yield return(current); } if (CultUtility.AreCultObjectsAvailable(Map) == false) { if (CultUtility.IsSomeoneInvestigating(Map) == false) { Action action0 = delegate { Job job = new Job(CultsDefOf.Cults_Investigate, myPawn, this); job.playerForced = true; myPawn.jobs.TryTakeOrderedJob(job); //mypawn.CurJob.EndCurrentJob(JobCondition.InterruptForced); }; yield return(new FloatMenuOption("Cults_Investigate".Translate(), action0, MenuOptionPriority.Default, null, null, 0f, null)); } } }
public static void Postfix(Vector3 clickPos, Pawn pawn, ref List <FloatMenuOption> opts) { IntVec3 c = IntVec3.FromVector3(clickPos); if (pawn.equipment != null) { List <Thing> thingList = c.GetThingList(pawn.Map); for (int i = 0; i < thingList.Count; i++) { var options = thingList[i].def.GetModExtension <HeavyWeapon>(); if (options != null && options.isHeavy) { var equipment = (ThingWithComps)thingList[i]; TaggedString toCheck = "Equip".Translate(equipment.LabelShort); FloatMenuOption floatMenuOption = opts.FirstOrDefault((FloatMenuOption x) => x.Label.Contains(toCheck)); if (floatMenuOption != null && !CanEquip(pawn, options)) { opts.Remove(floatMenuOption); opts.Add(new FloatMenuOption("CannotEquip".Translate(equipment.LabelShort) + " (" + options.disableOptionLabelKey.Translate(pawn.LabelShort) + ")", null)); } break; } } } }
public static FloatMenuOption DecoratePrioritizedTask(FloatMenuOption option, Pawn pawn, LocalTargetInfo target, string reservedText = "ReservedBy") { if (option.action == null) { return(option); } if (pawn != null && !pawn.CanReserve(target, 1, -1, null, false) && pawn.CanReserve(target, 1, -1, null, true)) { Pawn pawn2 = pawn.Map.reservationManager.FirstRespectedReserver(target, pawn); if (pawn2 == null) { pawn2 = pawn.Map.physicalInteractionReservationManager.FirstReserverOf(target); } if (pawn2 != null) { option.Label = option.Label + " (" + reservedText.Translate(new object[] { pawn2.LabelShort }) + ")"; } } if (option.revalidateClickTarget != null && option.revalidateClickTarget != target.Thing) { Log.ErrorOnce(string.Format("Click target mismatch; {0} vs {1} in {2}", option.revalidateClickTarget, target.Thing, option.Label), 52753118, false); } option.revalidateClickTarget = target.Thing; return(option); }
public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan) { using (IEnumerator <FloatMenuOption> enumerator = base.GetFloatMenuOptions(caravan).GetEnumerator()) { if (enumerator.MoveNext()) { FloatMenuOption f2 = enumerator.Current; yield return(f2); /*Error: Unable to find new state assignment for yield return*/; } } using (IEnumerator <FloatMenuOption> enumerator2 = this.core.Worker.GetFloatMenuOptions(caravan, this).GetEnumerator()) { if (enumerator2.MoveNext()) { FloatMenuOption f = enumerator2.Current; yield return(f); /*Error: Unable to find new state assignment for yield return*/; } } yield break; IL_0166: /*Error near IL_0167: Unexpected return in MoveNext()*/; }
public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { foreach (FloatMenuOption o in base.GetFloatMenuOptions(myPawn)) { yield return(o); } if (this.innerContainer.Count < maxCount) { if (Toils_bunker.getEnterOutLoc(this) == null)//!myPawn.CanReach(this, PathEndMode.InteractionCell, Danger.Deadly, false, TraverseMode.ByPawn)) { FloatMenuOption failer = new FloatMenuOption("CannotUseNoPath".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null); yield return(failer); } else { JobDef jobDef = DefDatabase <JobDef> .GetNamed("EnterRa2Bunker", true); //JobDefOf.EnterCryptosleepCasket; string jobStr = "EnterRa2Bunker".Translate(); Action jobAction = delegate { Job job = new Job(jobDef, this); myPawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }; yield return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(jobStr, jobAction, MenuOptionPriority.Default, null, null, 0f, null, null), myPawn, this, "ReservedBy")); } } yield break; }
public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { foreach (FloatMenuOption fmo in base.GetFloatMenuOptions(myPawn)) { yield return(fmo); } if (mountableComp.IsMounted) { FloatMenuOption fmoBoard = new FloatMenuOption(); fmoBoard.Label = "Ride".Translate(mountableComp.Driver.LabelShort); fmoBoard.priority = MenuOptionPriority.High; fmoBoard.action = () => { Job jobNew = new Job(DefDatabase <JobDef> .GetNamed("Board"), this); myPawn.drafter.TakeOrderedJob(jobNew); }; if (this.storage.Count(x => x is Pawn) >= 1) { fmoBoard.Label = "AlreadyRide".Translate(); fmoBoard.Disabled = true; } yield return(fmoBoard); } }
public override IEnumerable <FloatMenuOption> CompFloatMenuOptions(Pawn pawn) { if (pawn.RaceProps.ToolUser) { if (pawn.CanReserveAndReach(this.parent, PathEndMode.InteractionCell, Danger.Deadly, 1, -1, null, false)) { if (this.Props.manWorkType != WorkTags.None && pawn.story != null && pawn.story.WorkTagIsDisabled(this.Props.manWorkType)) { if (this.Props.manWorkType == WorkTags.Violent) { yield return(new FloatMenuOption("CannotManThing".Translate(new object[] { this.parent.LabelShort }) + " (" + "IsIncapableOfViolenceLower".Translate(new object[] { pawn.LabelShort }) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } } else { FloatMenuOption opt = new FloatMenuOption("OrderManThing".Translate(new object[] { this.parent.LabelShort }), delegate { Job job = new Job(JobDefOf.ManTurret, this.$this.parent); pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, MenuOptionPriority.Default, null, null, 0f, null, null); yield return(opt); } } } }
public static void Postfix(ref bool __result, FloatMenuOption __instance) { if (!Ad2Mod.settings.useRightClickMenu || !PatchFloatMenu.IsTracked(__instance)) { return; } if (!__result || Event.current.button != 1) { return; } __result = false; var recipe = Ad2.GetRecipeByLabel(__instance.Label); if (recipe == null || !Ad2.IsSrcRecipe(recipe)) { return; } var nlst = Ad2.GetNewRecipesList(recipe); if (nlst == null) { return; } Find.WindowStack.Add(new FloatMenu(RecipeOptionsMaker(nlst))); }
public override IEnumerable <FloatMenuOption> CompFloatMenuOptions(Pawn myPawn) { if (this.parent.Stuff == null) { this.parent.SetStuffDirect(ThingDefOf.Cloth); } if (!myPawn.CanReserve(this.parent, 1)) { yield return(new FloatMenuOption("Repair the tent" + " (" + "Reserved".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null)); } else { if (this.parent.HitPoints < this.parent.MaxHitPoints) { FloatMenuOption floatMenuOptionRepair = new FloatMenuOption("Repair the tent (" + (this.parent.MaxHitPoints - this.parent.HitPoints).ToString() + " " + this.parent.Stuff.label.Translate() + " needed)", delegate { if (myPawn.CanReserveAndReach(this.parent, PathEndMode.Touch, Danger.Deadly, 1)) { this.TryStartRepairJob(myPawn); } }, MenuOptionPriority.Default, null, null, 0f, null, null); yield return(floatMenuOptionRepair); } } yield break; }
public override IEnumerable <FloatMenuOption> CompFloatMenuOptions(Pawn selPawn) { ArmorRack armorRack = this.parent as ArmorRack; if (!selPawn.CanReach(armorRack, PathEndMode.Touch, Danger.Deadly, false, false, TraverseMode.ByPawn)) { FloatMenuOption failer = new FloatMenuOption("CannotUseNoPath".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null); yield return(failer); yield break; } var nonViolentOptionYielded = false; if (ArmorRackJobUtil.PawnCanEquipWeaponSet(armorRack, selPawn)) { // Transfer to var swapWithOption = new FloatMenuOption("ArmorRacks_TransferToRack_FloatMenuLabel".Translate(), delegate { var target_info = new LocalTargetInfo(armorRack); var wearRackJob = new Job(ArmorRacksJobDefOf.ArmorRacks_JobTransferToRack, target_info); selPawn.jobs.TryTakeOrderedJob(wearRackJob); }); yield return(FloatMenuUtility.DecoratePrioritizedTask(swapWithOption, selPawn, armorRack, "ReservedBy")); } else { yield return(new FloatMenuOption("ArmorRacks_WearRack_FloatMenuLabel_NonViolent".Translate(), null)); nonViolentOptionYielded = true; } if (ForbidUtility.IsForbidden(armorRack, selPawn)) { yield break; } if (ArmorRackJobUtil.RackHasItems(armorRack)) { if (ArmorRackJobUtil.PawnCanEquipWeaponSet(armorRack, selPawn)) { // Equip from var equipFromOption = new FloatMenuOption("ArmorRacks_WearRack_FloatMenuLabel".Translate(), delegate { var target_info = new LocalTargetInfo(armorRack); var wearRackJob = new Job(ArmorRacksJobDefOf.ArmorRacks_JobWearRack, target_info); selPawn.jobs.TryTakeOrderedJob(wearRackJob); }); yield return(FloatMenuUtility.DecoratePrioritizedTask(equipFromOption, selPawn, armorRack, "ReservedBy")); } else if (!nonViolentOptionYielded) { yield return(new FloatMenuOption("ArmorRacks_WearRack_FloatMenuLabel_NonViolent".Translate(), null)); } } else { yield return(new FloatMenuOption("ArmorRacks_WearRack_FloatMenuLabel_Empty".Translate(), null)); } }
public override IEnumerable <FloatMenuOption> CompFloatMenuOptions(Pawn selPawn) { Need_Energy energyNeed = selPawn.needs.TryGetNeed <Need_Energy>(); if (EnergyProps.isConsumable) { if (energyNeed != null) { //Consume for self. int thingCount = (int)Math.Ceiling((energyNeed.MaxLevel - energyNeed.CurLevel) / EnergyProps.energyWhenConsumed); if (thingCount > 0) { FloatMenuOption floatMenuOption = new FloatMenuOption("AndroidConsumeEnergySource".Translate(parent.LabelCap), () => selPawn.jobs.TryTakeOrderedJob( new Verse.AI.Job(JobDefOf.ChJAndroidRechargeEnergyComp, new LocalTargetInfo(parent)) { count = thingCount }), MenuOptionPriority.Default, null, parent); yield return(floatMenuOption); } } } }
public static IEnumerable <FloatMenuOption> GetSettle( SettlementBase bs, IEnumerable <IThingHolder> pods, CompLaunchableHelicopter representative, Caravan car) { foreach (FloatMenuOption floatMenuOption in HelicopterStatic.GetMapParent((MapParent)bs, pods, representative, car)) { FloatMenuOption o = floatMenuOption; yield return(o); o = (FloatMenuOption)null; } foreach (FloatMenuOption visitFloatMenuOption in HelicoptersArrivalActionUtility.GetVisitFloatMenuOptions(representative, pods, bs, car)) { FloatMenuOption f = visitFloatMenuOption; yield return(f); f = (FloatMenuOption)null; } foreach (FloatMenuOption giftFloatMenuOption in HelicoptersArrivalActionUtility.GetGIFTFloatMenuOptions(representative, pods, bs, car)) { FloatMenuOption f2 = giftFloatMenuOption; yield return(f2); f2 = (FloatMenuOption)null; } foreach (FloatMenuOption atkFloatMenuOption in HelicoptersArrivalActionUtility.GetATKFloatMenuOptions(representative, pods, bs, car)) { FloatMenuOption f3 = atkFloatMenuOption; yield return(f3); f3 = (FloatMenuOption)null; } }
public static FloatMenuOption DecoratePrioritizedTask(FloatMenuOption option, Pawn pawn, LocalTargetInfo target, string reservedText = "ReservedBy") { if (option.action == null) { return(option); } if (pawn != null && !pawn.CanReserve(target) && pawn.CanReserve(target, 1, -1, null, ignoreOtherReservations: true)) { Pawn pawn2 = pawn.Map.reservationManager.FirstRespectedReserver(target, pawn); if (pawn2 == null) { pawn2 = pawn.Map.physicalInteractionReservationManager.FirstReserverOf(target); } if (pawn2 != null) { option.Label = option.Label + " (" + reservedText.Translate(pawn2.LabelShort, pawn2) + ")"; } } if (option.revalidateClickTarget != null && option.revalidateClickTarget != target.Thing) { Log.ErrorOnce($"Click target mismatch; {option.revalidateClickTarget} vs {target.Thing} in {option.Label}", 52753118); } option.revalidateClickTarget = target.Thing; return(option); }
public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { foreach (FloatMenuOption o in base.GetFloatMenuOptions(selPawn)) { yield return(o); } if (this.innerContainer.Count == 0) { if (!myPawn.CanReach(this, PathEndMode.InteractionCell, Danger.Deadly, false, TraverseMode.ByPawn)) { FloatMenuOption failer = new FloatMenuOption("CannotUseNoPath".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null); yield return(failer); } else { JobDef jobDef = JobDefOf.EnterCryptosleepCasket; string jobStr = "EnterCryptosleepCasket".Translate(); Action jobAction = delegate { Job job = new Job(jobDef, this.$this); myPawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }; yield return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(jobStr, jobAction, MenuOptionPriority.Default, null, null, 0f, null, null), myPawn, this, "ReservedBy")); } } }
public static void Listener(Pawn myPawn, Building_Bed __instance, ref IEnumerable <FloatMenuOption> __result) { if ((__instance.def.defName != "ATPP_AndroidPod" && __instance.def.defName != "ATPP_AndroidPodMech") || __instance.Medical || (myPawn.ownership != null && myPawn.ownership.OwnedBed != null && myPawn.ownership.OwnedBed != __instance)) { return; } if (__result == null) { __result = new List <FloatMenuOption>(); } FloatMenuOption failureReason = GetFailureReason(__instance, myPawn); if (failureReason != null) { __result = __result.AddItem(failureReason); } else { __result = __result.AddItem(new FloatMenuOption("ATPP_ForceReload".Translate(), delegate() { //Affectation du pod a myPawn pour eviter le rehet du job myPawn.ownership.ClaimBedIfNonMedical(__instance); Job job = new Job(DefDatabase <JobDef> .GetNamed("ATPP_GoReloadBattery"), new LocalTargetInfo(__instance)); myPawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }, MenuOptionPriority.Default, null, null, 0f, null, null)); } }
public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Caravan caravan) { using (IEnumerator <FloatMenuOption> enumerator = base.GetFloatMenuOptions(caravan).GetEnumerator()) { if (enumerator.MoveNext()) { FloatMenuOption o = enumerator.Current; yield return(o); /*Error: Unable to find new state assignment for yield return*/; } } if (UseGenericEnterMapFloatMenuOption) { using (IEnumerator <FloatMenuOption> enumerator2 = CaravanArrivalAction_Enter.GetFloatMenuOptions(caravan, this).GetEnumerator()) { if (enumerator2.MoveNext()) { FloatMenuOption f = enumerator2.Current; yield return(f); /*Error: Unable to find new state assignment for yield return*/; } } } yield break; IL_0166: /*Error near IL_0167: Unexpected return in MoveNext()*/; }
public override IEnumerable <FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { if (!ReachabilityUtility.CanReach(myPawn, this, PathEndMode.InteractionCell, Danger.Deadly, false, 0)) { FloatMenuOption floatMenuOption = new FloatMenuOption(Translator.Translate("CannotUseNoPath"), null, MenuOptionPriority.Default, null, null, 0f, null, null); yield return(floatMenuOption); } else if (this.CanLearnFromBook(myPawn)) { string label = "VBE.ReadBook".Translate(); Action action = delegate() { Job job = JobMaker.MakeJob(VBE_DefOf.VBE_ReadBook, null, this); job.count = 1; myPawn.jobs.TryTakeOrderedJob(job, JobTag.Misc); }; yield return(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption (label, action, MenuOptionPriority.Default, null, null, 0f, null, null), myPawn, this, "ReservedBy")); } else if (!this.CanLearnFromBook(myPawn)) { FloatMenuOption floatMenuOption = new FloatMenuOption(Translator.Translate("VBE.CantReadSkillBookTooSimple"), null, MenuOptionPriority.Default, null, null, 0f, null, null); yield return(floatMenuOption); } yield break; }
public static IEnumerable <FloatMenuOption> GetATKFloatMenuOptions( CompLaunchableSRTS representative, IEnumerable <IThingHolder> pods, SettlementBase settlement, Caravan car) { Func <FloatMenuAcceptanceReport> acceptanceReportGetter1 = (Func <FloatMenuAcceptanceReport>)(() => TransportPodsArrivalAction_AttackSettlement.CanAttack(pods, settlement)); Func <TransportPodsArrivalAction_AttackSettlement> arrivalActionGetter1 = (Func <TransportPodsArrivalAction_AttackSettlement>)(() => new TransportPodsArrivalAction_AttackSettlement(settlement, PawnsArrivalModeDefOf.EdgeDrop)); object[] objArray1 = new object[1] { (object)settlement.Label }; foreach (FloatMenuOption floatMenuOption in SRTSArrivalActionUtility.GetFloatMenuOptions <TransportPodsArrivalAction_AttackSettlement>(acceptanceReportGetter1, arrivalActionGetter1, "AttackAndDropAtEdge".Translate(objArray1), representative, settlement.Tile, car)) { FloatMenuOption f = floatMenuOption; yield return(f); f = (FloatMenuOption)null; } Func <FloatMenuAcceptanceReport> acceptanceReportGetter2 = (Func <FloatMenuAcceptanceReport>)(() => TransportPodsArrivalAction_AttackSettlement.CanAttack(pods, settlement)); Func <TransportPodsArrivalAction_AttackSettlement> arrivalActionGetter2 = (Func <TransportPodsArrivalAction_AttackSettlement>)(() => new TransportPodsArrivalAction_AttackSettlement(settlement, PawnsArrivalModeDefOf.CenterDrop)); object[] objArray2 = new object[1] { (object)settlement.Label }; foreach (FloatMenuOption floatMenuOption in SRTSArrivalActionUtility.GetFloatMenuOptions <TransportPodsArrivalAction_AttackSettlement>(acceptanceReportGetter2, arrivalActionGetter2, "AttackAndDropInCenter".Translate(objArray2), representative, settlement.Tile, car)) { FloatMenuOption f2 = floatMenuOption; yield return(f2); f2 = (FloatMenuOption)null; } }
protected override void FillTab() { Rect rect = new Rect(0f, 0f, this.size.x, this.size.y); GUI.BeginGroup(rect); Rect rect2 = new Rect(rect.x, rect.y + 20f, rect.width, 30f); Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(rect2, "FleetManagement".Translate()); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; rect = rect.ContractedBy(10f); GUI.BeginGroup(rect); Rect newFleetRect = new Rect(10f, rect2.yMax + 10f, 100f, 40f); Rect assignFleetRect = new Rect(newFleetRect.xMax + 10f, newFleetRect.y, 100f, 40f); Rect assignedFleetRect = new Rect(assignFleetRect.xMax + 10f, newFleetRect.y, 300f, 40f); if (Widgets.ButtonText(newFleetRect, "AddFleetEntry".Translate())) { shipTacker.AddNewFleetEntry(); } if (Widgets.ButtonText(assignFleetRect, "AssignFleet".Translate())) { List <FloatMenuOption> opts = new List <FloatMenuOption>(); opts.Add(new FloatMenuOption("None", delegate { this.ship.fleetID = -1; })); foreach (KeyValuePair <int, string> currentFleet in this.shipTacker.PlayerFleetManager) { FloatMenuOption option = new FloatMenuOption(currentFleet.Value, delegate { this.ship.fleetID = currentFleet.Key; }); opts.Add(option); } Find.WindowStack.Add(new FloatMenu(opts)); } string curFleetString = "AssignedFleet".Translate() + (this.ship.fleetID != -1 && this.shipTacker.PlayerFleetManager.Count > 0 ? this.shipTacker.PlayerFleetManager[this.ship.fleetID] : "None".Translate()); Widgets.Label(assignedFleetRect, curFleetString); Rect fleetRect = new Rect(newFleetRect.x, newFleetRect.yMax + 20f, rect.width, 500f); Rect viewRect = new Rect(0f, 0f, rect.width - 16f, ITab_Fleet.billsScrollHeight); Widgets.BeginScrollView(fleetRect, ref ITab_Fleet.ScrollPosition, viewRect); float num = 0; foreach (KeyValuePair <int, string> fleetEntry in this.shipTacker.PlayerFleetManager) { this.DrawFleetEntry(ref num, viewRect.width, fleetEntry); } Widgets.EndScrollView(); GUI.EndGroup(); GUI.EndGroup(); }
public static void AddHumanlikeOrders_PostFix(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts) { var c = IntVec3.FromVector3(clickPos); var slotLoadable = pawn.equipment.AllEquipmentListForReading.FirstOrDefault(x => x.TryGetComp <CompSlotLoadable>() != null); if (slotLoadable != null) { var compSlotLoadable = slotLoadable.GetComp <CompSlotLoadable>(); if (compSlotLoadable != null) { var thingList = c.GetThingList(pawn.Map); foreach (var slot in compSlotLoadable.Slots) { var loadableThing = thingList.FirstOrDefault(y => slot.CanLoad(y.def)); if (loadableThing != null) { FloatMenuOption itemSlotLoadable; var labelShort = loadableThing.Label; if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { itemSlotLoadable = new FloatMenuOption( "CannotEquip".Translate(labelShort) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.CanReach(loadableThing, PathEndMode.ClosestTouch, Danger.Deadly)) { itemSlotLoadable = new FloatMenuOption( "CannotEquip".Translate(labelShort) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else if (!pawn.CanReserve(loadableThing, 1)) { itemSlotLoadable = new FloatMenuOption( "CannotEquip".Translate(labelShort) + " (" + "ReservedBy".Translate(pawn.Map.physicalInteractionReservationManager .FirstReserverOf(loadableThing).LabelShort) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null); } else { var text2 = "Equip".Translate(labelShort); itemSlotLoadable = new FloatMenuOption(text2, delegate { loadableThing.SetForbidden(false, true); pawn.jobs.TryTakeOrderedJob(new Job(DefDatabase <JobDef> .GetNamed("GatherSlotItem"), loadableThing)); MoteMaker.MakeStaticMote(loadableThing.DrawPos, loadableThing.Map, ThingDefOf.Mote_FeedbackEquip, 1f); //PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total); }, MenuOptionPriority.High, null, null, 0f, null, null); } opts.Add(itemSlotLoadable); } } } } }
public override IEnumerable<FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { foreach(var m in base.GetFloatMenuOptions(myPawn)) { yield return m; } FloatMenuOption option = new FloatMenuOption(); option.action = () => OpenManagerUI(); option.label = "Open manager"; option.priority = MenuOptionPriority.High; option.autoTakeable = true; yield return option; }
public override IEnumerable<FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { List<FloatMenuOption> list = new List<FloatMenuOption>(); { if (!myPawn.CanReserve(this, 1)) { FloatMenuOption item = new FloatMenuOption("CannotUseReserved", null); return new List<FloatMenuOption> { item }; } if (!myPawn.CanReach(this, PathEndMode.Touch, Danger.Some)) { FloatMenuOption item2 = new FloatMenuOption("CannotUseNoPath", null); return new List<FloatMenuOption> { item2 }; } Action action3 = delegate { Job job = new Job(DefDatabase<JobDef>.GetNamed("ClutterGoAndPickUpItem", true), this, this.Position); myPawn.drafter.TakeOrderedJob(job); OwnerPawn = myPawn; }; list.Add(new FloatMenuOption("Pick Up" + this.def.LabelCap, action3)); Action action2 = delegate { Job job = new Job(DefDatabase<JobDef>.GetNamed("ClutterUseItem", true), this, this.Position); myPawn.drafter.TakeOrderedJob(job); OwnerPawn = myPawn; }; list.Add(new FloatMenuOption("Use" + this.def.LabelCap, action2)); } return list; }
public override IEnumerable<FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { List<FloatMenuOption> list = new List<FloatMenuOption>(); { if (!myPawn.CanReserve(this)) { FloatMenuOption item = new FloatMenuOption("CannotUseReserved", null); return new List<FloatMenuOption> { item }; } if (!myPawn.CanReach(this, PathEndMode.Touch, Danger.Some)) { FloatMenuOption item2 = new FloatMenuOption("CannotUseNoPath", null); return new List<FloatMenuOption> { item2 }; } if (OwnerPawn == null) { Action action = delegate { job1 = new Job(JobDefOf.Goto, this.InteractionCell); job2 = new Job(JobDefOf.Wait, 18100); myPawn.drafter.TakeOrderedJob(job1); myPawn.drafter.pawn.QueueJob(job2); JobPawn = myPawn; myPawn.Reserve(this); }; list.Add(new FloatMenuOption("Use Dermal Regenerator", action)); } } return list; }
public override IEnumerable<FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { List<FloatMenuOption> list = new List<FloatMenuOption>(); { if (!myPawn.CanReserve(this, 1)) { FloatMenuOption item = new FloatMenuOption("CannotUseReserved", null); return new List<FloatMenuOption> { item }; } if (!myPawn.CanReach(this, PathEndMode.Touch, Danger.Some)) { FloatMenuOption item2 = new FloatMenuOption("CannotUseNoPath", null); return new List<FloatMenuOption> { item2 }; } Action action1 = delegate { Job job = new Job(JobDefOf.Goto, this); myPawn.QueueJob(job); myPawn.jobs.StopAll(); MainDealer = myPawn; ActiveUse = true; }; list.Add(new FloatMenuOption("Use Pills", action1)); Action action = delegate { Job job = new Job(DefDatabase<JobDef>.GetNamed("ClutterGoAndPickUpItem", true), this, this.Position); Job job1 = new Job(DefDatabase<JobDef>.GetNamed("JobDriver_SleepPills", true), this, myPawn.CurrentBed()); myPawn.QueueJob(job); myPawn.QueueJob(job1); MainDealer = myPawn; ActivePickUp = true; }; list.Add(new FloatMenuOption("Pick Up", action)); if (this.stackCount > 1) { Action action3 = delegate { Job job = new Job(DefDatabase<JobDef>.GetNamed("ClutterGoAndPickUpItem", true), this, this.Position); myPawn.QueueJob(job); myPawn.jobs.StopAll(); MainDealer = myPawn; ActivePickOne = true; ActivePickUp = true; }; list.Add(new FloatMenuOption("Pick Up One Pill", action3)); } } return list; }
public override IEnumerable<FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { List<FloatMenuOption> list = new List<FloatMenuOption>(); { if (!myPawn.CanReserve(this, 1)) { FloatMenuOption item = new FloatMenuOption("CannotUseReserved", null); return new List<FloatMenuOption> { item }; } if (!myPawn.CanReach(this, PathEndMode.Touch, Danger.Some)) { FloatMenuOption item2 = new FloatMenuOption("CannotUseNoPath", null); return new List<FloatMenuOption> { item2 }; } } return list; }
protected override void FillTab() { float fieldHeight = 30.0f; Vehicle_Cart cart = this.SelThing as Vehicle_Cart; ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.GuiFrame); Text.Font = GameFont.Small; Rect innerRect1 = GenUI.ContractedBy(new Rect(0.0f, 0.0f, this.size.x, this.size.y), 10f); GUI.BeginGroup(innerRect1); Rect mountedRect = new Rect(0.0f, 30.0f, innerRect1.width, fieldHeight); float mountedRectY = mountedRect.y; Widgets.ListSeparator(ref mountedRectY, innerRect1.width, txtDriver.Translate()); mountedRect.y += fieldHeight; Rect thingIconRect = new Rect(mountedRect.x, mountedRect.y, 30f, fieldHeight); Rect thingLabelRect = new Rect(mountedRect.x + 35f, mountedRect.y + 5.0f, innerRect1.width - 35f, fieldHeight); Rect thingButtonRect = new Rect(mountedRect.x, mountedRect.y, innerRect1.width, fieldHeight); if(cart.mountableComp.IsMounted) { Pawn driver = cart.mountableComp.Driver; Widgets.ThingIcon(thingIconRect, driver); Widgets.Label(thingLabelRect, driver.Label); if(Event.current.button == 1 && Widgets.InvisibleButton(thingButtonRect)) { List<FloatMenuOption> options = new List<FloatMenuOption>(); FloatMenuOption dismount = new FloatMenuOption(txtDismount.Translate(driver.LabelBase), () => { cart.mountableComp.Dismount(); }); options.Add(dismount); Find.WindowStack.Add(new FloatMenu(options)); } thingIconRect.y += fieldHeight; thingLabelRect.y += fieldHeight; } Rect storageRect = new Rect(0.0f, thingIconRect.y, innerRect1.width, fieldHeight); float storageRectY = storageRect.y; Widgets.ListSeparator(ref storageRectY, innerRect1.width, txtStorage.Translate()); storageRect.y += fieldHeight; thingIconRect.y = storageRect.y; thingLabelRect.y = storageRect.y; thingButtonRect.y = storageRect.y; foreach (var thing in cart.storage) { if ((thing.ThingID.IndexOf("Human_Corpse") <= -1) ? false : true) Widgets.DrawTextureFitted(thingIconRect, ContentFinder<Texture2D>.Get("Things/Pawn/IconHuman_Corpse"), 1.0f); else if ((thing.ThingID.IndexOf("Corpse") <= -1) ? false : true) { Corpse corpse = thing as Corpse; Widgets.ThingIcon(thingIconRect, corpse.innerPawn.def); } else Widgets.ThingIcon(thingIconRect, thing); Widgets.Label(thingLabelRect, thing.Label.Translate()); if (Event.current.button == 1 && Widgets.InvisibleButton(thingButtonRect)) { List<FloatMenuOption> options = new List<FloatMenuOption>(); options.Add(new FloatMenuOption(Translator.Translate("ThingInfo"), () => { Find.WindowStack.Add((Window)new Dialog_InfoCard(thing)); })); options.Add(new FloatMenuOption(Translator.Translate("DropThing"), () => { Thing dummy; cart.storage.TryDrop(thing, cart.Position, ThingPlaceMode.Near, out dummy); })); Find.WindowStack.Add((Window)new FloatMenu(options, thing.LabelCap, false, false)); } thingIconRect.y += fieldHeight; thingLabelRect.y += fieldHeight; } if (Widgets.TextButton(new Rect(180f, 400f, 100f, 30f), "Drop All")) cart.storage.TryDropAll(cart.Position, ThingPlaceMode.Near); GUI.EndGroup(); }
public override IEnumerable<FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { List<FloatMenuOption> list = new List<FloatMenuOption>(); { if (!myPawn.CanReserve(this, 1)) { FloatMenuOption item = new FloatMenuOption("CannotUseReserved", null); return new List<FloatMenuOption> { item }; } if (!myPawn.CanReach(this, PathEndMode.Touch, Danger.Some)) { FloatMenuOption item2 = new FloatMenuOption("CannotUseNoPath", null); return new List<FloatMenuOption> { item2 }; } if (Find.MapConditionManager.ConditionIsActive(MapConditionDefOf.SolarFlare)) { FloatMenuOption item3 = new FloatMenuOption("CannotUseSolarFlare".Translate(), null); return new List<FloatMenuOption> { item3 }; } if (!this.powerComp.PowerOn) { FloatMenuOption item4 = new FloatMenuOption("CannotUseNoPower".Translate(), null); return new List<FloatMenuOption> { item4 }; } if (!Find.ResearchManager.IsFinished(ResearchProjectDef.Named("ColoredLights"))) { FloatMenuOption item5 = new FloatMenuOption("NeedsResearch".Translate(), null); return new List<FloatMenuOption> { item5 }; } if (!YellowLight) { Action action1 = delegate { Job job = new Job(JobDefOf.Goto, this); myPawn.QueueJob(job); myPawn.jobs.StopAll(); LampNumber = 1; pawn = myPawn; ; jobPawn = job; }; list.Add(new FloatMenuOption("Yellow Light", action1)); } if (!BlueLight) { Action action2 = delegate { Job job = new Job(JobDefOf.Goto, this); myPawn.QueueJob(job); myPawn.jobs.StopAll(); LampNumber = 2; pawn = myPawn; jobPawn = job; }; list.Add(new FloatMenuOption("Blue Light", action2)); } if (!RedLight) { Action action3 = delegate { Job job = new Job(JobDefOf.Goto, this); myPawn.QueueJob(job); myPawn.jobs.StopAll(); LampNumber = 3; pawn = myPawn; jobPawn = job; }; list.Add(new FloatMenuOption("Red Light", action3)); } if (!GreenLight) { Action action4 = delegate { Job job = new Job(JobDefOf.Goto, this); myPawn.QueueJob(job); myPawn.jobs.StopAll(); LampNumber = 4; pawn = myPawn; jobPawn = job; }; list.Add(new FloatMenuOption("Green Light", action4)); } if (!OrangeLight) { Action action5 = delegate { Job job = new Job(JobDefOf.Goto, this); myPawn.QueueJob(job); myPawn.jobs.StopAll(); LampNumber = 5; pawn = myPawn; jobPawn = job; }; list.Add(new FloatMenuOption("Orange Light", action5)); } if (!VoiletLight) { Action action6 = delegate { Job job = new Job(JobDefOf.Goto, this); myPawn.QueueJob(job); myPawn.jobs.StopAll(); LampNumber = 6; pawn = myPawn; jobPawn = job; }; list.Add(new FloatMenuOption("Voilet Light", action6)); } } return list; }
public override IEnumerable<FloatMenuOption> GetFloatMenuOptions(Pawn pawn) { List<FloatMenuOption> list = new List<FloatMenuOption>(); if (pawn.Dead || pawn.Downed || pawn.IsBurning()) { FloatMenuOption item = new FloatMenuOption("Cannot use (incapacitated)", null); yield return item; yield break; } if (pawn.CanReserve(this) == false) { FloatMenuOption item = new FloatMenuOption("Cannot use (reserved)", null); yield return item; yield break; } else if (pawn.CanReach(this, PathEndMode.ClosestTouch, Danger.Some) == false) { FloatMenuOption item = new FloatMenuOption("Cannot use (no path)", null); yield return item; yield break; } else { switch (this.reverseEngineeringState) { case ReverseEngineeringState.BuildingNotApproched: Action action = delegate { Job job = new Job(DefDatabase<JobDef>.GetNamed(Util_MechanoidTerraformer.JobDefName_ScoutStrangeArtifact), this); pawn.drafter.TakeOrderedJob(job); }; FloatMenuOption item = new FloatMenuOption("Scout strange artifact", action); yield return item; break; case ReverseEngineeringState.BuildingNotSecured: Action action2 = delegate { Job job = new Job(DefDatabase<JobDef>.GetNamed(Util_MechanoidTerraformer.JobDefName_SecureStrangeArtifact), this); pawn.drafter.TakeOrderedJob(job); }; FloatMenuOption item2 = new FloatMenuOption("Secure strange artifact", action2); yield return item2; break; case ReverseEngineeringState.Studying: if (pawn.drafter.Drafted) { yield break; } if (this.studyIsPaused) { Action action3 = delegate { this.studyIsPaused = false; if ((pawn.skills.GetSkill(SkillDefOf.Research).TotallyDisabled == false) && (pawn.skills.GetSkill(SkillDefOf.Research).level >= minResearchLevelToStudyArtifact)) { Job job = new Job(DefDatabase<JobDef>.GetNamed(Util_MechanoidTerraformer.JobDefName_StudyStrangeArtifact), this); pawn.drafter.TakeOrderedJob(job); } else { Messages.Message(pawn.Name.ToStringShort + " is not skilled enough to study the strange artifact (research level " + minResearchLevelToStudyArtifact + " is required).", MessageSound.RejectInput); pawn.jobs.StopAll(true); } }; FloatMenuOption item3 = new FloatMenuOption("Start study", action3); yield return item3; } else { Action action4 = delegate { this.studyIsPaused = true; pawn.jobs.StopAll(true); }; FloatMenuOption item4 = new FloatMenuOption("Pause study", action4); yield return item4; } break; case ReverseEngineeringState.StudyCompleted: if (pawn.drafter.Drafted) { yield break; } Action action5 = delegate { this.reroutingIsPaused = false; this.reverseEngineeringState = ReverseEngineeringState.ReroutingPower; if ((pawn.skills.GetSkill(SkillDefOf.Research).TotallyDisabled == false) && (pawn.skills.GetSkill(SkillDefOf.Research).level >= minResearchLevelToReroutePower)) { Job job = new Job(DefDatabase<JobDef>.GetNamed(Util_MechanoidTerraformer.JobDefName_ReroutePower), this); pawn.drafter.TakeOrderedJob(job); } else { Messages.Message(pawn.Name.ToStringShort + " is not skilled enough to reroute the terraformer power network (research level " + minResearchLevelToReroutePower + " is required).", MessageSound.RejectInput); pawn.jobs.StopAll(true); } }; FloatMenuOption item5 = new FloatMenuOption("1) Reroute power network OR", action5); yield return item5; Action action6 = delegate { this.extractionIsPaused = false; this.reverseEngineeringState = ReverseEngineeringState.ExtractingWeatherController; if ((pawn.skills.GetSkill(SkillDefOf.Research).TotallyDisabled == false) && (pawn.skills.GetSkill(SkillDefOf.Research).level >= minResearchLevelToExtractWeatherController)) { Job job = new Job(DefDatabase<JobDef>.GetNamed(Util_MechanoidTerraformer.JobDefName_ExtractWeatherController), this); pawn.drafter.TakeOrderedJob(job); } else { Messages.Message(pawn.Name.ToStringShort + " is not skilled enough to extract the terraformer weather controller (research level " + minResearchLevelToExtractWeatherController + " is required).", MessageSound.RejectInput); pawn.jobs.StopAll(true); } }; FloatMenuOption item6 = new FloatMenuOption("2) Extract weather controller", action6); yield return item6; break; case ReverseEngineeringState.ReroutingPower: if (pawn.drafter.Drafted) { yield break; } if (this.reroutingIsPaused) { Action action7 = delegate { this.reroutingIsPaused = false; if ((pawn.skills.GetSkill(SkillDefOf.Research).TotallyDisabled == false) && (pawn.skills.GetSkill(SkillDefOf.Research).level >= minResearchLevelToReroutePower)) { Job job = new Job(DefDatabase<JobDef>.GetNamed(Util_MechanoidTerraformer.JobDefName_ReroutePower), this); pawn.drafter.TakeOrderedJob(job); } else { Messages.Message(pawn.Name.ToStringShort + " is not skilled enough to reroute the terraformer power network (research level " + minResearchLevelToReroutePower + " is required).", MessageSound.RejectInput); pawn.jobs.StopAll(true); } }; FloatMenuOption item7 = new FloatMenuOption("Reroute power network", action7); yield return item7; } else { Action action8 = delegate { this.reroutingIsPaused = true; pawn.jobs.StopAll(true); }; FloatMenuOption item8 = new FloatMenuOption("Pause power rerouting", action8); yield return item8; } break; case ReverseEngineeringState.ExtractingWeatherController: if (pawn.drafter.Drafted) { yield break; } if (this.extractionIsPaused) { Action action9 = delegate { this.extractionIsPaused = false; if ((pawn.skills.GetSkill(SkillDefOf.Research).TotallyDisabled == false) && (pawn.skills.GetSkill(SkillDefOf.Research).level >= minResearchLevelToExtractWeatherController)) { Job job = new Job(DefDatabase<JobDef>.GetNamed(Util_MechanoidTerraformer.JobDefName_ReroutePower), this); pawn.drafter.TakeOrderedJob(job); } else { Messages.Message(pawn.Name.ToStringShort + " is not skilled enough to extract the terraformer weather controller (research level " + minResearchLevelToExtractWeatherController + " is required).", MessageSound.RejectInput); pawn.jobs.StopAll(true); } }; FloatMenuOption item9 = new FloatMenuOption("Extract weather controller", action9); yield return item9; } else { Action action10 = delegate { this.extractionIsPaused = true; pawn.jobs.StopAll(true); }; FloatMenuOption item10 = new FloatMenuOption("Pause weather controller extraction", action10); yield return item10; } break; } if ((this.reverseEngineeringState >= ReverseEngineeringState.StudyCompleted) && (this.invasionIsDone == false)) { Action action11 = delegate { Job job = new Job(DefDatabase<JobDef>.GetNamed(Util_MechanoidTerraformer.JobDefName_DisableBeacon), this); pawn.drafter.TakeOrderedJob(job); }; FloatMenuOption item11 = new FloatMenuOption("Disable beacon", action11); yield return item11; } } yield break; }
public override IEnumerable<FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { if (myPawn.Faction != Faction.OfColony) yield break; foreach (FloatMenuOption fmo in base.GetFloatMenuOptions(myPawn)) yield return fmo; if (this.Faction == myPawn.Faction) { // order to mount FloatMenuOption fmoMount = new FloatMenuOption(); fmoMount.label = "Mount on " + this.LabelBase; fmoMount.priority = MenuOptionPriority.High; fmoMount.action = () => { Job jobNew = new Job(DefDatabase<JobDef>.GetNamed("Mount"), this, MountPos); myPawn.drafter.TakeOrderedJob(jobNew); }; if (this.IsMounted) { fmoMount.label = "Already mounted"; fmoMount.Disabled = true; } yield return fmoMount; // order to board FloatMenuOption fmoBoard = new FloatMenuOption(); fmoBoard.label = "Board on " + this.LabelBase; fmoBoard.priority = MenuOptionPriority.High; fmoBoard.action = () => { Job jobNew = new Job(DefDatabase<JobDef>.GetNamed("Board"), this, MountPos); myPawn.drafter.TakeOrderedJob(jobNew); }; if (vehicleDef.vehicle.boardableNum > 0 && this.inventory.container.Count(x => x is Pawn) >= vehicleDef.vehicle.boardableNum) { fmoMount.label = "No space for boarding"; fmoMount.Disabled = true; } yield return fmoBoard; } else { FloatMenuOption fmoClaim = new FloatMenuOption(); fmoClaim.label = "Claim " + this.LabelBase; fmoClaim.priority = MenuOptionPriority.High; fmoClaim.action = () => { Job jobNew = new Job(DefDatabase<JobDef>.GetNamed("ClaimVehicle"), this); myPawn.drafter.TakeOrderedJob(jobNew); }; yield return fmoClaim; } }
public override IEnumerable<FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { if (this.Faction == Faction.OfPlayer) { return base.GetFloatMenuOptions(myPawn); } else { List<FloatMenuOption> list = new List<FloatMenuOption>(); CompPowerTrader powerComp = this.TryGetComp<CompPowerTrader>(); if (myPawn.Dead || myPawn.Downed || myPawn.IsBurning()) { FloatMenuOption item = new FloatMenuOption("Cannot use (incapacitated)", null); list.Add(item); } if (myPawn.CanReserve(this) == false) { FloatMenuOption item = new FloatMenuOption("Cannot use (reserved)", null); list.Add(item); } else if (myPawn.CanReach(this, PathEndMode.ClosestTouch, Danger.Some) == false) { FloatMenuOption item = new FloatMenuOption("Cannot use (no path)", null); list.Add(item); } else if (this.IsBurning()) { FloatMenuOption item = new FloatMenuOption("Cannot use (burning)", null); list.Add(item); } else if (powerComp.PowerOn == false) { FloatMenuOption item = new FloatMenuOption("Cannot use (no power)", null); list.Add(item); } else { Action action = delegate { Job job = new Job(DefDatabase<JobDef>.GetNamed(OG_Util.JobDefName_TryToCaptureOutpost), this); myPawn.drafter.TakeOrderedJob(job); }; FloatMenuOption item2 = new FloatMenuOption("Try to capture outpost", action); list.Add(item2); } return list; } }
protected override void FillTab() { float fieldHeight = 30.0f; Vehicle vehicle = this.SelThing as Vehicle; ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.GuiFrame); Text.Font = GameFont.Small; Rect innerRect1 = GenUI.ContractedBy(new Rect(0.0f, 0.0f, this.size.x, this.size.y), 10f); GUI.BeginGroup(innerRect1); Rect mountedRect = new Rect(0.0f, 30.0f, innerRect1.width, fieldHeight); float mountedRectY = mountedRect.y; Widgets.ListSeparator(ref mountedRectY, innerRect1.width, "Mounted Character"); mountedRect.y += fieldHeight; Rect thingIconRect = new Rect(mountedRect.x, mountedRect.y, 30f, fieldHeight); Rect thingLabelRect = new Rect(mountedRect.x + 35f, mountedRect.y + 5.0f, innerRect1.width - 35f, fieldHeight); Rect thingButtonRect = new Rect(mountedRect.x, mountedRect.y, innerRect1.width, fieldHeight); if (vehicle.IsMounted) { Pawn driver = vehicle.Driver; Widgets.ThingIcon(thingIconRect, driver.def); Widgets.Label(thingLabelRect, driver.Label); if (Widgets.InvisibleButton(thingButtonRect)) { List<FloatMenuOption> options = new List<FloatMenuOption>(); FloatMenuOption dismount = new FloatMenuOption("Dismount " + driver.LabelBase, () => { vehicle.Dismount(); }); options.Add(dismount); Find.WindowStack.Add(new FloatMenu(options)); } thingIconRect.y += fieldHeight; thingLabelRect.y += fieldHeight; } Rect storageRect = new Rect(0.0f, thingIconRect.y, innerRect1.width, fieldHeight); float storageRectY = storageRect.y; Widgets.ListSeparator(ref storageRectY, innerRect1.width, "Storage"); storageRect.y += fieldHeight; thingIconRect.y = storageRect.y; thingLabelRect.y = storageRect.y; thingButtonRect.y = storageRect.y; foreach (var thing in vehicle.inventory.container) { if ((thing.ThingID.IndexOf("Human_Corpse") <= -1) ? false : true) Widgets.DrawTextureFitted(thingIconRect, ContentFinder<Texture2D>.Get("Things/Pawn/IconHuman_Corpse"), 1.0f); else if ((thing.ThingID.IndexOf("Corpse") <= -1) ? false : true) { Corpse corpse = thing as Corpse; Widgets.ThingIcon(thingIconRect, corpse.innerPawn.def); } else Widgets.ThingIcon(thingIconRect, thing); Widgets.Label(thingLabelRect, thing.Label); if (Widgets.InvisibleButton(thingButtonRect)) { List<FloatMenuOption> options = new List<FloatMenuOption>(); FloatMenuOption dropit = new FloatMenuOption("Drop it", () => { Thing dummy; vehicle.inventory.container.TryDrop(thing, vehicle.Position, ThingPlaceMode.Near, out dummy); }); options.Add(dropit); Find.WindowStack.Add(new FloatMenu(options)); } thingIconRect.y += fieldHeight; thingLabelRect.y += fieldHeight; } GUI.EndGroup(); }
public static void MedicalCareSetterAll( List<Pawn> pawns ) { List<FloatMenuOption> list = new List<FloatMenuOption>( ); for ( int i = 0; i < 5; i++ ) { MedicalCareCategory mc = (MedicalCareCategory) i; FloatMenuOption option = new FloatMenuOption( mc.GetLabel( ), delegate { foreach ( Pawn t in pawns ) { t.playerSettings.medCare = mc; } SoundDefOf.TickHigh.PlayOneShotOnCamera( ); MainTabWindow_Medical.IsDirty = true; } ); list.Add( option ); } Find.WindowStack.Add( new FloatMenu( list, true ) ); }
protected override void FillTab() { float fieldHeight = 30.0f; Vehicle vehicle = this.SelThing as Vehicle; ConceptDatabase.KnowledgeDemonstrated(ConceptDefOf.PrisonerTab, KnowledgeAmount.GuiFrame); Text.Font = GameFont.Small; Rect innerRect1 = GenUI.ContractedBy(new Rect(0.0f, 0.0f, this.size.x, this.size.y), 10f); GUI.BeginGroup(innerRect1); Rect mountedRect = new Rect(0.0f, 30.0f, innerRect1.width, fieldHeight); float mountedRectY = mountedRect.y; //Driver Widgets.ListSeparator(ref mountedRectY, innerRect1.width, "Driver"); mountedRect.y += fieldHeight; Rect thingIconRect = new Rect(mountedRect.x, mountedRect.y, 30f, fieldHeight); Rect thingFillableBar = new Rect(mountedRect.x, mountedRect.y + 22f, 30f, fieldHeight - 22f); Rect thingLabelRect = new Rect(mountedRect.x + 35f, mountedRect.y + 5.0f, innerRect1.width - 35f, fieldHeight); Rect thingButtonRect = new Rect(mountedRect.x, mountedRect.y, innerRect1.width, fieldHeight); if (vehicle.IsMounted) { Pawn driver = vehicle.Driver; Texture2D healthFilledBar = SolidColorMaterials.NewSolidColorTexture( new Color( 0.15f, 1.0f, 0.15f ) ) as Texture2D; if (driver.health.ShouldBeTreatedNow) healthFilledBar = SolidColorMaterials.NewSolidColorTexture(new Color(1.0f, 1.0f, 0.15f)) as Texture2D; Texture2D healthUnfilledBar = SolidColorMaterials.NewSolidColorTexture(new Color(0.15f, 0.15f, 0.15f)) as Texture2D; Widgets.ThingIcon(thingIconRect, driver); if (driver.needs.food.CurCategory == HungerCategory.Hungry || driver.needs.rest.CurCategory == RestCategory.Tired) Widgets.DrawTextureFitted(thingIconRect, GraphicDatabase.Get<Graphic_Single>("Things/Pawn/Effects/Unhappy").MatSingle.mainTexture as Texture2D, 2.0f); Widgets.FillableBar(thingFillableBar, driver.health.summaryHealth.SummaryHealthPercent, healthFilledBar, healthUnfilledBar, true); Widgets.Label(thingLabelRect, driver.Label); if (SelPawn.Faction == Faction.OfColony && Widgets.InvisibleButton(thingButtonRect)) { List<FloatMenuOption> options = new List<FloatMenuOption>(); FloatMenuOption dismount = new FloatMenuOption("Dismount " + driver.LabelBase, () => { vehicle.Dismount(); }); options.Add(dismount); Find.WindowStack.Add(new FloatMenu(options)); } thingIconRect.y += fieldHeight; thingFillableBar.y += fieldHeight; thingLabelRect.y += fieldHeight; } //Crews /* Rect crewRect = new Rect(0.0f, thingIconRect.y, innerRect1.width, fieldHeight); float crewRectY = crewRect.y; Widgets.ListSeparator(ref crewRectY, innerRect1.width, "Crews"); crewRect.y += fieldHeight; thingIconRect.y = crewRect.y; thingFillableBar.y = crewRect.y + 22f; thingLabelRect.y = crewRect.y; thingButtonRect.y = crewRect.y; foreach (Pawn crew in vehicle.crewContainer) { Texture2D healthFilledBar = SolidColorMaterials.NewSolidColorTexture(new Color(0.15f, 1.0f, 0.15f)) as Texture2D; if (crew.health.ShouldBeTreatedNow) healthFilledBar = SolidColorMaterials.NewSolidColorTexture(new Color(1.0f, 1.0f, 0.15f)) as Texture2D; Texture2D healthUnfilledBar = SolidColorMaterials.NewSolidColorTexture(new Color(0.15f, 0.15f, 0.15f)) as Texture2D; Widgets.ThingIcon(thingIconRect, crew); if (crew.needs.food.CurCategory == HungerCategory.Hungry || crew.needs.rest.CurCategory == RestCategory.Tired) Widgets.DrawTextureFitted(thingIconRect, GraphicDatabase.Get<Graphic_Single>("Things/Pawn/Effects/Unhappy").MatSingle.mainTexture as Texture2D, 2.0f); Widgets.FillableBar(thingFillableBar, crew.health.summaryHealth.SummaryHealthPercent, healthFilledBar, healthUnfilledBar, true); Widgets.Label(thingLabelRect, crew.Label); if (SelPawn.Faction == Faction.OfColony && Widgets.InvisibleButton(thingButtonRect)) { List<FloatMenuOption> options = new List<FloatMenuOption>(); FloatMenuOption getOff = new FloatMenuOption("Get off " + crew.LabelBase, () => { vehicle.GetOff(crew); }); options.Add(getOff); Find.WindowStack.Add(new FloatMenu(options)); } thingIconRect.y += fieldHeight; thingFillableBar.y += fieldHeight; thingLabelRect.y += fieldHeight; thingButtonRect.y += fieldHeight; }*/ //storage Rect storageRect = new Rect(0.0f, thingIconRect.y, innerRect1.width, fieldHeight); float storageRectY = storageRect.y; Widgets.ListSeparator(ref storageRectY, innerRect1.width, "Storage"); storageRect.y += fieldHeight; thingIconRect.y = storageRect.y; thingFillableBar.y = storageRect.y + 22f; thingLabelRect.y = storageRect.y; thingButtonRect.y = storageRect.y; if (vehicle.inventory != null) foreach (var thing in vehicle.inventory.container) { if ((thing.ThingID.IndexOf("Human_Corpse") <= -1) ? false : true) Widgets.DrawTextureFitted(thingIconRect, ContentFinder<Texture2D>.Get("Things/Pawn/IconHuman_Corpse"), 1.0f); else if ((thing.ThingID.IndexOf("Corpse") <= -1) ? false : true) { Corpse corpse = thing as Corpse; Widgets.ThingIcon(thingIconRect, corpse.innerPawn.def); } else Widgets.ThingIcon(thingIconRect, thing); Widgets.Label(thingLabelRect, thing.Label); if (SelPawn.Faction == Faction.OfColony && Widgets.InvisibleButton(thingButtonRect)) { List<FloatMenuOption> options = new List<FloatMenuOption>(); FloatMenuOption dropit = new FloatMenuOption("Drop it", () => { Thing dummy; vehicle.inventory.container.TryDrop(thing, vehicle.Position, ThingPlaceMode.Near, out dummy); }); options.Add(dropit); Find.WindowStack.Add(new FloatMenu(options)); } thingIconRect.y += fieldHeight; thingFillableBar.y += fieldHeight; thingLabelRect.y += fieldHeight; } if (Widgets.TextButton(new Rect(180f, 400f, 100f, 30f), vehicle.visibleInside ? "Hide inside" : "Show inside")) vehicle.visibleInside = !vehicle.visibleInside; GUI.EndGroup(); }
private void DrawBatteryChooser(Rect rect) { GUI.BeginGroup(rect); Rect batteryButtonRect = new Rect(0f, 0f, rect.width, ButtonSize.y); if (Widgets.TextButton(batteryButtonRect, _bp.BatteryDef.LabelCap)) { List<FloatMenuOption> options = new List<FloatMenuOption>(); foreach (var def in (from d in DefDatabase<ThingDef>.AllDefs where d != _bp.BatteryDef && d.statBases != null && d.statBases.Any((s) => s.stat == StatDef.Named("MD2PowerCellMaxStorage")) orderby d.label select d).ToList()) { ThingDef tDef = def; FloatMenuOption o = new FloatMenuOption(def.label, delegate { _bp.BatteryDef = tDef; }); options.Add(o); } Find.LayerStack.Add(new Layer_FloatMenu(options, true)); } GUI.EndGroup(); }
public override IEnumerable<FloatMenuOption> GetFloatMenuOptions(Pawn myPawn) { if (!this.powerComp.PowerOn) { FloatMenuOption item5 = new FloatMenuOption("CannotUseNoPower".Translate(), null); return new List<FloatMenuOption> { item5 }; } if (!myPawn.CanReserve(this, 1)) { FloatMenuOption item = new FloatMenuOption("CannotUseReserved".Translate(), null); return new List<FloatMenuOption> { item }; } if (!myPawn.CanReach(this, PathEndMode.InteractionCell, Danger.Some)) { FloatMenuOption item2 = new FloatMenuOption("CannotUseNoPath".Translate(), null); return new List<FloatMenuOption> { item2 }; } if (!HasAnyContents) { FloatMenuOption item3 = new FloatMenuOption("Enter the Mind Altering Device", () => { myPawn.Reserve(this, 0); Job job = new Job(DefDatabase<JobDef>.GetNamed("EnterMAD"), this); myPawn.drafter.TakeOrderedJob(job); }); return new List<FloatMenuOption> { item3 }; } if (HasAnyContents) { FloatMenuOption item4 = new FloatMenuOption("Open the Mind Altering Device", () => { myPawn.Reserve(this, 0); Job job = new Job(DefDatabase<JobDef>.GetNamed("OpenMAD"), this); myPawn.drafter.TakeOrderedJob(job); }); return new List<FloatMenuOption> { item4 }; } return null; }
protected override void FillTab() { Rect mainRect = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f); try { GUI.BeginGroup(mainRect); #region Button Rect buttonRect = new Rect(0f, 0f, 150f, 29f); if (Widgets.TextButton(buttonRect, "AddBill".Translate())) { List<FloatMenuOption> options = new List<FloatMenuOption>(); foreach (var f in BlueprintFiles.AllFiles) { string s = Path.GetFileNameWithoutExtension(f.Name); FloatMenuOption o = new FloatMenuOption(s, delegate { Find.LayerStack.Add(new Dialog_AddBill(Assembly, s)); }); options.Add(o); } Find.LayerStack.Add(new Layer_FloatMenu(options)); } #endregion Rect scrollRect = new Rect(0f, buttonRect.yMax + Margin, mainRect.width, mainRect.height - buttonRect.yMax - Margin); #region Scroll View try { GUI.BeginGroup(scrollRect); Rect outRect = new Rect(0f, 0f, scrollRect.width, scrollRect.height); if (Assembly.AssemblyBillStack.Count == 0) { Rect labelRect = new Rect(0f, 0f, outRect.width, outRect.height); Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.MiddleCenter; Widgets.Label(labelRect, "NoBlueprintBills".Translate()); Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperLeft; } else { float EntryHeightWithMargin = EntryHeight + EntrySpacing; float height = Assembly.AssemblyBillStack.Count * EntryHeightWithMargin; Rect viewRect = new Rect(0f, 0f, outRect.width - 16f, height); float curY = 0f; Widgets.BeginScrollView(outRect, ref scrollPos, viewRect); List<AssemblyBill> bills = Assembly.AssemblyBillStack.Bills; bool alternate = true; foreach (var bill in bills) { Rect entryRect = new Rect(0f, curY, viewRect.width, EntryHeight); DrawEntry(entryRect, bill, alternate); curY += EntryHeightWithMargin; alternate = !alternate; } Widgets.EndScrollView(); } } catch (Exception e) { Log.Error("Exception drawing the scroll box: \n" + e.ToString() + "\n" + e.StackTrace); } finally { GUI.EndGroup(); } #endregion } catch (Exception ex) { Log.Error("Error drawing assembly ITab: \n" + ex.ToString()); } finally { GUI.EndGroup(); } }
private void DrawExtras(Rect rect) { Widgets.DrawMenuSection(rect); Listing_Standard listing = new Listing_Standard(rect.ContractedBy(5f)); listing.DoLabelCheckbox("ExplodeOnDeath".Translate(), ref _bp.ExplodeOnDeath); if (_bp.ExplodeOnDeath) { listing.DoLabel("ExplosionRadius".Translate(_bp.ExplosionRadius.ToString("0.0"))); _bp.ExplosionRadius = listing.DoSlider(_bp.ExplosionRadius, 0.9f, 3.9f); } listing.DoLabel("StartingSkill".Translate(_bp.StartingSkillLevel)); _bp.StartingSkillLevel = (int)listing.DoSlider(_bp.StartingSkillLevel, 1, 20); if (listing.DoTextButtonLabeled("SkillPassion".Translate(), _bp.SkillPassion.ToString())) { List<FloatMenuOption> list = new List<FloatMenuOption>(); foreach (Passion p in Enum.GetValues(typeof(Passion))) { if (p != _bp.SkillPassion) { FloatMenuOption option = new FloatMenuOption(p.ToString(), () => _bp.SkillPassion = p); list.Add(option); } } Find.LayerStack.Add(new Layer_FloatMenu(list)); } listing.End(); }