using UnityEngine; using UnityEngine.UIElements; namespace Soundings { public sealed partial class SoundingsApp { private static readonly (int HullIndex, bool Used)[] Offers = { (0, true), (0, false), (1, true), (1, false), (2, false) }; private enum DeckTools { GuestFacilities, LargerVenues, ShipSystems } private DeckTools deckTools; private static readonly Color DraftGrid = new Color(.37f, .62f, .65f, .19f); private static readonly Color DraftFine = new Color(.47f, .75f, .74f, .42f); private static readonly Color DraftInk = new Color(.64f, .89f, .82f, .88f); private static readonly Color DraftGold = new Color(.91f, .70f, .42f, .88f); private void DrawDecks(VisualElement workspace) { var work = Add(workspace, "ship-work deck-work"); Ship ship = Ship; if (ship == null) { var empty = Add(work, "ship-work-empty"); AddDisplay(empty, "No vessel in dock", "ship-work-heading"); AddText(empty, "Acquire a hull at the shipyard before fitting a deck.", "ship-work-detail"); empty.Add(Action("Visit shipyard", () => ChangePage(2), "work-primary", "open-shipyard")); return; } deckIndex = Mathf.Clamp(deckIndex, 0, ship.Decks.Count - 1); var titleBar = Add(work, "ship-work-head"); var heading = Add(titleBar, "ship-work-name"); AddText(heading, "DECK PLANS", "work-caption"); AddDisplay(heading, ship.Name, "ship-work-heading"); AddText(heading, $"{ship.Hull.Name} hull · Deck {deckIndex + 1} of {ship.Decks.Count}", "ship-work-detail"); var deckControls = Add(titleBar, "work-deck-controls"); var selector = Add(deckControls, "work-deck-selector"); for (int i = 0; i < ship.Decks.Count; i++) { int floor = i; Button level = Action($"Deck {i + 1}", () => { deckIndex = floor; Notify(null); Render(); }, "work-deck-tab", $"deck-{i}"); level.EnableInClassList("work-selected", deckIndex == i); selector.Add(level); } int deckPrice = company.DeckPrice(ship); string addLabel = ship.Decks.Count == ship.Hull.MaxDecks ? "Deck limit reached" : $"+ Deck {Money(deckPrice)}"; Button add = Action(addLabel, () => { string failure = company.AddDeck(ship); if (failure == null) deckIndex = ship.Decks.Count - 1; Apply(failure, "New deck ready to fit out."); }, "work-deck-add", "add-deck"); add.SetEnabled(ship.Decks.Count < ship.Hull.MaxDecks && company.AvailableCash >= deckPrice); deckControls.Add(add); var board = Add(work, "work-draft"); board.generateVisualContent += context => DrawDeckOutline(context, ship.Hull.Columns); var markings = Add(board, "work-draft-markings"); markings.pickingMode = PickingMode.Ignore; AddText(markings, "STERN", "work-caption"); AddText(markings, "TOP VIEW", "work-caption"); AddText(markings, "BOW →", "work-caption"); var layout = Add(board, "work-berth-grid"); var placement = Add(board, "work-placement"); var placementLabel = AddText(placement, PlacementInstruction(ship, tool), "work-placement-text"); placementLabel.name = "berth-placement"; DrawBerthGrid(layout, placementLabel, ship); var fittings = Add(work, "work-fittings"); var gauges = Add(fittings, "work-capacity-strip"); if (deckTools == DeckTools.ShipSystems) { AddText(gauges, $"{ship.GalleyCapacity:N0} galley covers", "work-capacity"); AddText(gauges, $"{ship.FoodCapacity:N0} stored portions", "work-capacity"); AddText(gauges, $"{ship.WaterCapacity:N0} L freshwater", "work-capacity"); AddText(gauges, $"{ship.WasteCapacity:N0} L sewage buffer", "work-capacity"); } else { string rooms = ship.SuiteBerths == 0 ? $"{ship.Beds:N0} berths" : $"{ship.Beds:N0} berths · {ship.SuiteBerths:N0} in suites"; AddText(gauges, rooms, "work-capacity"); AddText(gauges, $"{ship.Meals:N0} meal covers", "work-capacity"); AddText(gauges, $"{ship.Entertainment:N0} show seats", "work-capacity"); if (deckTools == DeckTools.LargerVenues) { AddText(gauges, $"{ship.PoolCapacity:N0} pool admissions", "work-capacity"); AddText(gauges, $"{ship.BarCapacity:N0} drink orders", "work-capacity"); } else AddText(gauges, $"{ship.Tank:N0} t bunker capacity", "work-capacity"); AddText(gauges, $"{ship.Capacity:N0} guests per sailing", "work-capacity work-capacity-emphasis"); } var toolMode = Add(fittings, "work-fit-modes"); AddBuildToolTab(toolMode, "Guest facilities", "facility-guests", DeckTools.GuestFacilities, Facility.Cabin); AddBuildToolTab(toolMode, "Larger venues", "facility-larger", DeckTools.LargerVenues, Facility.Suite); AddBuildToolTab(toolMode, "Ship systems", "facility-systems", DeckTools.ShipSystems, Facility.Galley); var tools = Add(fittings, "work-tool-tray"); var (start, end) = deckTools switch { DeckTools.LargerVenues => (Facility.Suite, Facility.Extension), DeckTools.ShipSystems => (Facility.Galley, Facility.Suite), _ => (Facility.Cabin, Facility.Galley) }; for (int i = (int)start; i <= (int)end; i++) { Facility option = i == (int)end ? Facility.Empty : (Facility)i; FacilitySpec spec = Market.Facilities[(int)option]; bool locked = ship.HullIndex < spec.MinimumHull; Button button = Action("", () => { tool = option; Notify(null); Render(); }, "work-tool work-tool-" + (int)option, "facility-" + (int)option); button.EnableInClassList("work-selected", option == tool); button.EnableInClassList("work-tool-locked", locked); button.tooltip = locked ? VenueRequirement(spec) : spec.Details; AddFacilityMark(button, option); var copy = Add(button, "work-tool-copy"); copy.pickingMode = PickingMode.Ignore; AddText(copy, spec.Name, "work-tool-name"); string price = option == Facility.Empty ? "25% refund" : Money(spec.Price); if (spec.Length > 1) { price = $"{spec.Length} bays · {price}"; button.AddToClassList("work-tool-larger"); } AddText(copy, price, "work-tool-cost"); if (locked) AddText(copy, $"{Market.Hulls[spec.MinimumHull].Name} hull required", "work-tool-lock"); tools.Add(button); } } private void DrawBerthGrid(VisualElement layout, Label instruction, Ship ship) { Deck deck = ship.Decks[deckIndex]; int columns = ship.Hull.Columns; var berths = new Button[deck.Cells.Length]; int hovered = -1, focused = -1; void UpdatePreview() { int selected = hovered >= 0 ? hovered : focused; for (int i = 0; i < berths.Length; i++) { berths[i].RemoveFromClassList("work-berth-preview"); berths[i].RemoveFromClassList("work-berth-blocked"); } if (selected < 0) { instruction.text = PlacementInstruction(ship, tool); return; } Facility room = deck.FacilityAt(selected, columns); int anchor = room == Facility.Empty ? selected : deck.AnchorAt(selected, columns); Facility sizeOf = room == Facility.Empty ? tool : room; int span = Market.Facilities[(int)sizeOf].Length; string blocked = PlacementBlock(ship, selected, room); instruction.text = BerthDescription(deck, columns, selected, room, tool, blocked); int rowEnd = (anchor / columns + 1) * columns; for (int i = anchor; i < Mathf.Min(rowEnd, anchor + span); i++) berths[i].AddToClassList(blocked == null ? "work-berth-preview" : "work-berth-blocked"); } for (int row = 0; row < ship.Hull.Rows; row++) { var strip = Add(layout, "work-berth-row"); for (int column = 0; column < columns; column++) { int cell = row * columns + column; int anchor = deck.AnchorAt(cell, columns); Facility existing = deck.FacilityAt(cell, columns); FacilitySpec room = Market.Facilities[(int)existing]; var slot = Add(strip, "work-berth-slot"); Button berth = Action("", () => BuildAtBerth(ship, deck, cell), "work-berth work-room-" + (int)existing, "berth-" + cell); berths[cell] = berth; slot.Add(berth); string blocked = PlacementBlock(ship, cell, existing); berth.tooltip = BerthDescription(deck, columns, cell, existing, tool, blocked); berth.RegisterCallback(_ => { hovered = cell; UpdatePreview(); }); berth.RegisterCallback(_ => { hovered = -1; UpdatePreview(); }); berth.RegisterCallback(_ => { focused = cell; UpdatePreview(); }); berth.RegisterCallback(_ => { focused = -1; UpdatePreview(); }); AddText(berth, BerthName(cell, columns), "work-berth-index"); if (existing == Facility.Empty) AddText(berth, "+", "work-berth-open"); else if (room.Length == 1) AddVenueLabel(berth, existing); else { berth.EnableInClassList("work-berth-join-left", anchor < cell); berth.EnableInClassList("work-berth-join-right", anchor + room.Length - 1 > cell); } } for (int column = 0; column < columns; column++) { Facility room = deck.Cells[row * columns + column]; int span = Market.Facilities[(int)room].Length; if (span <= 1) continue; var label = Add(strip, "work-span-caption"); label.pickingMode = PickingMode.Ignore; label.style.left = Length.Percent(100f * column / columns); label.style.width = Length.Percent(100f * span / columns); AddVenueLabel(label, room); } } } private string PlacementBlock(Ship ship, int cell, Facility existing) { if (existing != Facility.Empty && tool != Facility.Empty) return null; FacilitySpec spec = Market.Facilities[(int)tool]; return ship.HullIndex < spec.MinimumHull ? VenueRequirement(spec) : company.BuildBlock(ship, deckIndex, cell, tool); } private void BuildAtBerth(Ship ship, Deck deck, int cell) { int columns = ship.Hull.Columns; int anchor = deck.AnchorAt(cell, columns); Facility previous = deck.FacilityAt(cell, columns); string failure = company.Build(ship, deckIndex, cell, tool); if (failure == null && previous != tool) SetRecommendedFuel(); FacilitySpec room = Market.Facilities[(int)(tool == Facility.Empty ? previous : tool)]; string area = BerthRange(tool == Facility.Empty ? anchor : cell, room.Length, columns); string confirmation = tool == Facility.Empty ? $"Removed {room.Name.ToLowerInvariant()} from {area}." : $"Built {room.Name.ToLowerInvariant()} at {area}."; Apply(failure, previous == tool ? null : confirmation); } private void AddBuildToolTab(VisualElement parent, string label, string id, DeckTools group, Facility initial) { Button tab = Action(label, () => { if (deckTools == group) return; deckTools = group; tool = initial; Notify(null); Render(); }, deckTools == group ? "work-selected" : "", id); parent.Add(tab); } private static void AddVenueLabel(VisualElement parent, Facility facility) { var center = Add(parent, "work-berth-center"); center.pickingMode = PickingMode.Ignore; AddFacilityMark(center, facility); AddText(center, Market.Facilities[(int)facility].Name, "work-berth-name").pickingMode = PickingMode.Ignore; } private static string VenueRequirement(FacilitySpec spec) { HullSpec hull = Market.Hulls[spec.MinimumHull]; return $"Requires a {hull.Name} hull. Unlock the hull with {hull.Voyages} completed voyages and {hull.Reputation} reputation."; } private static string PlacementInstruction(Ship ship, Facility selected) { FacilitySpec spec = Market.Facilities[(int)selected]; if (selected == Facility.Empty) return "Select any bay in a fitted room to remove it and recover 25%."; if (ship.HullIndex < spec.MinimumHull) return VenueRequirement(spec); string plan = spec.Length == 1 ? "Select an open bay" : $"Select the sternmost of {spec.Length} open bays in a row"; return $"{plan} to build {spec.Name.ToLowerInvariant()}. {spec.Details} · {Money(spec.Price)}"; } private static string BerthName(int cell, int columns) => $"{(char)('A' + cell / columns)}{cell % columns + 1}"; private static string BerthRange(int start, int span, int columns) { int end = Mathf.Min(start + span - 1, (start / columns + 1) * columns - 1); return end == start ? BerthName(start, columns) : $"{BerthName(start, columns)}–{BerthName(end, columns)}"; } private static string BerthDescription(Deck deck, int columns, int cell, Facility room, Facility selected, string blocked) { if (blocked != null) return $"{BerthName(cell, columns)} · {blocked}"; FacilitySpec existing = Market.Facilities[(int)room]; if (room == Facility.Empty) { FacilitySpec fitting = Market.Facilities[(int)selected]; string location = BerthRange(cell, fitting.Length, columns); return selected == Facility.Empty ? $"{location} is already clear." : $"{location} · {fitting.Name} · {fitting.Details} · {Money(fitting.Price)}"; } string area = BerthRange(deck.AnchorAt(cell, columns), existing.Length, columns); return selected == Facility.Empty ? $"{area} · Remove {existing.Name.ToLowerInvariant()} and recover {Money(existing.Price / 4)}" : $"{area} · {existing.Name} · {existing.Details}"; } private static void AddFacilityMark(VisualElement parent, Facility facility) { var mark = Add(parent, "work-facility-icon work-mark-" + (int)facility); mark.pickingMode = PickingMode.Ignore; mark.generateVisualContent += context => { Painter2D pen = context.painter2D; float scale = context.visualElement.contentRect.width / 24; Vector2 Point(float x, float y) => new Vector2(x * scale, y * scale); pen.strokeColor = new Color(.88f, .94f, .89f); pen.lineWidth = 1.6f; pen.BeginPath(); void Line(float x1, float y1, float x2, float y2) { pen.MoveTo(Point(x1, y1)); pen.LineTo(Point(x2, y2)); } void Segment(params float[] xy) { pen.MoveTo(Point(xy[0], xy[1])); for (int i = 2; i < xy.Length; i += 2) pen.LineTo(Point(xy[i], xy[i + 1])); } switch (facility) { case Facility.Cabin: case Facility.Suite: case Facility.GrandSuite: Segment(3,18,3,6,5,6,5,12,20,12,20,18); Line(4,16,20,16); Segment(6,11,6,9,10,9,10,11); Segment(11,11,11,8,18,8,20,10,20,12); break; case Facility.Dining: case Facility.Restaurant: Segment(9,9,11,7,15,7,17,10,17,14,15,17,11,17,9,15,9,9); Segment(3,5,3,10,5,12,7,10,7,5); Line(5,11,5,19); Segment(21,5,19,8,19,12,21,12,21,19); break; case Facility.Entertainment: case Facility.GrandTheater: Segment(3,19,3,5,21,5,21,19); Segment(4,7,9,7,7,13,4,16); Segment(20,7,15,7,17,13,20,16); Line(9,19,15,19); break; case Facility.Tank: Segment(6,20,6,9,8,7,16,7,18,9,18,20,6,20); Segment(10,7,10,4,14,4,14,7); Line(6,11,18,11); Line(6,16,18,16); break; case Facility.Bar: case Facility.CocktailLounge: Segment(4,5,20,5,12,13,4,5); Segment(12,13,12,20,7,20); Line(12,20,17,20); Line(8,8,16,8); break; case Facility.Amenity: case Facility.ResortPool: Segment(4,11,6,7,10,5,14,5,18,7,20,11,4,11); Line(12,11,12,17); Segment(3,19,6,17,9,19,12,17,15,19,18,17,21,19); break; case Facility.Galley: Segment(3,13,17,13,15,18,5,18,3,13); Line(17,13,22,11); Line(8,10,8,6); Line(12,10,12,5); break; case Facility.Stores: Segment(4,5,20,5,20,19,4,19,4,5); Line(4,11,20,11); Line(8,8,16,8); Line(8,15,16,15); break; case Facility.Water: case Facility.Waste: Segment(12,3,18,11,19,15,17,19,12,21,7,19,5,15,6,11,12,3); Line(8,16,16,16); break; case Facility.Workshop: Segment(6,19,15,10,14,7,18,5,20,7,19,10,16,11,8,21,6,19); break; default: Line(6,6,18,18); Line(6,18,18,6); break; } pen.Stroke(); }; } private void DrawShipyard(VisualElement workspace) { var work = Add(workspace, "ship-work yard-work"); (int hullIndex, bool used) = Offers[yardSelection]; HullSpec hull = Market.Hulls[hullIndex]; var titleBar = Add(work, "ship-work-head"); var heading = Add(titleBar, "ship-work-name"); AddText(heading, "MIAMI SHIPYARD", "work-caption"); AddDisplay(heading, used ? $"Pre-owned {hull.Name}" : $"{hull.Name} commission", "ship-work-heading"); AddText(heading, used ? "Fitted for service · 72% condition at delivery" : hull.Description, "ship-work-detail"); var stamp = Add(titleBar, "work-yard-stamp"); AddText(stamp, "DELIVERY AT MIAMI", "work-caption"); AddText(stamp, $"{hull.StarterDecks} decks delivered · {hull.MaxDecks} max · {hull.Tank} t fuel", "work-yard-specs"); var slipway = Add(work, "work-slipway"); slipway.generateVisualContent += context => DrawYardElevation(context, hullIndex, used); var markings = Add(slipway, "work-draft-markings"); markings.pickingMode = PickingMode.Ignore; AddText(markings, "STARBOARD ELEVATION", "work-caption"); AddText(markings, used ? "FITTED HULL" : $"BARE HULL / {hull.StarterDecks} STARTER DECKS", "work-caption"); var inventory = Add(work, "work-ship-inventory"); for (int item = 0; item < Offers.Length; item++) { int selection = item; var offer = Offers[item]; HullSpec candidate = Market.Hulls[offer.HullIndex]; bool locked = company.Voyages < candidate.Voyages || company.Reputation < candidate.Reputation; Button option = Action("", () => { yardSelection = selection; Notify(null); Render(); }, "work-offer", "yard-" + item); option.EnableInClassList("work-selected", selection == yardSelection); AddText(option, locked ? "LOCKED" : offer.Used ? "PRE-OWNED" : "NEW HULL", "work-caption"); AddText(option, candidate.Name, "work-offer-name"); AddText(option, Money(offer.Used ? Market.UsedPrice(offer.HullIndex) : candidate.Price), "work-offer-price"); inventory.Add(option); } var order = Add(work, "work-order"); DrawShipyardOrder(order, hullIndex, used); if (Ship != null) DrawShipyardService(order, Ship); } private void DrawShipyardOrder(VisualElement order, int hullIndex, bool used) { var purchase = Add(order, "work-purchase"); if (!used) { var nameControl = Add(purchase, "work-name-control"); AddText(nameControl, "VESSEL NAME", "work-caption"); var field = new TextField { value = shipName, maxLength = 24, name = "vessel-name" }; field.AddToClassList("work-name-field"); field.RegisterValueChangedCallback(evt => shipName = evt.newValue); nameControl.Add(field); } string block = company.ShipyardBlock(hullIndex, used); var contract = Add(purchase, "work-contract"); long price = used ? Market.UsedPrice(hullIndex) : Market.Hulls[hullIndex].Price; Button buy = Action(used ? $"Purchase · {Money(price)}" : $"Commission · {Money(price)}", () => { string failure = company.Acquire(hullIndex, used, shipName); if (failure == null) { deckIndex = 0; ResetItinerary(); page = used ? 0 : 1; } Apply(failure, used ? "The vessel is ready in Miami." : "The hull is ready. Fit cabins and dining before sailing."); }, "work-primary work-commission", "buy-ship"); buy.SetEnabled(block == null); contract.Add(buy); if (block != null) AddText(contract, block, "work-contract-block"); } private void DrawShipyardService(VisualElement order, Ship ship) { var service = Add(order, "work-service"); var shipInfo = Add(service, "work-service-info"); AddText(shipInfo, ship.Name, "work-offer-name"); AddText(shipInfo, $"{ship.Condition}% condition", "work-yard-specs"); int price = company.ServiceCost(ship); Button overhaul = Action(price > 0 ? $"Overhaul · {Money(price)}" : "No repairs needed", () => { string failure = company.Service(ship); if (failure == null) SetRecommendedFuel(); Apply(failure, "The ship has been restored to 100% condition."); }, "work-overhaul", "overhaul"); overhaul.SetEnabled(price > 0 && company.AvailableCash >= price); service.Add(overhaul); } private static void DrawDeckOutline(MeshGenerationContext context, int columns) { Rect bounds = context.visualElement.contentRect; if (bounds.width <= 0 || bounds.height <= 0) return; Painter2D pen = context.painter2D; Vector2 P(float x, float y) => new Vector2(bounds.width * x, bounds.height * y); DrawDraftGrid(pen, bounds, 26); void Hull(float inset) { Vector2 aftPort = P(.047f + inset, .37f + inset); Vector2 portShoulder = P(.17f + inset, .145f + inset); Vector2 portBow = P(.75f - inset, .145f + inset); Vector2 bow = P(.965f - inset, .50f); Vector2 starboardBow = P(.75f - inset, .855f - inset); Vector2 starboardShoulder = P(.17f + inset, .855f - inset); Vector2 aftStarboard = P(.047f + inset, .63f - inset); pen.MoveTo(aftPort); TraceDraftCurve(pen, aftPort, P(.078f + inset, .16f + inset), portShoulder); pen.LineTo(portBow); TraceDraftCurve(pen, portBow, P(.91f - inset, .15f + inset), bow); TraceDraftCurve(pen, bow, P(.91f - inset, .85f - inset), starboardBow); pen.LineTo(starboardShoulder); TraceDraftCurve(pen, starboardShoulder, P(.078f + inset, .84f - inset), aftStarboard); pen.LineTo(aftPort); } pen.fillColor = new Color(.065f, .18f, .217f, .98f); pen.strokeColor = DraftInk; pen.lineWidth = 2; pen.BeginPath(); Hull(0); pen.Fill(); pen.Stroke(); pen.strokeColor = DraftFine; pen.lineWidth = 1; pen.BeginPath(); Hull(.014f); pen.Stroke(); pen.BeginPath(); void Guide(float x, float top, float control, float bottom) { Vector2 start = P(x, top); pen.MoveTo(start); TraceDraftCurve(pen, start, P(control, .50f), P(x, bottom)); } Guide(.104f, .23f, .145f, .77f); Guide(.780f, .18f, .853f, .82f); Guide(.824f, .21f, .894f, .79f); Guide(.872f, .28f, .937f, .72f); pen.Stroke(); pen.BeginPath(); for (int i = 0; i <= columns; i++) { float station = Mathf.Lerp(.135f, .785f, i / (float)columns); pen.MoveTo(P(station, .198f)); pen.LineTo(P(station, .256f)); pen.MoveTo(P(station, .744f)); pen.LineTo(P(station, .80f)); } for (int i = 0; i < 9; i++) { float y = .37f + .033f * i; pen.MoveTo(P(.073f, y)); pen.LineTo(P(.094f, y)); } pen.MoveTo(P(.055f, .50f)); pen.LineTo(P(.131f, .50f)); pen.MoveTo(P(.789f, .50f)); pen.LineTo(P(.948f, .50f)); pen.Stroke(); pen.strokeColor = DraftGold; pen.BeginPath(); pen.MoveTo(P(.91f, .47f)); pen.LineTo(P(.934f, .50f)); pen.LineTo(P(.91f, .53f)); pen.Stroke(); } private static void DrawYardElevation(MeshGenerationContext context, int hullIndex, bool used) { Rect bounds = context.visualElement.contentRect; if (bounds.width <= 0 || bounds.height <= 0) return; Painter2D pen = context.painter2D; DrawDraftGrid(pen, bounds, 33); Vector2 P(float x, float y) => new Vector2(bounds.width * x, bounds.height * y); float stern = .178f - hullIndex * .028f; float bow = .833f + hullIndex * .029f; float L(float position) => Mathf.Lerp(stern, bow, position); void Path(params float[] xy) { pen.MoveTo(P(L(xy[0]), xy[1])); for (int i = 2; i < xy.Length; i += 2) pen.LineTo(P(L(xy[i]), xy[i + 1])); } pen.strokeColor = DraftFine; pen.lineWidth = 1; pen.BeginPath(); for (int i = 0; i < 33; i++) { float x = .055f + i * .028f; pen.MoveTo(P(x, .80f)); pen.LineTo(P(x, i % 4 == 0 ? .85f : .825f)); } pen.MoveTo(P(.055f, .80f)); pen.LineTo(P(.955f, .80f)); for (int i = 1; i < 13; i++) { float position = i / 13f; pen.MoveTo(P(L(position), .665f)); pen.LineTo(P(L(position - .022f), .80f)); pen.LineTo(P(L(position + .026f), .80f)); pen.ClosePath(); } pen.Stroke(); pen.strokeColor = DraftGold; pen.lineWidth = 1.35f; pen.BeginPath(); Path(0,.875f, 0,.918f); Path(0,.897f, 1,.897f); Path(1,.875f, 1,.918f); Path(0,.897f, .012f,.881f); Path(0,.897f, .012f,.913f); Path(1,.897f, .988f,.881f); Path(1,.897f, .988f,.913f); pen.Stroke(); pen.fillColor = new Color(.13f, .23f, .24f); pen.strokeColor = DraftInk; pen.lineWidth = 1.8f; pen.BeginPath(); Vector2 transom = P(stern, .56f); Vector2 aftDeck = P(L(.21f), .565f); Vector2 foreDeck = P(L(.79f), .565f); Vector2 stem = P(bow, .49f); Vector2 forwardKeel = P(L(.903f), .712f); Vector2 aftKeel = P(L(.135f), .712f); pen.MoveTo(transom); TraceDraftCurve(pen, transom, P(L(.11f), .57f), aftDeck); pen.LineTo(foreDeck); TraceDraftCurve(pen, foreDeck, P(L(.94f), .565f), stem); TraceDraftCurve(pen, stem, P(L(.974f), .64f), forwardKeel); pen.LineTo(aftKeel); TraceDraftCurve(pen, aftKeel, P(L(.047f), .702f), transom); pen.Fill(); pen.Stroke(); pen.strokeColor = DraftGold; pen.lineWidth = 1; pen.BeginPath(); Path(.026f,.609f, .119f,.627f, .885f,.627f, .959f,.579f); pen.Stroke(); int levels = Market.Hulls[hullIndex].StarterDecks; int allowedDecks = Market.Hulls[hullIndex].MaxDecks; const float deckRise = .047f; pen.strokeColor = new Color(DraftFine.r, DraftFine.g, DraftFine.b, .28f); pen.BeginPath(); for (int level = levels; level < allowedDecks; level++) { float y = .561f - level * deckRise; float left = .079f + level * .031f; float right = .872f - level * .04f; for (float x = left; x < right; x += .022f) Path(x, y, Mathf.Min(x + .012f, right), y); } pen.Stroke(); for (int level = 0; level < levels; level++) { float bottom = .561f - level * deckRise; float left = .079f + level * .031f; float right = .872f - level * .04f; pen.fillColor = new Color(.17f + .022f * level, .29f, .30f); pen.strokeColor = DraftFine; pen.lineWidth = 1.25f; pen.BeginPath(); Path(left,bottom, left + .006f,bottom - .038f, right - .036f,bottom - .044f, right,bottom); pen.ClosePath(); pen.Fill(); pen.Stroke(); pen.strokeColor = DraftInk; pen.BeginPath(); if (used) for (float x = left + .022f; x < right - .04f; x += .028f) Path(x,bottom - .022f, x + .014f,bottom - .022f); else for (float x = left + .025f; x < right - .04f; x += .1f) Path(x,bottom - .019f, x + .050f,bottom - .019f); pen.Stroke(); } float top = .57f - levels * deckRise; pen.fillColor = new Color(.38f, .30f, .19f); pen.strokeColor = DraftGold; pen.BeginPath(); Path(.403f,top, .420f,top - .111f, .466f,top - .111f, .452f,top); pen.ClosePath(); pen.Fill(); pen.Stroke(); pen.strokeColor = DraftInk; pen.BeginPath(); Path(.645f,top + .01f, .645f,top - .125f); Path(.619f,top - .090f, .671f,top - .090f); Path(.628f,top - .108f, .662f,top - .108f); pen.Stroke(); } private static void TraceDraftCurve(Painter2D pen, Vector2 start, Vector2 control, Vector2 end) { // Explicit line segments keep UI Toolkit from closing these curves through the drawing origin. const int subdivisions = 18; for (int index = 1; index <= subdivisions; index++) { float t = index / (float)subdivisions; pen.LineTo(Vector2.Lerp(Vector2.Lerp(start, control, t), Vector2.Lerp(control, end, t), t)); } } private static void DrawDraftGrid(Painter2D pen, Rect bounds, float cell) { pen.strokeColor = DraftGrid; pen.lineWidth = 1; pen.BeginPath(); for (float x = bounds.width / 2 % cell; x < bounds.width; x += cell) { pen.MoveTo(new Vector2(x, 0)); pen.LineTo(new Vector2(x, bounds.height)); } for (float y = bounds.height / 2 % cell; y < bounds.height; y += cell) { pen.MoveTo(new Vector2(0, y)); pen.LineTo(new Vector2(bounds.width, y)); } pen.Stroke(); } } }