AlertSpeaker class.
Inheritance: Building
 /// <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, Map map, Thing thingToIgnore = null, Thing thing = null)
 {
     // Check it is built near a wall.
     if (Building_AlertSpeaker.IsSupportAlive(map, loc, rot) == false)
     {
         return(new AcceptanceReport("Alert speaker must be built near a wall or tall edifice."));
     }
     return(true);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Performs the drawing treatment. Applies the drawing parameters.
        /// </summary>
        public override void Draw()
        {
            base.Draw();

            if (Find.Selector.IsSelected(this))
            {
                List <IntVec3> cellsInEffectZone = Building_AlertSpeaker.GetEffectZoneCells(this.Position);
                GenDraw.DrawFieldEdges(cellsInEffectZone);
            }
        }
        public override void DrawGhost(ThingDef def, IntVec3 center, Rot4 rot, Color ghostCol, Thing thing = null)
        {
            base.DrawGhost(def, center, rot, ghostCol, thing);

            // Display effect zone.
            if (center.GetEdifice(Find.CurrentMap) == null)
            {
                List <IntVec3> cellsInAoe = Building_AlertSpeaker.GetAreaOfEffectCells(Find.CurrentMap, center);
                GenDraw.DrawFieldEdges(cellsInAoe);
            }
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
0
        /// <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, Map map, Thing thingToIgnore = null)
        {
            // Check it is built near a wall.
            if (Building_AlertSpeaker.IsSupportAlive(map, loc, rot) == false)
            {
                return(new AcceptanceReport("Alert speaker must be built near a wall or tall edifice."));
            }

            // Display effect zone.
            if (loc.GetEdifice(map) == null)
            {
                List <IntVec3> cellsInAoe = Building_AlertSpeaker.GetAreaOfEffectCells(map, loc);
                GenDraw.DrawFieldEdges(cellsInAoe);
            }

            return(true);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Performs the drawing treatment. Applies the drawing parameters.
        /// </summary>
        public override void Draw()
        {
            base.Draw();

            if ((currentDangerRate == StoryDanger.High) &&
                (this.powerComp.PowerOn))
            {
                redAlertLightMatrix.SetTRS(this.Position.ToVector3Shifted() + new Vector3(0f, 10f, -0.25f).RotatedBy(this.Rotation.AsAngle) + Altitudes.AltIncVect, redAlertLightAngle.ToQuat(), redAlertLightScale);
                Graphics.DrawMesh(MeshPool.plane10, redAlertLightMatrix, FadedMaterialPool.FadedVersionOf(redAlertLight, redAlertLightIntensity), 0);
            }

            if (Find.Selector.IsSelected(this))
            {
                List <IntVec3> cellsInEffectZone = Building_AlertSpeaker.GetEffectZoneCells(this.Map, this.Position);
                GenDraw.DrawFieldEdges(cellsInEffectZone);
            }
        }
Ejemplo n.º 7
0
        /// <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;
        }