Add MEGA Ocean Liner, split decks, and detailed ship materials

This commit is contained in:
josh
2026-11-28 21:02:42 -05:00
parent ce0d38c8de
commit 46624bf5ba
47 changed files with 2042 additions and 382 deletions

View File

@@ -6,24 +6,25 @@ namespace BigShipTycoon
public sealed partial class Harbor
{
internal const float PortCinematicDuration = 4.2f;
private const float QuayLength = 174f, QuayWidth = 12f;
private const float RegionalQuayLength = 174f, QuayWidth = 12f;
private readonly List<Mesh> quayMeshes = new();
private readonly List<Material> quayFinishes = new();
private GameObject portQuay;
private int cinematicPort = -1;
private bool portArrival;
private float portFrame;
private float portFrame, quayLength;
private Vector3 resumeVesselPosition, resumeWaterPosition;
private Quaternion resumeVesselRotation;
private Vector4 resumeHull, resumeCourse;
internal bool PortCinematicActive => cinematicPort >= 0;
private bool MegaPortBerth => displayedShip?.HullIndex == Market.Mega;
internal (Vector2 Near, Vector2 Far, Vector4 Matte) PortCinematicAlignment()
{
Vector3 edge = new(0, 1.4f, -QuayWidth * .5f);
Vector3 near = portQuay.transform.TransformPoint(edge - Vector3.right * QuayLength * .45f);
Vector3 far = portQuay.transform.TransformPoint(edge + Vector3.right * QuayLength * .45f);
Vector3 near = portQuay.transform.TransformPoint(edge - Vector3.right * quayLength * .45f);
Vector3 far = portQuay.transform.TransformPoint(edge + Vector3.right * quayLength * .45f);
return (viewCamera.WorldToViewportPoint(near), viewCamera.WorldToViewportPoint(far), water.GetVector("_PortMatteCrop"));
}
@@ -42,10 +43,17 @@ namespace BigShipTycoon
resumeHull = water.GetVector("_HullSpan");
resumeCourse = water.GetVector("_HullCourse");
portQuay ??= BuildPortQuay();
portQuay.transform.localPosition = new Vector3(vesselLength * .27f, 0, vesselBeam + 2.05f + QuayWidth * .5f);
float berthLength = MegaPortBerth ? vesselLength + 44f : RegionalQuayLength;
if (portQuay == null || !Mathf.Approximately(quayLength, berthLength))
{
ReleaseCinematicQuay();
quayLength = berthLength;
portQuay = BuildPortQuay();
}
float berthCenter = vesselLength * (MegaPortBerth ? .016f : .27f);
portQuay.transform.localPosition = new Vector3(berthCenter, 0, vesselBeam + 2.05f + QuayWidth * .5f);
Vector3 quay = portQuay.transform.position;
water.SetVector("_PortBerth", new Vector4(quay.x, quay.z, QuayLength * .5f, QuayWidth * .5f));
water.SetVector("_PortBerth", new Vector4(quay.x, quay.z, quayLength * .5f, QuayWidth * .5f));
portQuay.SetActive(true);
ShowPortScenery(port);
water.SetFloat("_Underway", 0);
@@ -110,21 +118,23 @@ namespace BigShipTycoon
private (Vector2 Center, float Heading, float Knots) PortMotion(float t)
{
float run = PortRun;
// The stern of the longer hull sweeps farther out from the pivot during a turn.
float turn = MegaPortBerth ? .68f : 1f;
if (portArrival)
{
float slowing = t * (2f - t);
float approach = Mathf.SmoothStep(0, 1, t);
return (new Vector2((slowing - .88f) * run, -(1f - approach) * (8.5f + vesselBeam * .31f)),
-12f * (1f - approach), Mathf.Lerp(11.8f, .35f, Mathf.Clamp01(t)));
-12f * turn * (1f - approach), Mathf.Lerp(11.8f, .35f, Mathf.Clamp01(t)));
}
float leaving = t * (.21f + t * .79f);
float castOff = Mathf.SmoothStep(0, 1, t);
return (new Vector2((leaving - .35f) * run, -castOff * (9f + vesselBeam * .31f)),
castOff * 10.5f, Mathf.Lerp(1.4f, 12.6f, t));
castOff * 10.5f * turn, Mathf.Lerp(1.4f, 12.6f, t));
}
private float PortRun => Mathf.Min(35f, vesselLength * .38f);
private float PortRun => MegaPortBerth ? vesselLength * .18f : Mathf.Min(35f, vesselLength * .38f);
private static Vector2 PortBow(float heading)
{
@@ -183,17 +193,19 @@ namespace BigShipTycoon
var paint = new HarborMesh();
var lantern = new HarborMesh();
float edge = -QuayWidth * .5f;
concrete.Box(new Vector3(0, .5f, 0), new Vector3(QuayLength, 1.32f, QuayWidth));
caps.Box(new Vector3(0, 1.24f, 0), new Vector3(QuayLength + .3f, .19f, QuayWidth + .20f));
caps.Box(new Vector3(0, 1.43f, edge + .10f), new Vector3(QuayLength, .24f, .48f));
paint.Box(new Vector3(0, 1.34f, edge + .61f), new Vector3(QuayLength - .35f, .026f, .085f));
steel.Box(new Vector3(0, 1.41f, -edge - .37f), new Vector3(QuayLength - .3f, .16f, .19f));
for (int station = -9; station <= 9; station++)
concrete.Box(new Vector3(0, .5f, 0), new Vector3(quayLength, 1.32f, QuayWidth));
caps.Box(new Vector3(0, 1.24f, 0), new Vector3(quayLength + .3f, .19f, QuayWidth + .20f));
caps.Box(new Vector3(0, 1.43f, edge + .10f), new Vector3(quayLength, .24f, .48f));
paint.Box(new Vector3(0, 1.34f, edge + .61f), new Vector3(quayLength - .35f, .026f, .085f));
steel.Box(new Vector3(0, 1.41f, -edge - .37f), new Vector3(quayLength - .3f, .16f, .19f));
const float stationSpacing = 9.52f;
int stations = Mathf.FloorToInt(quayLength / (2 * stationSpacing));
for (int station = -stations; station <= stations; station++)
{
float x = station * 9.52f;
float x = station * stationSpacing;
fenders.Box(new Vector3(x, .61f, edge - .079f), new Vector3(.64f, 1.04f, .29f));
if (station < 9)
fenders.Box(new Vector3(x + 4.76f, 1.33f, 0), new Vector3(.031f, .021f, QuayWidth - 1.6f));
if (station < stations)
fenders.Box(new Vector3(x + stationSpacing * .5f, 1.33f, 0), new Vector3(.031f, .021f, QuayWidth - 1.6f));
Vector3 foot = new Vector3(x, 1.33f, edge + 1.54f);
steel.Rod(foot, foot + Vector3.up * .48f, .14f, 8, true);
steel.Rod(foot + new Vector3(-.23f, .42f, 0), foot + new Vector3(.23f, .42f, 0), .10f, 8, true);
@@ -234,10 +246,23 @@ namespace BigShipTycoon
private void ReleasePortQuay()
{
portScenery?.Release();
ReleaseCinematicQuay();
}
private void ReleaseCinematicQuay()
{
if (portQuay != null)
{
portQuay.SetActive(false);
Destroy(portQuay);
portQuay = null;
}
foreach (Mesh mesh in quayMeshes)
Destroy(mesh);
foreach (Material material in quayFinishes)
Destroy(material);
quayMeshes.Clear();
quayFinishes.Clear();
}
}
}