Unlock expanded venues and manage concurrent fleet voyages

This commit is contained in:
josh
2026-11-28 15:36:55 -05:00
parent 636a0e2cf8
commit a9472edc35
33 changed files with 2094 additions and 363 deletions

View File

@@ -1,38 +1,43 @@
using System;
using System.Globalization;
using UnityEngine;
namespace Soundings
{
// Simplified outlines for the network diagram, using the same projection as its port markers.
internal static class WorldCoastlines
{
public static readonly Vector2[][] Shapes =
{
Coast(-172,62, -146,61, -134,57, -127,49, -123,39, -117,32, -107,27, -97,22, -89,19, -83,22,
-90,30, -83,28, -80,26, -78,34, -72,41, -60,49, -57,55, -67,61, -82,62, -96,71, -121,73, -144,69),
Coast(-117,32, -111,26, -105,20, -96,18, -89,17, -85,12, -82,9, -77,8, -74,11, -78,12, -88,23,
-96,22, -107,26),
Coast(-81,10, -72,12, -62,8, -54,4, -48,0, -36,-7, -40,-16, -44,-21, -54,-32, -63,-41,
-66,-55, -74,-51, -77,-29, -81,-9),
Coast(-59,64, -48,60, -41,60, -28,69, -22,75, -49,76),
Coast(-11,36, -10,43, -4,49, 4,53, 11,54, 18,60, 20,68, 34,69, 44,66, 62,71, 92,74, 116,73,
140,70, 176,66, 163,58, 141,52, 134,43, 126,38, 122,30, 117,22, 109,17, 105,9, 101,2, 98,9,
94,17, 88,22, 83,17, 77,8, 72,16, 69,23, 58,25, 53,17, 43,13, 38,20, 33,30, 26,37, 20,39,
15,44, 9,43, 6,39, -1,35),
Coast(-9,35, 12,36, 25,32, 32,30, 38,18, 43,13, 51,11, 45,3, 41,-6, 40,-15, 34,-25, 27,-34,
17,-35, 11,-21, 6,-9, 8,4, -5,5, -17,14, -16,24),
Coast(113,-24, 117,-17, 125,-15, 134,-12, 141,-18, 143,-12, 148,-22, 153,-29,
151,-36, 142,-39, 132,-34, 123,-34, 115,-33),
Coast(95,6, 103,2, 108,-3, 119,-8, 116,-10, 105,-7, 100,-3),
Coast(109,1, 117,7, 119,2, 116,-4, 111,-2),
Coast(173,-34, 178,-38, 175,-41, 170,-45, 166,-47, 168,-42, 173,-38)
};
private static readonly (Vector2[][] Shapes, Rect[] Bounds) Outlines = ReadOutlines();
public static Vector2[][] Shapes => Outlines.Shapes;
public static Rect[] Bounds => Outlines.Bounds;
private static Vector2[] Coast(params float[] coordinates)
private static (Vector2[][] Shapes, Rect[] Bounds) ReadOutlines()
{
var polygon = new Vector2[coordinates.Length / 2];
for (int i = 0; i < polygon.Length; i++)
polygon[i] = new Vector2((coordinates[i * 2] + 180) / 360, (76 - coordinates[i * 2 + 1]) / 137);
return polygon;
// Public-domain Natural Earth 1:50m land, simplified with extra detail around the ports.
// Each line is one exterior outline, with longitude and latitude in thousandths of a degree.
TextAsset data = Resources.Load<TextAsset>("Coastlines");
if (data == null)
return (Array.Empty<Vector2[]>(), Array.Empty<Rect>());
string[] outlines = data.text.Split('\n', StringSplitOptions.RemoveEmptyEntries);
var shapes = new Vector2[outlines.Length][];
var bounds = new Rect[outlines.Length];
for (int ring = 0; ring < outlines.Length; ring++)
{
string[] coordinates = outlines[ring].Split(' ', StringSplitOptions.RemoveEmptyEntries);
var polygon = shapes[ring] = new Vector2[coordinates.Length / 2];
Vector2 lower = Vector2.positiveInfinity, upper = Vector2.negativeInfinity;
for (int vertex = 0; vertex < polygon.Length; vertex++)
{
int lon = int.Parse(coordinates[vertex * 2], CultureInfo.InvariantCulture);
int lat = int.Parse(coordinates[vertex * 2 + 1], CultureInfo.InvariantCulture);
polygon[vertex] = new Vector2((lon + 180_000) / 360_000f, (76_000 - lat) / 137_000f);
var degrees = new Vector2(lon * .001f, -lat * .001f);
lower = Vector2.Min(lower, degrees);
upper = Vector2.Max(upper, degrees);
}
bounds[ring] = Rect.MinMaxRect(lower.x, lower.y, upper.x, upper.y);
}
return (shapes, bounds);
}
}
}