TShockAPI.DB.Region.InArea C# (CSharp) Method

InArea() public method

Checks if a given (x, y) coordinate is in the region's area
public InArea ( int x, int y ) : bool
x int X coordinate to check
y int Y coordinate to check
return bool
        public bool InArea(int x, int y)
        {
            /*
            DO NOT CHANGE TO Area.Contains(x, y)!
            Area.Contains does not account for the right and bottom 'border' of the rectangle,
            which results in regions being trimmed.
            */
            return x >= Area.X && x <= Area.X + Area.Width && y >= Area.Y && y <= Area.Y + Area.Height;
        }

Same methods

Region::InArea ( Rectangle point ) : bool

Usage Example

コード例 #1
0
        public bool TryGetHouseRegionAtPlayer(TSPlayer player, out string owner, out int houseIndex, out Region region)
        {
            Contract.Requires<ArgumentNullException>(player != null);

              for (int i = 0; i < TShock.Regions.Regions.Count; i++) {
            region = TShock.Regions.Regions[i];
            if (region.InArea(player.TileX, player.TileY) && this.TryGetHouseRegionData(region.Name, out owner, out houseIndex))
              return true;
              }

              owner = null;
              region = null;
              houseIndex = -1;
              return false;
        }