Example #1
0
 public virtual bool ForceAllowPlaceOver(BuildableDef other)
 {
     return(false);
 }
Example #2
0
 public static void CheckAutoRebuildOnDestroyed(Thing thing, DestroyMode mode, Map map, BuildableDef buildingDef)
 {
     if (Find.PlaySettings.autoRebuild && mode == DestroyMode.KillFinalize && thing.Faction == Faction.OfPlayer && buildingDef.blueprintDef != null && buildingDef.IsResearchFinished && map.areaManager.Home[thing.Position] && GenConstruct.CanPlaceBlueprintAt(buildingDef, thing.Position, thing.Rotation, map).Accepted)
     {
         GenConstruct.PlaceBlueprintForBuild(buildingDef, thing.Position, map, thing.Rotation, Faction.OfPlayer, thing.Stuff);
     }
 }
Example #3
0
 public virtual AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Map map, Thing thingToIgnore = null)
 {
     return(AcceptanceReport.WasAccepted);
 }
Example #4
0
 public virtual void PostPlace(Map map, BuildableDef def, IntVec3 loc, Rot4 rot)
 {
 }
Example #5
0
 public static bool WouldWipeAnythingWith(IntVec3 thingPos, Rot4 thingRot, BuildableDef thingDef, Map map, Predicate <Thing> predicate)
 {
     return(GenSpawn.WouldWipeAnythingWith(GenAdj.OccupiedRect(thingPos, thingRot, thingDef.Size), thingDef, map, predicate));
 }
Example #6
0
        public static bool SpawningWipes(BuildableDef newEntDef, BuildableDef oldEntDef)
        {
            ThingDef thingDef  = newEntDef as ThingDef;
            ThingDef thingDef2 = oldEntDef as ThingDef;

            if (thingDef == null || thingDef2 == null)
            {
                return(false);
            }
            if (thingDef.category == ThingCategory.Attachment || thingDef.category == ThingCategory.Mote || thingDef.category == ThingCategory.Filth || thingDef.category == ThingCategory.Projectile)
            {
                return(false);
            }
            if (!thingDef2.destroyable)
            {
                return(false);
            }
            if (thingDef.category == ThingCategory.Plant)
            {
                return(false);
            }
            if (thingDef2.category == ThingCategory.Filth && thingDef.passability != Traversability.Standable)
            {
                return(true);
            }
            if (thingDef2.category == ThingCategory.Item && thingDef.passability == Traversability.Impassable && thingDef.surfaceType == SurfaceType.None)
            {
                return(true);
            }
            if (thingDef.EverTransmitsPower && thingDef2 == ThingDefOf.PowerConduit)
            {
                return(true);
            }
            if (thingDef.IsFrame && GenSpawn.SpawningWipes(thingDef.entityDefToBuild, oldEntDef))
            {
                return(true);
            }
            BuildableDef buildableDef  = GenConstruct.BuiltDefOf(thingDef);
            BuildableDef buildableDef2 = GenConstruct.BuiltDefOf(thingDef2);

            if (buildableDef == null || buildableDef2 == null)
            {
                return(false);
            }
            ThingDef thingDef3 = thingDef.entityDefToBuild as ThingDef;

            if (thingDef2.IsBlueprint)
            {
                if (thingDef.IsBlueprint)
                {
                    if (thingDef3 != null && thingDef3.building != null && thingDef3.building.canPlaceOverWall && thingDef2.entityDefToBuild is ThingDef && (ThingDef)thingDef2.entityDefToBuild == ThingDefOf.Wall)
                    {
                        return(true);
                    }
                    if (thingDef2.entityDefToBuild is TerrainDef)
                    {
                        if (thingDef.entityDefToBuild is ThingDef && ((ThingDef)thingDef.entityDefToBuild).coversFloor)
                        {
                            return(true);
                        }
                        if (thingDef.entityDefToBuild is TerrainDef)
                        {
                            return(true);
                        }
                    }
                }
                return(thingDef2.entityDefToBuild == ThingDefOf.PowerConduit && thingDef.entityDefToBuild is ThingDef && (thingDef.entityDefToBuild as ThingDef).EverTransmitsPower);
            }
            if ((thingDef2.IsFrame || thingDef2.IsBlueprint) && thingDef2.entityDefToBuild is TerrainDef)
            {
                ThingDef thingDef4 = buildableDef as ThingDef;
                if (thingDef4 != null && !thingDef4.CoexistsWithFloors)
                {
                    return(true);
                }
            }
            if (thingDef2 == ThingDefOf.ActiveDropPod)
            {
                return(false);
            }
            if (thingDef == ThingDefOf.ActiveDropPod)
            {
                return(thingDef2 != ThingDefOf.ActiveDropPod && (thingDef2.category == ThingCategory.Building && thingDef2.passability == Traversability.Impassable));
            }
            if (thingDef.IsEdifice())
            {
                if (thingDef.BlockPlanting && thingDef2.category == ThingCategory.Plant)
                {
                    return(true);
                }
                if (!(buildableDef is TerrainDef) && buildableDef2.IsEdifice())
                {
                    return(true);
                }
            }
            return(false);
        }
Example #7
0
        public static void WipeAndRefundExistingThings(IntVec3 thingPos, Rot4 thingRot, BuildableDef thingDef, Map map)
        {
            CellRect occupiedRect = GenAdj.OccupiedRect(thingPos, thingRot, thingDef.Size);

            foreach (IntVec3 current in occupiedRect)
            {
                foreach (Thing current2 in current.GetThingList(map).ToList <Thing>())
                {
                    if (GenSpawn.SpawningWipes(thingDef, current2.def))
                    {
                        if (current2.def.category == ThingCategory.Item)
                        {
                            current2.DeSpawn(DestroyMode.Vanish);
                            if (!GenPlace.TryPlaceThing(current2, current, map, ThingPlaceMode.Near, null, (IntVec3 x) => !occupiedRect.Contains(x)))
                            {
                                current2.Destroy(DestroyMode.Vanish);
                            }
                        }
                        else
                        {
                            GenSpawn.Refund(current2, map, occupiedRect);
                        }
                    }
                }
            }
        }
Example #8
0
        public static void WipeAndRefundExistingThings(IntVec3 thingPos, Rot4 thingRot, BuildableDef thingDef, Map map)
        {
            CellRect occupiedRect = GenAdj.OccupiedRect(thingPos, thingRot, thingDef.Size);

            foreach (IntVec3 item in occupiedRect)
            {
                foreach (Thing item2 in item.GetThingList(map).ToList())
                {
                    if (SpawningWipes(thingDef, item2.def))
                    {
                        if (item2.def.category == ThingCategory.Item)
                        {
                            item2.DeSpawn();
                            if (!GenPlace.TryPlaceThing(item2, item, map, ThingPlaceMode.Near, null, (IntVec3 x) => !occupiedRect.Contains(x)))
                            {
                                item2.Destroy();
                            }
                        }
                        else
                        {
                            Refund(item2, map, occupiedRect);
                        }
                    }
                }
            }
        }
 private bool <ResolveDesignators> m__1(BuildableDef tDef)
 {
     return(tDef.designationCategory == this);
 }
Example #10
0
 public virtual bool IsBuildDesignatorVisible(BuildableDef def)
 {
     return(true);
 }
        public static bool IsEdifice(this BuildableDef def)
        {
            ThingDef thingDef = def as ThingDef;

            return(thingDef != null && thingDef.category == ThingCategory.Building && thingDef.building.isEdifice);
        }