public static void EquipRigthTool(Pawn pawn, StatDef def) { float num = -3.40282347E+38f; ThingWithComps thingWithComps = null; CompInventory compInventory = pawn.TryGetComp <CompInventory>(); using (IEnumerator <Thing> enumerator = compInventory.container.AsEnumerable <Thing>().GetEnumerator()) { while (enumerator.MoveNext()) { ThingWithComps thingWithComps2 = (ThingWithComps)enumerator.Current; if (thingWithComps2.def.equippedStatOffsets != null) { foreach (StatModifier current in thingWithComps2.def.equippedStatOffsets) { if (current.stat == def) { if (current.value > num) { num = current.value; thingWithComps = thingWithComps2; } } } } } } if (thingWithComps != null) { compInventory.TrySwitchToWeapon(thingWithComps); } }
private void DrawThingRow(ref float y, float width, Thing thing) { Rect rect = new Rect(0f, y, width, 28f); TooltipHandler.TipRegion(rect, thing.GetWeightAndBulkTip()); if (Mouse.IsOver(rect)) { GUI.color = _highlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (Widgets.ButtonInvisible(rect) && Event.current.button == 1) { List <FloatMenuOption> floatOptionList = new List <FloatMenuOption>(); floatOptionList.Add(new FloatMenuOption("ThingInfo".Translate(), delegate { Find.WindowStack.Add(new Dialog_InfoCard(thing)); }, MenuOptionPriority.Medium, null, null)); if (this.CanEdit) { // Equip option ThingWithComps eq = thing as ThingWithComps; if (eq != null && eq.TryGetComp <CompEquippable>() != null) { CompInventory compInventory = SelPawnForGear.TryGetComp <CompInventory>(); if (compInventory != null) { FloatMenuOption equipOption; string eqLabel = GenLabel.ThingLabel(eq.def, eq.Stuff, 1); if (SelPawnForGear.equipment.AllEquipment.Contains(eq) && SelPawnForGear.inventory != null) { equipOption = new FloatMenuOption("CR_PutAway".Translate(new object[] { eqLabel }), new Action(delegate { ThingWithComps oldEq; SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.container, out oldEq); })); } else if (!SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }), null); } else { string equipOptionLabel = "Equip".Translate(new object[] { eqLabel }); if (eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler)) { equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate(); } equipOption = new FloatMenuOption(equipOptionLabel, new Action(delegate { compInventory.TrySwitchToWeapon(eq); })); } floatOptionList.Add(equipOption); } } // Drop option Action action = null; Apparel ap = thing as Apparel; if (ap != null && SelPawnForGear.apparel.WornApparel.Contains(ap)) { Apparel unused; action = delegate { this.SelPawnForGear.apparel.TryDrop(ap, out unused, this.SelPawnForGear.Position, true); }; } else if (eq != null && this.SelPawnForGear.equipment.AllEquipment.Contains(eq)) { ThingWithComps unused; action = delegate { this.SelPawnForGear.equipment.TryDropEquipment(eq, out unused, this.SelPawnForGear.Position, true); }; } else if (!thing.def.destroyOnDrop) { Thing unused; action = delegate { this.SelPawnForGear.inventory.container.TryDrop(thing, this.SelPawnForGear.Position, ThingPlaceMode.Near, out unused); }; } floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), action, MenuOptionPriority.Medium, null, null)); } FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false); Find.WindowStack.Add(window); } if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null) { Widgets.ThingIcon(new Rect(4f, y, 28f, 28f), thing); } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = _thingLabelColor; Rect rect2 = new Rect(36f, y, width - 36f, 28f); string text = thing.LabelCap; if (thing is Apparel && this.SelPawnForGear.outfits != null && this.SelPawnForGear.outfits.forcedHandler.IsForced((Apparel)thing)) { text = text + ", " + "ApparelForcedLower".Translate(); } Widgets.Label(rect2, text); y += 28f; }
protected override Job TryGiveJob(Pawn pawn) { if (!pawn.RaceProps.Humanlike || (pawn.story != null && pawn.story.WorkTagIsDisabled(WorkTags.Violent))) { return(null); } if (pawn.Faction.IsPlayer && pawn.Drafted) { return(null); } /* * Log.Message(pawn.ToString() + " priority:" + (GetPriorityWork(pawn)).ToString()); * Log.Message(pawn.ToString() + " capacityWeight: " + pawn.TryGetComp<CompInventory>().capacityWeight.ToString()); * Log.Message(pawn.ToString() + " currentWeight: " + pawn.TryGetComp<CompInventory>().currentWeight.ToString()); * Log.Message(pawn.ToString() + "capacityBulk: " + pawn.TryGetComp<CompInventory>().capacityBulk.ToString()); * Log.Message(pawn.ToString() + "currentBulk: " + pawn.TryGetComp<CompInventory>().currentBulk.ToString()); */ var brawler = pawn.story.traits.HasTrait(TraitDefOf.Brawler); CompInventory inventory = pawn.TryGetComp <CompInventory>(); CompAmmoUser ammouser = pawn.TryGetComp <CompAmmoUser>(); CompAmmoUser primaryammouser = pawn.equipment.Primary.TryGetComp <CompAmmoUser>(); if (inventory != null) { Room room = RoomQuery.RoomAtFast(pawn.Position, pawn.Map); // Prefer ranged weapon in inventory if (!pawn.Faction.IsPlayer && pawn.equipment != null) { if (pawn.equipment.Primary != null && pawn.equipment.Primary.def.IsMeleeWeapon && !brawler && (pawn.skills.GetSkill(SkillDefOf.Shooting).Level >= pawn.skills.GetSkill(SkillDefOf.Melee).Level || pawn.skills.GetSkill(SkillDefOf.Shooting).Level >= 6)) { ThingWithComps InvListGun3 = inventory.rangedWeaponList.Find(thing => thing.TryGetComp <CompAmmoUser>() != null); if (InvListGun3 != null) { Thing ammoInvListGun3 = null; foreach (ThingDef InvListGunDef3 in InvListGun3.TryGetComp <CompAmmoUser>().Props.ammoSet.ammoTypes) { ammoInvListGun3 = inventory.ammoList.Find(thing => thing.def == InvListGunDef3); break; } if (ammoInvListGun3 != null) { inventory.TrySwitchToWeapon(InvListGun3); } } } } // Drop excess ranged weapon if (!pawn.Faction.IsPlayer && pawn.equipment.Primary != null && primaryammouser != null && GetPriorityWork(pawn) == WorkPriority.Unloading && inventory.rangedWeaponList.Count >= 1) { Thing ListGun = inventory.rangedWeaponList.Find(thing => pawn.equipment != null && pawn.equipment.Primary != null && thing.TryGetComp <CompAmmoUser>() != null && thing.def != pawn.equipment.Primary.def); if (ListGun != null) { Thing ammoListGun = null; foreach (ThingDef ListGunDef in ListGun.TryGetComp <CompAmmoUser>().Props.ammoSet.ammoTypes) { if (inventory.ammoList.Find(thing => thing.def == ListGunDef) == null) { ammoListGun = ListGun; break; } } if (ammoListGun != null) { Thing droppedWeapon; if (inventory.container.TryDrop(ListGun, pawn.Position, pawn.Map, ThingPlaceMode.Near, ListGun.stackCount, out droppedWeapon)) { pawn.jobs.EndCurrentJob(JobCondition.None, true); pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.DropEquipment, droppedWeapon, 30, true)); } } } } // Find and drop not need ammo from inventory if (!pawn.Faction.IsPlayer && inventory.ammoList.Count > 1 && GetPriorityWork(pawn) == WorkPriority.Unloading) { Thing WrongammoThing = null; foreach (ThingDef WrongammoDef in primaryammouser.Props.ammoSet.ammoTypes) { WrongammoThing = inventory.ammoList.Find(thing => thing.def != WrongammoDef); break; } if (WrongammoThing != null) { Thing InvListGun = inventory.rangedWeaponList.Find(thing => pawn.equipment != null && pawn.equipment.Primary != null && thing.TryGetComp <CompAmmoUser>() != null && thing.def != pawn.equipment.Primary.def); if (InvListGun != null) { Thing ammoInvListGun = null; foreach (ThingDef InvListGunDef in InvListGun.TryGetComp <CompAmmoUser>().Props.ammoSet.ammoTypes) { ammoInvListGun = inventory.ammoList.Find(thing => thing.def == InvListGunDef); break; } if (ammoInvListGun != null && ammoInvListGun != WrongammoThing) { Thing droppedThingAmmo; if (inventory.container.TryDrop(ammoInvListGun, pawn.Position, pawn.Map, ThingPlaceMode.Near, ammoInvListGun.stackCount, out droppedThingAmmo)) { pawn.jobs.EndCurrentJob(JobCondition.None, true); pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.DropEquipment, 30, true)); } } } else { Thing droppedThing; if (inventory.container.TryDrop(WrongammoThing, pawn.Position, pawn.Map, ThingPlaceMode.Near, WrongammoThing.stackCount, out droppedThing)) { pawn.jobs.EndCurrentJob(JobCondition.None, true); pawn.jobs.TryTakeOrderedJob(new Job(JobDefOf.DropEquipment, 30, true)); } } } } // Find weapon in inventory and try to switch if any ammo in inventory. if (GetPriorityWork(pawn) == WorkPriority.Weapon && pawn.equipment.Primary == null) { ThingWithComps InvListGun2 = inventory.rangedWeaponList.Find(thing => thing.TryGetComp <CompAmmoUser>() != null); if (InvListGun2 != null) { Thing ammoInvListGun2 = null; foreach (ThingDef InvListGunDef2 in InvListGun2.TryGetComp <CompAmmoUser>().Props.ammoSet.ammoTypes) { ammoInvListGun2 = inventory.ammoList.Find(thing => thing.def == InvListGunDef2); break; } if (ammoInvListGun2 != null) { inventory.TrySwitchToWeapon(InvListGun2); } } // Find weapon with near ammo for ai. if (!pawn.Faction.IsPlayer && pawn.equipment.Primary == null) { Predicate <Thing> validatorWS = (Thing w) => w.def.IsWeapon && w.MarketValue > 500 && pawn.CanReserve(w, 1) && pawn.CanReach(w, PathEndMode.Touch, Danger.Deadly, true) && ((!pawn.Faction.HostileTo(Faction.OfPlayer) && pawn.Map.areaManager.Home[w.Position]) || (pawn.Faction.HostileTo(Faction.OfPlayer))) && (w.Position.DistanceToSquared(pawn.Position) < 15f || room == RoomQuery.RoomAtFast(w.Position, pawn.Map)); List <Thing> weapon = ( from w in pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.HaulableAlways) where validatorWS(w) where w.def.IsRangedWeapon // added this since what we are doing with the weapon list is looking for ammo. orderby w.MarketValue - w.Position.DistanceToSquared(pawn.Position) * 2f descending select w ).ToList(); if (weapon != null && weapon.Count > 0) { foreach (Thing thing in weapon) { List <ThingDef> thingDefAmmoList = (from ThingDef g in thing.TryGetComp <CompAmmoUser>().Props.ammoSet.ammoTypes select g).ToList <ThingDef>(); Predicate <Thing> validatorA = (Thing t) => t.def.category == ThingCategory.Item && t is AmmoThing && pawn.CanReserve(t, 1) && pawn.CanReach(t, PathEndMode.Touch, Danger.Deadly, true) && (t.Position.DistanceToSquared(pawn.Position) < 20f || room == RoomQuery.RoomAtFast(t.Position, pawn.Map)); List <Thing> thingAmmoList = ( from t in pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.HaulableAlways) where validatorA(t) select t ).ToList(); if (thingAmmoList.Count > 0 && thingDefAmmoList.Count > 0) { foreach (Thing th in thingAmmoList) { foreach (ThingDef thd in thingDefAmmoList) { if (thd == th.def) { int ammothingcount = 0; foreach (ThingDef ammoDef in thing.TryGetComp <CompAmmoUser>().Props.ammoSet.ammoTypes) { ammothingcount += th.stackCount; } if (ammothingcount > thing.TryGetComp <CompAmmoUser>().Props.magazineSize * 2) { int numToThing = 0; if (inventory.CanFitInInventory(thing, out numToThing)) { if (thing.Position == pawn.Position || thing.Position.AdjacentToCardinal(pawn.Position)) { return(new Job(JobDefOf.Equip, thing) { checkOverrideOnExpire = true, expiryInterval = 100, canBash = true, locomotionUrgency = LocomotionUrgency.Sprint }); } return(GotoForce(pawn, thing, PathEndMode.Touch)); } } } } } } } } // else if we didn't find a ranged weapon with available ammo above, lets try a melee weapon. Thing meleeWeapon = ( from w in pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.HaulableAlways) where validatorWS(w) where !w.def.IsRangedWeapon // Looking for non-ranged weapons. where w.def.IsMeleeWeapon // Make sure it's melee capable. orderby w.MarketValue - w.Position.DistanceToSquared(pawn.Position) * 2f descending select w ).FirstOrDefault(); if (meleeWeapon != null) { if (meleeWeapon.Position == pawn.Position || meleeWeapon.Position.AdjacentToCardinal(pawn.Position)) { return(new Job(JobDefOf.Equip, meleeWeapon) { checkOverrideOnExpire = true, expiryInterval = 100, canBash = true, locomotionUrgency = LocomotionUrgency.Sprint }); } return(GotoForce(pawn, meleeWeapon, PathEndMode.Touch)); } } } // Find ammo if ((GetPriorityWork(pawn) == WorkPriority.Ammo || GetPriorityWork(pawn) == WorkPriority.LowAmmo) && pawn.equipment != null && pawn.equipment.Primary != null && primaryammouser != null) { List <ThingDef> curAmmoList = (from ThingDef g in primaryammouser.Props.ammoSet.ammoTypes select g).ToList <ThingDef>(); if (curAmmoList.Count > 0) { Predicate <Thing> validator = (Thing t) => t is AmmoThing && pawn.CanReserve(t, 1) && pawn.CanReach(t, PathEndMode.Touch, Danger.Deadly, true) && ((pawn.Faction.IsPlayer && !ForbidUtility.IsForbidden(t, pawn)) || (!pawn.Faction.IsPlayer && (!pawn.Faction.HostileTo(Faction.OfPlayer) && pawn.Map.areaManager.Home[t.Position]) || (pawn.Faction.HostileTo(Faction.OfPlayer)))) && (t.Position.DistanceToSquared(pawn.Position) < 20f || room == RoomQuery.RoomAtFast(t.Position, pawn.Map)); List <Thing> curThingList = ( from t in pawn.Map.listerThings.ThingsInGroup(ThingRequestGroup.HaulableAlways) where validator(t) select t ).ToList(); foreach (Thing th in curThingList) { foreach (ThingDef thd in curAmmoList) { if (thd == th.def) { //Defence from low count loot spam float thw = (th.GetStatValue(CR_StatDefOf.Bulk)) * th.stackCount; if (thw > 0.5f) { if (pawn.Faction.IsPlayer) { int SearchRadius = 0; if (GetPriorityWork(pawn) == WorkPriority.LowAmmo) { SearchRadius = 70; } else { SearchRadius = 30; } Thing closestThing = GenClosest.ClosestThingReachable( pawn.Position, pawn.Map, ThingRequest.ForDef(th.def), PathEndMode.ClosestTouch, TraverseParms.For(pawn, Danger.None, TraverseMode.ByPawn), SearchRadius, x => !x.IsForbidden(pawn) && pawn.CanReserve(x)); if (closestThing != null) { int numToCarry = 0; if (inventory.CanFitInInventory(th, out numToCarry)) { return(new Job(JobDefOf.TakeInventory, th) { count = numToCarry }); } } } else { if (th.Position == pawn.Position || th.Position.AdjacentToCardinal(pawn.Position)) { int numToCarry = 0; if (inventory.CanFitInInventory(th, out numToCarry)) { return(new Job(JobDefOf.TakeInventory, th) { count = Mathf.RoundToInt(numToCarry * 0.8f), expiryInterval = 150, checkOverrideOnExpire = true, canBash = true, locomotionUrgency = LocomotionUrgency.Sprint }); } } return(GotoForce(pawn, th, PathEndMode.Touch)); } } } } } } } if (!pawn.Faction.IsPlayer && pawn.apparel != null && GetPriorityWork(pawn) == WorkPriority.Apparel) { if (!pawn.apparel.BodyPartGroupIsCovered(BodyPartGroupDefOf.Torso)) { Apparel apparel = this.FindGarmentCoveringPart(pawn, BodyPartGroupDefOf.Torso); if (apparel != null) { int numToapparel = 0; if (inventory.CanFitInInventory(apparel, out numToapparel)) { return(new Job(JobDefOf.Wear, apparel) { ignoreForbidden = true, locomotionUrgency = LocomotionUrgency.Sprint }); } } } if (!pawn.apparel.BodyPartGroupIsCovered(BodyPartGroupDefOf.Legs)) { Apparel apparel2 = this.FindGarmentCoveringPart(pawn, BodyPartGroupDefOf.Legs); if (apparel2 != null) { int numToapparel2 = 0; if (inventory.CanFitInInventory(apparel2, out numToapparel2)) { return(new Job(JobDefOf.Wear, apparel2) { ignoreForbidden = true, locomotionUrgency = LocomotionUrgency.Sprint }); } } } /* * if (!pawn.apparel.BodyPartGroupIsCovered(BodyPartGroupDefOf.FullHead)) * { * Apparel apparel3 = this.FindGarmentCoveringPart(pawn, BodyPartGroupDefOf.FullHead); * if (apparel3 != null) * { * int numToapparel3 = 0; * if (inventory.CanFitInInventory(apparel3, out numToapparel3)) * { * return new Job(JobDefOf.Wear, apparel3) * { * ignoreForbidden = true, * locomotionUrgency = LocomotionUrgency.Sprint * }; * } * } * } */ } return(null); } return(null); }
private void DrawThingRow(ref float y, float width, Thing thing) { Rect rect = new Rect(0f, y, width, _thingRowHeight); Widgets.InfoCardButton(rect.width - 24f, y, thing); rect.width -= 24f; if (CanControl) { Rect dropRect = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(dropRect, "DropThing".Translate()); if (Widgets.ButtonImage(dropRect, TexButton.Drop)) { SoundDefOf.TickHigh.PlayOneShotOnCamera(); InterfaceDrop(thing); } rect.width -= 24f; } if (this.CanControl && thing.def.IsNutritionGivingIngestible && thing.IngestibleNow && base.SelPawn.RaceProps.CanEverEat(thing)) { Rect rect3 = new Rect(rect.width - 24f, y, 24f, 24f); TooltipHandler.TipRegion(rect3, "ConsumeThing".Translate(new object[] { thing.LabelNoCount })); if (Widgets.ButtonImage(rect3, TexButton.Ingest)) { SoundDefOf.TickHigh.PlayOneShotOnCamera(); this.InterfaceEatThis(thing); } rect.width -= 24f; } if (Mouse.IsOver(rect)) { GUI.color = _highlightColor; GUI.DrawTexture(rect, TexUI.HighlightTex); } if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null) { Widgets.ThingIcon(new Rect(4f, y, _thingIconSize, _thingIconSize), thing); } Text.Anchor = TextAnchor.MiddleLeft; GUI.color = _thingLabelColor; Rect thingLabelRect = new Rect(_thingLeftX, y, rect.width - _thingLeftX, _thingRowHeight); string thingLabel = thing.LabelCap; if (thing is Apparel && SelPawnForGear.outfits != null && SelPawnForGear.outfits.forcedHandler.IsForced((Apparel)thing)) { thingLabel = thingLabel + ", " + "ApparelForcedLower".Translate(); } Widgets.Label(thingLabelRect, thingLabel); y += _thingRowHeight; TooltipHandler.TipRegion(thingLabelRect, thing.GetWeightAndBulkTip()); // RMB menu if (Widgets.ButtonInvisible(thingLabelRect) && Event.current.button == 1) { List <FloatMenuOption> floatOptionList = new List <FloatMenuOption>(); floatOptionList.Add(new FloatMenuOption("ThingInfo".Translate(), delegate { Find.WindowStack.Add(new Dialog_InfoCard(thing)); }, MenuOptionPriority.Default, null, null)); if (CanControl) { // Equip option ThingWithComps eq = thing as ThingWithComps; if (eq != null && eq.TryGetComp <CompEquippable>() != null) { CompInventory compInventory = SelPawnForGear.TryGetComp <CompInventory>(); if (compInventory != null) { FloatMenuOption equipOption; string eqLabel = GenLabel.ThingLabel(eq.def, eq.Stuff, 1); if (SelPawnForGear.equipment.AllEquipment.Contains(eq) && SelPawnForGear.inventory != null) { equipOption = new FloatMenuOption("CR_PutAway".Translate(new object[] { eqLabel }), new Action(delegate { ThingWithComps oldEq; SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.innerContainer, out oldEq); })); } else if (!SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) { equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }), null); } else { string equipOptionLabel = "Equip".Translate(new object[] { eqLabel }); if (eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler)) { equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate(); } equipOption = new FloatMenuOption(equipOptionLabel, new Action(delegate { compInventory.TrySwitchToWeapon(eq); })); } floatOptionList.Add(equipOption); } } // Drop option Action dropApparel = delegate { SoundDefOf.TickHigh.PlayOneShotOnCamera(); InterfaceDrop(thing); }; Action dropApparelHaul = delegate { SoundDefOf.TickHigh.PlayOneShotOnCamera(); InterfaceDropHaul(thing); }; Action eatFood = delegate { SoundDefOf.TickHigh.PlayOneShotOnCamera(); InterfaceEatThis(thing); }; floatOptionList.Add(new FloatMenuOption("CR_Eat".Translate(), eatFood)); floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), dropApparel)); floatOptionList.Add(new FloatMenuOption("CR_DropThingHaul".Translate(), dropApparelHaul)); //Action action = null; //Apparel ap = thing as Apparel; //if (ap != null && SelPawnForGear.apparel.WornApparel.Contains(ap)) //{ // Apparel unused; // action = delegate // { // this.SelPawnForGear.apparel.TryDrop(ap, out unused, this.SelPawnForGear.Position, true); // }; //} //else if (eq != null && this.SelPawnForGear.equipment.AllEquipment.Contains(eq)) //{ // ThingWithComps unused; // action = delegate // { // this.SelPawnForGear.equipment.TryDropEquipment(eq, out unused, this.SelPawnForGear.Position, true); // }; //} //else if (!thing.def.destroyOnDrop) //{ // Thing unused; // action = delegate // { // this.SelPawnForGear.inventory.container.TryDrop(thing, this.SelPawnForGear.Position, ThingPlaceMode.Near, out unused); // }; //} //floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), action, MenuOptionPriority.Medium, null, null)); } FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false); Find.WindowStack.Add(window); } // end menu // OLD //if (Mouse.IsOver(rect)) //{ // GUI.color = _highlightColor; // GUI.DrawTexture(rect, TexUI.HighlightTex); //} //if (Widgets.ButtonInvisible(rect) && Event.current.button == 1) //{ // List<FloatMenuOption> floatOptionList = new List<FloatMenuOption>(); // floatOptionList.Add(new FloatMenuOption("ThingInfo".Translate(), delegate // { // Find.WindowStack.Add(new Dialog_InfoCard(thing)); // }, MenuOptionPriority.Medium, null, null)); // if (this.CanControl) // { // // Equip option // ThingWithComps eq = thing as ThingWithComps; // if (eq != null && eq.TryGetComp<CompEquippable>() != null) // { // CompInventory compInventory = SelPawnForGear.TryGetComp<CompInventory>(); // if (compInventory != null) // { // FloatMenuOption equipOption; // string eqLabel = GenLabel.ThingLabel(eq.def, eq.Stuff, 1); // if (SelPawnForGear.equipment.AllEquipment.Contains(eq) && SelPawnForGear.inventory != null) // { // equipOption = new FloatMenuOption("CR_PutAway".Translate(new object[] { eqLabel }), // new Action(delegate // { // ThingWithComps oldEq; // SelPawnForGear.equipment.TryTransferEquipmentToContainer(SelPawnForGear.equipment.Primary, SelPawnForGear.inventory.container, out oldEq); // })); // } // else if (!SelPawnForGear.health.capacities.CapableOf(PawnCapacityDefOf.Manipulation)) // { // equipOption = new FloatMenuOption("CannotEquip".Translate(new object[] { eqLabel }), null); // } // else // { // string equipOptionLabel = "Equip".Translate(new object[] { eqLabel }); // if (eq.def.IsRangedWeapon && SelPawnForGear.story != null && SelPawnForGear.story.traits.HasTrait(TraitDefOf.Brawler)) // { // equipOptionLabel = equipOptionLabel + " " + "EquipWarningBrawler".Translate(); // } // equipOption = new FloatMenuOption(equipOptionLabel, new Action(delegate // { // compInventory.TrySwitchToWeapon(eq); // })); // } // floatOptionList.Add(equipOption); // } // } // // // Drop option // Action action = null; // Apparel ap = thing as Apparel; // if (ap != null && SelPawnForGear.apparel.WornApparel.Contains(ap)) // { // Apparel unused; // action = delegate // { // this.SelPawnForGear.apparel.TryDrop(ap, out unused, this.SelPawnForGear.Position, true); // }; // } // else if (eq != null && this.SelPawnForGear.equipment.AllEquipment.Contains(eq)) // { // ThingWithComps unused; // action = delegate // { // this.SelPawnForGear.equipment.TryDropEquipment(eq, out unused, this.SelPawnForGear.Position, true); // }; // } // else if (!thing.def.destroyOnDrop) // { // Thing unused; // action = delegate // { // this.SelPawnForGear.inventory.container.TryDrop(thing, this.SelPawnForGear.Position, ThingPlaceMode.Near, out unused); // }; // } // floatOptionList.Add(new FloatMenuOption("DropThing".Translate(), action, MenuOptionPriority.Medium, null, null)); // } // FloatMenu window = new FloatMenu(floatOptionList, thing.LabelCap, false); // Find.WindowStack.Add(window); //} //if (thing.def.DrawMatSingle != null && thing.def.DrawMatSingle.mainTexture != null) //{ // Widgets.ThingIcon(new Rect(4f, y, 28f, 28f), thing); //} //Text.Anchor = TextAnchor.MiddleLeft; //GUI.color = _thingLabelColor; //Rect rect2 = new Rect(_thingLeftX, y, width - _thingLeftX, 28f); //string text = thing.LabelCap; //if (thing is Apparel && this.SelPawnForGear.outfits != null && this.SelPawnForGear.outfits.forcedHandler.IsForced((Apparel)thing)) //{ // text = text + ", " + "ApparelForcedLower".Translate(); //} //Widgets.Label(rect2, text); //y += 28f; }