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

@@ -9,14 +9,17 @@ namespace BigShipTycoon
public Vector2 Position, ApproachWaypoint;
public float RouteDuration, Heading, Rudder, Speed, Progress, TurnRate;
public bool Manual, PropulsionStopped, Arrived, ExtendingApproach;
public HelmPracticeSnapshot Practice;
}
internal sealed class HelmNavigation
{
private const float MetresPerKnot = .514444f;
private const float RudderLimit = 35f;
private const float RudderSlew = 15f;
private const float IntegrationStep = .1f;
private readonly float duration, cruiseKnots, turnRateLimit, inertia, arrivalRadius;
private readonly HullSpec riverHull;
private float turnRate;
private Vector2 approachWaypoint;
private bool extendingApproach;
@@ -24,9 +27,12 @@ namespace BigShipTycoon
public HelmNavigation(float duration, int hullIndex)
{
this.duration = Mathf.Max(1, duration);
cruiseKnots = 17f + 2f * hullIndex;
turnRateLimit = 4.2f - .5f * hullIndex;
inertia = 1f + .16f * hullIndex;
bool river = hullIndex == Market.River;
riverHull = river ? Market.Hulls[hullIndex] : null;
cruiseKnots = river ? 10f : 17f + 2f * hullIndex;
turnRateLimit = river ? 8.5f : 4.2f - .5f * hullIndex;
inertia = river ? .62f : 1f + .16f * hullIndex;
Practice = new HelmPractice(hullIndex);
arrivalRadius = Mathf.Min(this.duration * .15f, Mathf.Clamp(this.duration * .006f, .6f, 1.8f));
}
@@ -38,7 +44,10 @@ namespace BigShipTycoon
public float Progress { get; private set; }
public Vector2 Position { get; private set; }
public bool Arrived { get; private set; }
public bool AtChannelEdge { get; private set; }
public float RemainingSeconds => Arrived ? 0 : (new Vector2(duration, 0) - Position).magnitude;
internal float CourseToDestination => Mathf.Atan2(-Position.y, duration - Position.x) * Mathf.Rad2Deg;
internal HelmPractice Practice { get; }
public void Advance(float seconds, float rudderInput, float engineSpeedFactor, WeatherCondition weather)
{
@@ -74,7 +83,17 @@ namespace BigShipTycoon
Heading = Mathf.Repeat(Heading + yawStep + 180f, 360f) - 180f;
float distance = (previousSpeed + Speed) * .5f / cruising * delta;
Position += new Vector2(Mathf.Cos(course), Mathf.Sin(course)) * distance;
Vector2 position = Position + new Vector2(Mathf.Cos(course), Mathf.Sin(course)) * distance;
AtChannelEdge = false;
if (riverHull != null)
{
float hullReach = Mathf.Abs(Mathf.Sin(course)) * riverHull.Length * .45f
+ Mathf.Abs(Mathf.Cos(course)) * riverHull.Beam * .5f;
float sideLimit = (33f - hullReach) / (cruising * MetresPerKnot);
AtChannelEdge = Mathf.Abs(position.y) > sideLimit;
position.y = Mathf.Clamp(position.y, -sideLimit, sideLimit);
}
Position = position;
Arrived = RemainingSeconds <= arrivalRadius;
Progress = Arrived ? 1 : Mathf.Max(Progress, Mathf.Clamp01(1 - RemainingSeconds / duration));
}
@@ -116,7 +135,8 @@ namespace BigShipTycoon
{
Position = Position, ApproachWaypoint = approachWaypoint, RouteDuration = duration, Heading = Heading,
Rudder = Rudder, Speed = Speed, Progress = Progress, TurnRate = turnRate, Manual = Manual,
PropulsionStopped = PropulsionStopped, Arrived = Arrived, ExtendingApproach = extendingApproach
PropulsionStopped = PropulsionStopped, Arrived = Arrived, ExtendingApproach = extendingApproach,
Practice = Practice.Capture()
};
internal bool RestoreState(HelmSnapshot state)
@@ -128,7 +148,7 @@ namespace BigShipTycoon
|| !Finite(state.Rudder) || Mathf.Abs(state.Rudder) > RudderLimit
|| !Finite(state.Speed) || state.Speed < 0 || state.Speed > 120
|| !Finite(state.Progress) || state.Progress < 0 || state.Progress > 1 || (state.Arrived && state.Progress != 1)
|| !Finite(state.TurnRate) || Mathf.Abs(state.TurnRate) > 40)
|| !Finite(state.TurnRate) || Mathf.Abs(state.TurnRate) > 40 || !Practice.Restore(state.Practice))
return false;
float scale = duration / state.RouteDuration;