CanPlaceNewPylonHere() public static method

public static CanPlaceNewPylonHere ( IntVec3 testedPosition, string &reason ) : bool
testedPosition IntVec3
reason string
return bool
コード例 #1
0
        public override AcceptanceReport AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot, Thing thingToIgnore = null)
        {
            string reason          = "";
            bool   canBePlacedHere = Building_LaserFencePylon.CanPlaceNewPylonHere(this.Map, loc, out reason);

            if (canBePlacedHere == false)
            {
                return(new AcceptanceReport(reason));
            }

            // Display potential placing positions.
            foreach (Thing pylon in this.Map.listerThings.ThingsOfDef(ThingDef.Named("LaserFencePylon").blueprintDef))
            {
                if (pylon.Position.InHorDistOf(loc, 6f))
                {
                    Building_LaserFencePylon.DrawPotentialPlacePositions(this.Map, pylon.Position);
                }
            }
            foreach (Thing pylon in this.Map.listerThings.ThingsOfDef(ThingDef.Named("LaserFencePylon").frameDef))
            {
                if (pylon.Position.InHorDistOf(loc, 6f))
                {
                    Building_LaserFencePylon.DrawPotentialPlacePositions(this.Map, pylon.Position);
                }
            }
            foreach (Thing pylon in this.Map.listerThings.ThingsOfDef(ThingDef.Named("LaserFencePylon")))
            {
                if (pylon.Position.InHorDistOf(loc, 6f))
                {
                    Building_LaserFencePylon.DrawPotentialPlacePositions(this.Map, pylon.Position);
                }
            }

            return(true);
        }
コード例 #2
0
        public override AcceptanceReport  AllowsPlacing(BuildableDef checkingDef, IntVec3 loc, Rot4 rot)
        {
            string reason          = "";
            bool   canBePlacedHere = Building_LaserFencePylon.CanPlaceNewPylonHere(loc, out reason);

            if (canBePlacedHere == false)
            {
                return(new AcceptanceReport(reason));
            }

            // Removed as it is consuming too much CPU when there are many pylons.

            /*// Display potential placing positions.
             * foreach (Building_LaserFencePylon pylon in Find.ListerBuildings.AllBuildingsColonistOfClass<Building_LaserFencePylon>())
             * {
             *  pylon.DrawPotentialPlacePositions();
             * }*/

            return(true);
        }
コード例 #3
0
        public static void DrawPotentialPlacePositions(Map map, IntVec3 pylonPosition)
        {
            List <IntVec3> potentialPlacingPositionsList = new List <IntVec3>();

            for (int directionAsInt = 0; directionAsInt < 4; directionAsInt++)
            {
                for (int offset = 1; offset <= 5; offset++)
                {
                    string  unusedReason   = "";
                    IntVec3 testedPosition = pylonPosition + new IntVec3(offset, 0, 0).RotatedBy(new Rot4(directionAsInt));
                    if (Building_LaserFencePylon.CanPlaceNewPylonHere(map, testedPosition, out unusedReason))
                    {
                        potentialPlacingPositionsList.Add(testedPosition);
                    }
                }
                if (potentialPlacingPositionsList.NullOrEmpty() == false)
                {
                    GenDraw.DrawFieldEdges(potentialPlacingPositionsList);
                }
            }
        }