// RimWorld.AreaAllowedGUI public static void DoStockpileSelectors(Rect rect, ref Zone_Stockpile stockpile, Map map) { // get all stockpiles List <Zone_Stockpile> allStockpiles = map.zoneManager.AllZones.OfType <Zone_Stockpile>().ToList(); // count + 1 for all stockpiles int areaCount = allStockpiles.Count + 1; // create colour swatch if (textures == null || textures.Count != areaCount - 1) { CreateTextures(allStockpiles); } float widthPerCell = rect.width / areaCount; Text.WordWrap = false; Text.Font = GameFont.Tiny; var nullAreaRect = new Rect(rect.x, rect.y, widthPerCell, rect.height); DoZoneSelector(nullAreaRect, ref stockpile, null, BaseContent.GreyTex); var areaIndex = 1; for (var j = 0; j < allStockpiles.Count; j++) { float xOffset = areaIndex * widthPerCell; var stockpileRect = new Rect(rect.x + xOffset, rect.y, widthPerCell, rect.height); DoZoneSelector(stockpileRect, ref stockpile, allStockpiles[j], textures[j]); areaIndex++; } Text.WordWrap = true; Text.Font = GameFont.Small; }
public ZoneContainer(Zone_Stockpile stockpile) : base(new Version(1, 0)) { ThingFilter filter = stockpile.settings.filter; Stockpile = stockpile; Color = stockpile.color; Priority = stockpile.settings.Priority; Reflection = new ThingFilterReflection(filter); // Allowed things var allowed = from thing in Reflection.AllStorableThingDefs where filter.Allows(thing) select thing; AllowedThings = new List <ThingDef>(allowed); // Can configure HP if (filter.allowedHitPointsConfigurable) { AllowedHitPoints = filter.AllowedHitPointsPercents; } // Can configure Qualities if (filter.allowedQualitiesConfigurable) { AllowedQualities = filter.AllowedQualityLevels; } // Disallowed Specials DisallowedSpecialThings = Reflection.DisallowedSpecialFilters; }
// RimWorld.AreaAllowedGUI private static void DoZoneSelector(Rect rect, ref Zone_Stockpile zoneAllowed, Zone_Stockpile zone, Texture2D tex) { rect = rect.ContractedBy(1f); GUI.DrawTexture(rect, tex); Text.Anchor = TextAnchor.MiddleLeft; string label = zone?.label ?? "Any stockpile"; Rect innerRect = rect; innerRect.xMin += 3f; innerRect.yMin += 2f; Widgets.Label(innerRect, label); if (zoneAllowed == zone) { Widgets.DrawBox(rect, 2); } if (Mouse.IsOver(rect)) { if (zone != null) { if (zone.AllSlotCellsList() != null && zone.AllSlotCellsList().Count > 0) { CameraJumper.TryJump(zone.Cells.First(), zone.Map); } } if (Input.GetMouseButton(0) && zoneAllowed != zone) { zoneAllowed = zone; SoundDefOf.Designate_DragStandard_Changed.PlayOneShotOnCamera(); } } TooltipHandler.TipRegion(rect, label); Text.Anchor = TextAnchor.UpperLeft; }
private static void NoStorageBlockersIn_Lazy_PostFix(IntVec3 c, Map map, Thing thing, ref bool __result) { Zone_Stockpile generic = map.zoneManager.ZoneAt(c) as Zone_Stockpile; if (__result && generic != null) { LazySettings stockPile = LazySettingsManager.AddOrGetSettings(generic.settings); if (stockPile == null) { //Log.Error("The stockpile settings are not Lazy. Will not utilize lazy settings at all."); return; } if (stockPile.type == LazyType.Cache) { List <Thing> list = map.thingGrid.ThingsListAt(c); for (int i = 0; i < list.Count; i++) { Thing potentialBlocker = list[i]; if (potentialBlocker.def.EverStorable(false) && potentialBlocker.Ratio() > stockPile.CacheThreshold) { __result = false; return; } } } else if (stockPile.type == LazyType.Buffer) { //if the thing we are trying to place is trying to go into the same stockpile that it is already in, and the stockpile is a lazy buffer, do not let it place itself back in //this should only be reached because the buffer is trying to get rid of the stack (greater than the threshold) LazySettings thingStock = LazySettingsManager.AddOrGetSettings(thing.GetSlotGroup()?.Settings); __result = stockPile != thingStock; } } }
protected override Zone MakeNewZone() { Zone_Stockpile zone_Stockpile = new Zone_Stockpile(StorageSettingsPreset.DefaultStockpile); if (this.emptyZonePreference != null && this.emptyZonePreference.Value) { if (Find.ZoneManager.AllZones.Count((Zone zone) => zone is Zone_Stockpile) > 1) { ThingFilter filter = zone_Stockpile.GetStoreSettings().filter; this.thingDefs.Clear(); foreach (ThingDef current in filter.AllowedThingDefs) { this.thingDefs.Add(current); } foreach (ThingDef current2 in this.thingDefs) { filter.SetAllow(current2, false); } foreach (SpecialThingFilterDef current3 in DefDatabase <SpecialThingFilterDef> .AllDefs) { if (filter.Allowed(current3)) { filter.SetAllow(current3, false); } } } } return(zone_Stockpile); }
public MapStockpileFilter(Map map, ThingFilter filter, Zone_Stockpile stockpile, bool countAllOnMap = false) { this.map = map; this.filter = filter; this.stockpile = stockpile; this.countAllOnMap = countAllOnMap; }
public bool GetTargetZone(Map map) { List <Zone> zones = map.zoneManager.AllZones; if (zones != null && zones.Any()) { foreach (Zone zone in zones) { Zone_Stockpile stockpile = zone as Zone_Stockpile; if (stockpile != null) { List <IntVec3> cells = zone.cells as List <IntVec3>; if (cells == null || !cells.Any()) { continue; } int foodAmount = 0; foreach (IntVec3 cell in cells) { Thing thing = map.thingGrid.ThingAt(cell, ThingCategory.Item); if (thing != null && !thing.def.IsCorpse && thing.IngestibleNow) { foodAmount += thing.stackCount; if (foodAmount >= 300) { targetZone = zone as Zone; return(true); } } } } } } return(false); }
// RimWorld.AreaAllowedGUI public static void DoStockpileSelectors( Rect rect, ref Zone_Stockpile stockpile, Map map ) { // get all stockpiles List<Zone_Stockpile> allStockpiles = map.zoneManager.AllZones.OfType<Zone_Stockpile>().ToList(); // count + 1 for all stockpiles int areaCount = allStockpiles.Count + 1; // create colour swatch if ( textures == null || textures.Count != areaCount - 1 ) CreateTextures( allStockpiles ); float widthPerCell = rect.width / areaCount; Text.WordWrap = false; Text.Font = GameFont.Tiny; Rect nullAreaRect = new Rect( rect.x, rect.y, widthPerCell, rect.height ); DoZoneSelector( nullAreaRect, ref stockpile, null, BaseContent.GreyTex ); int areaIndex = 1; for( int j = 0; j < allStockpiles.Count; j++ ) { float xOffset = areaIndex * widthPerCell; Rect stockpileRect = new Rect( rect.x + xOffset, rect.y, widthPerCell, rect.height ); DoZoneSelector( stockpileRect, ref stockpile, allStockpiles[j], textures[j] ); areaIndex++; } Text.WordWrap = true; Text.Font = GameFont.Small; }
public void ExposeData() { Scribe_Deep.Look(ref OutputFilter, "outputFilter", new object[0]); Scribe_Values.Look(ref AllowDeadmansApparel, "allowDeadmansApparel", false); Scribe_Values.Look(ref CountWornApparel, "countWornApparel", false); Scribe_Values.Look(ref UseInputFilter, "useInputFilter", false); Scribe_References.Look(ref Worker, "worker"); Scribe_Values.Look(ref Name, "name", null); // Stockpiles need special treatment; they cannot be referenced. if (Scribe.mode == LoadSaveMode.Saving) { _countingStockpileName = _countingStockpile?.label ?? "null"; _takeToStockpileName = _takeToStockpile?.label ?? "null"; } Scribe_Values.Look(ref _countingStockpileName, "countingStockpile", "null"); Scribe_Values.Look(ref _takeToStockpileName, "takeToStockpile", "null"); if (Scribe.mode == LoadSaveMode.PostLoadInit) { _countingStockpile = _countingStockpileName == "null" ? null : Find.VisibleMap.zoneManager.AllZones.FirstOrDefault(z => z is Zone_Stockpile && z.label == _countingStockpileName) as Zone_Stockpile; _takeToStockpile = _takeToStockpileName == "null" ? null : Find.VisibleMap.zoneManager.AllZones.FirstOrDefault(z => z is Zone_Stockpile && z.label == _takeToStockpileName) as Zone_Stockpile; } }
// RimWorld.AreaAllowedGUI private static void DoZoneSelector( Rect rect, ref Zone_Stockpile zoneAllowed, Zone_Stockpile zone, Texture2D tex) { rect = rect.ContractedBy( 1f ); GUI.DrawTexture( rect, tex ); Text.Anchor = TextAnchor.MiddleLeft; string label = zone?.label ?? "Any stockpile"; Rect innerRect = rect; innerRect.xMin += 3f; innerRect.yMin += 2f; Widgets.Label( innerRect, label ); if( zoneAllowed == zone ) { Widgets.DrawBox( rect, 2 ); } if( Mouse.IsOver( rect ) ) { if( zone != null ) { if ( zone.AllSlotCellsList() != null && zone.AllSlotCellsList().Count > 0 ) Find.CameraDriver.JumpTo( zone.AllSlotCellsList().FirstOrDefault() ); } if( Input.GetMouseButton( 0 ) && zoneAllowed != zone ) { zoneAllowed = zone; SoundDefOf.DesignateDragStandardChanged.PlayOneShotOnCamera(); } } TooltipHandler.TipRegion( rect, label ); Text.Anchor = TextAnchor.UpperLeft; }
public virtual bool CanPossiblyStoreInStockpile(Bill_Production bill, Zone_Stockpile stockpile) { if (!CanCountProducts(bill)) { return(true); } return(stockpile.GetStoreSettings().AllowedToAccept(recipe.products[0].thingDef)); }
public Command_StorageSettingsPresets(Zone_Stockpile stockpile) { icon = ContentFinder <Texture2D> .Get("UI/Commands/StorageSettingsPresets", true); defaultLabel = "CommandStorageSettingsPresetsLabel".Translate(); defaultDesc = "CommandStorageSettingsPresetsDesc".Translate(); filter = stockpile.settings.filter; }
public static void Postfix(Thing newItem, Zone_Stockpile __instance) //not actually newItem, but lost item (following B18 rimworld naming { //Log.Message("removed thing to stockpile: " + newItem); if (!__instance.settings.filter.Allows(CountCompletedDefOf.CountCompleted)) { __instance.Map.GetComponent <UncountCompletedThingTracker>().UpdateCounter(newItem.def, -newItem.stackCount); } }
public static void Postfix(Thing newItem, Zone_Stockpile __instance) { //Log.Message("added thing to stockpile: " + newItem); if (!__instance.settings.filter.Allows(CountCompletedDefOf.CountCompleted)) { __instance.Map.GetComponent <UncountCompletedThingTracker>().UpdateCounter(newItem.def, newItem.stackCount); } }
public Command_StorageSettingsPresets(Zone_Stockpile stockpile) { icon = StoragePresetsTex; defaultLabel = ResourceBank.Label; defaultDesc = ResourceBank.Description; this.stockpile = stockpile; }
public static void Postfix(Zone_Stockpile __instance) { KSLog.Message("[KanbanStockpile] Zone_Stockpile_PostDeregister_Patch.Postfix()"); if (State.Exists(__instance.ToString())) { KSLog.Message("[KanbanStockpile] Removing " + __instance.ToString()); State.Del(__instance.ToString()); } }
public ColorSelectDialog(Zone_Stockpile stockpile) : base() { if (ColorPresets == null) { ColorPresets = IOUtil.LoadColorPresets(); } this.stockpile = stockpile; this.SelectionColorWidget = new SelectionColorWidget(stockpile.color); this.SelectionColorWidget.SelectionChangeListener += this.updateMaterial; }
static void Postfix(Zone_Stockpile __instance, ref IEnumerable <Gizmo> __result) { SaveDialog.Stockpile = __instance; LoadDialog.Stockpile = __instance; __result = new List <Gizmo>(__result) { SaveGizmo, LoadGizmo }; }
/// <summary> /// Called by the game when the player creates a zone. This is when the custom zone is created with the settings specified in it's XML. /// </summary> /// <returns>The new custom zone.</returns> protected override Zone MakeNewZone() { // Create the zone, setting the custom settings. Zone_Stockpile zone = new Zone_Stockpile(this.preset); zone.settings.CopyFrom(this.storageSettings); zone.label = this.defaultLabel; return((Zone)zone); }
public bool StockpileIsTradeStockpile(Zone_Stockpile stockpile) { for (int i = 0; i < TradeStockpileNames.Count; i++) { if (TradeStockpileNames[i].Equals(stockpile.label) && TradeStockpileMapIds[i] == stockpile.Map.Index) { return(true); } } return(false); }
public static void Postfix(IntVec3 sq, Zone_Stockpile __instance) //not actually newItem, but lost item (following B18 rimworld naming { //Log.Message("removecell: " + sq.ToString()); if (!__instance.settings.filter.Allows(CountCompletedDefOf.CountCompleted)) { foreach (Thing thing in sq.GetThingList(__instance.Map)) { __instance.Map.GetComponent <UncountCompletedThingTracker>().UpdateCounter(thing.def, -thing.stackCount); } } }
public static void Postfix(IntVec3 sq, Zone_Stockpile __instance) { //Log.Message("addcell: " + sq.ToString()); if (!__instance.settings.filter.Allows(CountCompletedDefOf.CountCompleted)) { foreach (Thing thing in sq.GetThingList(__instance.Map)) { __instance.Map.GetComponent <UncountCompletedThingTracker>().UpdateCounter(thing.def, thing.stackCount); } } }
//protected override string NewZoneLabel { // get { // return Static.GetEnumDescription(preset); // } //} protected override Zone MakeNewZone() { Zone_Stockpile zone = base.MakeNewZone() as Zone_Stockpile; if (zone != null) { zone.settings.filter = DefaultFilters.GetFilterFromPreset(presetZoneType); zone.color = PresetZoneColorUtility.NewZoneColor(presetZoneType); } return(zone); }
public void CloneFrom(ExtendedBillData other) { OutputFilter.CopyAllowancesFrom(other.OutputFilter); AllowDeadmansApparel = other.AllowDeadmansApparel; CountWornApparel = other.CountWornApparel; UseInputFilter = other.UseInputFilter; Worker = other.Worker; Name = other.Name; _countingStockpile = other._countingStockpile; _takeToStockpile = other._takeToStockpile; }
public void RemoveTradeStockpile(Zone_Stockpile stockpile) { for (int i = 0; i < TradeStockpileNames.Count; i++) { if (TradeStockpileNames[i].Equals(stockpile.label) && TradeStockpileMapIds[i] == stockpile.Map.Index) { TradeStockpileNames.RemoveAt(i); TradeStockpileMapIds.RemoveAt(i); return; } } }
public static void SetRetaining(this Zone_Stockpile z, bool value) { var hs = HaulExplicitly.GetRetainingZones(); if (value) { hs.Add(z); } else { hs.Remove(z); } }
public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot) { IEnumerable <IntVec3> cells = GenAdj.CellsOccupiedBy(loc, rot, checkingDef.Size); foreach (IntVec3 cell in cells) { Zone_Stockpile zoneStockpile = cell.GetZone() as Zone_Stockpile; if (zoneStockpile != null && zoneStockpile.FindWarehouse() != null) { return("PlaceWorker_RTOnlyOneQWPerZone".Translate()); } } return(true); }
public override bool CanPossiblyStoreInStockpile(Bill_Production bill, Zone_Stockpile stockpile) { foreach (ThingDef allowedThingDef in bill.ingredientFilter.AllowedThingDefs) { if (!allowedThingDef.butcherProducts.NullOrEmpty()) { if (!stockpile.GetStoreSettings().AllowedToAccept(allowedThingDef)) { return(false); } } } return(true); }
static void Postfix(Zone_Stockpile __instance, ref IEnumerable <Gizmo> __result) { List <Gizmo> l = new List <Gizmo>(__result); Command_Action a = new Command_Action(); a.icon = Dialog.ColorSelectDialog.ChangeColorTexture; a.defaultLabel = "ReColorStockpile.ChangeColor".Translate(); a.defaultDesc = "ReColorStockpile.ChangeColorDesc".Translate(); a.activateSound = SoundDef.Named("Click"); a.action = delegate { Find.WindowStack.Add(new Dialog.ColorSelectDialog(__instance)); }; a.groupKey = 987767550; l.Add(a); __result = l; }
public override bool CanPossiblyStoreInStockpile(Bill_Production bill, Zone_Stockpile stockpile) { foreach (ThingDef current in bill.ingredientFilter.AllowedThingDefs) { if (!current.butcherProducts.NullOrEmpty <ThingDefCountClass>()) { ThingDef thingDef = current.butcherProducts[0].thingDef; if (!stockpile.GetStoreSettings().AllowedToAccept(thingDef)) { return(false); } } } return(true); }
private static void GetGizmos(Zone_Stockpile __instance, ref IEnumerable <Gizmo> __result) { if (QOLTweaksPack.TradingStockpiles.Value == false) { return; } List <Gizmo> results = new List <Gizmo>(); foreach (Gizmo gizmo in __result) { results.Add(gizmo); } results.Add(new Gizmo_TradeStockpileToggle(__instance)); __result = results; }
public override bool CanPossiblyStoreInStockpile(Bill_Production bill, Zone_Stockpile stockpile) { foreach (ThingDef allowedThingDef in bill.ingredientFilter.AllowedThingDefs) { if (allowedThingDef.ingestible != null && allowedThingDef.ingestible.sourceDef != null) { RaceProperties race = allowedThingDef.ingestible.sourceDef.race; if (race != null && race.meatDef != null && !stockpile.GetStoreSettings().AllowedToAccept(race.meatDef)) { return(false); } } } return(true); }
public override void SpawnSetup() { base.SpawnSetup(); deliveryZone1 = null; deliveryZone2 = null; }
public override void ExposeData() { Scribe_Values.LookValue( ref Count, "Count" ); Scribe_Values.LookValue( ref MaxUpperThreshold, "MaxUpperThreshold" ); Scribe_Values.LookValue( ref Op, "Operator" ); Scribe_Deep.LookDeep( ref ThresholdFilter, "ThresholdFilter" ); // stockpile needs special treatment - is not referenceable. if ( Scribe.mode == LoadSaveMode.Saving ) { _stockpile_scribe = stockpile?.ToString() ?? "null"; } Scribe_Values.LookValue( ref _stockpile_scribe, "Stockpile", "null" ); if ( Scribe.mode == LoadSaveMode.PostLoadInit ) { stockpile = manager.map.zoneManager.AllZones.FirstOrDefault( z => z is Zone_Stockpile && z.label == _stockpile_scribe ) as Zone_Stockpile; } }