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,33 +6,46 @@ namespace BigShipTycoon
{
internal sealed class SunDeckGrid
{
private const float Cell = 3f, RailClearance = .65f;
private const float RailClearance = .65f;
private readonly Ship ship;
private readonly SunDeckZone zone;
private readonly float length, offset, halfBeam;
private readonly Vector2 radome;
private readonly bool mega;
private readonly float cellSize;
private IReadOnlyList<SunDeckPlacement> existing;
internal SunDeckGrid(Ship ship, int deckCount = 0)
internal SunDeckGrid(Ship ship, int deckCount = 0, SunDeckZone zone = SunDeckZone.Sky)
{
this.ship = ship;
this.zone = zone;
mega = ship.HasAftTerrace;
cellSize = mega ? 4.5f : 3f;
deckCount = deckCount > 0 ? deckCount : ship.Decks.Count;
int top = deckCount - 1;
length = VesselExterior.DeckLength(ship.Hull.Length, top);
offset = VesselExterior.DeckOffset(ship.Hull.Length, top);
halfBeam = VesselExterior.DeckHalfBeam(ship.Hull.Beam * .5f, top);
Columns = Mathf.FloorToInt((length - 2 * RailClearance) / Cell);
Rows = Mathf.FloorToInt((2 * halfBeam - 2 * RailClearance) / Cell);
Area = new Rect(offset - Columns * Cell * .5f, -Rows * Cell * .5f, Columns * Cell, Rows * Cell);
(length, halfBeam, offset) = MegaDeckGeometry.ForShip(ship, deckCount - 1, deckCount);
Rect footprint = zone == SunDeckZone.AftTerrace ? MegaDeckGeometry.TerraceArea(ship.Hull.Length, ship.Hull.Beam * .5f, deckCount)
: new Rect(offset - length * .5f, -halfBeam, length, 2 * halfBeam);
Columns = Mathf.FloorToInt((footprint.width - 2 * RailClearance) / cellSize);
Rows = Mathf.FloorToInt((footprint.height - 2 * RailClearance) / cellSize);
Vector2 gridSize = new Vector2(Columns, Rows) * cellSize;
Area = new Rect(footprint.center - gridSize * .5f, gridSize);
float funnel = offset - length * .24f;
float funnelHalfWidth = halfBeam * .23f + 1.27f;
Funnels = new Rect(funnel - 2.4f, -funnelHalfWidth, 4.8f, 2 * funnelHalfWidth);
float funnelHalfWidth = mega ? halfBeam * .58f + .35f : halfBeam * .23f + 1.27f;
radome = new Vector2(funnel + 6.10f, halfBeam * .50f);
float bridge = VesselExterior.BridgeCenter(ship.Hull.Length, deckCount);
Bridge = new Rect(bridge - 4.85f, -halfBeam, 9.7f, 2 * halfBeam);
float bridge = MegaDeckGeometry.BridgeCenter(ship, deckCount);
if (zone == SunDeckZone.Sky)
{
float funnelHalfLength = mega ? 9.2f : 2.4f;
Funnels = new Rect(funnel - funnelHalfLength, -funnelHalfWidth, 2 * funnelHalfLength, 2 * funnelHalfWidth);
float bridgeHalfLength = mega ? 10.5f : 4.85f;
float bridgeHalfWidth = mega ? .66f * halfBeam + 1f : halfBeam;
Bridge = new Rect(bridge - bridgeHalfLength, -bridgeHalfWidth, 2 * bridgeHalfLength, 2 * bridgeHalfWidth);
}
SunPoolStyle pool = ship.SunDeckPlan.Pool;
bool automatic = pool == SunPoolStyle.Automatic && !ship.SunDeckPlan.CustomLayout;
SunDeckPlan plan = ship.SunDeckFor(zone);
SunPoolStyle pool = plan.Pool;
bool automatic = pool == SunPoolStyle.Automatic && !plan.CustomLayout;
Facility[] cells = ship.Decks[^1].Cells;
bool resort = automatic && (Array.IndexOf(cells, Facility.ResortPool) >= 0 || Array.IndexOf(cells, Facility.WaterPark) >= 0);
SelectedPool = pool is SunPoolStyle.Automatic or SunPoolStyle.None
@@ -41,14 +54,14 @@ namespace BigShipTycoon
internal int Columns { get; }
internal int Rows { get; }
internal float CellLength => Cell;
internal float CellWidth => Cell;
internal float CellLength => cellSize;
internal float CellWidth => cellSize;
internal Rect Area { get; }
internal Rect Bridge { get; }
internal Rect Funnels { get; }
internal SunPoolStyle SelectedPool { get; }
internal IReadOnlyList<SunDeckPlacement> Existing => existing ??= ship.SunDeckPlan.CustomLayout
? ship.SunDeckPlan.Placements ?? Array.Empty<SunDeckPlacement>() : LegacyFittings();
internal IReadOnlyList<SunDeckPlacement> Existing => existing ??= ship.SunDeckFor(zone).CustomLayout
? ship.SunDeckFor(zone).Placements ?? Array.Empty<SunDeckPlacement>() : LegacyFittings();
internal int PoolIndex
{
@@ -63,6 +76,7 @@ namespace BigShipTycoon
internal Vector2 PoolBasinHalfSize(SunPoolStyle pool) => Normalize(pool) switch
{
SunPoolStyle.Lagoon => new Vector2(11.8f, 4.7f),
SunPoolStyle.Resort => new Vector2(Mathf.Min(7.15f, length * .089f), Mathf.Min(2.77f, halfBeam * .39f)),
SunPoolStyle.Family => new Vector2(Mathf.Min(4.48f, length * .085f), Mathf.Min(2.18f, halfBeam * .38f)),
_ => new Vector2(VesselExterior.PoolHalfLength, VesselExterior.PoolHalfWidth)
@@ -72,6 +86,7 @@ namespace BigShipTycoon
{
SunAttraction.Pool => Normalize(pool) switch
{
SunPoolStyle.Lagoon => new Vector2(14.2f, 6.95f),
SunPoolStyle.Resort => new Vector2(9.2f, 4.65f),
SunPoolStyle.Family => new Vector2(6.5f, 4.1f),
_ => new Vector2(4.65f, 3.45f)
@@ -80,6 +95,7 @@ namespace BigShipTycoon
SunAttraction.Theater => new Vector2(4.3f, 2.7f),
SunAttraction.GoKarts => new Vector2(6.3f, 2.6f),
SunAttraction.RollerCoaster => new Vector2(7.4f, 3.5f),
SunAttraction.SkyGarden => new Vector2(8.7f, 5.25f),
_ => Vector2.zero
};
@@ -88,34 +104,36 @@ namespace BigShipTycoon
private Vector2Int Bays(SunDeckPlacement item, SunPoolStyle pool)
{
Vector2 half = HalfSize(item.Kind, pool);
Vector2Int size = new(Mathf.CeilToInt(2 * half.x / Cell), Mathf.CeilToInt(2 * half.y / Cell));
Vector2Int size = new(Mathf.CeilToInt(2 * half.x / cellSize), Mathf.CeilToInt(2 * half.y / cellSize));
return (item.Rotation & 1) == 0 ? size : new Vector2Int(size.y, size.x);
}
internal Rect Bounds(SunDeckPlacement item, SunPoolStyle pool)
{
Vector2Int size = Bays(item, pool);
return new Rect(Area.xMin + item.Column * Cell, Area.yMin + item.Row * Cell, size.x * Cell, size.y * Cell);
return new Rect(Area.xMin + item.Column * cellSize, Area.yMin + item.Row * cellSize, size.x * cellSize, size.y * cellSize);
}
internal bool IsBlocked(int column, int row)
{
if ((uint)column >= (uint)Columns || (uint)row >= (uint)Rows)
return true;
var cell = new Rect(Area.xMin + column * Cell, Area.yMin + row * Cell, Cell, Cell);
if (zone == SunDeckZone.AftTerrace)
return false;
var cell = new Rect(Area.xMin + column * cellSize, Area.yMin + row * cellSize, cellSize, cellSize);
if (cell.Overlaps(Bridge) || cell.Overlaps(Funnels))
return true;
float aft = (cell.xMin - offset) / (length * .994f) + .5f;
float fore = (cell.xMax - offset) / (length * .994f) + .5f;
float width = halfBeam * .992f * Mathf.Min(VesselExterior.SideWidth(aft), VesselExterior.SideWidth(fore));
return Mathf.Max(Mathf.Abs(cell.yMin), Mathf.Abs(cell.yMax)) > width - RailClearance
|| cell.Overlaps(new Rect(radome.x - .7f, radome.y - .7f, 1.4f, 1.4f))
|| cell.Overlaps(new Rect(radome.x - .7f, -radome.y - .7f, 1.4f, 1.4f));
|| !mega && (cell.Overlaps(new Rect(radome.x - .7f, radome.y - .7f, 1.4f, 1.4f))
|| cell.Overlaps(new Rect(radome.x - .7f, -radome.y - .7f, 1.4f, 1.4f)));
}
internal int At(int col, int row, SunPoolStyle pool)
{
Vector2 center = Area.min + new Vector2(col + .5f, row + .5f) * Cell;
Vector2 center = Area.min + new Vector2(col + .5f, row + .5f) * cellSize;
for (int i = 0; i < Existing.Count; i++)
if (Bounds(Existing[i], pool).Contains(center))
return i;
@@ -124,12 +142,11 @@ namespace BigShipTycoon
internal string PlacementBlock(SunDeckPlacement item, SunPoolStyle pool, IReadOnlyList<SunDeckPlacement> items, int replacing = -1)
{
if ((uint)item.Kind < (uint)SunAttraction.MiniGolf || (uint)item.Kind > (uint)SunAttraction.Pool || (uint)item.Rotation > 3)
if ((uint)item.Kind < (uint)SunAttraction.MiniGolf || (uint)item.Kind > (uint)SunAttraction.SkyGarden || (uint)item.Rotation > 3)
return "Select a fitting and turn it in quarter turns.";
if (replacing < -1 || replacing >= items.Count || replacing >= 0 && items[replacing].Kind != item.Kind)
return "Select a fitting on this sun deck.";
int hull = item.Kind == SunAttraction.Pool && Normalize(pool) == SunPoolStyle.Resort ? Market.Regional
: SunDeckPlan.RequiredHull(item.Kind);
int hull = item.Kind == SunAttraction.Pool ? SunDeckPlan.RequiredHull(Normalize(pool)) : SunDeckPlan.RequiredHull(item.Kind);
if (ship.HullIndex < hull)
return $"Requires a {Market.Hulls[hull].Name} hull or larger.";