static void CanPlaceBlueprintOverPostfix(ref bool __result, BuildableDef newDef, ThingDef oldDef)
 {
     if (newDef.ForceAllowPlaceOver(oldDef))
     {
         __result = true;
     }
 }
Exemplo n.º 2
0
        public static bool CanPlaceBlueprintOver(BuildableDef newDef, ThingDef oldDef)
        {
            if (oldDef.EverHaulable)
            {
                return(true);
            }
            TerrainDef terrainDef = newDef as TerrainDef;

            if (terrainDef != null)
            {
                if (oldDef.IsBlueprint || oldDef.IsFrame)
                {
                    if (!terrainDef.affordances.Contains(oldDef.entityDefToBuild.terrainAffordanceNeeded))
                    {
                        return(false);
                    }
                }
                else if (oldDef.category == ThingCategory.Building && !terrainDef.affordances.Contains(oldDef.terrainAffordanceNeeded))
                {
                    return(false);
                }
            }
            ThingDef     thingDef     = newDef as ThingDef;
            BuildableDef buildableDef = GenConstruct.BuiltDefOf(oldDef);
            ThingDef     thingDef2    = buildableDef as ThingDef;

            if (oldDef == ThingDefOf.SteamGeyser && !newDef.ForceAllowPlaceOver(oldDef))
            {
                return(false);
            }
            if (oldDef.category == ThingCategory.Plant && oldDef.passability == Traversability.Impassable && thingDef != null && thingDef.category == ThingCategory.Building && !thingDef.building.canPlaceOverImpassablePlant)
            {
                return(false);
            }
            if (oldDef.category == ThingCategory.Building || oldDef.IsBlueprint || oldDef.IsFrame)
            {
                if (thingDef != null)
                {
                    if (!thingDef.IsEdifice())
                    {
                        return((oldDef.building == null || oldDef.building.canBuildNonEdificesUnder) && (!thingDef.EverTransmitsPower || !oldDef.EverTransmitsPower));
                    }
                    if (thingDef.IsEdifice() && oldDef != null && oldDef.category == ThingCategory.Building && !oldDef.IsEdifice())
                    {
                        return(thingDef.building == null || thingDef.building.canBuildNonEdificesUnder);
                    }
                    if (thingDef2 != null && (thingDef2 == ThingDefOf.Wall || thingDef2.IsSmoothed) && thingDef.building != null && thingDef.building.canPlaceOverWall)
                    {
                        return(true);
                    }
                    if (newDef != ThingDefOf.PowerConduit && buildableDef == ThingDefOf.PowerConduit)
                    {
                        return(true);
                    }
                }
                return((newDef is TerrainDef && buildableDef is ThingDef && ((ThingDef)buildableDef).CoexistsWithFloors) || (buildableDef is TerrainDef && !(newDef is TerrainDef)));
            }
            return(true);
        }
        //// RimWorld.GenConstruct
        //public static void Chandeliers_BlocksConstruction(Thing constructible, Thing t, ref bool __result)
        //{
        //    Log.Message("BlocksConstruction Called");

        //    if (GetSpecialCases().Contains(constructible.def))
        //    {
        //        if (GetSpecialCases().Contains(t.def))
        //        {
        //            Log.Message("Blocks");
        //            __result = true;
        //            return;
        //        }
        //        Log.Message("Does not block");
        //        __result = false;
        //    }
        //}

        // RimWorld.GenConstruct
        public static void Chandeliers_CanPlaceBlueprintOver(
            BuildableDef newDef, ThingDef oldDef, ref bool __result)
        {
            List <ThingDef> specialCases = GetSpecialCases();

            if (newDef.ForceAllowPlaceOver(oldDef))
            {
                __result = true;
            }
        }
Exemplo n.º 4
0
 public static bool IsBlockingRock(this ThingDef td, BuildableDef placingDef)
 {
     //This checks ForceAllow, but not AllowsPlacing, since AllowsPlacing defaults to true, and PlaceWorks like ShowFacilites would be true.
     return(td.IsMineableRock() && !placingDef.ForceAllowPlaceOver(td));
 }
        // Token: 0x060000E4 RID: 228 RVA: 0x0000799C File Offset: 0x00005B9C
        public static bool CanPlaceBlueprintOver(BuildableDef newDef, ThingDef oldDef)
        {
            bool everHaulable = oldDef.EverHaulable;
            bool result;

            if (everHaulable)
            {
                result = true;
            }
            else
            {
                TerrainDef terrainDef = newDef as TerrainDef;
                bool       flag       = terrainDef != null;
                if (flag)
                {
                    bool flag2 = oldDef.category == ThingCategory.Building && !terrainDef.affordances.Contains(oldDef.terrainAffordanceNeeded);
                    if (flag2)
                    {
                        return(false);
                    }
                    bool flag3 = (oldDef.IsBlueprint || oldDef.IsFrame) && !terrainDef.affordances.Contains(oldDef.entityDefToBuild.terrainAffordanceNeeded);
                    if (flag3)
                    {
                        return(false);
                    }
                }
                ThingDef     thingDef     = newDef as ThingDef;
                BuildableDef buildableDef = WPGenConstruct.BuiltDefOf(oldDef);
                ThingDef     thingDef2    = buildableDef as ThingDef;
                bool         flag4        = oldDef == ThingDefOf.SteamGeyser && !newDef.ForceAllowPlaceOver(oldDef);
                if (flag4)
                {
                    result = false;
                }
                else
                {
                    bool flag5 = oldDef.category == ThingCategory.Plant && oldDef.passability == Traversability.Impassable && thingDef != null && thingDef.category == ThingCategory.Building && !thingDef.building.canPlaceOverImpassablePlant;
                    if (flag5)
                    {
                        result = false;
                    }
                    else
                    {
                        bool flag6 = oldDef.category == ThingCategory.Building || oldDef.IsBlueprint || oldDef.IsFrame;
                        if (flag6)
                        {
                            bool flag7 = thingDef != null;
                            if (flag7)
                            {
                                bool flag8 = !thingDef.IsEdifice();
                                if (flag8)
                                {
                                    return((oldDef.building == null || oldDef.building.canBuildNonEdificesUnder) && (!thingDef.EverTransmitsPower || !oldDef.EverTransmitsPower));
                                }
                                bool flag9 = thingDef.IsEdifice() && oldDef != null && oldDef.category == ThingCategory.Building && !oldDef.IsEdifice();
                                if (flag9)
                                {
                                    return(thingDef.building == null || thingDef.building.canBuildNonEdificesUnder);
                                }
                                bool flag10 = thingDef2 != null && thingDef2 == ThingDefOf.Wall && thingDef.building != null && thingDef.building.canPlaceOverWall;
                                if (flag10)
                                {
                                    return(true);
                                }
                                bool flag11 = newDef != ThingDefOf.PowerConduit && buildableDef == ThingDefOf.PowerConduit;
                                if (flag11)
                                {
                                    return(true);
                                }
                            }
                            result = ((newDef is TerrainDef && buildableDef is ThingDef && ((ThingDef)buildableDef).CoexistsWithFloors) || (buildableDef is TerrainDef && !(newDef is TerrainDef)));
                        }
                        else
                        {
                            result = true;
                        }
                    }
                }
            }
            return(result);
        }