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


C# IntVec3.InHorDistOf方法代码示例

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


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

示例1: AllowsPlacing

        /// <summary>
        /// Check if a new fishing pier can be built at this location.
        /// - the fishing pier bank cell must be on a bank.
        /// - the rest of the fishing pier and the fishing spot must be on water.
        /// - must not be too near from another fishing pier.
        /// </summary>
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot)
        {
            // Check fishing pier bank cell is on a "solid" terrain.
            if (IsAquaticTerrain(loc))
            {
                return new AcceptanceReport("Fishing pier must touch a bank.");
            }
            // Check fishing pier middle and river cells are on water.
            if ((IsAquaticTerrain(loc + new IntVec3(0, 0, 1).RotatedBy(rot)) == false)
                || (IsAquaticTerrain(loc + new IntVec3(0, 0, 2).RotatedBy(rot)) == false))
            {
                return new AcceptanceReport("Fishing pier must be placed on water.");
            }
            // Check fishing zone is on water.
            for (int xOffset = -1; xOffset <= 1; xOffset++)
            {
                for (int yOffset = 3; yOffset <= 5; yOffset++)
                {
                    if (IsAquaticTerrain(loc + new IntVec3(xOffset, 0, yOffset).RotatedBy(rot)) == false)
                    {
                        return new AcceptanceReport("Fishing zone must be placed on water.");
                    }
                }
            }

            // Check if another fishing pier is not too close (mind the test on "fishing pier" def and "fishing pier spawner" blueprint and frame defs.
            List<Thing> fishingPierList = Find.ListerThings.ThingsOfDef(Util_FishIndustry.FishingPierDef);
            List<Thing> fishingPierSpawnerBlueprintList = Find.ListerThings.ThingsOfDef(Util_FishIndustry.FishingPierSpawnerDef.blueprintDef);
            List<Thing> fishingPierSpawnerFrameList = Find.ListerThings.ThingsOfDef(Util_FishIndustry.FishingPierSpawnerDef.frameDef);

            if (fishingPierList != null)
            {
                IEnumerable<Thing> fishingPierInTheArea = fishingPierList.Where(building => loc.InHorDistOf(building.Position, minDistanceBetweenTwoFishingPiers));
                if (fishingPierInTheArea.Count() > 0)
                {
                    return new AcceptanceReport("An other fishing pier is too close.");
                }
            }
            if (fishingPierSpawnerBlueprintList != null)
            {
                IEnumerable<Thing> fishingPierBlueprintInTheArea = fishingPierSpawnerBlueprintList.Where(building => loc.InHorDistOf(building.Position, minDistanceBetweenTwoFishingPiers));
                if (fishingPierBlueprintInTheArea.Count() > 0)
                {
                    return new AcceptanceReport("An other fishing pier blueprint is too close.");
                }
            }
            if (fishingPierSpawnerFrameList != null)
            {
                IEnumerable<Thing> fishingPierFrameInTheArea = fishingPierSpawnerFrameList.Where(building => loc.InHorDistOf(building.Position, minDistanceBetweenTwoFishingPiers));
                if (fishingPierFrameInTheArea.Count() > 0)
                {
                    return new AcceptanceReport("An other fishing pier frame is too close.");
                }
            }

            return true;
        }
开发者ID:Rikiki123456789,项目名称:Rimworld,代码行数:63,代码来源:PlaceWorker_FishingPierSpawner.cs

示例2: AllowsPlacing

        /// <summary>
        /// Checks if a new alert speaker can be built at this location.
        /// - must be near a wall,
        /// - must not be too near from another alert speaker.
        /// </summary>
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot)
        {
            IntVec3 potentialWallPosition = loc;

            // Check if another alert speaker is not too close.
            List<Thing> alertSpeakerList = Find.ListerThings.ThingsOfDef(ThingDef.Named("AlertSpeaker"));
            List<Thing> alertSpeakerBlueprintList = Find.ListerThings.ThingsOfDef(ThingDef.Named("AlertSpeaker").blueprintDef);
            List<Thing> alertSpeakerFrameList = Find.ListerThings.ThingsOfDef(ThingDef.Named("AlertSpeaker").frameDef);

            if (alertSpeakerList != null)
            {
                IEnumerable<Thing> alertSpeakerInTheArea = alertSpeakerList.Where(building => loc.InHorDistOf(building.Position, minDistanceBetweenTwoAlertSpeakers));
                if (alertSpeakerInTheArea.Count() > 0)
                {
                    return new AcceptanceReport("An other alert speaker is too close.");
                }
            }
            if (alertSpeakerBlueprintList != null)
            {
                IEnumerable<Thing> alertSpeakerBlueprintInTheArea = alertSpeakerBlueprintList.Where(building => loc.InHorDistOf(building.Position, minDistanceBetweenTwoAlertSpeakers));
                if (alertSpeakerBlueprintInTheArea.Count() > 0)
                {
                    return new AcceptanceReport("An other alert speaker blueprint is too close.");
                }
            }
            if (alertSpeakerFrameList != null)
            {
                IEnumerable<Thing> alertSpeakerFrameInTheArea = alertSpeakerFrameList.Where(building => loc.InHorDistOf(building.Position, minDistanceBetweenTwoAlertSpeakers));
                if (alertSpeakerFrameInTheArea.Count() > 0)
                {
                    return new AcceptanceReport("An other alert speaker frame is too close.");
                }
            }

            // Check it is built near a wall.
            if (Building_AlertSpeaker.CheckIfSupportingWallIsAlive(loc, rot) == false)
            {
                return new AcceptanceReport("Alert speaker must be built near a wall.");
            }

            // Display effect zone.
            if (Find.ThingGrid.CellContains(loc, ThingCategory.Building) == false)
            {
                List<IntVec3> cellsInEffectZone = Building_AlertSpeaker.GetEffectZoneCells(loc);
                GenDraw.DrawFieldEdges(cellsInEffectZone);
            }

            return true;
        }
开发者ID:Rikiki123456789,项目名称:Rimworld,代码行数:54,代码来源:PlaceWorker_AlertSpeaker.cs


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