当前位置: 首页>>代码示例>>C#>>正文


C# IntVec3.GetTerrain方法代码示例

本文整理汇总了C#中IntVec3.GetTerrain方法的典型用法代码示例。如果您正苦于以下问题:C# IntVec3.GetTerrain方法的具体用法?C# IntVec3.GetTerrain怎么用?C# IntVec3.GetTerrain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IntVec3的用法示例。


在下文中一共展示了IntVec3.GetTerrain方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AllowsPlacing

 /// <summary>
 /// Restrict placement over non stony floors.
 /// </summary>
 public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot)
 {
     TerrainDef terrain = loc.GetTerrain();
     if ((terrain == TerrainDef.Named("Soil"))
         || (terrain == TerrainDef.Named("SoilRich"))
         || (terrain == TerrainDef.Named("Gravel"))
         || (terrain == TerrainDef.Named("MossyTerrain"))
         || (terrain == TerrainDef.Named("MarshyTerrain")))
     {
         return true;
     }
     return new AcceptanceReport("Dirt floor must be placed on soft soil.");
 }
开发者ID:Rikiki123456789,项目名称:Rimworld,代码行数:16,代码来源:PlaceWorker_OnEarth.cs

示例2: AllowsPlacing

        public override AcceptanceReport AllowsPlacing( BuildableDef checkingDef, IntVec3 loc, Rot4 rot )
        {
            ThingDef def = checkingDef as ThingDef;

            var Restrictions = def.GetCompProperties( typeof( RestrictedPlacement_Comp ) ) as RestrictedPlacement_Properties;
            if( Restrictions == null ){
                Log.Error( "Could not get restrictions!" );
                return false;
            }

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

            return "MessagePlacementNotOnTerrain".Translate() + terrainDef.label;
        }
开发者ID:TehJoE,项目名称:CommunityCoreLibrary,代码行数:17,代码来源:PlaceWorker_OnlyOnTerrain.cs

示例3: AllowsPlacing

        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;
        }
开发者ID:soulkata,项目名称:CommunityCoreLibrary,代码行数:22,代码来源:PlaceWorker_NotOnTerrain.cs

示例4: JobOnCell

        public override Job JobOnCell(Pawn pawn, IntVec3 cell)
        {
            // first run check to improve performance
            if (!pawn.CanReserve(cell) || cell.IsForbidden(pawn)) return null;

            // set plant to grow
            DetermineWantedPlantDef(cell);

            // cut improper plants in current cell
            var plant = Find.ThingGrid.ThingAt<Plant>(cell);
            if (plant != null)
            {
                if (plant.def != wantedPlantDef && Find.DesignationManager.DesignationOn(plant) == null)
                {
                    DesignatePlantToCut(plant);
                }
                return null;
            }

            // cut improper adjucent sow blockers (trees)
            var adjacentSowBlocker = GenPlant.AdjacentSowBlocker(wantedPlantDef, cell) as Plant;
            if (adjacentSowBlocker != null)
            {
                if (Find.DesignationManager.DesignationOn(adjacentSowBlocker) == null)
                {
                    var zoneGrowing = Find.ZoneManager.ZoneAt(adjacentSowBlocker.Position) as Zone_Growing;
                    if (zoneGrowing == null || zoneGrowing.GetPlantDefToGrow() != adjacentSowBlocker.def)
                    {
                        DesignatePlantToCut(adjacentSowBlocker);
                    }
                }
                return null;
            }

            // haul aside objects that block growing
            var haulGarbageAsideJob = HaulGarbageAsideJob(cell, pawn);
            if (haulGarbageAsideJob != null)
            {
                return haulGarbageAsideJob;
            }

            // cultivate or fertilize soil if needed
            var growingZone = Find.ZoneManager.ZoneAt(cell) as RA_Zone_Growing;
            if (growingZone != null)
            {
                if (growingZone.needsFertilization && cell.GetTerrain().defName.Contains("Cultivated"))
                {
                    return pawn.CanReach(cell, PathEndMode.ClosestTouch, pawn.NormalMaxDanger())
                        ? new Job(DefDatabase<JobDef>.GetNamedSilentFail("Fertilize"), cell)
                        : null;
                }
                if (growingZone.needsCultivation && !cell.GetTerrain().defName.Contains("Cultivated") && !cell.GetTerrain().defName.Contains("Fertilized"))
                {
                    if (!Find.DesignationManager.AllDesignationsAt(cell).Any())
                    {
                        Find.DesignationManager.AddDesignation(new Designation(cell,
                            DefDatabase<DesignationDef>.GetNamedSilentFail("CultivateLand")));
                    }
                    return null;
                }
            }

            // last check for allowed planting
            if (wantedPlantDef.CanEverPlantAt(cell))
            {
                // plant
                return new Job(JobDefOf.Sow, cell)
                {
                    plantDefToSow = wantedPlantDef
                };
            }

            // default exit
            return null;
        }
开发者ID:RWA-Team,项目名称:RimworldAscension,代码行数:75,代码来源:RA_WorkGiver_GrowerSow.cs

示例5: _CanBuildOnTerrain

 internal static bool _CanBuildOnTerrain( BuildableDef entDef, IntVec3 c, Rot4 rot, Thing thingToIgnore = null )
 {
     CompProperties_RestrictedPlacement Restrictions = null;
     if( entDef is TerrainWithComps )
     {
         var terrainWithComps = entDef as TerrainWithComps;
         if(
             ( !terrainWithComps.placeWorkers.NullOrEmpty() ) &&
             ( terrainWithComps.placeWorkers.Contains( typeof( PlaceWorker_OnlyOnTerrain ) ) )
         )
         {
             Restrictions = terrainWithComps.GetCompProperties( typeof( CompRestrictedPlacement ) ) as CompProperties_RestrictedPlacement;
         }
     }
     else if( entDef is ThingDef )
     {
         var thingDef = entDef as ThingDef;
         if(
             ( !thingDef.placeWorkers.NullOrEmpty() ) &&
             ( thingDef.placeWorkers.Contains( typeof( PlaceWorker_OnlyOnTerrain ) ) )
         )
         {
             Restrictions = thingDef.GetCompProperties<CompProperties_RestrictedPlacement>();
         }
     }
     if( Restrictions != null )
     {
         var cellRect = GenAdj.OccupiedRect( c, rot, entDef.Size );
         cellRect.ClipInsideMap();
         var iterator = cellRect.GetIterator();
         while( !iterator.Done() )
         {
             if( !Restrictions.RestrictedTerrain.Contains( Find.TerrainGrid.TerrainAt( iterator.Current ) ) )
             {
                 return false;
             }
             var thingList = iterator.Current.GetThingList();
             for( int index = 0; index < thingList.Count; ++index )
             {
                 if( thingList[ index ] != thingToIgnore )
                 {
                     var terrainDef = thingList[ index ].def.entityDefToBuild as TerrainDef;
                     if(
                         ( terrainDef != null )&&
                         ( !Restrictions.RestrictedTerrain.Contains( terrainDef ) )
                     )
                     {
                         return false;
                     }
                 }
             }
             iterator.MoveNext();
         }
     }
     else
     {
         // Use the vanilla method to check
         if(
             ( entDef is TerrainDef ) &&
             ( !c.GetTerrain().changeable )
         )
         {
             return false;
         }
         var cellRect = GenAdj.OccupiedRect( c, rot, entDef.Size );
         cellRect.ClipInsideMap();
         var iterator = cellRect.GetIterator();
         while( !iterator.Done() )
         {
             if( !Find.TerrainGrid.TerrainAt( iterator.Current ).affordances.Contains( entDef.terrainAffordanceNeeded ) )
             {
                 return false;
             }
             var thingList = iterator.Current.GetThingList();
             for( int index = 0; index < thingList.Count; ++index )
             {
                 if( thingList[ index ] != thingToIgnore )
                 {
                     var terrainDef = thingList[ index ].def.entityDefToBuild as TerrainDef;
                     if(
                         ( terrainDef != null )&&
                         ( !terrainDef.affordances.Contains( entDef.terrainAffordanceNeeded ) )
                     )
                     {
                         return false;
                     }
                 }
             }
             iterator.MoveNext();
         }
     }
     // Allow placement
     return true;
 }
开发者ID:RawCode,项目名称:CommunityCoreLibrary,代码行数:94,代码来源:GenConstruct.cs


注:本文中的IntVec3.GetTerrain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。