Ejemplo n.º 1
0
            static void DrawInventoryPrefix(object __instance, ref Rect viewRect, ref float num, bool inventory = false)
            {
                if (!inventory)
                {
                    return;
                }
                //
                Pawn pawn = (Pawn)LSelPawnForGear.GetValue(__instance);
                bool flag;
                var  loadout = pawn.getLoadout();

                if (pawn.IsColonist && (loadout == null || CEAccess.loadoutIsEmpty(loadout)))
                {
                    if (!pawn.inventory.innerContainer.Any <Thing>())
                    {
                        Pawn_EquipmentTracker equipment = pawn.equipment;
                        flag = (((equipment != null) ? equipment.Primary : null) != null);
                    }
                    else
                    {
                        flag = true;
                    }
                }
                else
                {
                    flag = false;
                }
                //
                if (!flag)
                {
                    return;
                }

                //num += 3f;
                Rect       rect   = new Rect(viewRect.width / 2f, num, viewRect.width / 2f, 26f);
                Color      color  = GUI.color;
                TextAnchor anchor = Text.Anchor;

                GUI.color = Color.cyan;
                if (Mouse.IsOver(rect))
                {
                    GUI.color = Color.white;
                }
                Text.Anchor = TextAnchor.UpperRight;
                Widgets.Label(rect, "CE_MakeLoadout".Translate());
                if (Widgets.ButtonInvisible(rect.ContractedBy(2f), true))
                {
                    loadout = pawn.generateLoadoutFromPawn();
                    CEAccess.addLoadoutToManager(loadout);
                    pawn.setLoadout(loadout);
                    Find.WindowStack.Add(CEAccess.dialogManageLoadouts(pawn));
                }
                Text.Anchor = anchor;
                GUI.color   = color;

                num += 3f;
            }
Ejemplo n.º 2
0
            static void TryDrawMassInfo1(object tab, ref float top, float left, float width)
            {
                Pawn pawn = (Pawn)LSelPawnForGear.GetValue(tab);

                if (pawn.Dead || !(bool)LShouldShowInventory.Invoke(tab, new object[] { pawn }))
                {
                    return;
                }
                //
                float val1;
                float val2;

                var comp = pawn.getCompInventory();

                if (comp == null)
                {
                    return;
                }

                CEAccess.getCurrentAndCapacityWeight(comp, out val1, out val2);
                //
                float statIconSize      = (float)LstatIconSize.GetValue(null);
                float stdThingIconSize  = (float)LstdThingIconSize.GetValue(null);
                float stdThingRowHeight = (float)LstdThingRowHeight.GetValue(null);
                //weight
                Rect rect1 = new Rect(left, top, statIconSize, statIconSize);

                GUI.DrawTexture(rect1, Sandy_Utility.texMass);
                TooltipHandler.TipRegion(rect1, "CE_Weight".Translate());
                string str   = val1.ToString("0.#");
                string str2  = CEAccess.formatWeight(val2);
                Rect   rect2 = new Rect(left + stdThingIconSize, top + (stdThingRowHeight - statIconSize) / 2f, width - stdThingIconSize, statIconSize);

                CEAccess.drawBar(rect2, val1, val2, "", pawn.getWeightTip());
                rect2.xMin += 4f;
                rect2.yMin += 2f;
                Widgets.Label(rect2, str + '/' + str2);
                top += stdThingRowHeight;
                //bulk
                rect1 = new Rect(left, top, statIconSize, statIconSize);
                GUI.DrawTexture(rect1, texBulk);
                TooltipHandler.TipRegion(rect1, "CE_Bulk".Translate());
                CEAccess.getCurrentAndCapacityBulk(comp, out val1, out val2);
                str   = CEAccess.formatBulk(val1);
                str2  = CEAccess.formatBulk(val2);
                rect2 = new Rect(left + stdThingIconSize, top + (stdThingRowHeight - statIconSize) / 2f, width - stdThingIconSize, statIconSize);
                CEAccess.drawBar(rect2, val1, val2, "", pawn.getBulkTip());
                rect2.xMin += 4f;
                rect2.yMin += 2f;
                Widgets.Label(rect2, str + '/' + str2);
                top += stdThingRowHeight;
            }
Ejemplo n.º 3
0
            static Rect FillTab_DrawBars(Rect position, object tab)
            {
                bool viewList = (bool)LviewList.GetValue(tab);

                if (!viewList)
                {
                    return(position);
                }
                Pawn pawn = (Pawn)LSelPawn.GetValue(tab);
                var  comp = pawn.getCompInventory();

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

                PlayerKnowledgeDatabase.KnowledgeDemonstrated(CEAccess.getConcept_InventoryWeightBulk(), KnowledgeAmount.FrameDisplayed);
                position.height -= 55f;
                Rect rect  = new Rect(15f, position.yMax + 7.5f, position.width - 10f, 20f);
                Rect rect2 = new Rect(15f, rect.yMax + 7.5f, position.width - 10f, 20f);

                float curB;
                float capB;

                CEAccess.getCurrentAndCapacityBulk(comp, out curB, out capB);
                CEAccess.drawBar(rect2, curB, capB, "CE_Bulk".Translate(), pawn.getBulkTip());
                float curW;
                float capW;

                CEAccess.getCurrentAndCapacityWeight(comp, out curW, out capW);
                CEAccess.drawBar(rect, curW, capW, "CE_Weight".Translate(), pawn.getWeightTip());
                Text.Font   = GameFont.Small;
                Text.Anchor = TextAnchor.MiddleCenter;
                string str  = CEAccess.formatBulk(curB);
                string str2 = CEAccess.formatBulk(capB);

                Widgets.Label(rect2, str + "/" + str2);
                string str3 = curW.ToString("0.#");
                string str4 = CEAccess.formatWeight(capW);

                Widgets.Label(rect, str3 + "/" + str4);
                Text.Anchor = TextAnchor.UpperLeft;
                return(position);
            }
Ejemplo n.º 4
0
            static void DropDownThingMenu(object tab, Thing thing)
            {
                Pawn SelPawnForGear         = (Pawn)LSelPawnForGear.GetValue(tab);
                Pawn SelPawn                = (Pawn)LSelPawn.GetValue(tab);
                bool canControl             = (bool)LCanControl.GetValue(tab);
                List <FloatMenuOption> list = new List <FloatMenuOption>();

                list.Add(new FloatMenuOption("ThingInfo".Translate(), delegate()
                {
                    Find.WindowStack.Add(new Dialog_InfoCard(thing));
                }, MenuOptionPriority.Default, null, null, 0f, null, null));
                //bool canControl = this.CanControl;
                if (canControl)
                {
                    ThingWithComps eq     = thing as ThingWithComps;
                    bool           flag10 = eq != null && eq.TryGetComp <CompEquippable>() != null;
                    if (flag10)
                    {
                        object         comp           = SelPawnForGear.getCompInventory();
                        CompBiocodable compBiocodable = eq.TryGetComp <CompBiocodable>();
                        bool           flag11         = comp != null;
                        if (flag11)
                        {
                            string          value  = GenLabel.ThingLabel(eq.def, eq.Stuff, 1);
                            bool            flag12 = compBiocodable != null && compBiocodable.Biocoded && compBiocodable.CodedPawn != SelPawnForGear;
                            FloatMenuOption item;
                            if (flag12)
                            {
                                item = new FloatMenuOption("CannotEquip".Translate(value) + ": " + "BiocodedCodedForSomeoneElse".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null);
                            }
                            else
                            {
                                bool flag13 = SelPawnForGear.IsQuestLodger() && !EquipmentUtility.QuestLodgerCanEquip(eq, SelPawnForGear);
                                if (flag13)
                                {
                                    TaggedString t = SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) ? "CE_CannotPutAway".Translate(value) : "CannotEquip".Translate(value);
                                    item = new FloatMenuOption(t + ": " + "CE_CannotChangeEquipment".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null);
                                }
                                else
                                {
                                    bool flag14 = SelPawnForGear.equipment.AllEquipmentListForReading.Contains(eq) && SelPawnForGear.inventory != null;
                                    if (flag14)
                                    {
                                        item = new FloatMenuOption("CE_PutAway".Translate(value), delegate()
                                        {
                                            SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.innerContainer);
                                        }, MenuOptionPriority.Default, null, null, 0f, null, null);
                                    }
                                    else
                                    {
                                        bool flag15 = !SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation);
                                        if (flag15)
                                        {
                                            item = new FloatMenuOption("CannotEquip".Translate(value), null, MenuOptionPriority.Default, null, null, 0f, null, null);
                                        }
                                        else
                                        {
                                            string text4  = "Equip".Translate(value);
                                            bool   flag16 = eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler);
                                            if (flag16)
                                            {
                                                text4 = text4 + " " + "EquipWarningBrawler".Translate();
                                            }
                                            item = new FloatMenuOption(text4, (SelPawnForGear.story != null && SelPawnForGear.WorkTagIsDisabled(WorkTags.Violent)) ? null : new Action(delegate()
                                            {
                                                CEAccess.trySwitchToWeapon(comp, eq);
                                            }), MenuOptionPriority.Default, null, null, 0f, null, null);
                                        }
                                    }
                                }
                            }
                            list.Add(item);
                        }
                    }
                    //Pawn selPawnForGear = SelPawnForGear;   //??
                    List <Apparel> list2;
                    if (SelPawnForGear == null)
                    {
                        list2 = null;
                    }
                    else
                    {
                        Pawn_ApparelTracker apparel2 = SelPawnForGear.apparel;
                        list2 = ((apparel2 != null) ? apparel2.WornApparel : null);
                    }
                    List <Apparel> list3 = list2;
                    using (List <Apparel> .Enumerator enumerator = list3.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            Apparel        apparel        = enumerator.Current;
                            CompReloadable compReloadable = apparel.TryGetComp <CompReloadable>();
                            bool           flag17         = compReloadable != null && compReloadable.AmmoDef == thing.def && compReloadable.NeedsReload(true);
                            if (flag17)
                            {
                                bool flag18 = !SelPawnForGear.Drafted;
                                if (flag18)
                                {
                                    FloatMenuOption item2 = new FloatMenuOption("CE_ReloadApparel".Translate(apparel.Label, thing.Label), delegate()
                                    {
                                        SelPawnForGear.jobs.TryTakeOrderedJob(JobMaker.MakeJob(JobDefOf.Reload, apparel, thing), JobTag.Misc);
                                    }, MenuOptionPriority.Default, null, null, 0f, null, null);
                                    list.Add(item2);
                                }
                            }
                        }
                    }
                    bool flag19 = canControl && thing.IngestibleNow && SelPawn.RaceProps.CanEverEat(thing);
                    if (flag19)
                    {
                        Action action = delegate()
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                            LInterfaceIngest.Invoke(tab, new object[] { thing });
                        };
                        string text5  = thing.def.ingestible.ingestCommandString.NullOrEmpty() ? (string)"ConsumeThing".Translate(thing.LabelShort, thing) : string.Format(thing.def.ingestible.ingestCommandString, thing.LabelShort);
                        bool   flag20 = SelPawnForGear.IsTeetotaler() && thing.def.IsNonMedicalDrug;
                        if (flag20)
                        {
                            List <FloatMenuOption> list4    = list;
                            string          str             = text5;
                            string          str2            = ": ";
                            TraitDegreeData traitDegreeData = (from x in TraitDefOf.DrugDesire.degreeDatas
                                                               where x.degree == -1
                                                               select x).First <TraitDegreeData>();
                            list4.Add(new FloatMenuOption(str + str2 + ((traitDegreeData != null) ? traitDegreeData.label : null), null, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                        else
                        {
                            list.Add(new FloatMenuOption(text5, action, MenuOptionPriority.Default, null, null, 0f, null, null));
                        }
                    }
                    bool flag21 = SelPawnForGear.isItemQuestLocked(eq);
                    if (flag21)
                    {
                        list.Add(new FloatMenuOption("CE_CannotDropThing".Translate() + ": " + "DropThingLocked".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null));
                        list.Add(new FloatMenuOption("CE_CannotDropThingHaul".Translate() + ": " + "DropThingLocked".Translate(), null, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                    else
                    {
                        list.Add(new FloatMenuOption("DropThing".Translate(), delegate()
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                            LInterfaceDrop.Invoke(tab, new object[] { thing });
                        }, MenuOptionPriority.Default, null, null, 0f, null, null));
                        list.Add(new FloatMenuOption("CE_DropThingHaul".Translate(), delegate()
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                            InterfaceDropHaul(SelPawnForGear, thing, SelPawn);
                        }, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                    bool flag22 = canControl && (bool)LHoldTrackerIsHeld.Invoke(null, new object[] { SelPawnForGear, thing }); //SelPawnForGear.HoldTrackerIsHeld(thing);
                    if (flag22)
                    {
                        Action action2 = delegate()
                        {
                            SoundDefOf.Tick_High.PlayOneShotOnCamera(null);
                            LHoldTrackerForget.Invoke(null, new object[] { SelPawnForGear, thing }); //SelPawnForGear.HoldTrackerForget(thing);
                        };
                        list.Add(new FloatMenuOption("CE_HoldTrackerForget".Translate(), action2, MenuOptionPriority.Default, null, null, 0f, null, null));
                    }
                }
                FloatMenu window = new FloatMenu(list, thing.LabelCap, false);

                Find.WindowStack.Add(window);
            }