core/iso/Grid.cs
public class Grid : Component {
protected override void DrawGizmos() {
if (Gizmo.CameraTransform.Position.z > 1500)
return;
Gizmo.Transform = global::Transform.Zero;
var center = Gizmo.CameraTransform.Position.WithZ(0);
center.x /= 1.5f;
center.y /= MathF.Sqrt(3);
var rect = new Rect(center.SnapToGrid(20) - 500, 1000);
for (int x = rect.Left.FloorToInt(); x < rect.Right.FloorToInt(); x += 20) {
for (int y = rect.Top.FloorToInt(); y < rect.Bottom.FloorToInt(); y += 20) {
var coord = Vector3.Zero.WithX(1.5f * x.SnapToGrid(20)).WithY(MathF.Sqrt(3) * y.SnapToGrid(20));
if (Math.Abs(x)/20%2 > 0)
coord.y += MathF.Sqrt(3) * 10;
Gizmo.Draw.Color = Color.Cyan * (1f - Gizmo.CameraTransform.Position.WithZ(Gizmo.CameraTransform.Position.z * 0.6f).Distance(coord) / 900f);
Gizmo.Draw.LineCircle(coord, Vector3.Up, 20, 60, 180, 3);
Gizmo.Draw.Color = Color.Red * 2f * Gizmo.Draw.Color.b;
if (IsBlocked(coord))
Gizmo.Draw.LineCircle(coord, Vector3.Up, 15, 60, 360, 6);
}
}
base.DrawGizmos();
}
public static Vector3 Snap(Vector3 point) {
point.x /= 1.5f;
point.y /= MathF.Sqrt(3);
var dy = point.y;
point = point.SnapToGrid(20);
dy -= point.y;
var x = point.x;
point.x *= 1.5f;
point.y *= MathF.Sqrt(3);
if (Math.Abs(x)/20%2 > 0) {
if (dy > 0)
point.y += MathF.Sqrt(3) * 10;
else
point.y -= MathF.Sqrt(3) * 10;
}
return point;
}
public static bool IsBlocked(Vector3 point) {
point = Snap(point);
return Game.ActiveScene.FindInPhysics(new Sphere(point, 5f)).Any();
}
}
public class RemoveNumbers : Component {
protected override void DrawGizmos() {
foreach (var obj in Scene.GetAllObjects(true)) {
if (obj.Name.EndsWith(" (1)"))
obj.Name = obj.Name.Replace(" (1)", null);
}
base.DrawGizmos();
}
}