Example #1
0
 public static void CancelAbove(BuildableDef defToBuild, DestroyMode mode, Map map, IntVec3 pos)
 {
     if (defToBuild.IsBridgelike() &&
         mode != DestroyMode.Vanish && mode != DestroyMode.FailConstruction)
     {
         List <Thing> toKill = new List <Thing>();
         foreach (Thing thing in map.thingGrid.ThingsListAtFast(pos))
         {
             //this sorta assumes the thing is not actually built, vanilla would handle that.
             if (thing is Blueprint bp && !bp.def.entityDefToBuild.IsBridgelike())
             {
                 toKill.Add(thing);
             }
             if (thing is Frame fr && !fr.def.entityDefToBuild.IsBridgelike())
             {
                 toKill.Add(thing);
             }
         }
         //Kill unless it's already killed or it's IsSelected.
         //IsSelected probably not the best since possible non-cancel destruction would keep the thing above, but what are the chances of that?
         toKill.Do(t => { if (!t.Destroyed && !Find.Selector.IsSelected(t))
                          {
                              t.Destroy(DestroyMode.Refund);
                          }
                   });
     }
 }
Example #2
0
        //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.IsBridgelike())
            {
                return;
            }

            foreach (IntVec3 pos in GenAdj.CellsOccupiedBy(center, rotation, sourceDef.Size))
            {
                EnsureBridge.PlaceBridgeIfNeeded(sourceDef, pos, map, rotation, faction, stuff);
            }
        }