protected override void RunInt() { Slate slate = QuestGen.slate; MonumentMarker monumentMarker = (MonumentMarker)ThingMaker.MakeThing(ThingDefOf.MonumentMarker); monumentMarker.sketch = sketch.GetValue(slate); slate.Set(storeAs.GetValue(slate), monumentMarker); }
protected override void RunInt() { Slate slate = QuestGen.slate; MonumentMarker value = monumentMarker.GetValue(slate); for (int i = 0; i < value.sketch.Things.Count; i++) { ThingDef def = value.sketch.Things[i].def; ThingDef stuff = value.sketch.Things[i].stuff; if (def.category == ThingCategory.Building && !def.BuildableByPlayer) { MinifiedThing obj = ThingMaker.MakeThing(def, stuff).MakeMinified(); QuestGenUtility.AddToOrMakeList(QuestGen.slate, addToList.GetValue(slate), obj); } } }
public static void VampExceptionsForMonumentMarkers(MonumentMarker __instance, ref Thing __result) { if (__result?.def?.defName == "ROMV_SarcophagusBed") { //Log.ErrorOnce("VampExceptionTriggered", 828676); if (!__instance.Spawned) { __result = null; return; } List <SketchTerrain> terrain = __instance.sketch.Terrain; for (int i = 0; i < terrain.Count; i++) { var tmpAllowedBuildings = (List <ThingDef>)AccessTools.Field(typeof(MonumentMarker), "tmpAllowedBuildings").GetValue(__instance); tmpAllowedBuildings.Clear(); SketchThing sketchThing; List <SketchThing> list; __instance.sketch.ThingsAt(terrain[i].pos, out sketchThing, out list); //Add sarcophagus sleep spot tmpAllowedBuildings.Add(__result.def); if (sketchThing != null) { tmpAllowedBuildings.Add(sketchThing.def); } if (list != null) { for (int j = 0; j < list.Count; j++) { tmpAllowedBuildings.Add(list[j].def); } } List <Thing> thingList = (terrain[i].pos + __instance.Position).GetThingList(__instance.Map); for (int k = 0; k < thingList.Count; k++) { if (thingList[k].def.IsBuildingArtificial && !thingList[k].def.IsBlueprint && !thingList[k].def.IsFrame && !tmpAllowedBuildings.Contains(thingList[k].def)) { __result = thingList[k]; return; } } } __result = null; return; } }
private void DoWork(Slate slate) { MonumentMarker value = monumentMarker.GetValue(slate); if (value == null) { if (!storeMarketValueAs.GetValue(slate).NullOrEmpty()) { slate.Set(storeMarketValueAs.GetValue(slate), 0f); } return; } Dictionary <ThingDef, int> dictionary = new Dictionary <ThingDef, int>(); List <Pair <List <StuffCategoryDef>, int> > list2 = new List <Pair <List <StuffCategoryDef>, int> >(); List <List <Pair <ThingDef, int> > > list3 = new List <List <Pair <ThingDef, int> > >(); SketchTerrain sketchTerrain; int num = value.sketch.Entities.Where((SketchEntity x) => (sketchTerrain = (x as SketchTerrain)) != null && sketchTerrain.treatSimilarAsSame).Count(); foreach (SketchEntity entity in value.sketch.Entities) { SketchBuildable sketchBuildable = entity as SketchBuildable; if (sketchBuildable != null) { SketchTerrain st; if (sketchBuildable.Buildable.MadeFromStuff && sketchBuildable.Stuff == null) { int num2 = FindStuffsIndexFor(sketchBuildable.Buildable, list2); if (num2 < 0) { list2.Add(new Pair <List <StuffCategoryDef>, int>(sketchBuildable.Buildable.stuffCategories, sketchBuildable.Buildable.costStuffCount)); } else { list2[num2] = new Pair <List <StuffCategoryDef>, int>(list2[num2].First, list2[num2].Second + sketchBuildable.Buildable.costStuffCount); } if (sketchBuildable.Buildable.costList != null) { for (int i = 0; i < sketchBuildable.Buildable.costList.Count; i++) { ThingDefCountClass thingDefCountClass = sketchBuildable.Buildable.costList[i]; if (!dictionary.TryGetValue(thingDefCountClass.thingDef, out int value2)) { value2 = 0; } dictionary[thingDefCountClass.thingDef] = value2 + thingDefCountClass.count; } } } else if ((st = (sketchBuildable as SketchTerrain)) != null && st.treatSimilarAsSame) { foreach (TerrainDef item in DefDatabase <TerrainDef> .AllDefs.Where((TerrainDef x) => st.IsSameOrSimilar(x))) { if (!item.costList.NullOrEmpty()) { List <Pair <ThingDef, int> > list = new List <Pair <ThingDef, int> >(); foreach (ThingDefCountClass cost in item.costList) { list.Add(new Pair <ThingDef, int>(cost.thingDef, cost.count * num)); } if (!list3.Any((List <Pair <ThingDef, int> > x) => x.ListsEqualIgnoreOrder(list))) { list3.Add(list); } } } } else { List <ThingDefCountClass> list4 = sketchBuildable.Buildable.CostListAdjusted(sketchBuildable.Stuff); for (int j = 0; j < list4.Count; j++) { if (!dictionary.TryGetValue(list4[j].thingDef, out int value3)) { value3 = 0; } dictionary[list4[j].thingDef] = value3 + list4[j].count; } } } } float num3 = 0f; StringBuilder stringBuilder = new StringBuilder(); foreach (Pair <List <StuffCategoryDef>, int> item2 in list2) { if (stringBuilder.Length != 0) { stringBuilder.AppendLine(); } stringBuilder.Append((string)(" - " + "AnyOf".Translate() + ": " + item2.First.Select((StuffCategoryDef x) => x.label).ToCommaList() + " x") + item2.Second); num3 += GetCheapestStuffMarketValue(item2.First, item2.Second); } foreach (KeyValuePair <ThingDef, int> item3 in dictionary) { if (stringBuilder.Length != 0) { stringBuilder.AppendLine(); } stringBuilder.Append(" - " + GenLabel.ThingLabel(item3.Key, null, item3.Value).CapitalizeFirst()); num3 += item3.Key.BaseMarketValue * (float)item3.Value; } if (list3.Any()) { if (stringBuilder.Length != 0) { stringBuilder.AppendLine(); } stringBuilder.Append(" - " + "AnyOf".Translate() + ":"); foreach (List <Pair <ThingDef, int> > item4 in list3) { stringBuilder.AppendLine(); stringBuilder.Append(" - " + item4.Select((Pair <ThingDef, int> x) => x.First.label + " x" + x.Second).ToCommaList()); } num3 += GetCheapestThingMarketValue(list3); } slate.Set(storeAs.GetValue(slate), stringBuilder.ToString()); if (!storeMarketValueAs.GetValue(slate).NullOrEmpty()) { slate.Set(storeMarketValueAs.GetValue(slate), num3); } }