public static void TentCanHaveFaction(ThingDef __instance, ref bool __result) { if (__instance.Equals(TentDefOf.NCS_TentBag)) { __result = true; } }
public static void NewBlueprintDef_Tent(ThingDef def, ref ThingDef __result) { if (def.Equals(TentDefOf.NCS_TentBag) && __result.defName.Equals(ThingDefGenerator_Buildings.BlueprintDefNamePrefix + ThingDefGenerator_Buildings.InstallBlueprintDefNamePrefix + def.defName)) // Tent bag match should only happen once, but just to be sure string match the install blueprint { __result.thingClass = typeof(TentBlueprint_Install); __result.drawerType = DrawerType.RealtimeOnly; } }
/* * Tells me whether or not a ThingDef is what I want */ private static bool IsThis(ThingDef def, string name) { if (name == "Stone" && def.IsWithinCategory(ThingCategoryDefOf.StoneBlocks)) { return(true); } try { return(def.Equals(DefDatabase <ThingDef> .GetNamed(name, false))); } catch { return(false); } }
public static void ProcessBlueprint(Blueprint blueprint, ScatterOptions options) { if (blueprint == null) { return; } //Each item should be checked if it can be placed or not. This should help preventing situations when simulated scavenging removes things which anyway won't be placed. //For each placed item it's cost should be calculated for (int x = 0; x < blueprint.width; x++) { for (int z = 0; z < blueprint.height; z++) { List <ItemTile> items = blueprint.itemsMap[x, z]; TerrainTile terrain = blueprint.terrainMap[x, z]; TerrainDef terrainDef = null; if (terrain != null) { terrainDef = DefDatabase <TerrainDef> .GetNamed(terrain.defName, false); if (terrainDef == null) { blueprint.terrainMap[x, z] = null; //remove unloadable terrain terrain = null; } } List <ItemTile> itemsToRemove = new List <ItemTile>(); if (items == null) { continue; } foreach (ItemTile item in items) { if (item.defName == "Corpse") { continue; //TODO: make some better way of handling corpses } //We can't move further with corpse item, because this item's thingDef is always null (actual corpse's def name depends on it's kind) ThingDef thingDef = DefDatabase <ThingDef> .GetNamed(item.defName, false); if (thingDef == null) { itemsToRemove.Add(item); continue; } //remove items we don't want to see in the ruins if (thingDef == ThingDefOf.Campfire || thingDef == ThingDefOf.TorchLamp) { itemsToRemove.Add(item); continue; } if (options.wallsDoorsOnly) //eleminate almost everything if "doors & walls" setting is active { if (!thingDef.IsDoor && !item.defName.ToLower().Contains("wall")) { itemsToRemove.Add(item); continue; } } if (options.disableSpawnItems) //eleminate haulables if corresponding tick is set { if (thingDef.EverHaulable) { itemsToRemove.Add(item); continue; } } if (thingDef.defName.Contains("Animal") || thingDef.defName.Contains("Spot")) { itemsToRemove.Add(item); continue; //remove animal sleeping beds and spots as wild animals tend to concentrate around. remove wedding, butchering and party spots, caravan spots as well } if (thingDef.IsCorpse || thingDef.Equals(ThingDefOf.MinifiedThing)) //check if corpses and minified things contain inner data, otherwise ignore { if ((item.innerItems?.Count() ?? 0) == 0 && item.itemXml == null) { itemsToRemove.Add(item); continue; } } } foreach (ItemTile item in itemsToRemove) { if (item.isWall || item.isDoor) { blueprint.RemoveWall(item.location.x, item.location.z); } items.Remove(item); } } } //Recalculate cost data after removing some items (should speed up, as cost calculation seems to be cpu-expensive process) blueprint.UpdateBlueprintStats(true); //Perform removing all items exceeding maximum cost for (int x = 0; x < blueprint.width; x++) { for (int z = 0; z < blueprint.height; z++) { List <ItemTile> items = blueprint.itemsMap[x, z]; TerrainTile terrain = blueprint.terrainMap[x, z]; List <ItemTile> itemsToRemove = new List <ItemTile>(); if (terrain != null) { if (terrain.cost > options.itemCostLimit) { blueprint.terrainMap[x, z] = null; } } if (items == null) { continue; } foreach (ItemTile item in items) { if (options.itemCostLimit > 0 && options.itemCostLimit < 1000) //filter too expensive items. limit of 1000 means "no limit" actually { if (item.cost > options.itemCostLimit) //removes only items where at least one item is more expensive than limit we have. limiting stacks is done later. { itemsToRemove.Add(item); } } } foreach (ItemTile item in itemsToRemove) { if (item.isWall || item.isDoor) { blueprint.RemoveWall(item.location.x, item.location.z); } items.Remove(item); } } } }