Add riverboat captain career and distinct ship classes

Add class-specific vessel geometry and sea motion, a guided helm qualification path, dockside sailing orders, and local excursions at all 24 ports.
This commit is contained in:
josh
2026-11-29 20:41:00 -05:00
parent 46624bf5ba
commit 290e4cb45d
67 changed files with 1783 additions and 301 deletions

View File

@@ -37,7 +37,8 @@ namespace BigShipTycoon
else
ports[1] = underway.Destination;
Vector2[][] paths = MapPaths(ports);
bool river = Ship.HullIndex == Market.River;
Vector2[][] paths = MapPaths(ports, river);
var chart = Add(overlay, "voyage-map");
var header = Add(chart, "voyage-map-header");
var heading = Add(header, "voyage-map-heading");
@@ -60,8 +61,8 @@ namespace BigShipTycoon
label.AddToClassList("voyage-map-port-next");
labels.Add(port, label);
}
plot.generateVisualContent += context => PaintVoyageMap(context, paths, currentLeg);
plot.RegisterCallback<GeometryChangedEvent>(change => PlaceMapLabels(change.newRect.size, paths, ports, labels));
plot.generateVisualContent += context => PaintVoyageMap(context, paths, currentLeg, river);
plot.RegisterCallback<GeometryChangedEvent>(change => PlaceMapLabels(change.newRect.size, paths, ports, labels, river));
var footer = Add(chart, "voyage-map-footer");
voyageMapReadout = AddText(footer, "", "voyage-map-readout");
@@ -95,17 +96,23 @@ namespace BigShipTycoon
voyageMapPlot.MarkDirtyRepaint();
}
private static Vector2[][] MapPaths(int[] ports)
private static Vector2[][] MapPaths(int[] ports, bool river = false)
{
var paths = new Vector2[ports.Length - 1][];
float longitude = Market.Ports[ports[0]].Longitude;
for (int leg = 0; leg < paths.Length; leg++)
{
Vector2[] path = paths[leg] = new Vector2[MapSamples + 1];
if (river)
{
for (int sample = 0; sample <= MapSamples; sample++)
path[sample] = Vector2.Lerp(RiverChartPoint(ports[leg]), RiverChartPoint(ports[leg + 1]), (float)sample / MapSamples);
continue;
}
PortSpec origin = Market.Ports[ports[leg]], dest = Market.Ports[ports[leg + 1]];
float start = longitude;
longitude = start + Mathf.DeltaAngle(start, dest.Longitude);
Vector3 a = GlobePoint(origin), b = GlobePoint(dest);
Vector2[] path = paths[leg] = new Vector2[MapSamples + 1];
for (int s = 0; s <= MapSamples; s++)
{
float t = (float)s / MapSamples;
@@ -129,7 +136,7 @@ namespace BigShipTycoon
public readonly Vector2 Center, Dimensions;
public readonly float Scale;
public MapProjection(Vector2 size, Vector2[][] paths)
public MapProjection(Vector2 size, Vector2[][] paths, bool river = false)
{
var minimum = paths[0][0];
var maximum = minimum;
@@ -140,7 +147,7 @@ namespace BigShipTycoon
maximum = Vector2.Max(maximum, point);
}
Center = (minimum + maximum) * .5f;
Vector2 span = Vector2.Max(maximum - minimum, new Vector2(5.5f, 3.1f));
Vector2 span = Vector2.Max(maximum - minimum, river ? new Vector2(.94f, .64f) : new Vector2(5.5f, 3.1f));
Scale = Mathf.Max(.01f, Mathf.Min((size.x - 146) / span.x, (size.y - 86) / span.y));
Dimensions = size;
}
@@ -148,9 +155,9 @@ namespace BigShipTycoon
public Vector2 Pixel(Vector2 point) => Dimensions * .5f + (point - Center) * Scale;
}
private static void PlaceMapLabels(Vector2 size, Vector2[][] paths, int[] ports, Dictionary<int, Label> labels)
private static void PlaceMapLabels(Vector2 size, Vector2[][] paths, int[] ports, Dictionary<int, Label> labels, bool river)
{
var projection = new MapProjection(size, paths);
var projection = new MapProjection(size, paths, river);
var used = new HashSet<int>();
var rows = new List<Rect>(ports.Length);
for (int i = 0; i < ports.Length; i++)
@@ -175,15 +182,18 @@ namespace BigShipTycoon
}
}
private void PaintVoyageMap(MeshGenerationContext context, Vector2[][] paths, int currentLeg)
private void PaintVoyageMap(MeshGenerationContext context, Vector2[][] paths, int currentLeg, bool river)
{
Vector2 size = context.visualElement.contentRect.size;
if (size.x < 50 || size.y < 50)
return;
var projection = new MapProjection(size, paths);
var projection = new MapProjection(size, paths, river);
Painter2D pen = context.painter2D;
PaintMapGrid(pen, projection);
PaintMapCoast(pen, projection);
if (river)
PaintRiverMapBanks(pen, projection);
else
PaintMapCoast(pen, projection);
for (int i = 0; i < paths.Length; i++)
{
@@ -226,6 +236,23 @@ namespace BigShipTycoon
pen.Stroke();
}
private static void PaintRiverMapBanks(Painter2D pen, MapProjection projection)
{
pen.fillColor = new Color(.14f, .27f, .28f);
pen.strokeColor = new Color(.42f, .51f, .47f);
pen.lineWidth = 1.15f;
foreach (Vector2[] bank in RiverBanksOnChart)
{
pen.BeginPath();
pen.MoveTo(projection.Pixel(bank[0]));
for (int i = 1; i < bank.Length; i++)
pen.LineTo(projection.Pixel(bank[i]));
pen.ClosePath();
pen.Fill();
pen.Stroke();
}
}
private static void PaintMapGrid(Painter2D pen, MapProjection map)
{
Vector2 reach = map.Dimensions / (2 * map.Scale);