CaveworldFlora.ClusterPlant.IsNearNaturalRockBlock C# (CSharp) Method

IsNearNaturalRockBlock() public static method

public static IsNearNaturalRockBlock ( IntVec3 position ) : bool
position IntVec3
return bool
        public static bool IsNearNaturalRockBlock(IntVec3 position)
        {
            for (int xOffset = -2; xOffset <= 2; xOffset++)
            {
                for (int zOffset = -2; zOffset <= 2; zOffset++)
                {
                    IntVec3 checkedPosition = position + new IntVec3(xOffset, 0, zOffset);
                    if (checkedPosition.InBounds())
                    {
                        Thing potentialRock = Find.ThingGrid.ThingAt(checkedPosition, ThingCategory.Building);
                        if ((potentialRock != null)
                            && ((potentialRock as Building) != null))
                        {
                            if ((potentialRock as Building).def.building.isNaturalRock)
                            {
                                return true;
                            }
                        }
                    }
                }
            }
            return false;
        }
    }