CheckIfSupportingWallIsAlive() public static method

Checks if the wall supporting the alert speaker is still alive.
public static CheckIfSupportingWallIsAlive ( IntVec3 alertSpeakerPosition, Rot4 alertSpeakerRotation ) : bool
alertSpeakerPosition IntVec3
alertSpeakerRotation Rot4
return bool
Example #1
0
        /// <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);
        }
        /// <summary>
        /// Checks if a new alert speaker can be built at this location (must be near a wall) and draw effect area.
        /// </summary>
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Thing thingToIgnore = null)
        {
            // Check it is built near a wall.
            if (Building_AlertSpeaker.CheckIfSupportingWallIsAlive(this.Map, loc, rot) == false)
            {
                return new AcceptanceReport("Alert speaker must be built near a wall.");
            }

            // Display effect zone.
            if (loc.GetEdifice(this.Map) == null)
            {
                List<IntVec3> cellsInEffectZone = Building_AlertSpeaker.GetEffectZoneCells(this.Map, loc);
                GenDraw.DrawFieldEdges(cellsInEffectZone);
            }

            return true;
        }