public override void SpawnSetup(Map map, bool respawningAfterLoad) { base.SpawnSetup(map, respawningAfterLoad); itemFilterComp = GetComp <CompInnerContainerItemFilter>(); refuelableComp = GetComp <CompRefuelable>(); breakdownableComp = GetComp <CompBreakdownable>(); powerComp = GetComp <CompPowerTrader>(); if (Faction != null && Faction.IsPlayer) { contentsKnown = true; } }
public override Job JobOnThing(Pawn pawn, Thing thing, bool forced = false) { if (!HaulAIUtility.PawnCanAutomaticallyHaul(pawn, thing, forced) || !pawn.CanReserve(thing, 1, -1, null, forced) || thing.IsForbidden(pawn) || thing.IsBurning()) { return(null); } if (pawn.Map.designationManager.DesignationOn(thing, DefDatabase <DesignationDef> .GetNamed("HaulToEnchant")) == null) { return(null); } foreach (Building building in pawn.Map.listerBuildings.allBuildingsColonist) { if (!(building is Building_ProductionResearchBench_InternalRecipes)) { continue; } CompInnerContainerItemFilter filter = building.GetComp <CompInnerContainerItemFilter>(); int quantity = -1; if (filter == null) { continue; } quantity = filter.AcceptsHowMany(thing); if (quantity <= 0) { continue; } if (!pawn.CanReserveAndReach(building, PathEndMode.Touch, pawn.NormalMaxDanger(), 1, -1, null, false)) { continue; } Job job = HaulAIUtility_Helper.HaulToBuildingJob(pawn, thing, building, quantity); if (job != null) { return(job); } } JobFailReason.Is(NoEnchantingBuildingsWithSufficientStorageFoundTrans); return(null); }
public override void ExposeData() { base.ExposeData(); if (Scribe.mode == LoadSaveMode.PostLoadInit) { if (itemFilterComp == null) { itemFilterComp = GetComp <CompInnerContainerItemFilter>(); } } Scribe_Values.Look(ref itemFilterComp, "itemFilterComp", null, false); Scribe_Deep.Look(ref billStack, "billStack", new object[] { this }); Scribe_Deep.Look(ref innerContainer, "innerContainer", new object[] { this }); Scribe_Values.Look(ref contentsKnown, "contentsKnown", false, false); }
protected override void FillTab() { ThingOwner thingOwner = SelTable.GetDirectlyHeldThings(); CompInnerContainerItemFilter itemFilterComp = SelTable.GetComp <CompInnerContainerItemFilter>(); Rect baseRect = new Rect(0f, 0f, WinSize.x, WinSize.y).ContractedBy(10f); GUI.BeginGroup(baseRect); // Entire Window // DoEnchantBills(); // Enchantables List <Thing> enchantables = new List <Thing>(); foreach (Thing thing in thingOwner) { foreach (ThingCategoryDef thingCategoryDef in thing.def.thingCategories) { CompStorableByDesignation storableComp = thing.TryGetComp <CompStorableByDesignation>(); if (thingCategoryDef == EnchantableCategoryDef && !storableComp.inUseByBill) { enchantables.Add(thing); } } } Rect enchantablesOuterRect = new Rect(0f, 220f, baseRect.width, 116f); Rect enchantablesViewRect = new Rect( enchantablesOuterRect.x, 0f, enchantablesOuterRect.width - 16f, enchantables.NullOrEmpty() ? enchantablesOuterRect.height : enchantables.Count * EnchantableThingHeight + (enchantables.Count - 1) * EnchantableVerticalGap); Rect enchantablesLabelRect = new Rect(enchantablesOuterRect.x, enchantablesOuterRect.y - 30f, enchantablesOuterRect.width, 30f); Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.yellow; Widgets.Label(enchantablesLabelRect, "EnchantableItemsLabel".Translate()); GUI.color = Color.gray; Widgets.BeginScrollView(enchantablesOuterRect, ref enchantablesScrollPosition, enchantablesViewRect, true); GUI.BeginGroup(enchantablesViewRect); if (enchantables.NullOrEmpty()) { Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperCenter; GUI.color = Color.white; Widgets.Label(enchantablesViewRect, "EnchantableInstructionsTrans".Translate()); } else { DoEnchantables(thingOwner, enchantablesViewRect, enchantables); } GUI.EndGroup(); // enchantablesViewRect Widgets.EndScrollView(); // Soul Gems List <Thing> soulGems = new List <Thing>(); foreach (Thing thing in thingOwner) { foreach (ThingCategoryDef thingCategoryDef in thing.def.thingCategories) { CompStorableByDesignation storableComp = thing.TryGetComp <CompStorableByDesignation>(); if (thingCategoryDef == SoulGemCategoryDef && !storableComp.inUseByBill) { soulGems.Add(thing); } } } int maxPerRow = (int)(baseRect.width / SoulGemWidth) - 1; Rect soulGemsOuterRect = new Rect(0f, 370f, baseRect.width, 94f); Rect soulGemsViewRect = new Rect( soulGemsOuterRect.x, 0f, soulGemsOuterRect.width - 16f, soulGems.NullOrEmpty() ? soulGemsOuterRect.height : (soulGems.Count / maxPerRow) * SoulGemHeight + (soulGems.Count - 1) * SoulGemVerticalGap); Rect soulGemsLabelRect = new Rect(soulGemsOuterRect.x, soulGemsOuterRect.y - 30f, soulGemsOuterRect.width, 30f); Text.Font = GameFont.Medium; Text.Anchor = TextAnchor.UpperLeft; GUI.color = Color.yellow; Widgets.Label(soulGemsLabelRect, "SoulGemsLabel".Translate()); GUI.color = Color.gray; Widgets.BeginScrollView(soulGemsOuterRect, ref soulGemsScrollPosition, soulGemsViewRect, true); GUI.BeginGroup(soulGemsViewRect); if (soulGems.NullOrEmpty()) { Text.Font = GameFont.Small; Text.Anchor = TextAnchor.UpperCenter; GUI.color = Color.white; Widgets.Label(soulGemsViewRect, "SoulGemsInstructionsTrans".Translate()); } else { DoSoulGems(thingOwner, soulGemsViewRect, soulGems); } GUI.EndGroup(); // soulGemsViewRect Widgets.EndScrollView(); GUI.EndGroup(); // baseRect Text.Anchor = TextAnchor.UpperLeft; }