19 lines
648 B
C#
19 lines
648 B
C#
using Godot;
|
||
|
||
/// <summary>
|
||
/// 辅助工具类
|
||
/// </summary>
|
||
public class H {
|
||
/// <summary>
|
||
/// 判断矩形是否包含点(包含边界)
|
||
/// </summary>
|
||
/// <param name="r">矩形区域</param>
|
||
/// <param name="p">点坐标</param>
|
||
/// <returns>如果点在矩形内(包括边界)则返回true</returns>
|
||
public static bool RectHasPointInclusive(Rect2I r, Vector2I p) {
|
||
if (r.HasPoint(p)) return true;
|
||
if (r.End.Y == p.Y && p.X >= r.Position.X && p.X <= r.End.X) return true;
|
||
if (r.End.X == p.X && p.Y >= r.Position.Y && p.Y <= r.End.Y) return true;
|
||
return false;
|
||
}
|
||
} |