Ejemplo n.º 1
0
        public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot )
        {
            var Restrictions = checkingDef.RestrictedPlacement_Properties();
            #if DEBUG
            if( Restrictions == null ){
                CCL_Log.Error( "PlaceWorker_RestrictedCount unable to get properties!", checkingDef.defName );
                return AcceptanceReport.WasRejected;
            }
            #endif

            var thingDef = checkingDef as ThingDef;
            #if DEBUG
            if( thingDef == null )
            {
                CCL_Log.Error( "PlaceWorker_RestrictedCount unable to get cast BuildableDef to ThingDef!", checkingDef.defName );
                return AcceptanceReport.WasRejected;
            }
            #endif

            // Get the current count of instances and blueprints of
            int count = Find.ListerThings.ThingsOfDef( thingDef ).Count
                + Find.ListerThings.ThingsOfDef( thingDef.blueprintDef ).Count;

            return count < Restrictions.MaxCount
                ? AcceptanceReport.WasAccepted
                    : "MessagePlacementCountRestricted".Translate( Restrictions.MaxCount );
        }
        public override AcceptanceReport    AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot)
        {
            var Restrictions = checkingDef.RestrictedPlacement_Properties();

#if DEBUG
            if (Restrictions == null)
            {
                CCL_Log.Error("PlaceWorker_RestrictedCount unable to get properties!", checkingDef.defName);
                return(AcceptanceReport.WasRejected);
            }
#endif

            var thingDef = checkingDef as ThingDef;
#if DEBUG
            if (thingDef == null)
            {
                CCL_Log.Error("PlaceWorker_RestrictedCount unable to get cast BuildableDef to ThingDef!", checkingDef.defName);
                return(AcceptanceReport.WasRejected);
            }
#endif

            // Get the current count of instances and blueprints of
            int count = Find.ListerThings.ThingsOfDef(thingDef).Count
                        + Find.ListerThings.ThingsOfDef(thingDef.blueprintDef).Count;

            return(count < Restrictions.MaxCount
                ? AcceptanceReport.WasAccepted
                    : "MessagePlacementCountRestricted".Translate(Restrictions.MaxCount));
        }
        public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot )
        {
            var Restrictions = checkingDef.RestrictedPlacement_Properties();
            #if DEBUG
            if( Restrictions == null )
            {
                CCL_Log.Error( "PlaceWorker_OnlyOnThing unable to get properties!", checkingDef.defName );
                return AcceptanceReport.WasRejected;
            }
            #endif

            var thingDef = checkingDef as ThingDef;
            #if DEBUG
            if( thingDef == null )
            {
                CCL_Log.Error( "PlaceWorker_OnlyOnTerrain unable to cast BuildableDef to ThingDef!", checkingDef.defName );
                return AcceptanceReport.WasRejected;
            }
            #endif

            // Override steam-geyser restriction if required
            if(
                ( Restrictions.RestrictedThing.Exists( r => r == ThingDefOf.SteamGeyser ) )&&
                ( ThingDefOf.GeothermalGenerator != thingDef )
            )
            {
                ThingDefOf.GeothermalGenerator = thingDef;
            }

            foreach( Thing t in loc.GetThingList() )
            {
                if(
                    ( Restrictions.RestrictedThing.Find( r => r == t.def ) != null )&&
                    ( t.Position == loc )
                )
                {
                    return AcceptanceReport.WasAccepted;
                }
            }

            return (AcceptanceReport)( "MessagePlacementNotHere".Translate() );
        }
        public override AcceptanceReport    AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot)
        {
            var Restrictions = checkingDef.RestrictedPlacement_Properties();

#if DEBUG
            if (Restrictions == null)
            {
                CCL_Log.Error("PlaceWorker_OnlyOnTerrain unable to get properties!", checkingDef.defName);
                return(AcceptanceReport.WasRejected);
            }
#endif

            TerrainDef terrainDef = loc.GetTerrain();
            if (Restrictions.RestrictedTerrain.Contains(terrainDef))
            {
                return(AcceptanceReport.WasAccepted);
            }

            return("MessagePlacementNotOn".Translate(terrainDef.label));
        }
        public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot )
        {
            var Restrictions = checkingDef.RestrictedPlacement_Properties();
            #if DEBUG
            if( Restrictions == null )
            {
                Log.Error( "Community Core Library :: Restricted PlaceWorker :: NotOnThing - Unable to get properties!" );
                return AcceptanceReport.WasRejected;
            }
            #endif

            foreach( Thing t in loc.GetThingList() )
            {
                if( Restrictions.RestrictedThing.Find( r => r == t.def ) != null )
                {
                    return (AcceptanceReport)( "MessagePlacementNotOn".Translate() + t.def.label );
                }
            }

            return AcceptanceReport.WasAccepted;
        }
        public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot )
        {
            var Restrictions = checkingDef.RestrictedPlacement_Properties();
            #if DEBUG
            if( Restrictions == null )
            {
                CCL_Log.Error( "PlaceWorker_NotOnThing unable to get properties!", checkingDef.defName );
                return AcceptanceReport.WasRejected;
            }
            #endif

            foreach( Thing t in loc.GetThingList() )
            {
                if( Restrictions.RestrictedThing.Contains( t.def ) )
                {
                    return "MessagePlacementNotOn".Translate( t.def.label );
                }
            }

            return AcceptanceReport.WasAccepted;
        }
        public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot )
        {
            var Restrictions = checkingDef.RestrictedPlacement_Properties();
            #if DEBUG
            if( Restrictions == null )
            {
                Log.Error( "Community Core Library :: Restricted PlaceWorker :: NotOnTerrain - Unable to get properties!" );
                return AcceptanceReport.WasRejected;
            }
            #endif

            TerrainDef terrainDef = loc.GetTerrain();
            for( int i = 0; i < Restrictions.RestrictedTerrain.Count; i++ )
            {
                if( Restrictions.RestrictedTerrain[ i ] == terrainDef )
                {
                    return "MessagePlacementNotOn".Translate(terrainDef.label);
                }
            }

            return AcceptanceReport.WasAccepted;
        }
Ejemplo n.º 8
0
        public override AcceptanceReport    AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot)
        {
            var Restrictions = checkingDef.RestrictedPlacement_Properties();

#if DEBUG
            if (Restrictions == null)
            {
                Log.Error("Community Core Library :: Restricted PlaceWorker :: NotOnThing - Unable to get properties!");
                return(AcceptanceReport.WasRejected);
            }
#endif

            foreach (Thing t in loc.GetThingList())
            {
                if (Restrictions.RestrictedThing.Find(r => r == t.def) != null)
                {
                    return((AcceptanceReport)("MessagePlacementNotOn".Translate() + t.def.label));
                }
            }

            return(AcceptanceReport.WasAccepted);
        }
Ejemplo n.º 9
0
        public override AcceptanceReport    AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot)
        {
            var Restrictions = checkingDef.RestrictedPlacement_Properties();

#if DEBUG
            if (Restrictions == null)
            {
                CCL_Log.Error("PlaceWorker_OnlyOnThing unable to get properties!", checkingDef.defName);
                return(AcceptanceReport.WasRejected);
            }
#endif

            foreach (Thing t in loc.GetThingList())
            {
                if (Restrictions.RestrictedThing.Contains(t.def))
                {
                    return(AcceptanceReport.WasAccepted);
                }
            }

            return((AcceptanceReport)("MessagePlacementNotHere".Translate()));
        }
Ejemplo n.º 10
0
        public override AcceptanceReport    AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot)
        {
            var Restrictions = checkingDef.RestrictedPlacement_Properties();

#if DEBUG
            if (Restrictions == null)
            {
                Log.Error("Community Core Library :: Restricted PlaceWorker :: OnlyOnThing - Unable to get properties!");
                return(AcceptanceReport.WasRejected);
            }
#endif

            var thingDef = checkingDef as ThingDef;
#if DEBUG
            if (thingDef == null)
            {
                Log.Error("Community Core Library :: Restricted PlaceWorker :: OnlyOnThing - Unable to cast BuildableDef to ThingDef!");
                return(AcceptanceReport.WasRejected);
            }
#endif

            // Override steam-geyser restriction if required
            if ((Restrictions.RestrictedThing.Exists(r => r == ThingDefOf.SteamGeyser)) &&
                (ThingDefOf.GeothermalGenerator != thingDef))
            {
                ThingDefOf.GeothermalGenerator = thingDef;
            }

            foreach (Thing t in loc.GetThingList())
            {
                if ((Restrictions.RestrictedThing.Find(r => r == t.def) != null) &&
                    (t.Position == loc))
                {
                    return(AcceptanceReport.WasAccepted);
                }
            }

            return((AcceptanceReport)("MessagePlacementNotHere".Translate()));
        }
        public override AcceptanceReport    AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot)
        {
            var Restrictions = checkingDef.RestrictedPlacement_Properties();

#if DEBUG
            if (Restrictions == null)
            {
                Log.Error("Community Core Library :: Restricted PlaceWorker :: OnlyOnTerrain - Unable to get properties!");
                return(AcceptanceReport.WasRejected);
            }
#endif

            TerrainDef terrainDef = loc.GetTerrain();
            for (int i = 0; i < Restrictions.RestrictedTerrain.Count; i++)
            {
                if (Restrictions.RestrictedTerrain[i] == terrainDef)
                {
                    return(AcceptanceReport.WasAccepted);
                }
            }

            return((AcceptanceReport)("MessagePlacementNotOn".Translate() + terrainDef.label));
        }
Ejemplo n.º 12
0
        // This method is to remove the hard-coded references allowing more flexibility in
        // building placements.  Specifically, it removes the steam geyser/geothermal generator
        // lock.
        internal static bool                _CanPlaceBlueprintOver(BuildableDef newDef, ThingDef oldDef)
        {
            if (oldDef.EverHaulable)
            {
                return(true);
            }

            // Handle steam geysers in a mod friendly way (not geothermal exclusive)
            // By default, nothing can be placed on steam geysers without a place worker which allows it
            if (oldDef == ThingDefOf.SteamGeyser)
            {
                if (newDef.placeWorkers.NullOrEmpty())
                {
                    // No place workers means nothing to allow it
                    return(false);
                }
                if (newDef.placeWorkers.Contains(typeof(PlaceWorker_OnSteamGeyser)))
                {
                    return(true);
                }
                if (newDef.placeWorkers.Contains(typeof(PlaceWorker_OnlyOnThing)))
                {
                    var Restrictions = newDef.RestrictedPlacement_Properties();
#if DEBUG
                    if (Restrictions == null)
                    {
                        CCL_Log.Error("PlaceWorker_OnlyOnThing unable to get properties!", newDef.defName);
                        return(false);
                    }
#endif
                    if (Restrictions.RestrictedThing.Contains(ThingDefOf.SteamGeyser))
                    {
                        return(true);
                    }
                }
                return(false);
            }

            ThingDef     newThingDef    = newDef as ThingDef;
            ThingDef     oldThingDef    = oldDef;
            BuildableDef buildableDef   = GenSpawn.BuiltDefOf(oldDef);
            ThingDef     resultThingDef = buildableDef as ThingDef;

            if (
                (oldDef.category == ThingCategory.Plant) &&
                (oldDef.passability == Traversability.Impassable) &&
                (
                    (newThingDef != null) &&
                    (newThingDef.category == ThingCategory.Building)
                ) &&
                (!newThingDef.building.canPlaceOverImpassablePlant)
                )
            {
                return(false);
            }

            if (
                (oldDef.category != ThingCategory.Building) &&
                (!oldDef.IsBlueprint) &&
                (!oldDef.IsFrame)
                )
            {
                return(true);
            }


            if (newThingDef != null)
            {
                if (!EdificeUtility.IsEdifice((BuildableDef)newThingDef))
                {
                    return
                        ((
                             (oldDef.building == null) ||
                             (oldDef.building.canBuildNonEdificesUnder)
                             ) &&
                         (
                             (!newThingDef.EverTransmitsPower) ||
                             (!oldDef.EverTransmitsPower)
                         ));
                }
                if (
                    (EdificeUtility.IsEdifice((BuildableDef)newThingDef)) &&
                    (oldThingDef != null) &&
                    (
                        (oldThingDef.category == ThingCategory.Building) &&
                        (!EdificeUtility.IsEdifice((BuildableDef)oldThingDef))
                    )
                    )
                {
                    return
                        ((newThingDef.building == null) ||
                         (newThingDef.building.canBuildNonEdificesUnder));
                }
                if (
                    (resultThingDef != null) &&
                    (resultThingDef == ThingDefOf.Wall) &&
                    (
                        (newThingDef.building != null) &&
                        (newThingDef.building.canPlaceOverWall)
                    ) ||
                    (newDef != ThingDefOf.PowerConduit) &&
                    (buildableDef == ThingDefOf.PowerConduit)
                    )
                {
                    return(true);
                }
            }

            return
                ((
                     (newDef is TerrainDef) &&
                     (buildableDef is ThingDef) &&
                     (((ThingDef)buildableDef).CoexistsWithFloors)
                     ) ||
                 (
                     (buildableDef is TerrainDef) &&
                     (!(newDef is TerrainDef))
                 ));
        }