public bool MoveNext() { uint num = (uint)this.$PC; this.$PC = -1; switch (num) { case 0u: this.$current = TerrainAffordanceDefOf.Heavy; if (!this.$disposing) { this.$PC = 1; } return(true); case 1u: this.$current = TerrainAffordanceDefOf.MovingFluid; if (!this.$disposing) { this.$PC = 2; } return(true); case 2u: this.$PC = -1; break; } return(false); }
public static bool TerrainOrBridgesCanDo(TerrainDef tDef, TerrainAffordanceDef neededDef, BuildableDef def, IntVec3 pos, Map map) { //Code Used to be: if (tDef.affordances.Contains(neededDef)) { return(true); } if (def is TerrainDef) { return(false); } //Now it's gonna also check bridges: //Bridge blueprint there that will support this: //TODO isn't this redundant? if (pos.GetThingList(map).Any(t => t.def.entityDefToBuild is TerrainDef bpTDef && bpTDef.affordances.Contains(neededDef))) { return(true); } //Player not choosing to build and bridges possible: ok (elsewhere in code will place blueprints) if (DesignatorContext.designating && BridgelikeTerrain.FindBridgeFor(tDef, neededDef, map) != null) { return(true); } return(false); }
public static bool CanBuildOnTerrain(BuildableDef entDef, IntVec3 c, Map map, Rot4 rot, Thing thingToIgnore = null, ThingDef stuffDef = null) { TerrainAffordanceDef terrainAffordanceNeed = entDef.GetTerrainAffordanceNeed(stuffDef); if (terrainAffordanceNeed != null) { CellRect cellRect = GenAdj.OccupiedRect(c, rot, entDef.Size); cellRect.ClipInsideMap(map); foreach (IntVec3 item in cellRect) { if (!map.terrainGrid.TerrainAt(item).affordances.Contains(terrainAffordanceNeed)) { return(false); } List <Thing> thingList = item.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { if (thingList[i] != thingToIgnore) { TerrainDef terrainDef = thingList[i].def.entityDefToBuild as TerrainDef; if (terrainDef != null && !terrainDef.affordances.Contains(terrainAffordanceNeed)) { return(false); } } } } } return(true); }
public static bool NeedsBridge(BuildableDef def, IntVec3 pos, Map map, ThingDef stuff) { TerrainAffordanceDef needed = def.GetTerrainAffordanceNeed(stuff); return(pos.InBounds(map) && !pos.SupportsStructureType(map, needed) && pos.SupportsStructureType(map, TerrainDefOf.Bridge.terrainAffordanceNeeded) && TerrainDefOf.Bridge.affordances.Contains(needed)); }
static FertileFieldsCompatibilityPatch() { TerrainAffordanceDef fertileGravelAffordance = DefDatabase <TerrainAffordanceDef> .GetNamed("Gravel", false); if (fertileGravelAffordance != null) { TerrainDef pebbles = TerrainDef.Named("BiomesCore_Pebbles"); pebbles.affordances.Add(fertileGravelAffordance); } }
public static TerrainDef GetNeededBridge(BuildableDef def, IntVec3 pos, Map map, ThingDef stuff) { if (!pos.InBounds(map)) { return(null); } TerrainAffordanceDef needed = def.GetTerrainAffordanceNeed(stuff); return(BridgelikeTerrain.FindBridgeFor(map.terrainGrid.TerrainAt(pos), needed, map)); }
public TerrainAffordanceDef OverrideAffordance() { if (Find.DesignatorManager.SelectedDesignator is Designator_Build des) { TerrainAffordanceDef needed = des.PlacingDef.terrainAffordanceNeeded; return((needed == TerrainAffordanceDefOf.Light || needed == TerrainAffordanceDefOf.Medium || needed == TerrainAffordanceDefOf.Heavy) ? null : needed); } return(null); }
public override void Update() { TerrainAffordanceDef newAffordance = OverrideAffordance(); if (newAffordance != curAffordance) { Log.Message($"newAffordance is {newAffordance}"); curAffordance = newAffordance; SetDirty(); } bool newGeo = PlacingGeothermal(); if (newGeo != placingGeothermal) { Log.Message($"newGeo is {newGeo}"); placingGeothermal = newGeo; SetDirty(); } bool newPump = PlacingMoisturePump(); if (newPump != placingMoisturePump) { Log.Message($"newPump is {newPump}"); placingMoisturePump = newPump; SetDirty(); } if (placingMoisturePump && dirty) { HashSet <IntVec3> centers = new HashSet <IntVec3>(Find.CurrentMap.listerThings.ThingsOfDef(MoreThingDefOf.MoisturePump).Select(t => t.Position)); centers.AddRange(Find.CurrentMap.listerThings.ThingsInGroup(ThingRequestGroup.Blueprint) .Where(bp => GenConstruct.BuiltDefOf(bp.def) == MoreThingDefOf.MoisturePump).Select(t => t.Position).ToList()); centers.AddRange(Find.CurrentMap.listerThings.ThingsInGroup(ThingRequestGroup.BuildingFrame) .Where(frame => GenConstruct.BuiltDefOf(frame.def) == MoreThingDefOf.MoisturePump).Select(t => t.Position).ToList()); moisturePumpCells.Clear(); float radius = MoreThingDefOf.MoisturePump.specialDisplayRadius; foreach (IntVec3 center in centers) { int num = GenRadial.NumCellsInRadius(radius); for (int i = 0; i < num; i++) { moisturePumpCells.Add(center + GenRadial.RadialPattern[i]); } } } base.Update(); }
public static void AddDefaultWaterAffordances() { TerrainAffordanceDef waterAffordance = DefDatabase <TerrainAffordanceDef> .GetNamed("Water"); foreach (TerrainDef t in DefDatabase <TerrainDef> .AllDefs) { if (t.HasTag("Fishable") && !t.affordances.Contains(waterAffordance)) { t.affordances.Add(waterAffordance); t.changeable = true; } } }
static Splash() { TerrainAffordanceDef waterproof = DefDatabase <TerrainAffordanceDef> .GetNamed("Waterproof"); foreach (TerrainDef t in DefDatabase <TerrainDef> .AllDefs) { t.affordances.Add(waterproof); } foreach (ThingDef t in DefDatabase <ThingDef> .AllDefs.Where(x => x.defName.Contains("Trap") && x.terrainAffordanceNeeded != null)) { t.terrainAffordanceNeeded = waterproof; } }
//public static Blueprint_Build PlaceBlueprintForBuild(BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction, ThingDef stuff) public static void Prefix(BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction, ThingDef stuff) { if (faction != Faction.OfPlayer || sourceDef == TerrainDefOf.Bridge) { return; } TerrainAffordanceDef affNeeded = sourceDef.GetTerrainAffordanceNeed(stuff); foreach (IntVec3 pos in GenAdj.CellsOccupiedBy(center, rotation, sourceDef.Size)) { EnsureBridge.PlaceBridgeIfNeeded(sourceDef, pos, map, rotation, faction, stuff); } }
static BridgelikeTerrain() { //Ignore providing diggable because VFE's dirt can turn any terrain into diggable HashSet <TerrainAffordanceDef> ignoreAff = new HashSet <TerrainAffordanceDef> { TerrainAffordanceDefOf.Diggable, TerrainAffordanceDefOf.GrowSoil }; //If you have Affordance 1 and need Affordance 2, you can build one of these TerrainDef var affordanceBridges = new Dictionary <ValueTuple <TerrainAffordanceDef, TerrainAffordanceDef>, List <TerrainDef> >(); //Find bridge terrains: foreach (TerrainDef terdef in DefDatabase <TerrainDef> .AllDefs) { //Filter out some terrains if (terdef.IsFloorBase()) { continue; //nothing special, so easy pass on these } TerrainAffordanceDef bridgeAff = terdef.terrainAffordanceNeeded; if (bridgeAff == null) { continue; //nothing needed implies it's not buildable } if (ignoreAff.Contains(bridgeAff)) { continue; //don't care to bridge from these types aka growsoil -> heavy, marsh->tilled soil } if (!terdef.Removable) { continue; //If you can't remove it, it's a permanent change, let's not do that automatically } foreach (TerrainAffordanceDef provideAff in terdef.affordances) { if (provideAff == bridgeAff) { continue; //Already can do, not an upgrade } if (ignoreAff.Contains(provideAff)) { continue; //Don't want to bridge to this affordance (aka diggable) } //If some terrain exists with 'bridgeAff' and we want to place something that needs 'provideAff', //This terrain can act as a bridge, because it needs 'bridgeAff' and can provide 'provideAff' if (affordanceBridges.TryGetValue((bridgeAff, provideAff), out List <TerrainDef> bridgeTerrains)) { bridgeTerrains.Add(terdef); }
public static void Postfix(ref AcceptanceReport __result, BuildableDef entDef, IntVec3 center, Map map) { TerrainDef terrainDef = entDef as TerrainDef; if (terrainDef == null) { return; } TerrainAffordanceDef neededAffordance = map.terrainGrid.TerrainAt(center).terrainAffordanceNeeded; if (neededAffordance == TerrainAffordanceDefOf.Bridgeable || neededAffordance == TerrainAffordanceDefOf.BridgeableDeep) { __result = new AcceptanceReport("NoFloorsOnBridges".Translate()); } }
public override bool ShowCell(int index) { if (placingGeothermal) { return(Find.CurrentMap.thingGrid.ThingsListAtFast(index).Any(t => t.def == ThingDefOf.SteamGeyser)); } if (placingMoisturePump) { return(Find.CurrentMap.terrainGrid.TerrainAt(index)?.driesTo != null || Find.CurrentMap.terrainGrid.UnderTerrainAt(index)?.driesTo != null); } TerrainAffordanceDef noShow = curAffordance ?? TerrainAffordanceDefOf.Heavy; return(!Find.CurrentMap.terrainGrid.TerrainAt(index).affordances.Contains(noShow)); }
// Token: 0x060000DE RID: 222 RVA: 0x00006F5C File Offset: 0x0000515C public static bool CanBuildOnTerrain(BuildableDef entDef, IntVec3 c, Map map, Rot4 rot, Thing thingToIgnore = null, ThingDef stuffDef = null) { bool flag = entDef is TerrainDef && !c.GetTerrain(map).changeable; bool result; if (flag) { result = false; } else { TerrainAffordanceDef terrainAffordanceNeed = entDef.GetTerrainAffordanceNeed(stuffDef); bool flag2 = terrainAffordanceNeed != null; if (flag2) { CellRect cellRect = GenAdj.OccupiedRect(c, rot, entDef.Size); cellRect.ClipInsideMap(map); foreach (IntVec3 c2 in cellRect) { bool flag3 = !map.terrainGrid.TerrainAt(c2).affordances.Contains(terrainAffordanceNeed); if (flag3) { return(false); } List <Thing> thingList = c2.GetThingList(map); for (int i = 0; i < thingList.Count; i++) { bool flag4 = thingList[i] != thingToIgnore; if (flag4) { TerrainDef terrainDef = thingList[i].def.entityDefToBuild as TerrainDef; bool flag5 = terrainDef != null && !terrainDef.affordances.Contains(terrainAffordanceNeed); if (flag5) { return(false); } } } } result = true; } else { result = true; } } return(result); }
//public static Blueprint_Build PlaceBlueprintForBuild(BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction, ThingDef stuff) public static void Prefix(BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction) { if (faction != Faction.OfPlayer || sourceDef == TerrainDefOf.Bridge) { return; } TerrainAffordanceDef affNeeded = sourceDef.terrainAffordanceNeeded; foreach (IntVec3 pos in GenAdj.CellsOccupiedBy(center, rotation, sourceDef.Size)) { if (PlaceBridges.NeedsBridge(sourceDef, pos, map)) { GenConstruct.PlaceBlueprintForBuild(TerrainDefOf.Bridge, pos, map, rotation, faction, null); } } }
//public static Blueprint_Build PlaceBlueprintForBuild(BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction, ThingDef stuff) public static void Prefix(BuildableDef sourceDef, IntVec3 center, Map map, Rot4 rotation, Faction faction) { if (faction != Faction.OfPlayer || sourceDef == TerrainDefOf.Bridge) { return; } TerrainAffordanceDef affNeeded = sourceDef.terrainAffordanceNeeded; foreach (IntVec3 cell in GenAdj.CellsOccupiedBy(center, rotation, sourceDef.Size)) { if (cell.SupportsStructureType(map, affNeeded)) { continue; } if (cell.SupportsStructureType(map, TerrainDefOf.Bridge.terrainAffordanceNeeded) && TerrainDefOf.Bridge.affordances.Contains(affNeeded)) { GenConstruct.PlaceBlueprintForBuild(TerrainDefOf.Bridge, cell, map, rotation, faction, null); } } }
public static bool TerrainOrBridgesCanDo(List <TerrainAffordanceDef> affordances, TerrainAffordanceDef neededDef, IntVec3 pos, Map map) { //Terrain already supports: vanilla, ok if (affordances.Contains(neededDef)) { return(true); } //If bridges won't help: no. if (!TerrainDefOf.Bridge.affordances.Contains(neededDef)) { return(false); } //Bridge blueprint there: ok if (pos.GetThingList(map).Any(t => t.def.entityDefToBuild == TerrainDefOf.Bridge)) { return(true); } //Player choosing to build and bridges possible: ok (elsewhere in code will place blueprints) if (DesignatorContext.designating && affordances.Contains(TerrainDefOf.Bridge.terrainAffordanceNeeded)) //terrain can support bridges { return(true); } return(false); }
public static bool CanDoTerrain(List <TerrainAffordanceDef> affordances, TerrainAffordanceDef neededDef) { return(affordances.Contains(neededDef) || (affordances.Contains(TerrainDefOf.Bridge.terrainAffordanceNeeded) && TerrainDefOf.Bridge.affordances.Contains(neededDef))); }
public static bool SupportsStructureType(this IntVec3 c, Map map, TerrainAffordanceDef surfaceType) { return(c.GetTerrain(map).affordances.Contains(surfaceType)); }
public override void DoSettingsWindowContents(Rect inRect) { string str1 = settings.fertility.ToString(); string str2 = settings.soilcost.ToString(); string str3 = settings.workamount.ToString(); Listing_Standard listingStandard = new Listing_Standard(); listingStandard.Begin(inRect); listingStandard.ColumnWidth = 200f; listingStandard.Label("Fertility %", -1f); listingStandard.Gap(10f); listingStandard.Label("Place on anything", -1f); listingStandard.Gap(10f); listingStandard.Label("Requires Wood", -1f); listingStandard.Gap(10f); listingStandard.Label("Construction cost in wood", -1f); listingStandard.Gap(10f); listingStandard.Label("Work amount required", -1f); listingStandard.Gap(20f); if (listingStandard.ButtonText("Reset", null)) { settings.fertility = 120f; str1 = "100"; settings.placeonanything = false; settings.requirecost = false; settings.soilcost = 1; str2 = "1"; str3 = "500"; } listingStandard.NewColumn(); listingStandard.ColumnWidth = 200f; float previousfertility = settings.fertility; listingStandard.TextFieldNumeric(ref settings.fertility, ref str1, 70, 10000); if (settings.fertility != previousfertility) { ApplySettings(); } listingStandard.Gap(10f); bool previousTerrainAffordanceDef = settings.placeonanything; listingStandard.CheckboxLabeled("", ref settings.placeonanything); TerrainAffordanceDef placeonanything = settings.placeonanything ? TerrainAffordanceDefOf.Light : TerrainAffordanceDefOf.GrowSoil; if (settings.placeonanything != previousTerrainAffordanceDef) { TerrainDef soilplacement = TerrainDef.Named("TilledSoil"); soilplacement.terrainAffordanceNeeded = placeonanything; } listingStandard.Gap(10f); bool previousState = settings.requirecost; listingStandard.CheckboxLabeled("", ref settings.requirecost); if (settings.requirecost != previousState) { BuildableDef togglecost = TerrainDef.Named("TilledSoil"); togglecost.costList = new List <ThingDefCountClass>() { new ThingDefCountClass(null, 0) }; } listingStandard.Gap(10f); int previousCost = settings.soilcost; listingStandard.TextFieldNumeric(ref settings.soilcost, ref str2, 0, 100); listingStandard.Gap(10f); float previousWork = settings.workamount; listingStandard.TextFieldNumeric(ref settings.workamount, ref str3, 1, 5000); if (settings.workamount != previousWork) { ApplySettings(); } listingStandard.Gap(10f); listingStandard.NewColumn(); listingStandard.ColumnWidth = 500f; listingStandard.Label("100% = Normal soil, 140% = Rich soil, 120% is default."); listingStandard.Gap(10f); listingStandard.Label("Toggles between placing on only soil and everything."); listingStandard.Gap(10f); listingStandard.Label("Does the Tilled Soil require wood to construct? Restart Required."); listingStandard.Gap(10f); listingStandard.Label("How much wood is required for 1 tile."); listingStandard.Gap(10f); listingStandard.Label("How much work is required to construct the soil. 100 = Concrete, "); listingStandard.Label("500 = Flagstone."); listingStandard.Gap(10f); listingStandard.End(); settings.Write(); }