House.House.IsInsideAnotherHouse C# (CSharp) Method

IsInsideAnotherHouse() public method

public IsInsideAnotherHouse ( string PlayerName, int x, int y, int check ) : bool
PlayerName string
x int
y int
check int
return bool
        public bool IsInsideAnotherHouse(string PlayerName, int x, int y, int check = 0)
        {
            foreach (PlayerHouses playerHouse in playerHouses)
            {
                if (playerHouse.PlayerName != PlayerName)
                {
                    foreach (PlayerHouseCoords houseCoords in playerHouse.Houses)
                    {
                        if (x >= houseCoords.TopLeft.X && x <= houseCoords.BottomRight.X &&
                            y >= houseCoords.TopLeft.Y && y <= houseCoords.BottomRight.Y)
                        {
                            for (int i = 0; i < houseCoords.Allowed.Count; i++)
                            {
                                if (houseCoords.Allowed[i] == PlayerName)
                                {
                                    return false;
                                }
                            }

                            if (check == House.CHECK_CHEST_LOCK && !houseCoords.LockChests)
                                return false;

                            if (check == House.CHECK_DOOR_LOCK && !houseCoords.LockDoors)
                                return false;

                            if (check == House.CHECK_SIGN_LOCK && !houseCoords.LockSigns)
                                return false;

                            return true;
                        }
                    }
                }
            }

            return false;
        }