/// <summary> /// Handles the tithe cutomization FloatMenuOptions for any given <paramref name="resource"/> with <paramref name="resourceType"/> /// </summary> /// <param name="resource"></param> /// <param name="resourceType"></param> private void TitheCustomizationClicked(ResourceFC resource, ResourceType resourceType) { //if click faction customize button if (resource.filter == null) { resource.filter = new ThingFilter(); PaymentUtil.resetThingFilter(settlement, resourceType); } List <FloatMenuOption> options = new List <FloatMenuOption> { new FloatMenuOption("FCTitheEnableAll".Translate(), delegate { PaymentUtil.resetThingFilter(settlement, resourceType); resource.returnLowestCost(); }), new FloatMenuOption("FCTitheDisableAll".Translate(), delegate { resource.filter.SetDisallowAll(); resource.returnLowestCost(); }) }; List <ThingDef> things = PaymentUtil.debugGenerateTithe(resourceType); foreach (ThingDef thing in things.Where(thing => thing.race?.animalType != AnimalType.Dryad)) { if (!FactionColonies.canCraftItem(thing)) { resource.filter.SetAllow(thing, false); continue; } FloatMenuOption option = new FloatMenuOption("FCTitheSingleOption".Translate(thing.LabelCap, thing.BaseMarketValue, IsAllowedTranslation(resource.filter.Allows(thing))), null, thing); //Seperated because the label needs to be modified on press option.action = delegate { resource.filter.SetAllow(thing, !resource.filter.Allows(thing)); resource.returnLowestCost(); option.Label = "FCTitheSingleOption".Translate(thing.LabelCap, thing.BaseMarketValue, IsAllowedTranslation(resource.filter.Allows(thing))); SoundDefOf.Click.PlayOneShotOnCamera(); }; options.Add(option); } Find.WindowStack.Add(new Searchable_FloatMenu(options, true)); }
public void DrawProductionHeaderLower(int x, int y, int spacing) { Text.Anchor = TextAnchor.MiddleRight; Text.Font = GameFont.Small; //Assigned workers Widgets.Label(new Rect(x, y, 410, 30), "AssignedWorkers".Translate() + ": " + settlement.getTotalWorkers().ToString() + " / " + settlement.workersMax.ToString() + " / " + settlement.workersUltraMax.ToString()); Text.Anchor = TextAnchor.MiddleCenter; Text.Font = GameFont.Tiny; //Item Headers Widgets.DrawHighlight(new Rect(x, y + 30, 40, 40)); Widgets.Label(new Rect(x, y + 30, 40, 40), "IsTithe".Translate() + "?"); Widgets.DrawHighlight(new Rect(x + 80, y + 30, 100, 40)); Widgets.Label(new Rect(x + 80, y + 30, 100, 40), "ProductionEfficiency".Translate()); Widgets.DrawHighlight(new Rect(x + 195, y + 30, 45, 40)); Widgets.Label(new Rect(x + 195, y + 30, 45, 40), "Base".Translate()); Widgets.DrawHighlight(new Rect(x + 250, y + 30, 50, 40)); Widgets.Label(new Rect(x + 250, y + 30, 50, 40), "Modifier".Translate()); Widgets.DrawHighlight(new Rect(x + 310, y + 30, 45, 40)); Widgets.Label(new Rect(x + 310, y + 30, 45, 40), "Final".Translate()); Widgets.DrawHighlight(new Rect(x + 365, y + 30, 45, 40)); Widgets.Label(new Rect(x + 365, y + 30, 45, 40), "EstimatedProfit".Translate()); Widgets.DrawHighlight(new Rect(x + 420, y + 30, 45, 40)); Widgets.Label(new Rect(x + 420, y + 30, 45, 40), "TaxPercentage".Translate()); //Per resource for (int i = 0; i < settlement.getNumberResource(); i++) { ResourceFC resource = settlement.returnResourceByInt(i); if ((i * scrollSpacing) + scroll < 0) { //if outside view } else { //loop through each resource //isTithe bool disabled = false; switch (i) { case 6: case 7: disabled = true; break; } switch (i) { case 0: //food case 1: case 2: case 3: case 4: case 5: case 8: if (Widgets.ButtonImage(new Rect(x - 15, scroll + y + 65 + (i * (45 + spacing)) + 8, 20, 20), texLoad.iconCustomize)) { //if click faction customize button int k = i; if (resource.filter == null) { resource.filter = new ThingFilter(); PaymentUtil.resetThingFilter(settlement, i); } List <FloatMenuOption> options = new List <FloatMenuOption>(); options.Add(new FloatMenuOption("Enable All", delegate { PaymentUtil.resetThingFilter(settlement, k); resource.returnLowestCost(); })); options.Add(new FloatMenuOption("Disable All", delegate { resource.filter.SetDisallowAll(); resource.returnLowestCost(); })); List <ThingDef> things = PaymentUtil.debugGenerateTithe(i); foreach (ThingDef thing in things) { FloatMenuOption option; if (!FactionColonies.canCraftItem(thing)) { resource.filter.SetAllow(thing, false); } else { option = new FloatMenuOption(thing.LabelCap + " - Cost - " + thing.BaseMarketValue + " | Allowed: " + resource.filter.Allows(thing), delegate { resource.filter.SetAllow(thing, !resource.filter.Allows(thing)); resource.returnLowestCost(); }, thing); options.Add(option); } } FloatMenu menu = new FloatMenu(options); Find.WindowStack.Add(menu); //Log.Message("Settlement customize clicked"); } break; } Widgets.Checkbox(new Vector2(x + 8, scroll + y + 65 + (i * (45 + spacing)) + 8), ref settlement.returnResourceByInt(i).isTithe, 24, disabled); if (settlement.returnResourceByInt(i).isTithe != settlement.returnResourceByInt(i).isTitheBool) { settlement.returnResourceByInt(i).isTitheBool = settlement.returnResourceByInt(i).isTithe; //Log.Message("changed tithe"); settlement.updateProfitAndProduction(); WindowUpdateFC(); } //Icon if (Widgets.ButtonImage(new Rect(x + 45, scroll + y + 75 + (i * (45 + spacing)), 30, 30), settlement.returnResourceByInt(i).getIcon())) { Find.WindowStack.Add(new descWindowFC("SettlementProductionOf".Translate() + ": " + settlement.returnResourceByInt(i).label, char.ToUpper(settlement.returnResourceByInt(i).label[0]) + settlement.returnResourceByInt(i).label.Substring(1))); } ; //Production Efficiency Widgets.DrawBox(new Rect(x + 80, scroll + y + 70 + (i * (45 + spacing)), 100, 20)); Widgets.FillableBar(new Rect(x + 80, scroll + y + 70 + (i * (45 + spacing)), 100, 20), (float)Math.Min(settlement.returnResourceByInt(i).baseProductionMultiplier, 1.0)); Widgets.Label(new Rect(x + 80, scroll + y + 90 + (i * (45 + spacing)), 100, 20), "Workers".Translate() + ": " + settlement.returnResourceByInt(i).assignedWorkers.ToString()); if (Widgets.ButtonText(new Rect(x + 80, scroll + y + 90 + (i * (45 + spacing)), 20, 20), "<")) { //if clicked to lower amount of workers settlement.increaseWorkers(i, -1); WindowUpdateFC(); } if (Widgets.ButtonText(new Rect(x + 160, scroll + y + 90 + (i * (45 + spacing)), 20, 20), ">")) { //if clicked to lower amount of workers settlement.increaseWorkers(i, 1); WindowUpdateFC(); } //Base Production Widgets.Label(new Rect(x + 195, scroll + y + 70 + (i * (45 + spacing)), 45, 40), FactionColonies.FloorStat(settlement.returnResourceByInt(i).baseProduction)); //Final Modifier Widgets.Label(new Rect(x + 250, scroll + y + 70 + (i * (45 + spacing)), 50, 40), FactionColonies.FloorStat(settlement.returnResourceByInt(i).endProductionMultiplier)); //Final Base Widgets.Label(new Rect(x + 310, scroll + y + 70 + (i * (45 + spacing)), 45, 40), (FactionColonies.FloorStat(settlement.returnResourceByInt(i).endProduction))); //Est Income Widgets.Label(new Rect(x + 365, scroll + y + 70 + (i * (45 + spacing)), 45, 40), (FactionColonies.FloorStat(settlement.returnResourceByInt(i).endProduction *LoadedModManager.GetMod <FactionColoniesMod>().GetSettings <FactionColonies>().silverPerResource))); //Tithe Percentage Widgets.Label(new Rect(x + 420, scroll + y + 70 + (i * (45 + spacing)), 45, 40), FactionColonies.FloorStat(settlement.returnResourceByInt(i).taxPercentage) + "%"); } } //Scroll window for resources if (Event.current.type == EventType.ScrollWheel) { scrollWindow(Event.current.delta.y); } }
public override void DrawTab(Rect rect) { Rect SelectionBar = new Rect(5, 45, 200, 30); Rect importButton = new Rect(5, SelectionBar.y + SelectionBar.height + 10, 200, 30); Rect nameTextField = new Rect(5, importButton.y + importButton.height + 10, 250, 30); Rect isCivilian = new Rect(5, nameTextField.y + nameTextField.height + 10, 100, 30); Rect isTrader = new Rect(isCivilian.x, isCivilian.y + isCivilian.height + 5, isCivilian.width, isCivilian.height); Rect unitIcon = new Rect(560, 235, 120, 120); Rect animalIcon = new Rect(560, 335, 120, 120); Rect ApparelHead = new Rect(600, 140, 50, 50); Rect ApparelTorsoSkin = new Rect(700, 170, 50, 50); Rect ApparelBelt = new Rect(700, 240, 50, 50); Rect ApparelLegs = new Rect(700, 310, 50, 50); Rect AnimalCompanion = new Rect(500, 160, 50, 50); Rect ApparelTorsoShell = new Rect(500, 230, 50, 50); Rect ApparelTorsoMiddle = new Rect(500, 310, 50, 50); Rect EquipmentWeapon = new Rect(440, 230, 50, 50); Rect ApparelWornItems = new Rect(440, 385, 330, 175); Rect EquipmentTotalCost = new Rect(450, 50, 350, 40); Rect ResetButton = new Rect(700, 50, 100, 30); Rect DeleteButton = new Rect(ResetButton.x, ResetButton.y + ResetButton.height + 5, ResetButton.width, ResetButton.height); Rect SavePawn = new Rect(DeleteButton.x, DeleteButton.y + DeleteButton.height + 5, DeleteButton.width, DeleteButton.height); Rect ChangeRace = new Rect(325, ResetButton.y, SavePawn.width, SavePawn.height); Rect RollNewPawn = new Rect(325, ResetButton.y + SavePawn.height + 5, SavePawn.width, SavePawn.height); if (Widgets.CustomButtonText(ref SelectionBar, selectedText, Color.gray, Color.white, Color.black)) { List <FloatMenuOption> Units = new List <FloatMenuOption> { new FloatMenuOption("Create New Unit", delegate { MilUnitFC newUnit = new MilUnitFC(false) { name = $"New Unit {util.units.Count() + 1}" }; selectedText = newUnit.name; selectedUnit = newUnit; util.units.Add(newUnit); newUnit.unequipAllEquipment(); }) }; //Option to create new unit //Create list of selectable units foreach (MilUnitFC unit in util.units) { void action() { selectedText = unit.name; selectedUnit = unit; } //Prevent units being modified when their squads are deployed FactionFC factionFC = Find.World.GetComponent <FactionFC>(); List <MilSquadFC> squadsContainingUnit = factionFC?.militaryCustomizationUtil?.squads.Where(squad => squad?.units != null && squad.units.Contains(unit)).ToList(); List <SettlementFC> settlementsContainingSquad = factionFC?.settlements?.Where(settlement => settlement?.militarySquad?.outfit != null && squadsContainingUnit.Any(squad => settlement.militarySquad.outfit == squad)).ToList(); if ((settlementsContainingSquad?.Count ?? 0) > 0) { if (settlementsContainingSquad.Any(settlement => settlement.militarySquad.isDeployed)) { Units.Add(new FloatMenuOption(unit.name, delegate { Messages.Message("CantBeModified".Translate(unit.name, "ReasonDeployed".Translate()), MessageTypeDefOf.NeutralEvent, false); })); continue; } else if (settlementsContainingSquad.Any(settlement => settlement.isUnderAttack && settlementsContainingSquad.Contains(settlement.worldSettlement.defenderForce.homeSettlement))) { Units.Add(new FloatMenuOption(unit.name, delegate { Messages.Message("CantBeModified".Translate(unit.name, "ReasonDefending".Translate()), MessageTypeDefOf.NeutralEvent, false); })); continue; } } if (unit.defaultPawn.equipment.Primary != null) { Units.Add(new FloatMenuOption(unit.name, action, unit.defaultPawn.equipment.Primary.def)); } else { Units.Add(new FloatMenuOption(unit.name, action)); } } FloatMenu selection = new Searchable_FloatMenu(Units); Find.WindowStack.Add(selection); } if (Widgets.ButtonText(importButton, "importUnit".Translate())) { Find.WindowStack.Add(new Dialog_ManageUnitExportsFC( FactionColoniesMilitary.SavedUnits.ToList())); } //Worn Items Widgets.DrawMenuSection(ApparelWornItems); //set text anchor and font GameFont fontBefore = Text.Font; TextAnchor anchorBefore = Text.Anchor; Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.UpperCenter; //if unit is not selected Widgets.Label(new Rect(new Vector2(ApparelHead.x, ApparelHead.y - 15), ApparelHead.size), "fcLabelHead".Translate()); Widgets.DrawMenuSection(ApparelHead); Widgets.Label( new Rect(new Vector2(ApparelTorsoSkin.x, ApparelTorsoSkin.y - 15), ApparelTorsoSkin.size), "fcLabelShirt".Translate()); Widgets.DrawMenuSection(ApparelTorsoSkin); Widgets.Label( new Rect(new Vector2(ApparelTorsoMiddle.x, ApparelTorsoMiddle.y - 15), ApparelTorsoMiddle.size), "fcLabelChest".Translate()); Widgets.DrawMenuSection(ApparelTorsoMiddle); Widgets.Label( new Rect(new Vector2(ApparelTorsoShell.x, ApparelTorsoShell.y - 15), ApparelTorsoShell.size), "fcLabelOver".Translate()); Widgets.DrawMenuSection(ApparelTorsoShell); Widgets.Label(new Rect(new Vector2(ApparelBelt.x, ApparelBelt.y - 15), ApparelBelt.size), "fcLabelBelt".Translate()); Widgets.DrawMenuSection(ApparelBelt); Widgets.Label(new Rect(new Vector2(ApparelLegs.x, ApparelLegs.y - 15), ApparelLegs.size), "fcLabelPants".Translate()); Widgets.DrawMenuSection(ApparelLegs); Widgets.Label( new Rect(new Vector2(EquipmentWeapon.x, EquipmentWeapon.y - 15), EquipmentWeapon.size), "fcLabelWeapon".Translate()); Widgets.DrawMenuSection(EquipmentWeapon); Widgets.Label( new Rect(new Vector2(AnimalCompanion.x, AnimalCompanion.y - 15), AnimalCompanion.size), "fcLabelAnimal".Translate()); Widgets.DrawMenuSection(AnimalCompanion); //Reset Text anchor and font Text.Font = fontBefore; Text.Anchor = anchorBefore; //if unit is selected if (selectedUnit == null) { return; } Text.Font = GameFont.Tiny; Text.Anchor = TextAnchor.UpperCenter; if (Widgets.ButtonText(ResetButton, "resetUnitToDefaultButton".Translate())) { selectedUnit.unequipAllEquipment(); } if (Widgets.ButtonText(DeleteButton, "deleteUnitButton".Translate())) { selectedUnit.removeUnit(); util.checkMilitaryUtilForErrors(); selectedUnit = null; selectedText = "selectAUnitButton".Translate(); //Reset Text anchor and font Text.Font = fontBefore; Text.Anchor = anchorBefore; return; } if (Widgets.ButtonText(RollNewPawn, "rollANewUnitButton".Translate())) { selectedUnit.generateDefaultPawn(); selectedUnit.unequipAllEquipment(); } if (Widgets.ButtonText(ChangeRace, "changeUnitRaceButton".Translate())) { List <string> races = new List <string>(); List <FloatMenuOption> options = new List <FloatMenuOption>(); foreach (PawnKindDef def in DefDatabase <PawnKindDef> .AllDefsListForReading.Where(def => def.IsHumanLikeRace() && !races.Contains(def.race.label) && faction.raceFilter.Allows(def.race))) { if (def.race == ThingDefOf.Human && def.LabelCap != "Colonist") { continue; } races.Add(def.race.label); string optionStr = def.race.label.CapitalizeFirst() + " - Cost: " + Math.Floor(def.race.BaseMarketValue * FactionColonies.militaryRaceCostMultiplier); options.Add(new FloatMenuOption(optionStr, delegate { selectedUnit.pawnKind = def; selectedUnit.generateDefaultPawn(); selectedUnit.changeTick(); })); } if (!options.Any()) { options.Add(new FloatMenuOption("changeUnitRaceNoRaces".Translate(), null)); } options.Sort(FactionColonies.CompareFloatMenuOption); FloatMenu menu = new Searchable_FloatMenu(options); Find.WindowStack.Add(menu); } if (Widgets.ButtonText(SavePawn, "exportUnitButton".Translate())) { // TODO: confirm FactionColoniesMilitary.SaveUnit(new SavedUnitFC(selectedUnit)); Messages.Message("ExportUnit".Translate(), MessageTypeDefOf.TaskCompletion); } //Unit Name selectedUnit.name = Widgets.TextField(nameTextField, selectedUnit.name); Widgets.CheckboxLabeled(isCivilian, "unitIsCivilianLabel".Translate(), ref selectedUnit.isCivilian); Widgets.CheckboxLabeled(isTrader, "unitIsTraderLabel".Translate(), ref selectedUnit.isTrader); selectedUnit.setTrader(selectedUnit.isTrader); selectedUnit.setCivilian(selectedUnit.isCivilian); //Reset Text anchor and font Text.Font = fontBefore; Text.Anchor = anchorBefore; //Draw Pawn if (selectedUnit.defaultPawn != null) { if (selectedUnit.animal != null) { //Widgets.DrawTextureFitted(animalIcon, selectedUnit.animal.race.graphicData.Graphic.MatNorth.mainTexture, 1); } Widgets.ThingIcon(unitIcon, selectedUnit.defaultPawn); } //Animal Companion if (Widgets.ButtonInvisible(AnimalCompanion)) { List <FloatMenuOption> list = (from animal in DefDatabase <PawnKindDef> .AllDefs where animal.IsAnimalAndAllowed() select new FloatMenuOption(animal.LabelCap + " - Cost: " + Math.Floor(animal.race.BaseMarketValue * FactionColonies.militaryAnimalCostMultiplier), delegate { //Do add animal code here selectedUnit.animal = animal; }, animal.race.uiIcon, Color.white)).ToList(); list.Sort(FactionColonies.CompareFloatMenuOption); list.Insert(0, new FloatMenuOption("unitActionUnequipThing".Translate(), delegate { //unequip here selectedUnit.animal = null; })); FloatMenu menu = new Searchable_FloatMenu(list); Find.WindowStack.Add(menu); } //Weapon Equipment if (Widgets.ButtonInvisible(EquipmentWeapon)) { List <FloatMenuOption> list = (from thing in DefDatabase <ThingDef> .AllDefs where thing.IsWeapon && thing.BaseMarketValue != 0 && FactionColonies.canCraftItem(thing) where true select new FloatMenuOption(thing.LabelCap + " - Cost: " + thing.BaseMarketValue, delegate { if (thing.MadeFromStuff) { //If made from stuff List <FloatMenuOption> stuffList = (from stuff in DefDatabase <ThingDef> .AllDefs where stuff.IsStuff && thing.stuffCategories.SharesElementWith(stuff.stuffProps.categories) select new FloatMenuOption(stuff.LabelCap + " - Total Value: " + StatWorker_MarketValue.CalculatedBaseMarketValue( thing, stuff), delegate { selectedUnit.equipWeapon( ThingMaker.MakeThing(thing, stuff) as ThingWithComps); })).ToList(); stuffList.Sort(FactionColonies.CompareFloatMenuOption); FloatMenu stuffWindow = new Searchable_FloatMenu(stuffList); Find.WindowStack.Add(stuffWindow); } else { //If not made from stuff selectedUnit.equipWeapon(ThingMaker.MakeThing(thing) as ThingWithComps); } }, thing)).ToList(); list.Sort(FactionColonies.CompareFloatMenuOption); list.Insert(0, new FloatMenuOption("unitActionUnequipThing".Translate(), delegate { selectedUnit.unequipWeapon(); })); FloatMenu menu = new Searchable_FloatMenu(list); Find.WindowStack.Add(menu); } //headgear Slot if (Widgets.ButtonInvisible(ApparelHead)) { List <FloatMenuOption> headgearList = new List <FloatMenuOption>(); foreach (ThingDef thing in DefDatabase <ThingDef> .AllDefs) { if (thing.IsApparel) { if (thing.apparel.layers.Contains(ApparelLayerDefOf.Overhead) && FactionColonies.canCraftItem(thing)) { headgearList.Add(new FloatMenuOption( thing.LabelCap + " - Cost: " + thing.BaseMarketValue, delegate { if (thing.MadeFromStuff) { //If made from stuff List <FloatMenuOption> stuffList = new List <FloatMenuOption>(); foreach (ThingDef stuff in DefDatabase <ThingDef> .AllDefs) { if (stuff.IsStuff && thing.stuffCategories.SharesElementWith(stuff.stuffProps .categories)) { stuffList.Add(new FloatMenuOption( stuff.LabelCap + " - Total Value: " + (StatWorker_MarketValue.CalculatedBaseMarketValue(thing, stuff)), delegate { selectedUnit.wearEquipment( ThingMaker.MakeThing(thing, stuff) as Apparel, true); })); } } stuffList.Sort(FactionColonies.CompareFloatMenuOption); FloatMenu stuffWindow = new Searchable_FloatMenu(stuffList); Find.WindowStack.Add(stuffWindow); } else { //If not made from stuff selectedUnit.wearEquipment(ThingMaker.MakeThing(thing) as Apparel, true); } }, thing)); } } } headgearList.Sort(FactionColonies.CompareFloatMenuOption); headgearList.Insert(0, new FloatMenuOption("unitActionUnequipThing".Translate(), delegate { //Remove old foreach (Apparel apparel in selectedUnit.defaultPawn.apparel.WornApparel .Where(apparel => apparel.def.apparel.layers.Contains(ApparelLayerDefOf.Overhead))) { selectedUnit.defaultPawn.apparel.Remove(apparel); break; } })); FloatMenu menu = new Searchable_FloatMenu(headgearList); Find.WindowStack.Add(menu); } //Torso Shell Slot if (Widgets.ButtonInvisible(ApparelTorsoShell)) { List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (ThingDef thing in DefDatabase <ThingDef> .AllDefs) { if (thing.IsApparel) { if (thing.apparel.layers.Contains(ApparelLayerDefOf.Shell) && thing.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso) && FactionColonies.canCraftItem(thing)) //CHANGE THIS { list.Add(new FloatMenuOption(thing.LabelCap + " - Cost: " + thing.BaseMarketValue, delegate { if (thing.MadeFromStuff) { //If made from stuff List <FloatMenuOption> stuffList = new List <FloatMenuOption>(); foreach (ThingDef stuff in DefDatabase <ThingDef> .AllDefs) { if (stuff.IsStuff && thing.stuffCategories.SharesElementWith(stuff.stuffProps .categories)) { stuffList.Add(new FloatMenuOption( stuff.LabelCap + " - Total Value: " + (StatWorker_MarketValue.CalculatedBaseMarketValue(thing, stuff)), delegate { selectedUnit.wearEquipment( ThingMaker.MakeThing(thing, stuff) as Apparel, true); })); } } stuffList.Sort(FactionColonies.CompareFloatMenuOption); FloatMenu stuffWindow = new Searchable_FloatMenu(stuffList); Find.WindowStack.Add(stuffWindow); } else { //If not made from stuff selectedUnit.wearEquipment(ThingMaker.MakeThing(thing) as Apparel, true); } }, thing)); } } } list.Sort(FactionColonies.CompareFloatMenuOption); list.Insert(0, new FloatMenuOption("unitActionUnequipThing".Translate(), delegate { //Remove old foreach (Apparel apparel in selectedUnit.defaultPawn.apparel.WornApparel) { if (apparel.def.apparel.layers.Contains(ApparelLayerDefOf.Shell) && apparel.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso)) //CHANGE THIS { selectedUnit.defaultPawn.apparel.Remove(apparel); break; } } })); FloatMenu menu = new Searchable_FloatMenu(list); Find.WindowStack.Add(menu); } //Torso Middle Slot if (Widgets.ButtonInvisible(ApparelTorsoMiddle)) { List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (ThingDef thing in DefDatabase <ThingDef> .AllDefs) { if (thing.IsApparel) { if (thing.apparel.layers.Contains(ApparelLayerDefOf.Middle) && thing.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso) && FactionColonies.canCraftItem(thing)) //CHANGE THIS { list.Add(new FloatMenuOption(thing.LabelCap + " - Cost: " + thing.BaseMarketValue, delegate { if (thing.MadeFromStuff) { //If made from stuff List <FloatMenuOption> stuffList = new List <FloatMenuOption>(); foreach (ThingDef stuff in DefDatabase <ThingDef> .AllDefs) { if (stuff.IsStuff && thing.stuffCategories.SharesElementWith(stuff.stuffProps .categories)) { stuffList.Add(new FloatMenuOption( stuff.LabelCap + " - Total Value: " + (StatWorker_MarketValue.CalculatedBaseMarketValue(thing, stuff)), delegate { selectedUnit.wearEquipment( ThingMaker.MakeThing(thing, stuff) as Apparel, true); })); } } stuffList.Sort(FactionColonies.CompareFloatMenuOption); FloatMenu stuffWindow = new Searchable_FloatMenu(stuffList); Find.WindowStack.Add(stuffWindow); } else { //If not made from stuff selectedUnit.wearEquipment(ThingMaker.MakeThing(thing) as Apparel, true); } }, thing)); } } } list.Sort(FactionColonies.CompareFloatMenuOption); list.Insert(0, new FloatMenuOption("unitActionUnequipThing".Translate(), delegate { //Remove old foreach (Apparel apparel in selectedUnit.defaultPawn.apparel.WornApparel) { if (apparel.def.apparel.layers.Contains(ApparelLayerDefOf.Middle) && apparel.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso)) //CHANGE THIS { selectedUnit.defaultPawn.apparel.Remove(apparel); break; } } })); FloatMenu menu = new Searchable_FloatMenu(list); Find.WindowStack.Add(menu); } //Torso Skin Slot if (Widgets.ButtonInvisible(ApparelTorsoSkin)) { List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (ThingDef thing in DefDatabase <ThingDef> .AllDefs) { if (thing.IsApparel) { if (thing.apparel.layers.Contains(ApparelLayerDefOf.OnSkin) && thing.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso) && FactionColonies.canCraftItem(thing)) //CHANGE THIS { list.Add(new FloatMenuOption(thing.LabelCap + " - Cost: " + thing.BaseMarketValue, delegate { if (thing.MadeFromStuff) { //If made from stuff List <FloatMenuOption> stuffList = new List <FloatMenuOption>(); foreach (ThingDef stuff in DefDatabase <ThingDef> .AllDefs) { if (stuff.IsStuff && thing.stuffCategories.SharesElementWith(stuff.stuffProps .categories)) { stuffList.Add(new FloatMenuOption( stuff.LabelCap + " - Total Value: " + (StatWorker_MarketValue.CalculatedBaseMarketValue(thing, stuff)), delegate { selectedUnit.wearEquipment( ThingMaker.MakeThing(thing, stuff) as Apparel, true); })); } } stuffList.Sort(FactionColonies.CompareFloatMenuOption); FloatMenu stuffWindow = new Searchable_FloatMenu(stuffList); Find.WindowStack.Add(stuffWindow); } else { //If not made from stuff selectedUnit.wearEquipment(ThingMaker.MakeThing(thing) as Apparel, true); } }, thing)); } } } list.Sort(FactionColonies.CompareFloatMenuOption); list.Insert(0, new FloatMenuOption("unitActionUnequipThing".Translate(), delegate { //Remove old foreach (Apparel apparel in selectedUnit.defaultPawn.apparel.WornApparel) { if (apparel.def.apparel.layers.Contains(ApparelLayerDefOf.OnSkin) && apparel.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso)) //CHANGE THIS { selectedUnit.defaultPawn.apparel.Remove(apparel); break; } } })); FloatMenu menu = new Searchable_FloatMenu(list); Find.WindowStack.Add(menu); } //Pants Slot if (Widgets.ButtonInvisible(ApparelLegs)) { List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (ThingDef thing in DefDatabase <ThingDef> .AllDefs) { if (thing.IsApparel) { if (thing.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs) && thing.apparel.layers.Contains(ApparelLayerDefOf.OnSkin) && FactionColonies.canCraftItem(thing)) //CHANGE THIS { list.Add(new FloatMenuOption(thing.LabelCap + " - Cost: " + thing.BaseMarketValue, delegate { if (thing.MadeFromStuff) { //If made from stuff List <FloatMenuOption> stuffList = new List <FloatMenuOption>(); foreach (ThingDef stuff in DefDatabase <ThingDef> .AllDefs) { if (stuff.IsStuff && thing.stuffCategories.SharesElementWith(stuff.stuffProps .categories)) { stuffList.Add(new FloatMenuOption( stuff.LabelCap + " - Total Value: " + (StatWorker_MarketValue.CalculatedBaseMarketValue(thing, stuff)), delegate { selectedUnit.wearEquipment( ThingMaker.MakeThing(thing, stuff) as Apparel, true); })); } } stuffList.Sort(FactionColonies.CompareFloatMenuOption); FloatMenu stuffWindow = new Searchable_FloatMenu(stuffList); Find.WindowStack.Add(stuffWindow); } else { //If not made from stuff selectedUnit.wearEquipment(ThingMaker.MakeThing(thing) as Apparel, true); } }, thing)); } } } list.Sort(FactionColonies.CompareFloatMenuOption); list.Insert(0, new FloatMenuOption("unitActionUnequipThing".Translate(), delegate { //Remove old foreach (Apparel apparel in selectedUnit.defaultPawn.apparel.WornApparel) { if (apparel.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs) && apparel.def.apparel.layers.Contains(ApparelLayerDefOf.OnSkin)) //CHANGE THIS { selectedUnit.defaultPawn.apparel.Remove(apparel); break; } } })); FloatMenu menu = new Searchable_FloatMenu(list); Find.WindowStack.Add(menu); } //Apparel Belt Slot if (Widgets.ButtonInvisible(ApparelBelt)) { List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (ThingDef thing in DefDatabase <ThingDef> .AllDefs) { if (thing.IsApparel) { if (thing.apparel.layers.Contains(ApparelLayerDefOf.Belt) && FactionColonies.canCraftItem(thing)) { list.Add(new FloatMenuOption(thing.LabelCap + " - Cost: " + thing.BaseMarketValue, delegate { if (thing.MadeFromStuff) { //If made from stuff List <FloatMenuOption> stuffList = new List <FloatMenuOption>(); foreach (ThingDef stuff in DefDatabase <ThingDef> .AllDefs) { if (stuff.IsStuff && thing.stuffCategories.SharesElementWith(stuff.stuffProps .categories)) { stuffList.Add(new FloatMenuOption( stuff.LabelCap + " - Total Value: " + (StatWorker_MarketValue.CalculatedBaseMarketValue(thing, stuff)), delegate { selectedUnit.wearEquipment( ThingMaker.MakeThing(thing, stuff) as Apparel, true); })); } } stuffList.Sort(FactionColonies.CompareFloatMenuOption); FloatMenu stuffWindow = new Searchable_FloatMenu(stuffList); Find.WindowStack.Add(stuffWindow); } else { //If not made from stuff //Remove old equipment foreach (Apparel apparel in selectedUnit.defaultPawn.apparel .WornApparel) { if (apparel.def.apparel.layers.Contains(ApparelLayerDefOf.Belt)) { selectedUnit.defaultPawn.apparel.Remove(apparel); break; } } selectedUnit.wearEquipment(ThingMaker.MakeThing(thing) as Apparel, true); } }, thing)); } } } list.Sort(FactionColonies.CompareFloatMenuOption); list.Insert(0, new FloatMenuOption("unitActionUnequipThing".Translate(), delegate { //Remove old foreach (Apparel apparel in selectedUnit.defaultPawn.apparel.WornApparel) { if (apparel.def.apparel.layers.Contains(ApparelLayerDefOf.Belt)) { selectedUnit.defaultPawn.apparel.Remove(apparel); break; } } })); FloatMenu menu = new Searchable_FloatMenu(list); Find.WindowStack.Add(menu); } //worn items float totalCost = 0; int i = 0; totalCost += (float)Math.Floor(selectedUnit.defaultPawn.def.BaseMarketValue * FactionColonies.militaryRaceCostMultiplier); foreach (Thing thing in selectedUnit.defaultPawn.apparel.WornApparel.Concat(selectedUnit.defaultPawn .equipment.AllEquipmentListForReading)) { Rect tmp = new Rect(ApparelWornItems.x, ApparelWornItems.y + i * 25, ApparelWornItems.width, 25); i++; totalCost += thing.MarketValue; if (Widgets.CustomButtonText(ref tmp, thing.LabelCap + " Cost: " + thing.MarketValue, Color.white, Color.black, Color.black)) { Find.WindowStack.Add(new Dialog_InfoCard(thing)); } } if (selectedUnit.animal != null) { Widgets.ButtonImage(AnimalCompanion, selectedUnit.animal.race.uiIcon); totalCost += (float)Math.Floor(selectedUnit.animal.race.BaseMarketValue * FactionColonies.militaryAnimalCostMultiplier); } foreach (Thing thing in selectedUnit.defaultPawn.apparel.WornApparel) { //Log.Message(thing.Label); if (thing.def.apparel.layers.Contains(ApparelLayerDefOf.Overhead)) { Widgets.ButtonImage(ApparelHead, thing.def.uiIcon); } if (thing.def.apparel.layers.Contains(ApparelLayerDefOf.Belt)) { Widgets.ButtonImage(ApparelBelt, thing.def.uiIcon); } if (thing.def.apparel.layers.Contains(ApparelLayerDefOf.Shell) && thing.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso)) { Widgets.ButtonImage(ApparelTorsoShell, thing.def.uiIcon); } if (thing.def.apparel.layers.Contains(ApparelLayerDefOf.Middle) && thing.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso)) { Widgets.ButtonImage(ApparelTorsoMiddle, thing.def.uiIcon); } if (thing.def.apparel.layers.Contains(ApparelLayerDefOf.OnSkin) && thing.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Torso)) { Widgets.ButtonImage(ApparelTorsoSkin, thing.def.uiIcon); } if (thing.def.apparel.bodyPartGroups.Contains(BodyPartGroupDefOf.Legs) && thing.def.apparel.layers.Contains(ApparelLayerDefOf.OnSkin)) { Widgets.ButtonImage(ApparelLegs, thing.def.uiIcon); } } foreach (Thing thing in selectedUnit.defaultPawn.equipment.AllEquipmentListForReading) { Widgets.ButtonImage(EquipmentWeapon, thing.def.uiIcon); } totalCost = (float)Math.Ceiling(totalCost); Widgets.Label(EquipmentTotalCost, "totalEquipmentCostLabel".Translate() + totalCost); }
public void DrawProductionHeaderLower(int x, int y, int spacing) { Text.Anchor = TextAnchor.MiddleRight; Text.Font = GameFont.Small; //Assigned workers Widgets.Label(new Rect(x, y, 410, 30), "AssignedWorkers".Translate() + ": " + settlement.getTotalWorkers().ToString() + " / " + settlement.workersMax.ToString() + " / " + settlement.workersUltraMax.ToString()); Text.Anchor = TextAnchor.MiddleCenter; Text.Font = GameFont.Tiny; //Item Headers Widgets.DrawHighlight(new Rect(x, y + 30, 40, 40)); Widgets.Label(new Rect(x, y + 30, 40, 40), "IsTithe".Translate() + "?"); Widgets.DrawHighlight(new Rect(x + 80, y + 30, 100, 40)); Widgets.Label(new Rect(x + 80, y + 30, 100, 40), "ProductionEfficiency".Translate()); Widgets.DrawHighlight(new Rect(x + 195, y + 30, 45, 40)); Widgets.Label(new Rect(x + 195, y + 30, 45, 40), "Base".Translate()); Widgets.DrawHighlight(new Rect(x + 250, y + 30, 50, 40)); Widgets.Label(new Rect(x + 250, y + 30, 50, 40), "Modifier".Translate()); Widgets.DrawHighlight(new Rect(x + 310, y + 30, 45, 40)); Widgets.Label(new Rect(x + 310, y + 30, 45, 40), "Final".Translate()); Widgets.DrawHighlight(new Rect(x + 365, y + 30, 45, 40)); Widgets.Label(new Rect(x + 365, y + 30, 45, 40), "EstimatedProfit".Translate()); Widgets.DrawHighlight(new Rect(x + 420, y + 30, 45, 40)); Widgets.Label(new Rect(x + 420, y + 30, 45, 40), "TaxPercentage".Translate()); //Per resource foreach (ResourceType resourceType in ResourceUtils.resourceTypes) { ResourceFC resource = settlement.getResource(resourceType); float rectY = scroll + y + 70 + (int)resourceType * (45 + spacing); if ((int)resourceType * ScrollSpacing + scroll < 0) { //if outside view } else { //loop through each resource //isTithe bool disabled = false; switch (resourceType) { case ResourceType.Research: case ResourceType.Power: disabled = true; break; default: if (Widgets.ButtonImage(new Rect(x - 15, scroll + y + 65 + (int)resourceType * (45 + spacing) + 8, 20, 20), TexLoad.iconCustomize)) { //if click faction customize button if (resource.filter == null) { resource.filter = new ThingFilter(); PaymentUtil.resetThingFilter(settlement, resourceType); } List <FloatMenuOption> options = new List <FloatMenuOption> { new FloatMenuOption("Enable All", delegate { PaymentUtil.resetThingFilter(settlement, resourceType); resource.returnLowestCost(); }), new FloatMenuOption("Disable All", delegate { resource.filter.SetDisallowAll(); resource.returnLowestCost(); }) }; List <ThingDef> things = PaymentUtil.debugGenerateTithe(resourceType); foreach (ThingDef thing in things.Where(thing => thing.race?.animalType != AnimalType.Dryad)) { if (!FactionColonies.canCraftItem(thing)) { resource.filter.SetAllow(thing, false); } else { FloatMenuOption option = new FloatMenuOption(thing.LabelCap + " - Cost - " + thing.BaseMarketValue + " | Allowed: " + resource.filter.Allows(thing), delegate { resource.filter.SetAllow(thing, !resource.filter.Allows(thing)); resource.returnLowestCost(); }, thing); options.Add(option); } } Find.WindowStack.Add(new FloatMenuSearchable(options)); //Log.Message("Settlement customize clicked"); } break; } Widgets.Checkbox(new Vector2(x + 8, scroll + y + 65 + (int)resourceType * (45 + spacing) + 8), ref resource.isTithe, 24, disabled); if (resource.isTithe != resource.isTitheBool) { resource.isTitheBool = resource.isTithe; //Log.Message("changed tithe"); settlement.updateProfitAndProduction(); windowUpdateFc(); } //Icon if (Widgets.ButtonImage(new Rect(x + 45, scroll + y + 75 + (int)resourceType * (45 + spacing), 30, 30), resource.getIcon())) { Find.WindowStack.Add(new DescWindowFc("SettlementProductionOf".Translate() + ": " + resource.label, char.ToUpper(resource.label[0]) + resource.label.Substring(1))); } //Production Efficiency Widgets.DrawBox(new Rect(x + 80, rectY, 100, 20)); Widgets.FillableBar(new Rect(x + 80, rectY, 100, 20), (float)Math.Min(resource.baseProductionMultiplier, 1.0)); Widgets.Label(new Rect(x + 80, scroll + y + 90 + (int)resourceType * (45 + spacing), 100, 20), "Workers".Translate() + ": " + resource.assignedWorkers.ToString()); if (Widgets.ButtonText(new Rect(x + 80, scroll + y + 90 + (int)resourceType * (45 + spacing), 20, 20), "<")) { if (settlement.isUnderAttack) { Messages.Message("SettlementUnderAttack".Translate(), MessageTypeDefOf.RejectInput); return; } //if clicked to lower amount of workers settlement.increaseWorkers(resourceType, -1); windowUpdateFc(); } if (Widgets.ButtonText(new Rect(x + 160, scroll + y + 90 + (int)resourceType * (45 + spacing), 20, 20), ">")) { if (settlement.isUnderAttack) { Messages.Message("SettlementUnderAttack".Translate(), MessageTypeDefOf.RejectInput); return; } //if clicked to lower amount of workers settlement.increaseWorkers(resourceType, 1); windowUpdateFc(); } //Base Production Widgets.Label(new Rect(x + 195, rectY, 45, 40), FactionColonies.FloorStat(resource.baseProduction)); //Final Modifier Widgets.Label(new Rect(x + 250, rectY, 50, 40), FactionColonies.FloorStat(resource.endProductionMultiplier)); //Final Base Widgets.Label(new Rect(x + 310, rectY, 45, 40), (FactionColonies.FloorStat(resource.endProduction))); //Est Income Widgets.Label(new Rect(x + 365, rectY, 45, 40), (FactionColonies.FloorStat(resource.endProduction * LoadedModManager .GetMod <FactionColoniesMod>().GetSettings <FactionColonies>().silverPerResource))); //Tithe Percentage resource.returnTaxPercentage(); string taxPercentage = FactionColonies.FloorStat(resource.taxPercentage) + "%"; Widgets.Label(new Rect(x + 420, rectY, 45, 40), taxPercentage); } } //Scroll window for resources if (Event.current.type == EventType.ScrollWheel) { scrollWindow(Event.current.delta.y); } }
public IEnumerable <Thing> ColonyThingsWillingToBuy(Pawn playerNegotiator) { foreach (Map map in Find.Maps) { if (map.IsPlayerHome) { foreach (Thing thing in map.listerThings.AllThings) { if (thing.IsInAnyStorage() == true && thing.def.category == ThingCategory.Item && TradeUtility.PlayerSellableNow(thing, this) && !FactionColonies.canCraftItem(thing.def, true)) { yield return(thing); } } } } }
public override bool HandlesThingDef(ThingDef thingDef) { FactionFC factionfc = Find.World.GetComponent <FactionFC>(); return(!FactionColonies.canCraftItem(thingDef, true)); }