private void DoGraphPage(Rect rect)
        {
            GUI.BeginGroup(rect);
            Rect graphRect  = new Rect(0f, 0f, rect.width - GraphItemAreaWidth - GraphLegendAreaWidth - FramePadding, GraphAreaHeight);
            Rect legendRect = new Rect(graphRect.xMax + FramePadding, graphRect.yMin, GraphLegendAreaWidth - FramePadding, GraphAreaHeight);

            if (this.historyAutoRecorderGroup != null)
            {
                MainTabWindow_DetailedHistory.marks.Clear();
                List <Tale> allTalesListForReading = Find.TaleManager.AllTalesListForReading;
                for (int i = 0; i < allTalesListForReading.Count; i++)
                {
                    Tale tale = allTalesListForReading[i];
                    if (tale.def.type == TaleType.PermanentHistorical)
                    {
                        float x = (float)GenDate.TickAbsToGame(tale.date) / 60000f;
                        MainTabWindow_DetailedHistory.marks.Add(new CurveMark(x, tale.ShortSummary, tale.def.historyGraphColor));
                    }
                }
                GraphUtility.DrawGraph(graphRect, legendRect, this.graphSection, MainTabWindow_DetailedHistory.marks, this.historyAutoRecorderGroup);
            }
            Text.Font = GameFont.Small;
            float  num = (float)Find.TickManager.TicksGame / 60000f;
            string str;
            float  daysMin;

            if (this.sliderValue > 300f)
            {
                str     = "AllDays";
                daysMin = 0f;
            }
            else
            {
                str     = "Last {0}Days".Translate(this.sliderValue);
                daysMin = Mathf.Max(0f, num - this.sliderValue);
            }
            Rect horizontalRect = new Rect(0f, GraphAreaHeight, 300f, 40f);

            this.sliderValue = Widgets.HorizontalSlider(horizontalRect, this.sliderValue, 5, 301f, true, str);

            this.graphSection = new FloatRange(daysMin, num);

            List <HistoryAutoRecorderGroup> list2 = Find.History.Groups();
            Rect outRect  = new Rect(legendRect.xMax + FramePadding, graphRect.yMin, GraphItemAreaWidth - FramePadding, GraphAreaHeight);
            Rect viewRect = new Rect(0f, 2f, outRect.width, 24f * list2.Count);

            GUI.color = Color.white;
            Widgets.DrawBox(outRect, 1);
            Widgets.BeginScrollView(outRect, ref this.graphItemScrollPosition, viewRect, true);
            Listing_Standard listing = new Listing_Standard();

            listing.Begin(new Rect(0f, 2f, viewRect.width, 9999f));
            for (int i = 0; i < list2.Count; i++)
            {
                HistoryAutoRecorderGroup groupLocal = list2[i];
                if (listing.RadioButton(groupLocal.def.LabelCap, this.historyAutoRecorderGroup == groupLocal))
                {
                    this.historyAutoRecorderGroup = groupLocal;
                    GraphUtility.RecalculateGraph(groupLocal);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.HistoryTab, KnowledgeAmount.Total);
                }
            }
            listing.End();
            Widgets.EndScrollView();
            GUI.EndGroup();
        }
예제 #2
0
        public override void ProcessInput(Event ev)
        {
            base.ProcessInput(ev);
            List <FloatMenuOption> list = new List <FloatMenuOption>();

            if (this.settables == null)
            {
                this.settables = new List <IPlantToGrowSettable>();
            }
            if (!this.settables.Contains(this.settable))
            {
                this.settables.Add(this.settable);
            }
            Command_SetPlantToGrow.tmpAvailablePlants.Clear();
            foreach (ThingDef thingDef in GenPlant.ValidPlantTypesForGrowers(this.settables))
            {
                if (this.IsPlantAvailable(thingDef, this.settable.Map))
                {
                    Command_SetPlantToGrow.tmpAvailablePlants.Add(thingDef);
                }
            }
            Command_SetPlantToGrow.tmpAvailablePlants.SortBy((ThingDef x) => - this.GetPlantListPriority(x), (ThingDef x) => x.label);
            for (int i = 0; i < Command_SetPlantToGrow.tmpAvailablePlants.Count; i++)
            {
                ThingDef plantDef = Command_SetPlantToGrow.tmpAvailablePlants[i];
                string   text     = plantDef.LabelCap;
                if (plantDef.plant.sowMinSkill > 0)
                {
                    string text2 = text;
                    text = string.Concat(new object[]
                    {
                        text2,
                        " (",
                        "MinSkill".Translate(),
                        ": ",
                        plantDef.plant.sowMinSkill,
                        ")"
                    });
                }
                list.Add(new FloatMenuOption(text, delegate()
                {
                    string s = this.tutorTag + "-" + plantDef.defName;
                    if (TutorSystem.AllowAction(s))
                    {
                        bool flag = true;
                        for (int j = 0; j < this.settables.Count; j++)
                        {
                            this.settables[j].SetPlantDefToGrow(plantDef);
                            if (flag && plantDef.plant.interferesWithRoof)
                            {
                                foreach (IntVec3 c in this.settables[j].Cells)
                                {
                                    if (c.Roofed(this.settables[j].Map))
                                    {
                                        Messages.Message("MessagePlantIncompatibleWithRoof".Translate(new object[]
                                        {
                                            Find.ActiveLanguageWorker.Pluralize(plantDef.LabelCap, -1)
                                        }), MessageTypeDefOf.CautionInput, false);
                                        flag = false;
                                        break;
                                    }
                                }
                            }
                        }
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.SetGrowingZonePlant, KnowledgeAmount.Total);
                        this.WarnAsAppropriate(plantDef);
                        TutorSystem.Notify_Event(s);
                    }
                }, MenuOptionPriority.Default, null, null, 29f, (Rect rect) => Widgets.InfoCardButton(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, plantDef), null));
            }
            Find.WindowStack.Add(new FloatMenu(list));
        }
예제 #3
0
            public bool MoveNext()
            {
                uint num = (uint)this.$PC;

                this.$PC = -1;
                bool flag = false;

                switch (num)
                {
                case 0u:
                    enumerator = base.< GetGizmos > __BaseCallProxy0().GetEnumerator();
                    num        = 4294967293u;
                    break;

                case 1u:
                    break;

                case 2u:
                    goto IL_144;

                case 3u:
                    goto IL_1F5;

                default:
                    return(false);
                }
                try
                {
                    switch (num)
                    {
                    }
                    if (enumerator.MoveNext())
                    {
                        g             = enumerator.Current;
                        this.$current = g;
                        if (!this.$disposing)
                        {
                            this.$PC = 1;
                        }
                        flag = true;
                        return(true);
                    }
                }
                finally
                {
                    if (!flag)
                    {
                        if (enumerator != null)
                        {
                            enumerator.Dispose();
                        }
                    }
                }
                if (base.TraderKind != null)
                {
                    Command_Action showSellableItems = new Command_Action();
                    showSellableItems.defaultLabel = "CommandShowSellableItems".Translate();
                    showSellableItems.defaultDesc  = "CommandShowSellableItemsDesc".Translate();
                    showSellableItems.icon         = SettlementBase.ShowSellableItemsCommand;
                    showSellableItems.action       = delegate()
                    {
                        Find.WindowStack.Add(new Dialog_SellableItems(base.TraderKind));
                    };
                    this.$current = showSellableItems;
                    if (!this.$disposing)
                    {
                        this.$PC = 2;
                    }
                    return(true);
                }
IL_144:
                if (base.Faction != Faction.OfPlayer && !PlayerKnowledgeDatabase.IsComplete(ConceptDefOf.FormCaravan))
                {
                    formCaravan = new Command_Action();
                    formCaravan.defaultLabel = "CommandFormCaravan".Translate();
                    formCaravan.defaultDesc  = "CommandFormCaravanDesc".Translate();
                    formCaravan.icon         = SettlementBase.FormCaravanCommand;
                    formCaravan.action       = delegate()
                    {
                        Find.Tutor.learningReadout.TryActivateConcept(ConceptDefOf.FormCaravan);
                        Messages.Message("MessageSelectOwnBaseToFormCaravan".Translate(), MessageTypeDefOf.RejectInput, false);
                    };
                    this.$current = formCaravan;
                    if (!this.$disposing)
                    {
                        this.$PC = 3;
                    }
                    return(true);
                }
IL_1F5:
                this.$PC = -1;
                return(false);
            }
예제 #4
0
        //private bool CanControl
        //{
        //    get
        //    {
        //        Pawn selPawnForGear = this.SelPawnForGear;
        //        return !selPawnForGear.Downed && !selPawnForGear.InMentalState && (selPawnForGear.Faction == Faction.OfPlayer || selPawnForGear.IsPrisonerOfColony) && (!selPawnForGear.IsPrisonerOfColony || !selPawnForGear.Spawned || selPawnForGear.Map.mapPawns.AnyFreeColonistSpawned) && (!selPawnForGear.IsPrisonerOfColony || (!PrisonBreakUtility.IsPrisonBreaking(selPawnForGear) && (selPawnForGear.CurJob == null || !selPawnForGear.CurJob.exitMapOnArrival)));
        //    }
        //}

        //private bool CanControlColonist
        //{
        //    get
        //    {
        //        return this.CanControl && this.SelPawnForGear.IsColonistPlayerControlled;
        //    }
        //}

        //private Pawn SelPawnForGear
        //{
        //    get
        //    {
        //        if (SelPawn != null)
        //        {
        //            return SelPawn;
        //        }
        //        Corpse corpse = SelThing as Corpse;
        //        if (corpse != null)
        //        {
        //            return corpse.InnerPawn;
        //        }
        //        throw new InvalidOperationException("Gear tab on non-pawn non-corpse " + SelThing);
        //    }
        //}

        #endregion Properties

        #region Methods

        public override void FillTab()
        {
            // get the inventory comp
            CompInventory comp = SelPawn.TryGetComp <CompInventory>();

            // set up rects
            Rect listRect = new Rect(
                _margin,
                _topPadding,
                size.x - 2 * _margin,
                size.y - _topPadding - _margin);

            if (comp != null)
            {
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(CE_ConceptDefOf.CE_InventoryWeightBulk, KnowledgeAmount.FrameDisplayed);

                // adjust rects if comp found
                listRect.height -= (_margin / 2 + _barHeight) * 2;
                Rect weightRect = new Rect(_margin, listRect.yMax + _margin / 2, listRect.width, _barHeight);
                Rect bulkRect   = new Rect(_margin, weightRect.yMax + _margin / 2, listRect.width, _barHeight);

                // draw bars
                Utility_Loadouts.DrawBar(bulkRect, comp.currentBulk, comp.capacityBulk, "CE_Bulk".Translate(), SelPawn.GetBulkTip());
                Utility_Loadouts.DrawBar(weightRect, comp.currentWeight, comp.capacityWeight, "CE_Weight".Translate(), SelPawn.GetWeightTip());

                // draw text overlays on bars
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.MiddleCenter;

                string currentBulk  = CE_StatDefOf.CarryBulk.ValueToString(comp.currentBulk, CE_StatDefOf.CarryBulk.toStringNumberSense);
                string capacityBulk = CE_StatDefOf.CarryBulk.ValueToString(comp.capacityBulk, CE_StatDefOf.CarryBulk.toStringNumberSense);
                Widgets.Label(bulkRect, currentBulk + "/" + capacityBulk);

                string currentWeight  = comp.currentWeight.ToString("0.#");
                string capacityWeight = CE_StatDefOf.CarryWeight.ValueToString(comp.capacityWeight, CE_StatDefOf.CarryWeight.toStringNumberSense);
                Widgets.Label(weightRect, currentWeight + "/" + capacityWeight);

                Text.Anchor = TextAnchor.UpperLeft;
            }

            // start drawing list (rip from ITab_Pawn_Gear)

            GUI.BeginGroup(listRect);
            Text.Font = GameFont.Small;
            GUI.color = Color.white;
            Rect outRect  = new Rect(0f, 0f, listRect.width, listRect.height);
            Rect viewRect = new Rect(0f, 0f, listRect.width - 16f, _scrollViewHeight);

            Widgets.BeginScrollView(outRect, ref _scrollPosition, viewRect);
            float num = 0f;

            TryDrawComfyTemperatureRange(ref num, viewRect.width);
            if (ShouldShowOverallArmorCE(SelPawnForGear))
            {
                Widgets.ListSeparator(ref num, viewRect.width, "OverallArmor".Translate());
                TryDrawOverallArmor(ref num, viewRect.width, StatDefOf.ArmorRating_Blunt, "ArmorBlunt".Translate(), " " + "CE_MPa".Translate());
                TryDrawOverallArmor(ref num, viewRect.width, StatDefOf.ArmorRating_Sharp, "ArmorSharp".Translate(), "CE_mmRHA".Translate());
                TryDrawOverallArmor(ref num, viewRect.width, StatDefOf.ArmorRating_Heat, "ArmorHeat".Translate(), "%");
            }
            if (ShouldShowEquipment(SelPawnForGear))
            {
                // get the loadout so we can make a decision to show a button.
                bool    showMakeLoadout = false;
                Loadout curLoadout      = SelPawnForGear.GetLoadout();
                if (SelPawnForGear.IsColonist && (curLoadout == null || curLoadout.Slots.NullOrEmpty()) && (SelPawnForGear.inventory.innerContainer.Any() || SelPawnForGear.equipment?.Primary != null))
                {
                    showMakeLoadout = true;
                }

                if (showMakeLoadout)
                {
                    num += 3;        // Make a little room for the button.
                }
                float buttonY = num; // Could be accomplished with seperator being after the button...

                Widgets.ListSeparator(ref num, viewRect.width, "Equipment".Translate());
                foreach (ThingWithComps current in SelPawnForGear.equipment.AllEquipmentListForReading)
                {
                    DrawThingRowCE(ref num, viewRect.width, current);
                }

                // only offer this button if the pawn has no loadout or has the default loadout and there are things/equipment...
                if (showMakeLoadout)
                {
                    Rect loadoutButtonRect = new Rect(viewRect.width / 2, buttonY, viewRect.width / 2, 26f); // button is half the available width...
                    // Backup GUI color
                    Color      color  = GUI.color;
                    TextAnchor anchor = Text.Anchor;

                    // Highlight if mouse over
                    GUI.color = Color.cyan;
                    if (Mouse.IsOver(loadoutButtonRect))
                    {
                        GUI.color = Color.white;
                    }

                    Text.Anchor = TextAnchor.UpperRight;
                    Widgets.Label(loadoutButtonRect, "CE_MakeLoadout".Translate());

                    if (Widgets.ButtonInvisible(loadoutButtonRect.ContractedBy(2), doMouseoverSound: true))
                    {
                        Loadout loadout = SelPawnForGear.GenerateLoadoutFromPawn();
                        LoadoutManager.AddLoadout(loadout);
                        SelPawnForGear.SetLoadout(loadout);

                        // Opening this window is the same way as if from the assign tab so should be correct.
                        Find.WindowStack.Add(new Dialog_ManageLoadouts(SelPawnForGear.GetLoadout()));
                    }
                    // Restore GUI color
                    Text.Anchor = anchor;
                    GUI.color   = color;
                }
            }
            if (ShouldShowApparel(SelPawnForGear))
            {
                Widgets.ListSeparator(ref num, viewRect.width, "Apparel".Translate());
                foreach (Apparel current2 in from ap in SelPawnForGear.apparel.WornApparel
                         orderby ap.def.apparel.bodyPartGroups[0].listOrder descending
                         select ap)
                {
                    DrawThingRowCE(ref num, viewRect.width, current2);
                }
            }
            if (ShouldShowInventory(SelPawnForGear))
            {
                Widgets.ListSeparator(ref num, viewRect.width, "Inventory".Translate());

                workingInvList.Clear();
                workingInvList.AddRange(SelPawnForGear.inventory.innerContainer);
                for (int i = 0; i < workingInvList.Count; i++)
                {
                    DrawThingRowCE(ref num, viewRect.width, workingInvList[i], true);
                }
            }
            if (Event.current.type == EventType.Layout)
            {
                _scrollViewHeight = num + 30f;
            }
            Widgets.EndScrollView();
            GUI.EndGroup();
            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
        }
예제 #5
0
        private static void AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
        {
            IntVec3 c2 = IntVec3.FromVector3(clickPos);

            foreach (Thing current in c2.GetThingList())
            {
                Thing t = current;
                if (t.def.ingestible != null && pawn.RaceProps.CanEverEat(t) && t.IngestibleNow)
                {
                    string text;
                    if (t.def.ingestible.ingestCommandString.NullOrEmpty())
                    {
                        text = "ConsumeThing".Translate(new object[]
                        {
                            t.LabelShort
                        });
                    }
                    else
                    {
                        text = string.Format(t.def.ingestible.ingestCommandString, t.LabelShort);
                    }
                    FloatMenuOption item;
                    if (t.def.IsPleasureDrug && pawn.story != null && pawn.story.traits.DegreeOfTrait(TraitDefOf.DrugDesire) < 0)
                    {
                        item = new FloatMenuOption(text + " (" + TraitDefOf.DrugDesire.DataAtDegree(-1).label + ")", null, MenuOptionPriority.Medium, null, null, 0f, null);
                    }
                    else if (!pawn.CanReach(t, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn))
                    {
                        item = new FloatMenuOption(text + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null);
                    }
                    else if (!pawn.CanReserve(t, 1))
                    {
                        item = new FloatMenuOption(text + " (" + "ReservedBy".Translate(new object[]
                        {
                            Find.Reservations.FirstReserverOf(t, pawn.Faction, true).LabelShort
                        }) + ")", null, MenuOptionPriority.Medium, null, null, 0f, null);
                    }
                    else
                    {
                        item = new FloatMenuOption(text, delegate
                        {
                            t.SetForbidden(false, true);
                            Job job           = new Job(JobDefOf.Ingest, t);
                            job.maxNumToCarry = FoodUtility.WillIngestStackCountOf(pawn, t.def);
                            pawn.drafter.TakeOrderedJob(job);
                        }, MenuOptionPriority.Medium, null, null, 0f, null);
                    }
                    opts.Add(item);
                }
            }
            if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
                foreach (TargetInfo current2 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true))
                {
                    Pawn victim = (Pawn)current2.Thing;
                    if (!victim.InBed() && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1))
                    {
                        if ((victim.Faction == Faction.OfPlayer && victim.MentalStateDef == null) || (victim.Faction != Faction.OfPlayer && victim.MentalStateDef == null && !victim.IsPrisonerOfColony && (victim.Faction == null || !victim.Faction.HostileTo(Faction.OfPlayer))))
                        {
                            Pawn victim2 = victim;
                            opts.Add(new FloatMenuOption("Rescue".Translate(new object[]
                            {
                                victim.LabelCap
                            }), delegate
                            {
                                Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, false, false, false);
                                if (building_Bed == null)
                                {
                                    string str2;
                                    if (victim.RaceProps.Animal)
                                    {
                                        str2 = "NoAnimalBed".Translate();
                                    }
                                    else
                                    {
                                        str2 = "NoNonPrisonerBed".Translate();
                                    }
                                    Messages.Message("CannotRescue".Translate() + ": " + str2, victim, MessageSound.RejectInput);
                                    return;
                                }
                                Job job           = new Job(JobDefOf.Rescue, victim, building_Bed);
                                job.maxNumToCarry = 1;
                                job.playerForced  = true;
                                pawn.drafter.TakeOrderedJob(job);
                                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Rescuing, KnowledgeAmount.Total);
                            }, MenuOptionPriority.Medium, null, victim2, 0f, null));
                        }
                        if (victim.MentalStateDef != null || (victim.RaceProps.Humanlike && victim.Faction != Faction.OfPlayer))
                        {
                            Pawn victim2 = victim;
                            opts.Add(new FloatMenuOption("Capture".Translate(new object[]
                            {
                                victim.LabelCap
                            }), delegate
                            {
                                Building_Bed building_Bed = RestUtility.FindBedFor(victim, pawn, true, false, false);
                                if (building_Bed == null)
                                {
                                    Messages.Message("CannotCapture".Translate() + ": " + "NoPrisonerBed".Translate(), victim, MessageSound.RejectInput);
                                    return;
                                }
                                Job job           = new Job(JobDefOf.Capture, victim, building_Bed);
                                job.maxNumToCarry = 1;
                                job.playerForced  = true;
                                pawn.drafter.TakeOrderedJob(job);
                                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Capturing, KnowledgeAmount.Total);
                            }, MenuOptionPriority.Medium, null, victim2, 0f, null));
                        }
                    }
                }
                foreach (TargetInfo current3 in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true))
                {
                    TargetInfo targetInfo = current3;
                    Pawn       victim     = (Pawn)targetInfo.Thing;
                    if (victim.Downed && pawn.CanReserveAndReach(victim, PathEndMode.OnCell, Danger.Deadly, 1) && Building_CryptosleepCasket.FindCryptosleepCasketFor(victim, pawn) != null)
                    {
                        string label = "CarryToCryptosleepCasket".Translate(new object[]
                        {
                            targetInfo.Thing.LabelCap
                        });
                        JobDef jDef   = JobDefOf.CarryToCryptosleepCasket;
                        Action action = delegate
                        {
                            Building_CryptosleepCasket building_CryptosleepCasket = Building_CryptosleepCasket.FindCryptosleepCasketFor(victim, pawn);
                            if (building_CryptosleepCasket == null)
                            {
                                Messages.Message("CannotCarryToCryptosleepCasket".Translate() + ": " + "NoCryptosleepCasket".Translate(), victim, MessageSound.RejectInput);
                                return;
                            }
                            Job job = new Job(jDef, victim, building_CryptosleepCasket);
                            job.maxNumToCarry = 1;
                            job.playerForced  = true;
                            pawn.drafter.TakeOrderedJob(job);
                        };
                        Pawn victim2 = victim;
                        opts.Add(new FloatMenuOption(label, action, MenuOptionPriority.Medium, null, victim2, 0f, null));
                    }
                }
            }
            foreach (TargetInfo current4 in GenUI.TargetsAt(clickPos, TargetingParameters.ForStrip(pawn), true))
            {
                TargetInfo      stripTarg = current4;
                FloatMenuOption item2;
                if (!pawn.CanReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                {
                    item2 = new FloatMenuOption("CannotStrip".Translate(new object[]
                    {
                        stripTarg.Thing.LabelCap
                    }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null);
                }
                else if (!pawn.CanReserveAndReach(stripTarg, PathEndMode.ClosestTouch, Danger.Deadly, 1))
                {
                    item2 = new FloatMenuOption("CannotStrip".Translate(new object[]
                    {
                        stripTarg.Thing.LabelCap
                    }) + " (" + "ReservedBy".Translate(new object[]
                    {
                        Find.Reservations.FirstReserverOf(stripTarg, pawn.Faction, true).LabelShort
                    }) + ")", null, MenuOptionPriority.Medium, null, null, 0f, null);
                }
                else
                {
                    item2 = new FloatMenuOption("Strip".Translate(new object[]
                    {
                        stripTarg.Thing.LabelCap
                    }), delegate
                    {
                        stripTarg.Thing.SetForbidden(false, false);
                        Job job          = new Job(JobDefOf.Strip, stripTarg);
                        job.playerForced = true;
                        pawn.drafter.TakeOrderedJob(job);
                    }, MenuOptionPriority.Medium, null, null, 0f, null);
                }
                opts.Add(item2);
            }
            if (pawn.equipment != null)
            {
                ThingWithComps equipment = null;
                List <Thing>   thingList = c2.GetThingList();
                for (int i = 0; i < thingList.Count; i++)
                {
                    if (thingList[i].TryGetComp <CompEquippable>() != null)
                    {
                        equipment = (ThingWithComps)thingList[i];
                        break;
                    }
                }
                if (equipment != null)
                {
                    string          label2 = equipment.Label;
                    FloatMenuOption item3;
                    if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                    {
                        item3 = new FloatMenuOption("CannotEquip".Translate(new object[]
                        {
                            label2
                        }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null);
                    }
                    else if (!pawn.CanReserve(equipment, 1))
                    {
                        item3 = new FloatMenuOption("CannotEquip".Translate(new object[]
                        {
                            label2
                        }) + " (" + "ReservedBy".Translate(new object[]
                        {
                            Find.Reservations.FirstReserverOf(equipment, pawn.Faction, true).LabelShort
                        }) + ")", null, MenuOptionPriority.Medium, null, null, 0f, null);
                    }
                    else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                    {
                        item3 = new FloatMenuOption("CannotEquip".Translate(new object[]
                        {
                            label2
                        }) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null);
                    }
                    else
                    {
                        string text2 = "Equip".Translate(new object[]
                        {
                            label2
                        });
                        if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler))
                        {
                            text2 = text2 + " " + "EquipWarningBrawler".Translate();
                        }
                        item3 = new FloatMenuOption(text2, delegate
                        {
                            equipment.SetForbidden(false, true);
                            Job job          = new Job(JobDefOf.Equip, equipment);
                            job.playerForced = true;
                            pawn.drafter.TakeOrderedJob(job);
                            MoteMaker.MakeStaticMote(equipment.DrawPos, ThingDefOf.Mote_FeedbackEquip, 1f);
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total);
                        }, MenuOptionPriority.Medium, null, null, 0f, null);
                    }
                    opts.Add(item3);
                }
            }
            if (pawn.apparel != null)
            {
                Apparel apparel = Find.ThingGrid.ThingAt <Apparel>(c2);
                if (apparel != null)
                {
                    FloatMenuOption item4;
                    if (!pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                    {
                        item4 = new FloatMenuOption("CannotWear".Translate(new object[]
                        {
                            apparel.Label
                        }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null);
                    }
                    else if (!pawn.CanReserve(apparel, 1))
                    {
                        Pawn pawn2 = Find.Reservations.FirstReserverOf(apparel, pawn.Faction, true);
                        item4 = new FloatMenuOption("CannotWear".Translate(new object[]
                        {
                            apparel.Label
                        }) + " (" + "ReservedBy".Translate(new object[]
                        {
                            pawn2.LabelShort
                        }) + ")", null, MenuOptionPriority.Medium, null, null, 0f, null);
                    }
                    else if (!ApparelUtility.HasPartsToWear(pawn, apparel.def))
                    {
                        item4 = new FloatMenuOption("CannotWear".Translate(new object[]
                        {
                            apparel.Label
                        }) + " (" + "CannotWearBecauseOfMissingBodyParts".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null);
                    }
                    else if (RaceRestricted(pawn, apparel))
                    {
                        item4 = new FloatMenuOption("CannotWear".Translate(new object[]
                        {
                            apparel.Label
                        }) + " (" + "CannotWearBecauseOfWrongRace".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null);
                    }
                    else
                    {
                        item4 = new FloatMenuOption("ForceWear".Translate(new object[]
                        {
                            apparel.LabelShort
                        }), delegate
                        {
                            apparel.SetForbidden(false, true);
                            Job job          = new Job(JobDefOf.Wear, apparel);
                            job.playerForced = true;
                            pawn.drafter.TakeOrderedJob(job);
                        }, MenuOptionPriority.Medium, null, null, 0f, null);
                    }
                    opts.Add(item4);
                }
            }
            if (pawn.equipment != null && pawn.equipment.Primary != null)
            {
                Thing thing = Find.ThingGrid.ThingAt(c2, ThingDefOf.EquipmentRack);
                if (thing != null)
                {
                    if (!pawn.CanReach(thing, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                    {
                        opts.Add(new FloatMenuOption("CannotDeposit".Translate(new object[]
                        {
                            pawn.equipment.Primary.LabelCap,
                            thing.def.label
                        }) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null));
                    }
                    else
                    {
                        foreach (IntVec3 c in GenAdj.CellsOccupiedBy(thing))
                        {
                            if (c.GetStorable() == null && pawn.CanReserveAndReach(c, PathEndMode.ClosestTouch, Danger.Deadly, 1))
                            {
                                Action action2 = delegate
                                {
                                    ThingWithComps t;
                                    if (pawn.equipment.TryDropEquipment(pawn.equipment.Primary, out t, pawn.Position, true))
                                    {
                                        t.SetForbidden(false, true);
                                        Job job = new Job(JobDefOf.HaulToCell, t, c);
                                        job.haulMode      = HaulMode.ToCellStorage;
                                        job.maxNumToCarry = 1;
                                        job.playerForced  = true;
                                        pawn.drafter.TakeOrderedJob(job);
                                    }
                                };
                                opts.Add(new FloatMenuOption("Deposit".Translate(new object[]
                                {
                                    pawn.equipment.Primary.LabelCap,
                                    thing.def.label
                                }), action2, MenuOptionPriority.Medium, null, null, 0f, null));
                                break;
                            }
                        }
                    }
                }
                if (pawn.equipment != null && GenUI.TargetsAt(clickPos, TargetingParameters.ForSelf(pawn), true).Any <TargetInfo>())
                {
                    Action action3 = delegate
                    {
                        ThingWithComps thingWithComps;
                        pawn.equipment.TryDropEquipment(pawn.equipment.Primary, out thingWithComps, pawn.Position, true);
                        pawn.drafter.TakeOrderedJob(new Job(JobDefOf.Wait, 20, false));
                    };
                    opts.Add(new FloatMenuOption("Drop".Translate(new object[]
                    {
                        pawn.equipment.Primary.Label
                    }), action3, MenuOptionPriority.Medium, null, null, 0f, null));
                }
            }
            foreach (TargetInfo current5 in GenUI.TargetsAt(clickPos, TargetingParameters.ForTrade(), true))
            {
                TargetInfo dest = current5;
                if (!pawn.CanReach(dest, PathEndMode.OnCell, Danger.Deadly, false, TraverseMode.ByPawn))
                {
                    opts.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null));
                }
                else if (!pawn.CanReserve(dest.Thing, 1))
                {
                    opts.Add(new FloatMenuOption("CannotTrade".Translate() + " (" + "Reserved".Translate() + ")", null, MenuOptionPriority.Medium, null, null, 0f, null));
                }
                else
                {
                    Pawn   pTarg   = (Pawn)dest.Thing;
                    Action action4 = delegate
                    {
                        Job job = new Job(JobDefOf.TradeWithPawn, pTarg);
                        job.playerForced = true;
                        pawn.drafter.TakeOrderedJob(job);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.InteractingWithTraders, KnowledgeAmount.Total);
                    };
                    string str = string.Empty;
                    if (pTarg.Faction != null)
                    {
                        str = " (" + pTarg.Faction.Name + ")";
                    }
                    Thing thing2 = dest.Thing;
                    opts.Add(new FloatMenuOption("TradeWith".Translate(new object[]
                    {
                        pTarg.LabelShort + ", " + pTarg.TraderKind.label
                    }) + str, action4, MenuOptionPriority.Medium, null, thing2, 0f, null));
                }
            }
            foreach (Thing current6 in Find.ThingGrid.ThingsAt(c2))
            {
                foreach (FloatMenuOption current7 in current6.GetFloatMenuOptions(pawn))
                {
                    opts.Add(current7);
                }
            }
        }
        protected override void DrawPawnRow(Rect rect, Pawn p)
        {
            // available space for row
            Rect rowRect = new Rect(rect.x + 165f, rect.y, rect.width - 165f, rect.height);

            // response button rect
            Vector2 responsePos = new Vector2(rowRect.xMin, rowRect.yMin + (rowRect.height - 24f) / 2f);

            // offset rest of row for that button, so we don't have to mess with all the other rect calculations
            rowRect.xMin += 24f + _margin;

            // label + buttons for outfit
            Rect outfitRect = new Rect(rowRect.xMin,
                                       rowRect.yMin,
                                       rowRect.width * (1f / 4f) + (_margin + _buttonSize) / 2f,
                                       rowRect.height);

            Rect labelOutfitRect = new Rect(outfitRect.xMin,
                                            outfitRect.yMin,
                                            outfitRect.width - _margin * 3 - _buttonSize * 2,
                                            outfitRect.height)
                                   .ContractedBy(_margin / 2f);
            Rect editOutfitRect = new Rect(labelOutfitRect.xMax + _margin,
                                           outfitRect.yMin + ((outfitRect.height - _buttonSize) / 2),
                                           _buttonSize,
                                           _buttonSize);
            Rect forcedOutfitRect = new Rect(labelOutfitRect.xMax + _buttonSize + _margin * 2,
                                             outfitRect.yMin + ((outfitRect.height - _buttonSize) / 2),
                                             _buttonSize,
                                             _buttonSize);

            // drucg policy
            Rect drugRect = new Rect(outfitRect.xMax,
                                     rowRect.yMin,
                                     rowRect.width * (1f / 4f) - (_margin + _buttonSize) / 2f,
                                     rowRect.height);
            Rect labelDrugRect = new Rect(drugRect.xMin,
                                          drugRect.yMin,
                                          drugRect.width - _margin * 2 - _buttonSize,
                                          drugRect.height)
                                 .ContractedBy(_margin / 2f);
            Rect editDrugRect = new Rect(labelDrugRect.xMax + _margin,
                                         drugRect.yMin + ((drugRect.height - _buttonSize) / 2),
                                         _buttonSize,
                                         _buttonSize);

            // label + button for loadout
            Rect loadoutRect = new Rect(drugRect.xMax,
                                        rowRect.yMin,
                                        rowRect.width * (1f / 4f) - (_margin + _buttonSize) / 2f,
                                        rowRect.height);
            Rect labelLoadoutRect = new Rect(loadoutRect.xMin,
                                             loadoutRect.yMin,
                                             loadoutRect.width - _margin * 2 - _buttonSize,
                                             loadoutRect.height)
                                    .ContractedBy(_margin / 2f);
            Rect editLoadoutRect = new Rect(labelLoadoutRect.xMax + _margin,
                                            loadoutRect.yMin + ((loadoutRect.height - _buttonSize) / 2),
                                            _buttonSize,
                                            _buttonSize);

            // fight or flight button
            HostilityResponseModeUtility.DrawResponseButton(responsePos, p);

            // weight + bulk indicators
            Rect weightRect = new Rect(loadoutRect.xMax, rowRect.yMin, rowRect.width * (1f / 8f) - _margin, rowRect.height).ContractedBy(_margin / 2f);
            Rect bulkRect   = new Rect(weightRect.xMax + _margin, rowRect.yMin, rowRect.width * (1f / 8f) - _margin, rowRect.height).ContractedBy(_margin / 2f);

            // OUTFITS
            // main button
            if (Widgets.ButtonText(labelOutfitRect, p.outfits.CurrentOutfit.label, true, false))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();
                foreach (Outfit current in Current.Game.outfitDatabase.AllOutfits)
                {
                    // need to create a local copy for delegate
                    Outfit localOut = current;
                    options.Add(new FloatMenuOption(localOut.label, delegate
                    {
                        p.outfits.CurrentOutfit = localOut;
                    }, MenuOptionPriority.Default, null, null));
                }
                Find.WindowStack.Add(new FloatMenu(options, optionalTitle, false));
            }

            // edit button
            TooltipHandler.TipRegion(editOutfitRect, "CR.EditX".Translate("CR.outfit".Translate() + " " + p.outfits.CurrentOutfit.label));
            if (Widgets.ButtonImage(editOutfitRect, _iconEdit))
            {
                Text.Font = GameFont.Small;
                Find.WindowStack.Add(new Dialog_ManageOutfits(p.outfits.CurrentOutfit));
            }

            // clear forced button
            if (p.outfits.forcedHandler.SomethingIsForced)
            {
                TooltipHandler.TipRegion(forcedOutfitRect, "ClearForcedApparel".Translate());
                if (Widgets.ButtonImage(forcedOutfitRect, _iconClearForced))
                {
                    p.outfits.forcedHandler.Reset();
                }
                TooltipHandler.TipRegion(forcedOutfitRect, new TipSignal(delegate
                {
                    string text = "ForcedApparel".Translate() + ":\n";
                    foreach (Apparel current2 in p.outfits.forcedHandler.ForcedApparel)
                    {
                        text = text + "\n   " + current2.LabelCap;
                    }
                    return(text);
                }, p.GetHashCode() * 612));
            }

            // DRUG POLICY
            // main button
            string textDrug = p.drugs.CurrentPolicy.label;

            if (p.story != null && p.story.traits != null)
            {
                Trait trait = p.story.traits.GetTrait(TraitDefOf.DrugDesire);
                if (trait != null)
                {
                    textDrug = textDrug + " (" + trait.Label + ")";
                }
            }
            if (Widgets.ButtonText(labelDrugRect, textDrug, true, false, true))
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (DrugPolicy current in Current.Game.drugPolicyDatabase.AllPolicies)
                {
                    DrugPolicy localAssignedDrugs = current;
                    list.Add(new FloatMenuOption(current.label, delegate
                    {
                        p.drugs.CurrentPolicy = localAssignedDrugs;
                    }, MenuOptionPriority.Default, null, null, 0f, null));
                }
                Find.WindowStack.Add(new FloatMenu(list));
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.DrugPolicies, KnowledgeAmount.Total);
            }


            // edit button
            TooltipHandler.TipRegion(editDrugRect, "CR.EditX".Translate("CR.drugs".Translate() + " " + p.drugs.CurrentPolicy.label));
            if (Widgets.ButtonImage(editDrugRect, _iconEdit))
            {
                Text.Font = GameFont.Small;
                Find.WindowStack.Add(new Dialog_ManageDrugPolicies(p.drugs.CurrentPolicy));
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.DrugPolicies, KnowledgeAmount.Total);
            }

            // LOADOUTS
            // main button
            if (Widgets.ButtonText(labelLoadoutRect, p.GetLoadout().LabelCap, true, false))
            {
                List <FloatMenuOption> options = new List <FloatMenuOption>();
                foreach (Loadout loadout in LoadoutManager.Loadouts)
                {
                    // need to create a local copy for delegate
                    Loadout localLoadout = loadout;
                    options.Add(new FloatMenuOption(localLoadout.LabelCap, delegate
                    {
                        p.SetLoadout(localLoadout);
                    }, MenuOptionPriority.Default, null, null));
                }
                Find.WindowStack.Add(new FloatMenu(options, optionalTitle, false));
            }

            // edit button
            TooltipHandler.TipRegion(editLoadoutRect, "CR.EditX".Translate("CR.loadout".Translate() + " " + p.GetLoadout().LabelCap));
            if (Widgets.ButtonImage(editLoadoutRect, _iconEdit))
            {
                Find.WindowStack.Add(new Dialog_ManageLoadouts(p.GetLoadout()));
            }

            // STATUS BARS
            // fetch the comp
            CompInventory comp = p.TryGetComp <CompInventory>();

            if (comp != null)
            {
                Utility_Loadouts.DrawBar(bulkRect, comp.currentBulk, comp.capacityBulk, "", p.GetBulkTip());
                Utility_Loadouts.DrawBar(weightRect, comp.currentWeight, comp.capacityWeight, "", p.GetWeightTip());
            }
        }
예제 #7
0
 public override IEnumerable <Gizmo> GetGizmos()
 {
     foreach (Gizmo g in base.GetGizmos())
     {
         yield return(g);
     }
     if (base.Faction != Faction.OfPlayer && Current.ProgramState == ProgramState.Playing && !PlayerKnowledgeDatabase.IsComplete(ConceptDefOf.FormCaravan))
     {
         Command_Action formCaravan = new Command_Action();
         formCaravan.defaultLabel = "CommandFormCaravan".Translate();
         formCaravan.defaultDesc  = "CommandFormCaravanDesc".Translate();
         formCaravan.icon         = Settlement.FormCaravanCommand;
         formCaravan.action       = delegate
         {
             Find.Tutor.learningReadout.TryActivateConcept(ConceptDefOf.FormCaravan);
             Messages.Message("MessageSelectOwnBaseToFormCaravan".Translate(), MessageTypeDefOf.RejectInput);
         };
         yield return(formCaravan);
     }
 }
예제 #8
0
        public static bool DoTimeControlsGUI(Rect timerRect)
        {
            TickManager tickManager = Find.TickManager;

            GUI.BeginGroup(timerRect);
            Rect rect = new Rect(0f, 0f, TimeControls.TimeButSize.x, TimeControls.TimeButSize.y);

            for (int i = 0; i < CachedTimeSpeedValues.Length; i++)
            {
                TimeSpeed timeSpeed = CachedTimeSpeedValues[i];
                if (timeSpeed == TimeSpeed.Ultrafast)
                {
                    continue;
                }

                if (Widgets.ButtonImage(rect, TexButton.SpeedButtonTextures[(uint)timeSpeed]))
                {
                    if (timeSpeed == TimeSpeed.Paused)
                    {
                        tickManager.TogglePaused();
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Pause, KnowledgeAmount.SpecificInteraction);
                    }
                    else
                    {
                        tickManager.CurTimeSpeed = timeSpeed;
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction);
                    }

                    PlaySoundOf(tickManager.CurTimeSpeed);
                }

                if (tickManager.CurTimeSpeed == timeSpeed)
                {
                    GUI.DrawTexture(rect, TexUI.HighlightTex);
                }

                rect.x += rect.width;
            }

            if (Find.TickManager.slower.ForcedNormalSpeed)
            {
                Widgets.DrawLineHorizontal(rect.width * 2f, rect.height / 2f, rect.width * 2f);
            }

            GUI.EndGroup();
            GenUI.AbsorbClicksInRect(timerRect);
            UIHighlighter.HighlightOpportunity(timerRect, "TimeControls");
            if (Event.current.type != EventType.KeyDown)
            {
                return(false);
            }

            if (KeyBindingDefOf.TogglePause.KeyDownEvent)
            {
                Find.TickManager.TogglePaused();
                PlaySoundOf(Find.TickManager.CurTimeSpeed);
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Pause, KnowledgeAmount.SpecificInteraction);
                Event.current.Use();
            }

            if (!Find.WindowStack.WindowsForcePause)
            {
                if (KeyBindingDefOf.TimeSpeed_Normal.KeyDownEvent)
                {
                    Find.TickManager.CurTimeSpeed = TimeSpeed.Normal;
                    PlaySoundOf(Find.TickManager.CurTimeSpeed);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction);
                    Event.current.Use();
                }

                if (KeyBindingDefOf.TimeSpeed_Fast.KeyDownEvent)
                {
                    Find.TickManager.CurTimeSpeed = TimeSpeed.Fast;
                    if (lastTickForcedSlow)
                    {
                        overrideForcedSlow = true;
                    }
                    //forceNormalSpeedUntil(Find.TickManager.slower) = 0;
                    PlaySoundOf(Find.TickManager.CurTimeSpeed);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction);
                    Event.current.Use();
                }

                if (KeyBindingDefOf.TimeSpeed_Superfast.KeyDownEvent)
                {
                    Find.TickManager.CurTimeSpeed = TimeSpeed.Superfast;
                    if (lastTickForcedSlow)
                    {
                        overrideForcedSlow = true;
                    }
                    //forceNormalSpeedUntil(Find.TickManager.slower) = 0;
                    PlaySoundOf(Find.TickManager.CurTimeSpeed);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction);
                    Event.current.Use();
                }

                if (KeyBindingDefOf.TimeSpeed_Ultrafast.KeyDownEvent)
                {
                    Find.TickManager.CurTimeSpeed = TimeSpeed.Ultrafast;
                    if (lastTickForcedSlow)
                    {
                        overrideForcedSlow = true;
                    }
                    //forceNormalSpeedUntil(Find.TickManager.slower) = 0;
                    PlaySoundOf(Find.TickManager.CurTimeSpeed);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction);
                    Event.current.Use();
                }
            }

            if (Prefs.DevMode)
            {
                if (KeyBindingDefOf.Dev_TickOnce.KeyDownEvent && tickManager.CurTimeSpeed == TimeSpeed.Paused)
                {
                    tickManager.DoSingleTick();
                    SoundDefOf.Clock_Stop.PlayOneShotOnCamera();
                }
            }
            return(false);
        }
        protected override bool TryExecuteWorker(IncidentParms parms)
        {
            ResolveRaidPoints(parms);
            if (!TryResolveRaidFaction(parms))
            {
                return(false);
            }
            PawnGroupKindDef combat = PawnGroupKindDefOf.Combat;

            ResolveRaidStrategy(parms, combat);
            ResolveRaidArriveMode(parms);
            parms.raidStrategy.Worker.TryGenerateThreats(parms);
            if (!parms.raidArrivalMode.Worker.TryResolveRaidSpawnCenter(parms))
            {
                return(false);
            }
            float points = parms.points;

            parms.points = AdjustedRaidPoints(parms.points, parms.raidArrivalMode, parms.raidStrategy, parms.faction, combat);
            RaidPatches.includeRaidToTheList = false;
            List <Pawn> list = parms.raidStrategy.Worker.SpawnThreats(parms);

            if (list == null)
            {
                list = PawnGroupMakerUtility.GeneratePawns(IncidentParmsUtility.GetDefaultPawnGroupMakerParms(combat, parms)).ToList();
                if (list.Count == 0)
                {
                    Log.Error("Got no pawns spawning raid from parms " + parms);
                    return(false);
                }
                parms.raidArrivalMode.Worker.Arrive(list, parms);
            }
            RaidPatches.includeRaidToTheList = true;

            GenerateRaidLoot(parms, points, list);
            TaggedString letterLabel = GetLetterLabel(parms);
            TaggedString letterText  = GetLetterText(parms, list);

            PawnRelationUtility.Notify_PawnsSeenByPlayer_Letter(list, ref letterLabel, ref letterText, GetRelatedPawnsInfoLetterText(parms), informEvenIfSeenBefore: true);
            List <TargetInfo> list2 = new List <TargetInfo>();

            if (parms.pawnGroups != null)
            {
                List <List <Pawn> > list3 = IncidentParmsUtility.SplitIntoGroups(list, parms.pawnGroups);
                List <Pawn>         list4 = list3.MaxBy((List <Pawn> x) => x.Count);
                if (list4.Any())
                {
                    list2.Add(list4[0]);
                }
                for (int i = 0; i < list3.Count; i++)
                {
                    if (list3[i] != list4 && list3[i].Any())
                    {
                        list2.Add(list3[i][0]);
                    }
                }
            }
            else if (list.Any())
            {
                foreach (Pawn item in list)
                {
                    list2.Add(item);
                }
            }
            SendStandardLetter(letterLabel, letterText, GetLetterDef(), parms, list2);
            parms.raidStrategy.Worker.MakeLords(parms, list);
            LessonAutoActivator.TeachOpportunity(ConceptDefOf.EquippingWeapons, OpportunityType.Critical);
            if (!PlayerKnowledgeDatabase.IsComplete(ConceptDefOf.ShieldBelts))
            {
                for (int j = 0; j < list.Count; j++)
                {
                    if (list[j].apparel?.WornApparel.Any((Apparel ap) => ap is ShieldBelt) ?? false)
                    {
                        LessonAutoActivator.TeachOpportunity(ConceptDefOf.ShieldBelts, OpportunityType.Critical);
                        break;
                    }
                }
            }
            Find.TickManager.slower.SignalForceNormalSpeedShort();
            Find.StoryWatcher.statsRecord.numRaidsEnemy++;
            return(true);
        }
예제 #10
0
        protected override void FillTab()
        {
            // get the inventory comp
            CompInventory comp = SelPawn.TryGetComp <CompInventory>();

            // set up rects
            Rect listRect = new Rect(
                _margin,
                _topPadding,
                size.x - 2 * _margin,
                size.y - _topPadding - _margin);

            if (comp != null)
            {
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(CE_ConceptDefOf.CE_InventoryWeightBulk, KnowledgeAmount.FrameDisplayed);

                // adjust rects if comp found
                listRect.height -= (_margin / 2 + _barHeight) * 2;
                Rect weightRect = new Rect(_margin, listRect.yMax + _margin / 2, listRect.width, _barHeight);
                Rect bulkRect   = new Rect(_margin, weightRect.yMax + _margin / 2, listRect.width, _barHeight);

                Utility_Loadouts.DrawBar(bulkRect, comp.currentBulk, comp.capacityBulk, "CE_Bulk".Translate(), SelPawn.GetBulkTip());
                Utility_Loadouts.DrawBar(weightRect, comp.currentWeight, comp.capacityWeight, "CE_Weight".Translate(), SelPawn.GetWeightTip());
            }

            // start drawing list (rip from ITab_Pawn_Gear)

            GUI.BeginGroup(listRect);
            Text.Font = GameFont.Small;
            GUI.color = Color.white;
            Rect outRect  = new Rect(0f, 0f, listRect.width, listRect.height);
            Rect viewRect = new Rect(0f, 0f, listRect.width - 16f, _scrollViewHeight);

            Widgets.BeginScrollView(outRect, ref _scrollPosition, viewRect);
            float num = 0f;

            TryDrawComfyTemperatureRange(ref num, viewRect.width);
            if (SelPawnForGear.apparel != null)
            {
                bool flag = false;
                TryDrawAverageArmor(ref num, viewRect.width, StatDefOf.ArmorRating_Blunt, "ArmorBlunt".Translate(), ref flag);
                TryDrawAverageArmor(ref num, viewRect.width, StatDefOf.ArmorRating_Sharp, "ArmorSharp".Translate(), ref flag);
                TryDrawAverageArmor(ref num, viewRect.width, StatDefOf.ArmorRating_Heat, "ArmorHeat".Translate(), ref flag);
            }
            if (SelPawnForGear.equipment != null)
            {
                Widgets.ListSeparator(ref num, viewRect.width, "Equipment".Translate());
                foreach (ThingWithComps current in SelPawnForGear.equipment.AllEquipmentListForReading)
                {
                    DrawThingRow(ref num, viewRect.width, current);
                }
            }
            if (SelPawnForGear.apparel != null)
            {
                Widgets.ListSeparator(ref num, viewRect.width, "Apparel".Translate());
                foreach (Apparel current2 in from ap in SelPawnForGear.apparel.WornApparel
                         orderby ap.def.apparel.bodyPartGroups[0].listOrder descending
                         select ap)
                {
                    DrawThingRow(ref num, viewRect.width, current2);
                }
            }
            if (SelPawnForGear.inventory != null)
            {
                // get the loadout so we can make a decision to show a button.
                bool    showMakeLoadout = false;
                Loadout curLoadout      = SelPawnForGear.GetLoadout();
                if (SelPawnForGear.IsColonist && (curLoadout == null || curLoadout.Slots.NullOrEmpty()) && (SelPawnForGear.inventory.innerContainer.Any() || SelPawnForGear.equipment?.Primary != null))
                {
                    showMakeLoadout = true;
                }

                if (showMakeLoadout)
                {
                    num += 3;        // Make a little room for the button.
                }
                float buttonY = num; // Could be accomplished with seperator being after the button...

                Widgets.ListSeparator(ref num, viewRect.width, "Inventory".Translate());

                // only offer this button if the pawn has no loadout or has the default loadout and there are things/equipment...
                if (showMakeLoadout)
                {
                    Rect loadoutButtonRect = new Rect(viewRect.width / 2, buttonY, viewRect.width / 2, 26f);     // button is half the available width...
                    if (Widgets.ButtonText(loadoutButtonRect, "Make Loadout"))
                    {
                        Loadout loadout = SelPawnForGear.GenerateLoadoutFromPawn();
                        LoadoutManager.AddLoadout(loadout);
                        SelPawnForGear.SetLoadout(loadout);

                        // UNDONE ideally we'd open the assign (MainTabWindow_OutfitsAndLoadouts) tab as if the user clicked on it here.
                        // (ProfoundDarkness) But I have no idea how to do that just yet.  The attempts I made seem to put the RimWorld UI into a bit of a bad state.
                        //                     ie opening the tab like the dialog below.
                        //                    Need to understand how RimWorld switches tabs and see if something similar can be done here
                        //                     (or just remove the unfinished marker).

                        // Opening this window is the same way as if from the assign tab so should be correct.
                        Find.WindowStack.Add(new Dialog_ManageLoadouts(SelPawnForGear.GetLoadout()));
                    }
                }

                workingInvList.Clear();
                workingInvList.AddRange(SelPawnForGear.inventory.innerContainer);
                for (int i = 0; i < workingInvList.Count; i++)
                {
                    DrawThingRow(ref num, viewRect.width, workingInvList[i].GetInnerIfMinified(), true);
                }
            }
            if (Event.current.type == EventType.Layout)
            {
                _scrollViewHeight = num + 30f;
            }
            Widgets.EndScrollView();
            GUI.EndGroup();
            GUI.color   = Color.white;
            Text.Anchor = TextAnchor.UpperLeft;
        }
예제 #11
0
        // RimWorld.ITab_Bills
        public static bool FillTab_Prefix()
        {
            var selTable = (Building_WorkTable)Find.Selector.SingleSelectedThing;

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

            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed);
            var x        = WinSize.x;
            var winSize2 = WinSize;
            var rect2    = new Rect(0f, 0f, x, winSize2.y).ContractedBy(10f);

            Dictionary <string, List <FloatMenuOption> > LabeledSortingActions()
            {
                var dictionary = new Dictionary <string, List <FloatMenuOption> >();

                // Dictionary<string, List<FloatMenuOption>> dictionary2 = new Dictionary<string, List<FloatMenuOption>>();
                var recipesWithoutPart = selTable.def.AllRecipes.Where(bam =>
                                                                       bam.products?.FirstOrDefault()?.thingDef?.apparel?.bodyPartGroups.NullOrEmpty() ?? true).ToList();
                var recipesWithPart = selTable.def.AllRecipes.Where(bam =>
                                                                    !bam.products?.FirstOrDefault()?.thingDef?.apparel?.bodyPartGroups.NullOrEmpty() ?? false).ToList();

                recipesWithPart.SortByDescending(blum => blum.label);

                foreach (var recipeDef in recipesWithoutPart)
                {
                    if (!recipeDef.AvailableNow)
                    {
                        continue;
                    }

                    var recipe = recipeDef;

                    void Action()
                    {
                        var any = false;

                        foreach (var col in selTable.Map.mapPawns.FreeColonists)
                        {
                            if (!recipe.PawnSatisfiesSkillRequirements(col))
                            {
                                continue;
                            }

                            any = true;
                            break;
                        }

                        if (!any)
                        {
                            Bill.CreateNoPawnsWithSkillDialog(recipe);
                        }

                        var bill = recipe.MakeNewBill();

                        selTable.billStack.AddBill(bill);
                        if (recipe.conceptLearned != null)
                        {
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                        }

                        if (TutorSystem.TutorialMode)
                        {
                            TutorSystem.Notify_Event(new EventPack("AddBill-" + recipe.LabelCap));
                        }
                    }

                    var floatMenuOption = new FloatMenuOption(recipe.LabelCap, Action, MenuOptionPriority.Default, null,
                                                              null, 29f,
                                                              rect => Widgets.InfoCardButton((float)(rect.x + 5.0),
                                                                                             (float)(rect.y + ((rect.height - 24.0) / 2.0)), recipe));

                    dictionary.Add(recipe.LabelCap, new List <FloatMenuOption> {
                        floatMenuOption
                    });
                }

                foreach (var recipeDef in recipesWithPart)
                {
                    if (!recipeDef.AvailableNow)
                    {
                        continue;
                    }

                    var recipe = recipeDef;

                    var recipeProduct = recipe.products.FirstOrDefault();

                    var colonistsWithThing = new List <Pawn>();
                    if (recipeProduct != null && recipeProduct.thingDef.IsApparel)
                    {
                        colonistsWithThing = selTable.Map.mapPawns.FreeColonistsSpawned.Where(p =>
                                                                                              p.apparel.WornApparel.Any(ap => ap.def == recipeProduct.thingDef))
                                             .ToList();
                    }

                    void MouseoverGuiAction()
                    {
                        var tooltip = string.Empty;

                        for (var index = 0; index < recipe.ingredients.Count; index++)
                        {
                            var ingredient = recipe.ingredients[index];
                            if (index > 0)
                            {
                                tooltip += ", ";
                            }

                            tooltip += ingredient.Summary;
                        }

                        tooltip += "\n";

                        if (recipeProduct != null)
                        {
                            var thingDef = recipeProduct.thingDef;
                            for (var index = 0; index < thingDef.apparel.bodyPartGroups.Count; index++)
                            {
                                var bpg = thingDef.apparel.bodyPartGroups[index];
                                if (index > 0)
                                {
                                    tooltip += ", ";
                                }

                                tooltip += bpg.LabelCap;
                            }

                            tooltip += "\n";
                            for (var index = 0; index < thingDef.apparel.layers.Count; index++)
                            {
                                var layer = thingDef.apparel.layers[index];
                                if (index > 0)
                                {
                                    tooltip += ", ";
                                }

                                tooltip += layer.ToString();
                            }

                            var statBases = thingDef.statBases
                                            .Where(bing => bing.stat.category == StatCategoryDefOf.Apparel)
                                            .ToList();
                            if (!statBases.NullOrEmpty())
                            {
                                // tooltip = StatCategoryDefOf.Apparel.LabelCap;
                                // tooltip += "\n-------------------------------";
                                tooltip += "\n";
                                foreach (var statOffset in statBases)
                                {
                                    {
                                        // if (index > 0)
                                        tooltip += "\n";
                                    }

                                    tooltip += statOffset.stat.LabelCap + Separator + statOffset.ValueToStringAsOffset;
                                }
                            }

                            if (!thingDef.equippedStatOffsets.NullOrEmpty())
                            {
                                // if (tooltip == string.Empty)
                                // {
                                // tooltip = StatCategoryDefOf.EquippedStatOffsets.LabelCap;
                                // }
                                {
                                    // else
                                    tooltip += "\n\n" + StatCategoryDefOf.EquippedStatOffsets.LabelCap;
                                }

                                tooltip += NewLine;
                                foreach (var statOffset in thingDef.equippedStatOffsets)
                                {
                                    tooltip += "\n";
                                    tooltip += statOffset.stat.LabelCap + Separator + statOffset.ValueToStringAsOffset;
                                }
                            }
                        }

                        if (colonistsWithThing.Count > 0)
                        {
                            tooltip += "\n\nWorn by: ";
                            for (var j = 0; j < colonistsWithThing.Count; j++)
                            {
                                var p = colonistsWithThing[j];
                                if (j > 0)
                                {
                                    tooltip += j != colonistsWithThing.Count - 1 ? ", " : " and ";
                                }

                                tooltip += p.LabelShort;
                            }
                        }

                        TooltipHandler.TipRegion(
                            new Rect(Event.current.mousePosition.x - 5f, Event.current.mousePosition.y - 5f, 10f, 10f),
                            tooltip);
                    }

                    void Action()
                    {
                        var any = false;

                        foreach (var col in selTable.Map.mapPawns.FreeColonists)
                        {
                            if (!recipe.PawnSatisfiesSkillRequirements(col))
                            {
                                continue;
                            }

                            any = true;
                            break;
                        }

                        if (!any)
                        {
                            Bill.CreateNoPawnsWithSkillDialog(recipe);
                        }

                        var bill = recipe.MakeNewBill();

                        selTable.billStack.AddBill(bill);
                        if (recipe.conceptLearned != null)
                        {
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                        }

                        if (TutorSystem.TutorialMode)
                        {
                            TutorSystem.Notify_Event(new EventPack("AddBill-" + recipe.LabelCap));
                        }
                    }

                    var floatMenuOption = new FloatMenuOption(recipe.LabelCap, Action, MenuOptionPriority.Default,
                                                              MouseoverGuiAction, null, 29f,
                                                              rect => Widgets.InfoCardButton((float)(rect.x + 5.0),
                                                                                             (float)(rect.y + ((rect.height - 24.0) / 2.0)), recipe));

                    // recipe.products?.FirstOrDefault()?.thingDef));

                    // list.Add(new FloatMenuOption("LoL", null));
                    // Outfitter jump in here

                    // for (int j = 0; j < recipe.products.Count; j++)
                    // {
                    if (recipeProduct == null)
                    {
                        continue;
                    }

                    var count = selTable.Map.listerThings.ThingsOfDef(recipeProduct.thingDef).Count;

                    var wornCount = colonistsWithThing.Count;

                    for (var k = 0; k < recipeProduct.thingDef?.apparel?.bodyPartGroups?.Count; k++)
                    {
                        var bPart = recipeProduct.thingDef.apparel.bodyPartGroups[k];

                        string key = bPart.LabelCap + Tools.NestedString;

                        if (!dictionary.ContainsKey(key))
                        {
                            dictionary.Add(key, new List <FloatMenuOption>());
                        }

                        if (k == 0)
                        {
                            floatMenuOption.Label += " (" + count + "/" + wornCount + ")";

                            // + "\n"
                            // + recipeProduct.thingDef.equippedStatOffsets.ToStringSafeEnumerable();
                        }

                        dictionary[key].Add(floatMenuOption);
                    }
                }

                // Dictionary<string, List<FloatMenuOption>> list2 = new Dictionary<string, List<FloatMenuOption>>();
                // dictionary2 = dictionary2.OrderByDescending(c => c.Key).ToDictionary(KeyValuePair<string, List<FloatMenuOption>>);
                if (!dictionary.Any())
                {
                    dictionary.Add("NoneBrackets".Translate(), new List <FloatMenuOption> {
                        null
                    });
                }

                // else
                // {
                // foreach (KeyValuePair<string, List<FloatMenuOption>> pair in list)
                // {
                // string label = pair.Key;
                // if (pair.Value.Count == 1)
                // {
                // label = pair.Value.FirstOrDefault().Label;
                // }
                // list2.Add(label, pair.Value);
                // }
                // }
                return(dictionary);
            }

            _mouseoverBill = DoListing(selTable.BillStack, rect2, LabeledSortingActions, ref _scrollPosition,
                                       ref _viewHeight);

            return(false);
        }
예제 #12
0
 public void Update()
 {
     if (LongEventHandler.ShouldWaitForEvent)
     {
         if (Current.SubcameraDriver != null)
         {
             Current.SubcameraDriver.UpdatePositions(this.MyCamera);
         }
     }
     else if (Find.CurrentMap != null)
     {
         Vector2 lhs = this.CalculateCurInputDollyVect();
         if (lhs != Vector2.zero)
         {
             float d = (this.rootSize - 11f) / 49f * 0.7f + 0.3f;
             this.velocity = new Vector3(lhs.x, 0f, lhs.y) * d;
             PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.CameraDolly, KnowledgeAmount.FrameInteraction);
         }
         if (!this.AnythingPreventsCameraMotion)
         {
             float d2 = Time.deltaTime * CameraDriver.HitchReduceFactor;
             this.rootPos  += this.velocity * d2 * this.config.moveSpeedScale;
             this.rootPos.x = Mathf.Clamp(this.rootPos.x, 2f, (float)Find.CurrentMap.Size.x + -2f);
             this.rootPos.z = Mathf.Clamp(this.rootPos.z, 2f, (float)Find.CurrentMap.Size.z + -2f);
         }
         int num = Gen.FixedTimeStepUpdate(ref this.fixedTimeStepBuffer, 60f);
         for (int i = 0; i < num; i++)
         {
             if (this.velocity != Vector3.zero)
             {
                 this.velocity *= this.config.camSpeedDecayFactor;
                 if (this.velocity.magnitude < 0.1f)
                 {
                     this.velocity = Vector3.zero;
                 }
             }
             if (this.config.smoothZoom)
             {
                 float num2 = Mathf.Lerp(this.rootSize, this.desiredSize, 0.05f);
                 this.desiredSize += (num2 - this.rootSize) * this.config.zoomPreserveFactor;
                 this.rootSize     = num2;
             }
             else
             {
                 float num3 = this.desiredSize - this.rootSize;
                 float num4 = num3 * 0.4f;
                 this.desiredSize += this.config.zoomPreserveFactor * num4;
                 this.rootSize    += num4;
             }
             this.config.ConfigFixedUpdate_60(ref this.velocity);
         }
         this.shaker.Update();
         this.ApplyPositionToGameObject();
         Current.SubcameraDriver.UpdatePositions(this.MyCamera);
         if (Find.CurrentMap != null)
         {
             RememberedCameraPos rememberedCameraPos = Find.CurrentMap.rememberedCameraPos;
             rememberedCameraPos.rootPos  = this.rootPos;
             rememberedCameraPos.rootSize = this.rootSize;
         }
     }
 }
예제 #13
0
 public void OnGUI()
 {
     GUI.depth = 100;
     if (!LongEventHandler.ShouldWaitForEvent)
     {
         if (Find.CurrentMap != null)
         {
             UnityGUIBugsFixer.OnGUI();
             this.mouseCoveredByUI = false;
             if (Find.WindowStack.GetWindowAt(UI.MousePositionOnUIInverted) != null)
             {
                 this.mouseCoveredByUI = true;
             }
             if (!this.AnythingPreventsCameraMotion)
             {
                 if (Event.current.type == EventType.MouseDrag && Event.current.button == 2)
                 {
                     this.mouseDragVect = Event.current.delta;
                     Event.current.Use();
                 }
                 float num = 0f;
                 if (Event.current.type == EventType.ScrollWheel)
                 {
                     num -= Event.current.delta.y * 0.35f;
                     PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.CameraZoom, KnowledgeAmount.TinyInteraction);
                 }
                 if (KeyBindingDefOf.MapZoom_In.KeyDownEvent)
                 {
                     num += 4f;
                     PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.CameraZoom, KnowledgeAmount.SmallInteraction);
                 }
                 if (KeyBindingDefOf.MapZoom_Out.KeyDownEvent)
                 {
                     num -= 4f;
                     PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.CameraZoom, KnowledgeAmount.SmallInteraction);
                 }
                 this.desiredSize -= num * this.config.zoomSpeed * this.rootSize / 35f;
                 this.desiredSize  = Mathf.Clamp(this.desiredSize, 11f, 60f);
                 this.desiredDolly = Vector3.zero;
                 if (KeyBindingDefOf.MapDolly_Left.IsDown)
                 {
                     this.desiredDolly.x = -this.config.dollyRateKeys;
                 }
                 if (KeyBindingDefOf.MapDolly_Right.IsDown)
                 {
                     this.desiredDolly.x = this.config.dollyRateKeys;
                 }
                 if (KeyBindingDefOf.MapDolly_Up.IsDown)
                 {
                     this.desiredDolly.y = this.config.dollyRateKeys;
                 }
                 if (KeyBindingDefOf.MapDolly_Down.IsDown)
                 {
                     this.desiredDolly.y = -this.config.dollyRateKeys;
                 }
                 if (this.mouseDragVect != Vector2.zero)
                 {
                     this.mouseDragVect  *= CameraDriver.HitchReduceFactor;
                     this.mouseDragVect.x = this.mouseDragVect.x * -1f;
                     this.desiredDolly   += this.mouseDragVect * this.config.dollyRateMouseDrag;
                     this.mouseDragVect   = Vector2.zero;
                 }
                 this.config.ConfigOnGUI();
             }
         }
     }
 }
예제 #14
0
        /* This is included in Building_Bed_Patch.cs where we adds a PostFix to the Building_Bed.GetGizmos method
         * public override IEnumerable<Gizmo> GetGizmos()
         * {
         * // Get original gizmos from Building class
         * var method = typeof(Building).GetMethod("GetGizmos"); //nizhuan-jjr:I think the type should be changed from Building to Building_Bed, but the Building_Bed_Patch.cs is doing the job.
         * var ftn = method.MethodHandle.GetFunctionPointer();
         * var func = (Func<IEnumerable<Gizmo>>)Activator.CreateInstance(typeof(Func<IEnumerable<Gizmo>>), this, ftn);
         *
         * foreach (var gizmo in func())
         * {
         * yield return gizmo;
         * }
         *
         * if (xxx.config.whore_beds_enabled && def.building.bed_humanlike)
         * {
         * yield return
         *  new Command_Toggle
         *  {
         *      defaultLabel = "CommandBedSetAsWhoreLabel".Translate(),
         *      defaultDesc = "CommandBedSetAsWhoreDesc".Translate(),
         *      icon = ContentFinder<Texture2D>.Get("UI/Commands/AsWhore"),
         *      isActive = () => true,
         *      toggleAction = () => Swap(this),
         *      hotKey = KeyBindingDefOf.Misc4
         *  };
         * }
         * }
         */

        public override void PostMake()
        {
            base.PostMake();
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDef.Named("WhoreBeds"), KnowledgeAmount.Total);
        }
예제 #15
0
        private static bool Patch_DrawHealthSummary_Prefix(Rect rect, Pawn pawn, bool allowOperations, Thing thingForMedBills)
        {
            if (pawn.Dead)
            {
                Corpse corpse = (thingForMedBills as Corpse);
                //Log.Message("Own DrawHealthSummary "+allowOperations);

                GUI.color = Color.white;
                if (!allowOperations)
                {
                    p.SetValue(null, false);
                }
                Widgets.DrawMenuSection(rect);
                List <TabRecord> list = new List <TabRecord>();
                list.Add(new TabRecord("HealthOverview".Translate(), delegate
                {
                    p.SetValue(null, false);
                }, !(bool)p.GetValue(null)));
                if (allowOperations)
                {
                    string label = (!corpse.InnerPawn.RaceProps.IsMechanoid) ? "MedicalOperationsShort".Translate(new object[]
                    {
                        corpse.BillStack.Count
                    }) : "MedicalOperationsMechanoidsShort".Translate(new object[]
                    {
                        corpse.BillStack.Count
                    });
                    list.Add(new TabRecord(label, delegate
                    {
                        p.SetValue(null, true);
                    }, (bool)p.GetValue(null)));
                }
                TabDrawer.DrawTabs(rect, list);
                rect = rect.ContractedBy(9f);
                GUI.BeginGroup(rect);
                float curY = 0f;
                Text.Font   = GameFont.Medium;
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperCenter;
                if ((bool)p.GetValue(null))
                {
                    //Log.Message("A");
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.MedicalOperations, KnowledgeAmount.FrameDisplayed);
                    curY = (float)AccessTools.Method(typeof(HealthCardUtility), "DrawMedOperationsTab", new Type[] { typeof(Rect), typeof(Pawn), typeof(Thing), typeof(float) }).Invoke(null, new object[] { rect, pawn, thingForMedBills, curY }); //(rect, pawn, thingForMedBills, curY);
                }
                else
                {
                    //Log.Message("B");
                    curY = (float)AccessTools.Method(typeof(HealthCardUtility), "DrawOverviewTab", new Type[] { typeof(Rect), typeof(Pawn), typeof(float) }).Invoke(null, new object[] { rect, pawn, curY });
                }
                Text.Font   = GameFont.Small;
                GUI.color   = Color.white;
                Text.Anchor = TextAnchor.UpperLeft;
                GUI.EndGroup();

                return(false);
            }
            else
            {
                //Log.Message("DrawHealthSummary forwarding");
                return(true);
            }
        }
예제 #16
0
 public override void GizmoUpdateOnMouseover()
 {
     base.GizmoUpdateOnMouseover();
     PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.InspectRoomStats, KnowledgeAmount.FrameInteraction);
     Room?.DrawFieldEdges();
 }
예제 #17
0
        private static void AddHumanlikeOrders(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
        {
            if (SimpleSidearms.CEOverride)
            {
                return;
            }

            IntVec3 c = IntVec3.FromVector3(clickPos);

            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];
                        break;
                    }
                }
                if (equipment != null)
                {
                    string          labelShort = equipment.LabelShort;
                    string          errStr;
                    FloatMenuOption item3;
                    if (equipment.def.IsWeapon && pawn.story.WorkTagIsDisabled(WorkTags.Violent))
                    {
                    }
                    else if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn))
                    {
                    }
                    else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
                    {
                    }
                    else if (!equipment.def.IsWeapon)
                    {
                    }
                    else if (!StatCalculator.canCarrySidearm(equipment.def, pawn, out errStr))
                    {
                        item3 = new FloatMenuOption("CannotEquip".Translate(new object[]
                        {
                            labelShort
                        }) + " (" + errStr + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
                        opts.Add(item3);
                    }
                    else
                    {
                        string text2 = "Equip".Translate(new object[]
                        {
                            labelShort
                        }) + "AsSidearm".Translate();

                        if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler))
                        {
                            text2 = text2 + " " + "EquipWarningBrawler".Translate();
                        }

                        item3 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text2, delegate
                        {
                            equipment.SetForbidden(false, true);
                            pawn.jobs.TryTakeOrderedJob(new Job(SidearmsDefOf.EquipSecondary, equipment), JobTag.Misc);
                            MoteMaker.MakeStaticMote(equipment.DrawPos, equipment.Map, ThingDefOf.Mote_FeedbackEquip, 1f);

                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction);
                        }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, equipment, "ReservedBy");
                        opts.Add(item3);
                    }
                }
            }
        }
        public static IEnumerable <FloatMenuOption> GetFloatMenuOptions(this Building_CommsConsole building, Pawn myPawn)
        {
            /*if (!myPawn.CanReserve(building, 1))
             * {
             *  FloatMenuOption item = new FloatMenuOption("CannotUseReserved".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null);
             *  return new List<FloatMenuOption>
             *  {
             *      item
             *  };
             * }*/
            if (!myPawn.CanReach(building, PathEndMode.InteractionCell, Danger.Some, false, TraverseMode.ByPawn))
            {
                FloatMenuOption item2 = new FloatMenuOption("CannotUseNoPath".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null);
                return(new List <FloatMenuOption>
                {
                    item2
                });
            }
            if (building.Map.mapConditionManager.ConditionIsActive(MapConditionDefOf.SolarFlare))
            {
                FloatMenuOption item3 = new FloatMenuOption("CannotUseSolarFlare".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null);
                return(new List <FloatMenuOption>
                {
                    item3
                });
            }
            if (!building.GetFieldViaReflection <CompPowerTrader>("powerComp").PowerOn)
            {
                FloatMenuOption item4 = new FloatMenuOption("CannotUseNoPower".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null);
                return(new List <FloatMenuOption>
                {
                    item4
                });
            }
            if (!myPawn.health.capacities.CapableOf(PawnCapacityDefOf.Talking))
            {
                FloatMenuOption item5 = new FloatMenuOption("CannotUseReason".Translate(new object[]
                {
                    "IncapableOfCapacity".Translate(new object[]
                    {
                        PawnCapacityDefOf.Talking.label
                    })
                }), null, MenuOptionPriority.Default, null, null, 0f, null);
                return(new List <FloatMenuOption>
                {
                    item5
                });
            }
            if (!building.CanUseCommsNow)
            {
                Log.Error(myPawn + " could not use comm console for unknown reason.");
                FloatMenuOption item6 = new FloatMenuOption("Cannot use now", null, MenuOptionPriority.Default, null, null, 0f, null);
                return(new List <FloatMenuOption>
                {
                    item6
                });
            }
            IEnumerable <ICommunicable> enumerable = myPawn.Map.passingShipManager.passingShips.Cast <ICommunicable>().Concat(Find.FactionManager.AllFactionsInViewOrder.Cast <ICommunicable>());
            List <FloatMenuOption>      list       = new List <FloatMenuOption>();

            foreach (ICommunicable commTarget in enumerable)
            {
                ICommunicable localCommTarget = commTarget;
                string        text            = "CallOnRadio".Translate(new object[]
                {
                    localCommTarget.GetCallLabel()
                });
                Faction faction = localCommTarget as Faction;
                if (faction != null)
                {
                    if (faction.IsPlayer)
                    {
                        continue;
                    }
                    if (!Building_CommsConsole.LeaderIsAvailableToTalk(faction))
                    {
                        list.Add(new FloatMenuOption(text + " (" + "LeaderUnavailable".Translate(new object[]
                        {
                            faction.leader.LabelShort
                        }) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                        continue;
                    }
                }
                Action action = delegate
                {
                    if (commTarget is TradeShip && !Building_OrbitalTradeBeacon.AllPowered(building.Map).Any <Building_OrbitalTradeBeacon>())
                    {
                        Messages.Message("MessageNeedBeaconToTradeWithShip".Translate(), building, MessageSound.RejectInput);
                        return;
                    }
                    Job job = new Job(JobDefOf.UseCommsConsole, building);
                    job.commTarget = localCommTarget;
                    myPawn.jobs.TryTakeOrderedJob(job);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.OpeningComms, KnowledgeAmount.Total);
                };
                ITWN.PostMenuOption(list,
                                    myPawn,
                                    building,
                                    text,
                                    action,
                                    priority: MenuOptionPriority.InitiateSocial);
            }
            return(list);
        }
        public override void DoWindowContents(Rect canvas)
        {
            // fix weird zooming bug
            Text.Font = GameFont.Small;

            base.DoWindowContents(canvas);

            // available space
            Rect header = new Rect(165f + 24f + _margin, _topArea - _rowHeight, canvas.width - 165f - 24f - _margin - 16f, _rowHeight);

            // label + buttons for outfit
            Rect outfitRect = new Rect(header.xMin,
                                       header.yMin,
                                       header.width * (1f / 4f) + (_margin + _buttonSize) / 2f,
                                       header.height);
            Rect labelOutfitRect = new Rect(outfitRect.xMin,
                                            outfitRect.yMin,
                                            outfitRect.width - _margin * 3 - _buttonSize * 2,
                                            outfitRect.height)
                                   .ContractedBy(_margin / 2f);
            Rect editOutfitRect = new Rect(labelOutfitRect.xMax + _margin,
                                           outfitRect.yMin + ((outfitRect.height - _buttonSize) / 2),
                                           _buttonSize,
                                           _buttonSize);
            Rect forcedOutfitRect = new Rect(labelOutfitRect.xMax + _buttonSize + _margin * 2,
                                             outfitRect.yMin + ((outfitRect.height - _buttonSize) / 2),
                                             _buttonSize,
                                             _buttonSize);

            // label + button for drugs
            Rect drugRect = new Rect(outfitRect.xMax,
                                     header.yMin,
                                     header.width * (1f / 4f) - (_margin + _buttonSize) / 2f,
                                     header.height);
            Rect labelDrugRect = new Rect(drugRect.xMin,
                                          drugRect.yMin,
                                          drugRect.width - _margin * 2 - _buttonSize,
                                          drugRect.height)
                                 .ContractedBy(_margin / 2f);
            Rect editDrugRect = new Rect(labelDrugRect.xMax + _margin,
                                         drugRect.yMin + ((drugRect.height - _buttonSize) / 2),
                                         _buttonSize,
                                         _buttonSize);

            // label + button for loadout
            Rect loadoutRect = new Rect(drugRect.xMax,
                                        header.yMin,
                                        header.width * (1f / 4f) - (_margin + _buttonSize) / 2f,
                                        header.height);
            Rect labelLoadoutRect = new Rect(loadoutRect.xMin,
                                             loadoutRect.yMin,
                                             loadoutRect.width - _margin * 2 - _buttonSize,
                                             loadoutRect.height)
                                    .ContractedBy(_margin / 2f);
            Rect editLoadoutRect = new Rect(labelLoadoutRect.xMax + _margin,
                                            loadoutRect.yMin + ((loadoutRect.height - _buttonSize) / 2),
                                            _buttonSize,
                                            _buttonSize);

            // weight + bulk indicators
            Rect weightRect = new Rect(loadoutRect.xMax, header.yMin, header.width * (1f / 8f) - _margin, header.height).ContractedBy(_margin / 2f);
            Rect bulkRect   = new Rect(weightRect.xMax + _margin, header.yMin, header.width * (1f / 8f) - _margin, header.height).ContractedBy(_margin / 2f);

            // draw headers
            Text.Anchor = TextAnchor.LowerCenter;
            Widgets.Label(labelOutfitRect, "CurrentOutfit".Translate());

            TooltipHandler.TipRegion(editOutfitRect, "CR.EditX".Translate("CR.Outfits".Translate()));
            if (Widgets.ButtonImage(editOutfitRect, _iconEdit))
            {
                Find.WindowStack.Add(new Dialog_ManageOutfits(null));
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Outfits, KnowledgeAmount.Total);
            }

            Widgets.Label(labelDrugRect, "CurrentDrugPolicies".Translate());
            TooltipHandler.TipRegion(editDrugRect, "ManageDrugPolicies".Translate("ButtonAssignDrugs"));
            if (Widgets.ButtonImage(editDrugRect, _iconEdit))
            {
                Find.WindowStack.Add(new Dialog_ManageDrugPolicies(null));
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.DrugPolicies, KnowledgeAmount.Total);
            }

            Widgets.Label(labelLoadoutRect, "CR.CurrentLoadout".Translate());
            TooltipHandler.TipRegion(editLoadoutRect, "CR.EditX".Translate("CR.Loadouts".Translate()));
            if (Widgets.ButtonImage(editLoadoutRect, _iconEdit))
            {
                Find.WindowStack.Add(new Dialog_ManageLoadouts(null));
            }
            Widgets.Label(weightRect, "CR.Weight".Translate());
            Widgets.Label(bulkRect, "CR.Bulk".Translate());
            Text.Anchor = TextAnchor.UpperLeft;

            // draw the rows
            canvas.yMin += 45f;
            DrawRows(canvas);
        }
예제 #20
0
        private void iconClickAction(int buttonID)
        {
            if (interactedWeapon != null)
            {
                Thing toSwapTo;
                if (interactedRanged)
                {
                    if (buttonID == 0)
                    {
                        toSwapTo = interactedWeapon;

                        if (GoldfishModule.GetGoldfishForPawn(parent) != null && toSwapTo.def.defName.Equals(GoldfishModule.GetGoldfishForPawn(parent).primary))
                        {
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SidearmsPrimary, KnowledgeAmount.Total);
                        }

                        WeaponAssingment.weaponSwapSpecific(parent, toSwapTo, true, MiscUtils.shouldDrop(DroppingModeEnum.UserForced), false);
                        SwapControlsHandler handler = SwapControlsHandler.GetHandlerForPawn(parent);
                        if (handler.autoLockOnManualSwap)
                        {
                            handler.currentWeaponLocked = true;
                        }

                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SidearmsInInventory, KnowledgeAmount.SpecificInteraction);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction);
                    }
                    else if (buttonID == 1)
                    {
                        WeaponAssingment.dropSidearm(parent, interactedWeapon);

                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SidearmsInInventory, KnowledgeAmount.SpecificInteraction);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction);
                    }
                }
                else
                {
                    if (buttonID == 0)
                    {
                        toSwapTo = interactedWeapon;

                        if (GoldfishModule.GetGoldfishForPawn(parent) != null && toSwapTo.def.defName.Equals(GoldfishModule.GetGoldfishForPawn(parent).primary))
                        {
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SidearmsPrimary, KnowledgeAmount.Total);
                        }

                        WeaponAssingment.weaponSwapSpecific(parent, toSwapTo, true, MiscUtils.shouldDrop(DroppingModeEnum.UserForced), false);

                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SidearmsInInventory, KnowledgeAmount.SpecificInteraction);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction);
                    }
                    else if (buttonID == 1)
                    {
                        WeaponAssingment.dropSidearm(parent, interactedWeapon);

                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SidearmsInInventory, KnowledgeAmount.SpecificInteraction);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction);
                    }
                }
            }
            else if (interactedWeaponMemory != null)
            {
                if (interactedRanged)
                {
                    if (buttonID == 0)
                    {
                    }
                    else if (buttonID == 1)
                    {
                        WeaponAssingment.forgetSidearmMemory(parent, interactedWeaponMemory);

                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SidearmsMissing, KnowledgeAmount.SpecificInteraction);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction);
                    }
                }
                else
                {
                    if (buttonID == 0)
                    {
                    }
                    else if (buttonID == 1)
                    {
                        WeaponAssingment.forgetSidearmMemory(parent, interactedWeaponMemory);

                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SidearmsMissing, KnowledgeAmount.SpecificInteraction);
                        PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction);
                    }
                }
            }
            else if (interactedUnarmed == true)
            {
                if (buttonID == 0)
                {
                    WeaponAssingment.weaponSwapSpecific(parent, null, true, MiscUtils.shouldDrop(DroppingModeEnum.UserForced), false);
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(SidearmsDefOf.Concept_SimpleSidearmsBasic, KnowledgeAmount.SmallInteraction);
                }
            }
        }
예제 #21
0
 private static void DoPlayLoad()
 {
     GraphicDatabase.Clear();
     DeepProfiler.Start("Load all active mods.");
     try
     {
         LoadedModManager.LoadAllActiveMods();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Load language metadata.");
     try
     {
         LanguageDatabase.LoadAllMetadata();
     }
     finally
     {
         DeepProfiler.End();
     }
     LongEventHandler.SetCurrentEventText("LoadingDefs".Translate());
     DeepProfiler.Start("Copy all Defs from mods to global databases.");
     try
     {
         foreach (Type current in typeof(Def).AllSubclasses())
         {
             GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), current, "AddAllInMods");
         }
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Resolve cross-references between non-implied Defs.");
     try
     {
         DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.Silent);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Rebind defs (early).");
     try
     {
         DefOfHelper.RebindAllDefOfs(true);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Inject selected language data into game data (early pass).");
     try
     {
         LanguageDatabase.activeLanguage.InjectIntoData_BeforeImpliedDefs();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Generate implied Defs (pre-resolve).");
     try
     {
         DefGenerator.GenerateImpliedDefs_PreResolve();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Resolve cross-references between Defs made by the implied defs.");
     try
     {
         DirectXmlCrossRefLoader.ResolveAllWantedCrossReferences(FailMode.LogErrors);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Rebind DefOfs (final).");
     try
     {
         DefOfHelper.RebindAllDefOfs(false);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Other def binding, resetting and global operations (pre-resolve).");
     try
     {
         PlayerKnowledgeDatabase.ReloadAndRebind();
         LessonAutoActivator.Reset();
         CostListCalculator.Reset();
         Pawn.ResetStaticData();
         PawnApparelGenerator.Reset();
         RestUtility.Reset();
         ThoughtUtility.Reset();
         PawnWeaponGenerator.Reset();
         ThinkTreeKeyAssigner.Reset();
         ThingCategoryNodeDatabase.FinalizeInit();
         TrainableUtility.Reset();
         HaulAIUtility.Reset();
         GenConstruct.Reset();
         MedicalCareUtility.Reset();
         InspectPaneUtility.Reset();
         GraphicDatabaseHeadRecords.Reset();
         DateReadout.Reset();
         ResearchProjectDef.GenerateNonOverlappingCoordinates();
         BaseGen.Reset();
         ResourceCounter.ResetDefs();
         ApparelProperties.ResetStaticData();
         WildPlantSpawner.ResetStaticData();
         PawnGenerator.Reset();
         TunnelHiveSpawner.ResetStaticData();
         Hive.ResetStaticData();
         ExpectationsUtility.Reset();
         WealthWatcher.ResetStaticData();
         SkillUI.Reset();
         WorkGiver_FillFermentingBarrel.ResetStaticData();
         WorkGiver_DoBill.ResetStaticData();
         WorkGiver_InteractAnimal.ResetStaticData();
         WorkGiver_Warden_DoExecution.ResetStaticData();
         WorkGiver_GrowerSow.ResetStaticData();
         WorkGiver_Miner.ResetStaticData();
         WorkGiver_FixBrokenDownBuilding.ResetStaticData();
         WorkGiver_ConstructDeliverResources.ResetStaticData();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Resolve references.");
     try
     {
         foreach (Type current2 in typeof(Def).AllSubclasses())
         {
             if (current2 != typeof(ThingDef))
             {
                 GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), current2, "ResolveAllReferences", new object[]
                 {
                     true
                 });
             }
         }
         DefDatabase <ThingDef> .ResolveAllReferences(true);
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Generate implied Defs (post-resolve).");
     try
     {
         DefGenerator.GenerateImpliedDefs_PostResolve();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Other def binding, resetting and global operations (post-resolve).");
     try
     {
         BuildingProperties.FinalizeInit();
         ThingSetMakerUtility.Reset();
     }
     finally
     {
         DeepProfiler.End();
     }
     if (Prefs.DevMode)
     {
         DeepProfiler.Start("Error check all defs.");
         try
         {
             foreach (Type current3 in typeof(Def).AllSubclasses())
             {
                 GenGeneric.InvokeStaticMethodOnGenericType(typeof(DefDatabase <>), current3, "ErrorCheckAllDefs");
             }
         }
         finally
         {
             DeepProfiler.End();
         }
     }
     LongEventHandler.SetCurrentEventText("Initializing".Translate());
     DeepProfiler.Start("Load keyboard preferences.");
     try
     {
         KeyPrefs.Init();
     }
     finally
     {
         DeepProfiler.End();
     }
     DeepProfiler.Start("Short hash giving.");
     try
     {
         ShortHashGiver.GiveAllShortHashes();
     }
     finally
     {
         DeepProfiler.End();
     }
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         DeepProfiler.Start("Load backstories.");
         try
         {
             BackstoryDatabase.ReloadAllBackstories();
         }
         finally
         {
             DeepProfiler.End();
         }
     });
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         DeepProfiler.Start("Inject selected language data into game data.");
         try
         {
             LanguageDatabase.activeLanguage.InjectIntoData_AfterImpliedDefs();
             GenLabel.ClearCache();
         }
         finally
         {
             DeepProfiler.End();
         }
     });
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         StaticConstructorOnStartupUtility.CallAll();
         if (Prefs.DevMode)
         {
             StaticConstructorOnStartupUtility.ReportProbablyMissingAttributes();
         }
     });
 }
		public static void Postfix(Vector3 clickPos, Pawn pawn, List<FloatMenuOption> opts)
		{
			IntVec3 c = IntVec3.FromVector3(clickPos);
			if (pawn.equipment != null) {
				//First equipment already handled by patched Method, so skip
				var equipmentList = c.GetThingList(pawn.Map).Where(t => t.TryGetComp<CompEquippable>() != null).OfType<ThingWithComps>().Skip(1);

				//Log.Message(string.Format("Adding {0:d} equipment orders", equipmentList.Count()));

				foreach (ThingWithComps equipment in equipmentList) {
					string labelShort = equipment.LabelShort;
					FloatMenuOption item3;
					if (equipment.def.IsWeapon && pawn.story.WorkTagIsDisabled(WorkTags.Violent)) {
						item3 = new FloatMenuOption("CannotEquip".Translate(new object[] {
							labelShort
						}) + " (" + "IsIncapableOfViolenceLower".Translate(new object[] {
							pawn.LabelShort
						}) + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
					}
					else if (!pawn.CanReach(equipment, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) {
						item3 = new FloatMenuOption("CannotEquip".Translate(new object[] {
							labelShort
						}) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
					}
					else if (!pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) {
						item3 = new FloatMenuOption("CannotEquip".Translate(new object[] {
							labelShort
						}) + " (" + "Incapable".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
					}
					else {
						string text3 = "Equip".Translate(new object[] {
							labelShort
						});
						if (equipment.def.IsRangedWeapon && pawn.story != null && pawn.story.traits.HasTrait(TraitDefOf.Brawler)) {
							text3 = text3 + " " + "EquipWarningBrawler".Translate();
						}
						item3 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(text3, delegate {
							equipment.SetForbidden(false, true);
							pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.Equip, equipment), JobTag.Misc);
							MoteMaker.MakeStaticMote(equipment.DrawPos, equipment.Map, ThingDefOf.Mote_FeedbackEquip, 1f);
							PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.EquippingWeapons, KnowledgeAmount.Total);
						}, MenuOptionPriority.High, null, null, 0f, null, null), pawn, equipment, "ReservedBy");
					}
					opts.Add(item3);
				}
			}
			if (pawn.apparel != null) {
				//First apparel already handled by patched method, so skip
				var apparelList = c.GetThingList(pawn.Map).OfType<Apparel>().Skip(1);

				//Log.Message(string.Format("Adding {0:d} apparel orders", apparelList.Count()));

				foreach (Apparel apparel in apparelList) {
					FloatMenuOption item4;
					if (!pawn.CanReach(apparel, PathEndMode.ClosestTouch, Danger.Deadly, false, TraverseMode.ByPawn)) {
						item4 = new FloatMenuOption("CannotWear".Translate(new object[] {
							apparel.Label
						}) + " (" + "NoPath".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
					}
					else if (!ApparelUtility.HasPartsToWear(pawn, apparel.def)) {
						item4 = new FloatMenuOption("CannotWear".Translate(new object[] {
							apparel.Label
						}) + " (" + "CannotWearBecauseOfMissingBodyParts".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null);
					}
					else {
						item4 = FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("ForceWear".Translate(new object[] {
							apparel.LabelShort
						}), delegate {
							apparel.SetForbidden(false, true);
							Job job = new Job(JobDefOf.Wear, apparel);
							pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
						}, MenuOptionPriority.High, null, null, 0f, null, null), pawn, apparel, "ReservedBy");
					}
					opts.Add(item4);
				}
			}
            AddReservationActionsIfOnlySingleItem(c, pawn.MapHeld, opts);
		}
        public override void Notify_PawnDied()
        {
            IntVec3 spawnLoc = !base.Pawn.Dead ? base.parent.pawn.Position : base.parent.pawn.PositionHeld;
            Map     spawnMap = !base.Pawn.Dead ? base.parent.pawn.Map : base.parent.pawn.MapHeld;

            this.Pawn.def.race.deathActionWorkerClass = typeof(DeathActionWorker_Simple);
            bool fullterm = this.parent.CurStageIndex >= this.parent.def.stages.Count - 3;

            if (!fullterm)
            {
                //    Log.Message(string.Format("died  before reaching fullterm, no spawning"));
                return;
            }
            else
            {
                if (spawnMap == null || spawnLoc == null)
                {
                    //    Log.Message(string.Format("spawnMap or spawnLoc is null, no spawning"));
                    return;
                }
                else
                {
                    for (int i = 0; i < countToSpawn; i++)
                    {
                        Pawn pawn = NeomorphSpawnRequest();
                        //    Log.Message(string.Format("Xenomorph to hatch: {0}", pawn.LabelShortCap));
                        pawn.ageTracker.CurKindLifeStage.bodyGraphicData.colorTwo = HostBloodColour;
                        pawn.Notify_ColorChanged();
                        pawn.ageTracker.AgeBiologicalTicks    = 0;
                        pawn.ageTracker.AgeChronologicalTicks = 0;
                        pawn.needs.food.CurLevel = 0;
                        Comp_Xenomorph _Xenomorph = pawn.TryGetComp <Comp_Xenomorph>();
                        if (_Xenomorph != null)
                        {
                            _Xenomorph.host = base.parent.pawn.kindDef;
                        }
                        GenSpawn.Spawn(pawn, spawnLoc, spawnMap, 0);
                    }
                    Vector3 vector = spawnLoc.ToVector3Shifted();
                    for (int i = 0; i < 101; i++)
                    {
                        if (Rand.MTBEventOccurs(DustMoteSpawnMTB, 2f, 3.TicksToSeconds()))
                        {
                            MoteMaker.ThrowDustPuffThick(new Vector3(vector.x, 0f, vector.z)
                            {
                                y = AltitudeLayer.MoteOverhead.AltitudeFor()
                            }, spawnMap, 1.5f, new Color(HostBloodColour.r, HostBloodColour.g, HostBloodColour.b, HostBloodColour.a));
                        }
                        if (i == 100)
                        {
                        }
                        if (i % 10 == 0)
                        {
                            FilthMaker.TryMakeFilth(spawnLoc + GenAdj.AdjacentCellsAndInside.RandomElement(), this.Pawn.MapHeld, this.Pawn.RaceProps.BloodDef, this.Pawn.LabelIndefinite(), 1);
                        }
                    }
                    ThingDef motedef = DefDatabase <ThingDef> .GetNamedSilentFail("Mote_BlastExtinguisher");

                    MoteMaker.ThrowExplosionCell(spawnLoc, MyMap, motedef, HostBloodColour);
                    // GenAdj.AdjacentCellsAndInside[i];
                    for (int i2 = 0; i2 < GenAdj.AdjacentCellsAndInside.Length; i2++)
                    {
                        FilthMaker.TryMakeFilth(spawnLoc + GenAdj.AdjacentCellsAndInside[i2], this.Pawn.MapHeld, this.Pawn.RaceProps.BloodDef, this.Pawn.LabelIndefinite(), 1);
                    }
                    string text = TranslatorFormattedStringExtensions.Translate("Xeno_Chestburster_Emerge", base.parent.pawn.LabelShort, this.parent.Part.LabelShort);
                    MoteMaker.ThrowText(spawnLoc.ToVector3(), spawnMap, text, 5f);
                    if (!PlayerKnowledgeDatabase.IsComplete(XenomorphConceptDefOf.RRY_Concept_Chestbursters) && MyMap != null)
                    {
                        LessonAutoActivator.TeachOpportunity(XenomorphConceptDefOf.RRY_Concept_Chestbursters, OpportunityType.Important);
                    }
                    Pawn.health.AddHediff(DefDatabase <HediffDef> .GetNamedSilentFail("RRY_PostBurstWound"), this.parent.Part);
                    Pawn.health.RemoveHediff(this.parent);
                }
            }
        }
예제 #24
0
        public string GetTextReadout()
        {
            StringBuilder stringBuilder = new StringBuilder();

            if (visibilityShift > 0)
            {
                stringBuilder.AppendLine("   " + "CE_VisibilityError".Translate() + "\t" + GenText.ToStringByStyle(visibilityShift, ToStringStyle.FloatTwo) + " c");

                if (lightingShift > 0)
                {
                    stringBuilder.AppendLine("      " + "Darkness".Translate() + "\t" + AsPercent(lightingShift));
                }
                if (weatherShift > 0)
                {
                    stringBuilder.AppendLine("      " + "Weather".Translate() + "\t" + AsPercent(weatherShift));
                }
                if (smokeDensity > 0)
                {
                    stringBuilder.AppendLine("      " + "CE_SmokeDensity".Translate() + "\t" + AsPercent(smokeDensity));
                }
            }
            if (leadShift > 0)
            {
                stringBuilder.AppendLine("   " + "CE_LeadError".Translate() + "\t" + GenText.ToStringByStyle(leadShift, ToStringStyle.FloatTwo) + " c");
            }
            if (distShift > 0)
            {
                stringBuilder.AppendLine("   " + "CE_RangeError".Translate() + "\t" + GenText.ToStringByStyle(distShift, ToStringStyle.FloatTwo) + " c");
            }
            if (swayDegrees > 0)
            {
                stringBuilder.AppendLine("   " + "CE_Sway".Translate() + "\t\t" + GenText.ToStringByStyle(swayDegrees, ToStringStyle.FloatTwo) + "°");
            }
            if (spreadDegrees > 0)
            {
                stringBuilder.AppendLine("   " + "CE_Spread".Translate() + "\t\t" + GenText.ToStringByStyle(spreadDegrees, ToStringStyle.FloatTwo) + "°");
            }
            // Don't display cover and target size if our weapon has a CEP
            if (circularMissRadius > 0)
            {
                stringBuilder.AppendLine("   " + "CE_MissRadius".Translate() + "\t" + GenText.ToStringByStyle(circularMissRadius, ToStringStyle.FloatTwo) + " c");
                if (indirectFireShift > 0)
                {
                    stringBuilder.AppendLine("   " + "CE_IndirectFire".Translate() + "\t" + GenText.ToStringByStyle(indirectFireShift, ToStringStyle.FloatTwo) + " c");
                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(CE_ConceptDefOf.CE_MortarDirectFire, KnowledgeAmount.FrameDisplayed); // Show we learned about indirect fire penalties
                }
            }
            else
            {
                if (cover != null)
                {
                    stringBuilder.AppendLine("   " + "CE_CoverHeight".Translate() + "\t" + new CollisionVertical(cover).Max + " c");
                }
                if (target.Thing != null)
                {
                    stringBuilder.AppendLine("   " + "CE_TargetHeight".Translate() + "\t" + GenText.ToStringByStyle(new CollisionVertical(target.Thing).HeightRange.Span, ToStringStyle.FloatTwo) + " c");
                    stringBuilder.AppendLine("   " + "CE_TargetWidth".Translate() + "\t" + GenText.ToStringByStyle(CE_Utility.GetCollisionWidth(target.Thing) * 2, ToStringStyle.FloatTwo) + " c");
                }
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(CE_ConceptDefOf.CE_AimingSystem, KnowledgeAmount.FrameDisplayed); // Show we learned about the aiming system
            }
            return(stringBuilder.ToString());
        }
예제 #25
0
        protected override void FillTab()
        {
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.BillsTab, KnowledgeAmount.FrameDisplayed);
            Rect rect = new Rect(ITab_Bills2.WinSize.x - ITab_Bills2.PasteX, ITab_Bills2.PasteY, ITab_Bills2.PasteSize, ITab_Bills2.PasteSize);

            if (BillUtility.Clipboard == null)
            {
                GUI.color = Color.gray;
                Widgets.DrawTextureFitted(rect, TexButton.Paste, 1f);
                GUI.color = Color.white;
                TooltipHandler.TipRegionByKey(rect, "PasteBillTip");
            }
            else if (!this.SelTable.def.AllRecipes.Contains(BillUtility.Clipboard.recipe) || !BillUtility.Clipboard.recipe.AvailableNow)
            {
                GUI.color = Color.gray;
                Widgets.DrawTextureFitted(rect, TexButton.Paste, 1f);
                GUI.color = Color.white;
                TooltipHandler.TipRegionByKey(rect, "ClipboardBillNotAvailableHere");
            }
            else if (this.SelTable.billStack.Count >= 15)
            {
                GUI.color = Color.gray;
                Widgets.DrawTextureFitted(rect, TexButton.Paste, 1f);
                GUI.color = Color.white;
                if (Mouse.IsOver(rect))
                {
                    TooltipHandler.TipRegion(rect, "PasteBillTip".Translate() + " (" + "PasteBillTip_LimitReached".Translate() + ")");
                }
            }
            else
            {
                if (Widgets.ButtonImageFitted(rect, TexButton.Paste, Color.white))
                {
                    Bill bill = BillUtility.Clipboard.Clone();
                    bill.InitializeAfterClone();
                    this.SelTable.billStack.AddBill(bill);
                    SoundDefOf.Tick_Low.PlayOneShotOnCamera(null);
                }
                TooltipHandler.TipRegionByKey(rect, "PasteBillTip");
            }
            Rect rect2 = new Rect(0f, 0f, ITab_Bills2.WinSize.x, ITab_Bills2.WinSize.y).ContractedBy(10f);
            Func <List <FloatMenuOption> > recipeOptionsMaker = delegate
            {
                List <FloatMenuOption> list = new List <FloatMenuOption>();
                foreach (var recipe in this.SelTable.AllRecipes)
                {
                    if (recipe.AvailableNow)
                    {
                        bool deletable = this.SelTable.IsRemovable(recipe);

                        list.Add(new FloatMenuOption(recipe.LabelCap, delegate
                        {
                            if (!this.SelTable.Map.mapPawns.FreeColonists.Any((Pawn col) => recipe.PawnSatisfiesSkillRequirements(col)))
                            {
                                Bill.CreateNoPawnsWithSkillDialog(recipe);
                            }
                            Bill bill2 = this.SelTable.MakeNewBill(recipe);
                            this.SelTable.billStack.AddBill(bill2);
                            if (recipe.conceptLearned != null)
                            {
                                PlayerKnowledgeDatabase.KnowledgeDemonstrated(recipe.conceptLearned, KnowledgeAmount.Total);
                            }
                            if (TutorSystem.TutorialMode)
                            {
                                TutorSystem.Notify_Event("AddBill-" + recipe.LabelCap.Resolve());
                            }
                        }, MenuOptionPriority.Default, null, null, deletable ? 58f : 29f, (Rect r) =>
                        {
                            if (deletable)
                            {
                                if (Widgets.ButtonImage(new Rect(r.x + 34f, r.y + (r.height - 24f), 24f, 24f), RS.DeleteX))
                                {
                                    this.SelTable.RemoveRecipe(recipe);
                                    return(true);
                                }
                            }
                            return(Widgets.InfoCardButton(r.x + 5f, r.y + (r.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);
            };

            this.mouseoverBill = this.SelTable.billStack.DoListing(rect2, recipeOptionsMaker, ref this.scrollPosition, ref this.viewHeight);
        }
        public static bool DoTimeControlsGUI(Rect timerRect)
        {
            TickManager tickManager = Find.TickManager;

            GUI.BeginGroup(timerRect);
            Rect rect = new Rect(0.0f, 0.0f, TimeControls.TimeButSize.x, TimeControls.TimeButSize.y);

            for (int index = 0; index < TimeControls.CachedTimeSpeedValues.Length; ++index)
            {
                TimeSpeed timeSpeed = TimeControls.CachedTimeSpeedValues[index];
                if (timeSpeed != TimeSpeed.Ultrafast)
                {
                    if (Widgets.ButtonImage(rect, TexButton.SpeedButtonTextures[(int)timeSpeed]))
                    {
                        if (timeSpeed == TimeSpeed.Paused)
                        {
                            tickManager.TogglePaused();
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Pause, KnowledgeAmount.SpecificInteraction);
                        }
                        else
                        {
                            tickManager.CurTimeSpeed = timeSpeed;
                            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction);
                        }
                        TimeControls.PlaySoundOf(tickManager.CurTimeSpeed);
                    }
                    if (tickManager.CurTimeSpeed == timeSpeed)
                    {
                        GUI.DrawTexture(rect, (Texture)TexUI.HighlightTex);
                    }
                    rect.x += rect.width;
                }
            }
            if (Find.TickManager.slower.ForcedNormalSpeed)
            {
                Widgets.DrawLineHorizontal(rect.width * 2f, rect.height / 2f, rect.width * 2f);
            }
            GUI.EndGroup();
            GenUI.AbsorbClicksInRect(timerRect);
            UIHighlighter.HighlightOpportunity(timerRect, "TimeControls");
            if (Event.current.type != EventType.KeyDown)
            {
                return(false);
            }
            if (KeyBindingDefOf.TogglePause.KeyDownEvent)
            {
                Find.TickManager.TogglePaused();
                TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed);
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.Pause, KnowledgeAmount.SpecificInteraction);
                Event.current.Use();
            }
            if (KeyBindingDefOf.TimeSpeedNormal.KeyDownEvent)
            {
                Find.TickManager.CurTimeSpeed = TimeSpeed.Normal;
                TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed);
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction);
                Event.current.Use();
            }
            if (KeyBindingDefOf.TimeSpeedFast.KeyDownEvent)
            {
                Find.TickManager.CurTimeSpeed = TimeSpeed.Fast;
                TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed);
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction);
                Event.current.Use();
            }
            if (KeyBindingDefOf.TimeSpeedSuperfast.KeyDownEvent)
            {
                Find.TickManager.CurTimeSpeed = TimeSpeed.Superfast;
                TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed);
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.TimeControls, KnowledgeAmount.SpecificInteraction);
                Event.current.Use();
            }

            //Removed to Allow Speed 4 Without Dev Mode.
            //if (!Prefs.DevMode)
            //    return false;
            if (KeyBindingDefOf.TimeSpeedUltrafast.KeyDownEvent)
            {
                Find.TickManager.CurTimeSpeed = TimeSpeed.Ultrafast;
                TimeControls.PlaySoundOf(Find.TickManager.CurTimeSpeed);
                Event.current.Use();
            }
            if (!KeyBindingDefOf.TickOnce.KeyDownEvent || tickManager.CurTimeSpeed != TimeSpeed.Paused)
            {
                return(false);
            }
            tickManager.DoSingleTick();
            SoundStarter.PlayOneShotOnCamera(SoundDef.Named(TimeControls.SpeedSounds[0]), (Map)null);

            return(false);
        }
예제 #27
0
        public static void DrawWorkBoxFor(float x, float y, WorkTypeDef wType, ColonistGroup group)
        {
            Rect rect = new Rect(x, y, 25f, 25f);

            GUI.color = Color.white;
            DrawWorkBoxBackground(rect, wType);
            if (Find.PlaySettings.useWorkPriorities)
            {
                int priority = GetAllCommonWorkPriority(group, wType);
                if (priority > 0)
                {
                    Text.Anchor = TextAnchor.MiddleCenter;
                    GUI.color   = ColorOfPriority(priority);
                    Widgets.Label(rect.ContractedBy(-3f), priority.ToStringCached());
                    GUI.color   = Color.white;
                    Text.Anchor = TextAnchor.UpperLeft;
                }
                if (Event.current.type != 0 || !Mouse.IsOver(rect))
                {
                    return;
                }
                if (Event.current.button == 0)
                {
                    int num2 = GetAllCommonWorkPriority(group, wType) - 1;
                    if (num2 < 0)
                    {
                        num2 = 4;
                    }

                    group.SetGroupWorkPriorityFor(wType, num2);

                    if (ModCompatibility.BetterPawnControlIsActive)
                    {
                        ModCompatibility.workManagerSaveCurrentStateMethod.Invoke(null, new object[] { group.pawns });
                    }
                    SoundDefOf.DragSlider.PlayOneShotOnCamera();
                }
                if (Event.current.button == 1)
                {
                    int num3 = GetAllCommonWorkPriority(group, wType) + 1;
                    if (num3 > 4)
                    {
                        num3 = 0;
                    }

                    group.SetGroupWorkPriorityFor(wType, num3);

                    if (ModCompatibility.BetterPawnControlIsActive)
                    {
                        ModCompatibility.workManagerSaveCurrentStateMethod.Invoke(null, new object[] { group.pawns });
                    }
                    SoundDefOf.DragSlider.PlayOneShotOnCamera();
                }
                Event.current.Use();
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorkTab, KnowledgeAmount.SpecificInteraction);
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.ManualWorkPriorities, KnowledgeAmount.SmallInteraction);
                return;
            }

            if (IsCommonEnabledWork(group, wType))
            {
                GUI.DrawTexture(rect, WorkBoxCheckTex);
            }
            if (!Widgets.ButtonInvisible(rect))
            {
                return;
            }
            if (IsCommonEnabledWork(group, wType))
            {
                group.SetGroupWorkPriorityFor(wType, 0);

                if (ModCompatibility.BetterPawnControlIsActive)
                {
                    ModCompatibility.workManagerSaveCurrentStateMethod.Invoke(null, new object[] { group.pawns });
                }
                SoundDefOf.Checkbox_TurnedOff.PlayOneShotOnCamera();
            }
            else
            {
                group.SetGroupWorkPriorityFor(wType, 3);

                if (ModCompatibility.BetterPawnControlIsActive)
                {
                    ModCompatibility.workManagerSaveCurrentStateMethod.Invoke(null, new object[] { group.pawns });
                }
                SoundDefOf.Checkbox_TurnedOn.PlayOneShotOnCamera();
            }
            PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.WorkTab, KnowledgeAmount.SpecificInteraction);
        }
예제 #28
0
        private static bool Method_Prefix_2(ref FloatMenuOption __result, Pawn pawn, Thing thingForMedBills, RecipeDef recipe, IEnumerable <ThingDef> missingIngredients, BodyPartRecord part = null)
        {
            //Traverse ThingDef_Traverse = Traverse.Create<ThingDef>();

            if (pawn.Dead)
            {
                //Log.Message("Own Generating SurgeryOptions");
                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
                    {
                        //Log.Message("Delegate action");
                        Corpse pawn2 = thingForMedBills as Corpse;
                        if (pawn2 != null)
                        {
                            Bill_Medical bill_Medical = new Bill_Medical(recipe);
                            //Log.Message("adding bill_Medical to billstack " + bill_Medical.ToString());
                            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.InnerPawn.InBed() && pawn2.InnerPawn.RaceProps.IsFlesh)
                            {
                                //if (pawn2.InnerPawn.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.InnerPawn, part, Faction.OfPlayer))
                            {
                                Messages.Message("MessageMedicalOperationWillAngerFaction".Translate(pawn2.Faction), pawn2, MessageTypeDefOf.CautionInput);
                            }
                            //Log.Message("Log10");
                            ThingDef minRequiredMedicine = (ThingDef)AccessTools.Method(typeof(HealthCardUtility), "GetMinRequiredMedicine", new Type[] { typeof(RecipeDef) }).Invoke(null, new object[] { recipe }); //(rect, pawn, thingForMedBills, curY);
                            //Log.Message("Log11");
                            if (minRequiredMedicine != null && pawn2.InnerPawn.playerSettings != null && !pawn2.InnerPawn.playerSettings.medCare.AllowsMedicine(minRequiredMedicine))
                            {
                                Messages.Message("MessageTooLowMedCare".Translate(minRequiredMedicine.label, pawn2.LabelShort, pawn2.InnerPawn.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(rect.x + 5f, rect.y + (rect.height - 24f) / 2f, recipe));
                __result = floatMenuOption;


                return(false);
            }
            else
            {
                //Log.Message("Generating SurgeryOptions forwarding");
                return(true);
            }
        }
        private static void DrawInfoWindow()
        {
            Room room      = UI.MouseCell().GetRoom(Find.VisibleMap, RegionType.Set_All);
            bool roomValid = room != null && room.Role != RoomRoleDefOf.None;

            Text.Font = GameFont.Small;
            Vector2 mousePosition  = Event.current.mousePosition;
            float   x              = mousePosition.x;
            Vector2 mousePosition2 = Event.current.mousePosition;
            Rect    windowRect     = new Rect(x, mousePosition2.y, 416f, 36f);

            windowRect.height += 25f;
            if (roomValid)
            {
                windowRect.height += 13f;
                windowRect.height += 23f;
                windowRect.height += (float)((float)EnvironmentInspectDrawer.DisplayedRoomStatsCount * 25.0);
            }
            windowRect.x += 26f;
            windowRect.y += 26f;
            if (windowRect.xMax > (float)UI.screenWidth)
            {
                windowRect.x -= (float)(windowRect.width + 52.0);
            }
            if (windowRect.yMax > (float)UI.screenHeight)
            {
                windowRect.y -= (float)(windowRect.height + 52.0);
            }
            Find.WindowStack.ImmediateWindow(74975, windowRect, WindowLayer.Super, delegate
            {
                PlayerKnowledgeDatabase.KnowledgeDemonstrated(ConceptDefOf.InspectRoomStats, KnowledgeAmount.FrameDisplayed);
                Text.Font    = GameFont.Small;
                float num    = 18f;
                float beauty = BeautyUtility.AverageBeautyPerceptible(UI.MouseCell(), Find.VisibleMap);
                Rect rect    = new Rect(18f, num, (float)(windowRect.width - 36.0), 100f);
                GUI.color    = BeautyDrawer.BeautyColor(beauty, 40f);
                Widgets.Label(rect, "BeautyHere".Translate() + ": " + beauty.ToString("F1"));
                num = (float)(num + 25.0);
                if (roomValid)
                {
                    num       = (float)(num + 5.0);
                    GUI.color = new Color(1f, 1f, 1f, 0.4f);
                    Widgets.DrawLineHorizontal(18f, num, (float)(windowRect.width - 36.0));
                    GUI.color  = Color.white;
                    num        = (float)(num + 8.0);
                    Rect rect2 = new Rect(18f, num, (float)(windowRect.width - 36.0), 100f);
                    GUI.color  = Color.white;
                    Widgets.Label(rect2, EnvironmentInspectDrawer.GetRoomRoleLabel(room));
                    num           = (float)(num + 25.0);
                    Text.WordWrap = false;
                    for (int i = 0; i < DefDatabase <RoomStatDef> .AllDefsListForReading.Count; i++)
                    {
                        RoomStatDef roomStatDef = DefDatabase <RoomStatDef> .AllDefsListForReading[i];
                        if (!roomStatDef.isHidden || DebugViewSettings.showAllRoomStats)
                        {
                            float stat = room.GetStat(roomStatDef);
                            RoomStatScoreStage scoreStage = roomStatDef.GetScoreStage(stat);
                            if (room.Role.IsStatRelated(roomStatDef))
                            {
                                GUI.color = EnvironmentInspectDrawer.RelatedStatColor;
                            }
                            else
                            {
                                GUI.color = Color.gray;
                            }
                            Rect rect3 = new Rect(rect2.x, num, 100f, 23f);
                            Widgets.Label(rect3, roomStatDef.LabelCap);
                            Rect rect4   = new Rect((float)(rect3.xMax + 35.0), num, 50f, 23f);
                            string label = roomStatDef.ScoreToString(stat);
                            Widgets.Label(rect4, label);
                            Rect rect5 = new Rect((float)(rect4.xMax + 35.0), num, 160f, 23f);
                            Widgets.Label(rect5, (scoreStage != null) ? scoreStage.label : string.Empty);
                            num = (float)(num + 25.0);
                        }
                    }
                    Text.WordWrap = true;
                }
                GUI.color = Color.white;
            }, true, false, 1f);
        }
        static void AddMenuItems(Vector3 clickPos, Pawn pawn, List <FloatMenuOption> opts)
        {
            // Stabilize
            if (pawn.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation))
            {
#pragma warning disable CS0618                                                                                              // You're supposed to migrate to GenUI.TargetsAt_NewTemp? But that scares me.
                foreach (LocalTargetInfo curTarget in GenUI.TargetsAt(clickPos, TargetingParameters.ForRescue(pawn), true)) // !! This needs to be patched into A17
#pragma warning restore CS0618
                {
                    Pawn patient = (Pawn)curTarget.Thing;
                    if (patient.Downed
                        //&& pawn.CanReserveAndReach(patient, PathEndMode.InteractionCell, Danger.Deadly)
                        && pawn.CanReach(patient, PathEndMode.InteractionCell, Danger.Deadly) &&
                        patient.health.hediffSet.GetHediffsTendable().Any(h => h.CanBeStabilized()))
                    {
                        if (pawn.WorkTypeIsDisabled(WorkTypeDefOf.Doctor))
                        {
                            opts.Add(new FloatMenuOption("CE_CannotStabilize".Translate() + ": " + "IncapableOfCapacity".Translate(WorkTypeDefOf.Doctor.gerundLabel), null, MenuOptionPriority.Default));
                        }
                        else
                        {
                            string label  = "CE_Stabilize".Translate(patient.LabelCap);
                            Action action = delegate
                            {
                                if (pawn.inventory == null || pawn.inventory.innerContainer == null || !pawn.inventory.innerContainer.Any(t => t.def.IsMedicine))
                                {
                                    Messages.Message("CE_CannotStabilize".Translate() + ": " + "CE_NoMedicine".Translate(pawn), patient, MessageTypeDefOf.RejectInput);
                                    return;
                                }
                                // Drop medicine from inventory
                                Medicine medicine = (Medicine)pawn.inventory.innerContainer.OrderByDescending(t => t.GetStatValue(StatDefOf.MedicalPotency)).FirstOrDefault();
                                Thing    medThing;
                                if (medicine != null && pawn.inventory.innerContainer.TryDrop(medicine, pawn.Position, pawn.Map, ThingPlaceMode.Direct, 1, out medThing))
                                {
                                    Job job = JobMaker.MakeJob(CE_JobDefOf.Stabilize, patient, medThing);
                                    job.count = 1;
                                    pawn.jobs.TryTakeOrderedJob(job);
                                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(CE_ConceptDefOf.CE_Stabilizing, KnowledgeAmount.Total);
                                }
                            };
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(label, action, MenuOptionPriority.Default, null, patient), pawn, patient, "ReservedBy"));
                        }
                    }
                }
            }

            // Item pickup.
            IntVec3       c             = IntVec3.FromVector3(clickPos);
            CompInventory compInventory = pawn.TryGetComp <CompInventory>();
            if (compInventory != null)
            {
                List <Thing> thingList = c.GetThingList(pawn.Map);
                foreach (Thing item in thingList)
                {
                    if (item != null && item.def.alwaysHaulable && !(item is Corpse))
                    {
                        //FloatMenuOption pickUpOption;
                        int count = 0;
                        if (!pawn.CanReach(item, PathEndMode.Touch, Danger.Deadly))
                        {
                            opts.Add(new FloatMenuOption("CannotPickUp".Translate() + " " + item.LabelShort + " (" + "NoPath".Translate() + ")", null));
                        }
                        else if (!compInventory.CanFitInInventory(item, out count))
                        {
                            opts.Add(new FloatMenuOption("CannotPickUp".Translate(item.LabelShort, item) + " (" + "CE_InventoryFull".Translate() + ")", null));
                        }
                        // Pick up x
                        else if (count == 1)
                        {
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUp".Translate(item.Label, item), delegate
                            {
                                item.SetForbidden(false, false);
                                Job job   = JobMaker.MakeJob(JobDefOf.TakeInventory, item);
                                job.count = 1;
                                pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
                                pawn.Notify_HoldTrackerJob(job);
                                PlayerKnowledgeDatabase.KnowledgeDemonstrated(CE_ConceptDefOf.CE_InventoryWeightBulk, KnowledgeAmount.SpecificInteraction);
                            }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy"));
                        }
                        else
                        {
                            if (count < item.stackCount)
                            {
                                opts.Add(new FloatMenuOption("CannotPickUpAll".Translate(item.Label, item) + " (" + "CE_InventoryFull".Translate() + ")", null, MenuOptionPriority.Default, null, null, 0f, null, null));
                            }
                            else
                            {
                                opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUpAll".Translate(item.Label, item), delegate
                                {
                                    item.SetForbidden(false, false);
                                    Job job   = JobMaker.MakeJob(JobDefOf.TakeInventory, item);
                                    job.count = item.stackCount;
                                    pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
                                    pawn.Notify_HoldTrackerJob(job);
                                    PlayerKnowledgeDatabase.KnowledgeDemonstrated(CE_ConceptDefOf.CE_InventoryWeightBulk, KnowledgeAmount.SpecificInteraction);
                                }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy"));
                            }
                            opts.Add(FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption("PickUpSome".Translate(item.Label, item), delegate
                            {
                                int to = Mathf.Min(count, item.stackCount);
                                Dialog_Slider window = new Dialog_Slider("PickUpCount".Translate(item.LabelShort, item), 1, to, delegate(int selectCount)
                                {
                                    item.SetForbidden(false, false);
                                    Job job   = JobMaker.MakeJob(JobDefOf.TakeInventory, item);
                                    job.count = selectCount;
                                    pawn.jobs.TryTakeOrderedJob(job, JobTag.Misc);
                                    pawn.Notify_HoldTrackerJob(job);
                                }, -2147483648);
                                Find.WindowStack.Add(window);
                                PlayerKnowledgeDatabase.KnowledgeDemonstrated(CE_ConceptDefOf.CE_InventoryWeightBulk, KnowledgeAmount.SpecificInteraction);
                            }, MenuOptionPriority.High, null, null, 0f, null, null), pawn, item, "ReservedBy"));
                        }
                    }
                }
            }
        }