Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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));
        }