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


C# IntVec3.IsForbidden方法代码示例

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


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

示例1: 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


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