Files
grass-cutters/Assets/Scripts/World/GridBlocker.cs
NiemandKG d1c3761e58 Grass Cutters Together: the project as of moon-sweepers f3666f0
A clean start for the shared repository: the Unity project (Assets, Packages, ProjectSettings), ArtSource, Docs and
Tools as they stood at f3666f0 in the old local repository, with its generated prefabs and scene brought up to date.
Images, audio, models and binaries go through Git LFS (.gitattributes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 18:44:40 +06:00

26 lines
902 B
C#

using UnityEngine;
namespace GrassCutter
{
/// <summary>
/// Fixed rig buildings (terminal, crew cabin, harbour) keep the ground under them to themselves, so nothing can be
/// built into them. Footprint = a local rectangle around <see cref="center"/>.
/// </summary>
public class GridBlocker : MonoBehaviour
{
public Vector3 center;
public Vector2 size = Vector2.one;
public static readonly System.Collections.Generic.List<GridBlocker> All = new System.Collections.Generic.List<GridBlocker>();
void OnEnable() => All.Add(this);
void OnDisable() => All.Remove(this);
public bool Covers(Vector3 p)
{
var d = p - transform.TransformPoint(center);
return Mathf.Abs(Vector3.Dot(d, transform.right)) < size.x * 0.5f && Mathf.Abs(Vector3.Dot(d, transform.forward)) < size.y * 0.5f;
}
}
}