using UnityEngine; namespace BigShipTycoon { internal sealed partial class VesselExterior { private const int MegaDeckStations = 56; private void BuildMegaPassengerDeck(int deck) { bool sky = deck == ship.Decks.Count - 1; float floor = DeckBase + deck * DeckSpacing; float roof = floor + DeckSpacing; var (span, halfWidth, offset) = MegaDeckGeometry.ForShip(ship, deck, ship.Decks.Count); var center = new Vector2(offset, 0); Vector2[] edge = Outline(span, halfWidth, offset, MegaDeckStations); Paint fascia = deck is 2 or 6 || sky ? Paint.AtriumGlass : Paint.Black; float wall = sky ? .88f : .86f; Coat(Paint.MegaHull).Loft(edge, center, false, new Vector3(.985f, floor, wall - .025f), new Vector3(.996f, floor + .22f, wall), new Vector3(.996f, roof - .30f, wall)); Coat(fascia).Loft(edge, center, false, new Vector3(.997f, roof - .36f, wall + .01f), new Vector3(1.009f, roof - .25f, .997f)); Coat(Paint.Pearl).Loft(edge, center, false, new Vector3(1.010f, roof - .23f, 1.002f), new Vector3(1.007f, roof - .09f, 1.002f), new Vector3(.997f, roof - .04f, .993f)); Coat(Paint.Teak).Loft(edge, center, true, new Vector3(.997f, roof - .04f, .993f), new Vector3(.994f, roof, .992f)); if (sky || deck >= ship.Decks.Count - 2 || deck is 2 or 6) BuildMegaGlassRail(edge, roof, sky); else Rails(edge, roof, roof + .78f, 3.3f); float bay = .79f * span / balconies; for (int i = 0; i < balconies; i++) { float station = Mathf.Lerp(.072f, .862f, (i + .5f) / balconies); int column = Mathf.Min(ship.Hull.Columns - 1, Mathf.FloorToInt(station * ship.Hull.Columns)); bool gallery = deck is >= 3 and <= 5 && station is >= .41f and <= .57f; bool band = deck is 2 or 6 || station > .72f || sky; for (int side = -1; side <= 1; side += 2) { var (at, along, outward) = SideFrame(station, floor, span * .996f, halfWidth * wall, offset, side, MegaDeckStations); int row = side < 0 ? 0 : ship.Hull.Rows - 1; Facility fitting = ship.Decks[deck].FacilityAt(row * ship.Hull.Columns + column, ship.Hull.Columns); float balconyDepth = halfWidth * SideWidth(station) * (.992f - wall); BuildMegaWindowBay(at, along, outward, side, bay, balconyDepth, fitting, i, deck, band, gallery); } } if (!sky) return; float stern = offset - span * .5f; for (int side = -1; side <= 1; side += 2) Coat(Paint.AtriumGlass).Loft(RoundedRectangle(new Vector2(stern + .84f, side * halfWidth * .34f), 1.3f, 2.15f, .46f), new Vector2(stern + .84f, side * halfWidth * .34f), false, new Vector3(.9f, floor + .21f, 1f), new Vector3(1f, roof - .16f, 1f)); } private void BuildMegaWindowBay(Vector3 at, Vector3 along, Vector3 outward, int side, float bay, float depth, Facility fitting, int index, int deck, bool band, bool gallery) { bool suite = fitting is Facility.Cabin or Facility.Suite or Facility.GrandSuite or Facility.SkyResidence; bool machinery = fitting is Facility.Tank or Facility.Stores or Facility.Waste or Facility.Water or Facility.Workshop or Facility.Galley or Facility.BunkerFarm or Facility.ColdChain or Facility.LaundryPlant or Facility.MembranePlant or Facility.ReclamationPlant or Facility.EngineeringCenter or Facility.ProductionGalley; if (machinery && !gallery) { if ((index & 1) == 0) BuildVent(at + outward * .075f + Vector3.up * 1.44f, along, outward, side, bay * .60f); return; } bool lit = fitting != Facility.Empty && (index * 13 + deck * 7 + side + 1) % 17 < 4; Paint glazing = gallery || band ? Paint.AtriumGlass : Paint.Glass; float width = bay * (gallery ? .965f : band ? .91f : .86f); float height = gallery ? 1.95f : suite ? 1.86f : 1.51f; Vector3 center = at + outward * .091f + Vector3.up * (gallery ? 1.28f : 1.23f); SidePanel(Coat(Paint.Black), center, along, side, width, height); int panes = gallery ? 2 : 3; float pane = (width - .036f) / panes; for (int ii = 0; ii < panes; ii++) { Vector3 glass = center + outward * .009f + along * ((ii + .5f - panes * .5f) * pane); SidePanel(Coat(lit && ii == 0 ? Paint.Lounge : glazing), glass, along, side, pane - .031f, height - .10f); } if (gallery && index % 3 == 0) { Vector3 stem = center + along * width * .50f + outward * .095f - Vector3.up * 1.25f; Coat(Paint.Pearl).Rod(stem, stem + Vector3.up * DeckSpacing + along * .41f, .055f, 5); } if (suite || !band && !gallery) { // A flush glass front is backed by an actual recessed balcony and a dividing privacy screen. Vector3 rail = at + outward * Mathf.Max(.90f, depth - .33f); SidePanel(Coat(Paint.BlueGlass), rail + Vector3.up * .53f, along, side, width * .95f, .71f); Coat(Paint.Steel).Rod(rail - along * width * .49f + Vector3.up * .93f, rail + along * width * .49f + Vector3.up * .93f, .030f, 5); Coat(Paint.Pearl).Box(at + along * (bay * .49f) + outward * (depth * .46f) + Vector3.up * .72f, new Vector3(.044f, 1.31f, Mathf.Max(.43f, depth * .78f)), along); } } private void BuildMegaGlassRail(Vector2[] contour, float y, bool sky) { HarborMesh upper = Coat(Paint.Steel); HarborMesh panes = Coat(Paint.AtriumGlass); float halfBeam = MegaDeckGeometry.ForShip(ship, ship.Decks.Count - 1, ship.Decks.Count).Beam; for (int segment = 0; segment < contour.Length; segment++) { Vector2 first = contour[segment]; Vector2 end = contour[(segment + 1) % contour.Length]; int spans = Mathf.Max(1, Mathf.CeilToInt(Vector2.Distance(first, end) / 2.8f)); for (int span = 0; span < spans; span++) { Vector2 a = Vector2.Lerp(first, end, span / (float)spans); Vector2 b = Vector2.Lerp(first, end, (span + 1f) / spans); float midway = (a.y + b.y) * .5f; if (sky && segment == contour.Length - 1 && Mathf.Abs(Mathf.Abs(midway) - halfBeam * .23f) < .90f) continue; Vector3 lowerA = HarborMesh.Point(a, y + .11f); Vector3 lowerB = HarborMesh.Point(b, y + .11f); Vector3 headA = HarborMesh.Point(a, y + .88f); Vector3 headB = HarborMesh.Point(b, y + .88f); Vector3 inset = (lowerB - lowerA).normalized * .041f; panes.Quad(lowerA + inset, lowerB - inset, headB - inset, headA + inset); panes.Quad(lowerB - inset, lowerA + inset, headA + inset, headB - inset); upper.Rod(headA, headB, .039f, 5); upper.Rod(lowerA - Vector3.up * .11f, headA, .033f, 5); } } } private void BuildMegaRoof() { int count = ship.Decks.Count; var (deckLength, halfWidth, offset) = MegaDeckGeometry.ForShip(ship, count - 1, count); float top = MegaDeckGeometry.RoofHeight(count, SunDeckZone.Sky); float bridge = MegaDeckGeometry.BridgeCenter(ship, count); BuildMegaObservationBridge(bridge, halfWidth, top); BuildMegaFunnelPavilion(offset - deckLength * .24f, halfWidth, top); BuildMegaRoofTrack(deckLength, halfWidth, offset, top); BuildMegaAftTerrace(count, top, halfWidth); BuildSunDeck(SunDeck(ship), top); BuildSunDeck(SunDeck(ship, SunDeckZone.AftTerrace), top - DeckSpacing); } private void BuildMegaObservationBridge(float bridge, float halfWidth, float y) { Vector2 center = new Vector2(bridge, 0); Vector2[] profile = Outline(19.1f, halfWidth * .62f, bridge, 28); Coat(Paint.Pearl).Loft(profile, center, false, new Vector3(.94f, y, .90f), new Vector3(1f, y + .74f, 1f)); Coat(Paint.AtriumGlass).Loft(profile, center, false, new Vector3(1f, y + .74f, 1f), new Vector3(.984f, y + 2.57f, .93f)); Coat(Paint.MegaHull).Loft(profile, center, true, new Vector3(.987f, y + 2.54f, .939f), new Vector3(1.047f, y + 2.76f, 1.03f), new Vector3(.98f, y + 2.98f, .96f)); Coat(Paint.FritGlass).Loft(profile, center, true, new Vector3(.77f, y + 2.98f, .79f), new Vector3(.67f, y + 3.78f, .72f), new Vector3(.47f, y + 4.48f, .52f), new Vector3(.25f, y + 4.86f, .34f)); for (int edge = 0; edge < profile.Length; edge += 2) { Vector2 point = profile[edge] - center; Coat(Paint.Pearl).Rod(HarborMesh.Point(center + point, y + .74f), HarborMesh.Point(center + Vector2.Scale(point, new Vector2(.984f, .933f)), y + 2.57f), .052f, 5); Vector3 spring = HarborMesh.Point(center + Vector2.Scale(point, new Vector2(.77f, .79f)), y + 2.99f); Vector3 knee = HarborMesh.Point(center + Vector2.Scale(point, new Vector2(.67f, .72f)), y + 3.80f); Vector3 shoulder = HarborMesh.Point(center + Vector2.Scale(point, new Vector2(.47f, .52f)), y + 4.50f); Coat(Paint.Pearl).Rod(spring, knee, .045f, 5); Coat(Paint.Pearl).Rod(knee, shoulder, .045f, 5); } for (int side = -1; side <= 1; side += 2) { Vector3 wing = new Vector3(bridge + 2.45f, y + 1.52f, side * halfWidth * .597f); Coat(Paint.AtriumGlass).Box(wing, new Vector3(3.50f, 1.39f, 2.12f)); Coat(Paint.Pearl).Box(wing + Vector3.up * .73f, new Vector3(3.65f, .14f, 2.26f)); Coat(Paint.Pearl).Box(wing - Vector3.up * .76f, new Vector3(3.65f, .21f, 2.24f)); Coat(side > 0 ? Paint.StarboardLight : Paint.PortLight).Box(wing + Vector3.forward * (side * 1.13f), new Vector3(.26f, .14f, .055f)); } Vector3 mast = new Vector3(bridge + 2.18f, y + 4.79f, 0); Coat(Paint.Pearl).Rod(mast, mast + new Vector3(-.21f, 1.03f, 0), .10f, 8); Coat(Paint.Steel).Rod(mast + new Vector3(-.13f, .65f, -1.24f), mast + new Vector3(-.13f, .65f, 1.24f), .039f, 6); Coat(Paint.LitGlass).Radome(mast + new Vector3(-.21f, 1.05f, 0), .115f); } private void BuildMegaFunnelPavilion(float x, float halfWidth, float y) { Vector2 center = new Vector2(x, 0); Vector2[] baseOutline = RoundedRectangle(center, 8.5f, halfWidth * .51f, 2.12f); Coat(Paint.Pearl).Loft(baseOutline, center, false, new Vector3(1f, y, 1f), new Vector3(1f, y + .45f, 1f)); Coat(Paint.AtriumGlass).Loft(baseOutline, center, false, new Vector3(.96f, y + .45f, .95f), new Vector3(.96f, y + 1.35f, .95f)); Coat(Paint.Pearl).Loft(baseOutline, center, true, new Vector3(.96f, y + 1.36f, .95f), new Vector3(1f, y + 1.54f, 1f), new Vector3(.93f, y + 1.73f, .94f)); for (int side = -1; side <= 1; side += 2) { float z = side * halfWidth * .295f; Vector2 stack = new Vector2(x - 1.45f, z); Vector2[] blade = Outline(11.15f, 2.36f, stack.x, 20, z); Coat(Paint.MegaHull).Loft(blade, stack, false, new Vector3(1f, y + 1.69f, 1f), new Vector3(.97f, y + 2.52f, .92f), new Vector3(.81f, y + 4.59f, .77f)); Coat(Paint.AtriumGlass).Loft(blade, stack, true, new Vector3(.813f, y + 4.54f, .774f), new Vector3(.78f, y + 4.82f, .70f), new Vector3(.73f, y + 4.92f, .65f)); for (int outlet = -1; outlet <= 1; outlet++) { Vector3 foot = new Vector3(stack.x - 1.9f + outlet * 1.33f, y + 4.88f, z); Coat(Paint.Black).Rod(foot, foot + new Vector3(-.25f, .55f, 0), .31f, 12, true); Coat(Paint.Steel).Rod(foot + new Vector3(-.24f, .49f, 0), foot + new Vector3(-.28f, .61f, 0), .34f, 12); } for (int louver = 0; louver < 11; louver++) { float lp = louver * .58f - 2.9f; Vector3 b = new Vector3(stack.x + lp, y + 2.03f, z + side * 2.09f); Vector3 t = b + new Vector3(-.43f, 1.82f, -side * .38f); Coat(Paint.Steel).Rod(b, t, .037f, 5); } Vector3 antenna = new Vector3(x + 5.78f, y + 1.71f, side * halfWidth * .36f); Coat(Paint.Steel).Rod(antenna, antenna + Vector3.up * .73f, .12f, 8); Coat(Paint.Pearl).Radome(antenna + Vector3.up * 1.10f, .72f); } } private void BuildMegaRoofTrack(float span, float halfWidth, float center, float y) { HarborMesh track = Coat(Paint.DeckTrack); HarborMesh lines = Coat(Paint.Pearl); for (int side = -1; side <= 1; side += 2) for (int segment = 0; segment < 54; segment++) { float a = Mathf.Lerp(.065f, .84f, segment / 54f); float b = Mathf.Lerp(.065f, .84f, (segment + 1f) / 54f); float ax = center + (a - .5f) * span * .994f; float bx = center + (b - .5f) * span * .994f; float az = side * (SideWidth(a) * halfWidth * .992f - .37f); float bz = side * (SideWidth(b) * halfWidth * .992f - .37f); var left = new Vector3(ax, y + .013f, az); var right = new Vector3(bx, y + .013f, bz); Vector3 inset = Vector3.forward * (-side * .52f); if (side < 0) track.Quad(left + inset, right + inset, right, left); else track.Quad(left, right, right + inset, left + inset); if (segment % 3 != 1) lines.Rod(left + inset * .55f + Vector3.up * .009f, right + inset * .55f + Vector3.up * .009f, .018f, 4); } } private void BuildMegaAftTerrace(int count, float top, float skyWidth) { float floor = top - DeckSpacing; Rect venueSpace = MegaDeckGeometry.TerraceArea(length, beam, count); for (int side = -1; side <= 1; side += 2) { float z = side * skyWidth * .23f; const int stepCount = 15; float stairSpan = .015f * length; for (int step = 0; step < stepCount; step++) { float rise = DeckSpacing * (step + 1f) / stepCount; float x = -.230f * length + stairSpan * (step + .5f) / stepCount; Coat(Paint.Pearl).Box(new Vector3(x, floor + rise * .5f, z), new Vector3(stairSpan / stepCount + .02f, rise, 1.47f)); Coat(Paint.Teak).Box(new Vector3(x, floor + rise + .006f, z), new Vector3(stairSpan / stepCount, .012f, 1.34f)); } Coat(Paint.Teak).Box(new Vector3(-.215f * length + .32f, top - .02f, z), new Vector3(.74f, .065f, 1.48f)); for (int rail = -1; rail <= 1; rail += 2) { Vector3 foot = new Vector3(-.230f * length, floor, z + rail * .70f); Vector3 head = new Vector3(-.215f * length, top, foot.z); Coat(Paint.Steel).Rod(foot + Vector3.up * .86f, head + Vector3.up * .89f, .041f, 6); for (int brace = 0; brace <= 4; brace++) { Vector3 post = Vector3.Lerp(foot, head, brace / 4f); Coat(Paint.Steel).Rod(post, post + Vector3.up * .86f, .026f, 5); } } float border = side * (venueSpace.height * .5f + 1.62f); for (int bay = 0; bay < 4; bay++) { float x = Mathf.Lerp(venueSpace.xMin + 4.5f, venueSpace.xMax - 6.4f, bay / 3f); Vector3 planter = new Vector3(x, floor, border); BuildMegaPlanter(planter, bay); if ((bay & 1) == 0) BuildParasol(planter + new Vector3(2.6f, 0, .38f * side), side > 0); } } } private void BuildMegaPlanter(Vector3 foot, int variant) { Coat(Paint.MegaHull).Box(foot + Vector3.up * .26f, new Vector3(2.52f, .52f, .88f)); Coat(Paint.Teak).Box(foot + Vector3.up * .52f, new Vector3(2.60f, .046f, .95f)); for (int plant = -1; plant <= 1; plant++) { Vector3 stem = foot + new Vector3(plant * .72f, .61f, 0); float scale = .29f + .039f * ((variant + plant + 3) % 4); Coat(Paint.Fringe).Radome(stem + Vector3.up * .21f, scale); Coat(Paint.Turf).Radome(stem + new Vector3(.10f, .36f, -.05f), .72f * scale); } } private void BuildMegaHullDetail() { for (int side = -1; side <= 1; side += 2) { for (int i = 0; i < 11; i++) { float station = Mathf.Lerp(.123f, .83f, i / 10f); var (at, along, outward) = SideFrame(station, 3.66f, length * 1.005f, beam * 1.0183f, 0, side, ExteriorHullStations); SidePanel(Coat(Paint.AtriumGlass), at + outward * .055f, along, side, 1.16f, .20f); } for (int i = 0; i < 3; i++) { var (opening, along, outward) = SideFrame(.237f + i * .195f, 3.92f, length * 1.006f, beam * 1.022f, 0, side, ExteriorHullStations); SidePanel(Coat(Paint.Steel), opening + outward * .069f, along, side, 5.91f, .70f); SidePanel(Coat(Paint.Black), opening + outward * .083f, along, side, 5.78f, .57f); for (int pane = -2; pane <= 2; pane++) SidePanel(Coat(Paint.AtriumGlass), opening + outward * .092f + along * (pane * 1.133f), along, side, 1.104f, .53f); } } float bow = length * .475f; var center = new Vector2(bow, 0); Vector2[] bulb = Outline(16.3f, beam * .118f, bow, 24); Coat(Paint.Antifouling).Loft(bulb, center, true, new Vector3(.61f, -2.48f, .56f), new Vector3(1f, -1.91f, 1f), new Vector3(.93f, -1.31f, .93f), new Vector3(.59f, -.88f, .65f)); } private void BuildMegaLifeboats() { const int count = 12; for (int side = -1; side <= 1; side += 2) for (int index = 0; index < count; index++) { float station = Mathf.Lerp(.168f, .704f, index / (count - 1f)); var (at, _, _) = SideFrame(station, 7.88f, length, beam, 0, side, ExteriorHullStations); float x = at.x; float z = at.z + side * .19f; var center = new Vector2(x, z); Vector2[] body = Outline(8.9f, 1.40f, x, 20, z); Coat(Paint.Pearl).Loft(body, center, false, new Vector3(.89f, 7.16f, .55f), new Vector3(1f, 7.53f, 1f), new Vector3(1f, 7.75f, 1f)); Coat(Paint.Lifeboat).Loft(body, center, true, new Vector3(1f, 7.75f, 1f), new Vector3(.92f, 8.18f, .89f), new Vector3(.77f, 8.57f, .76f)); for (int window = 0; window < 5; window++) { var (pane, along, outward) = SideFrame(.27f + .115f * window, 8.32f, 7.79f, 1.17f, x, side, 20); SidePanel(Coat(Paint.Black), pane + new Vector3(0, 0, z) + outward * .028f, along, side, .60f, .22f); } for (int davit = -1; davit <= 1; davit += 2) { var foot = new Vector3(x + davit * 3.14f, 6.82f, z - side * 1.77f); var elbow = foot + new Vector3(0, 2.86f, side * .63f); var hook = elbow + new Vector3(0, -.14f, side * 1.38f); Coat(Paint.Pearl).Rod(foot, elbow, .147f, 8, true); Coat(Paint.Pearl).Rod(elbow, hook, .123f, 8, true); Coat(Paint.Steel).Rod(hook, new Vector3(hook.x, 8.45f, hook.z), .040f, 6, true); } } } } }