supervisor-simulator/scripts/Helpers.cs
2026-01-18 20:05:23 +08:00

19 lines
648 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
}
}