Enable placeable sun deck attractions and finish project rebrand

This commit is contained in:
josh
2026-11-28 20:33:30 -05:00
parent 56fafba6d9
commit ce0d38c8de
352 changed files with 1523 additions and 552 deletions

View File

@@ -0,0 +1,123 @@
using UnityEngine.UIElements;
namespace BigShipTycoon
{
public sealed partial class TycoonApp
{
private bool crewManifestOpen;
private Label crewManifestLaundry;
private void DrawCrewOffice(VisualElement workspace)
{
var stage = Add(workspace, "crew-office");
var office = Add(stage, "crew-sheet");
var head = Add(office, "crew-heading");
var identity = Add(head, "crew-identity");
Ship ship = Ship;
AddText(identity, ship == null ? "PERSONNEL" : Market.Ports[ship.Port].Name.ToUpperInvariant() + " / PERSONNEL",
"crew-kicker");
AddDisplay(identity, "Crew office", "crew-title");
if (ship == null)
{
AddText(identity, "Register a ship to assign its crew.", "crew-note");
head.Add(Action("Open shipyard", () => ChangePage(2), "primary", "crew-open-yard"));
return;
}
AddText(identity, $"{ship.Name} · {ship.Hull.Name} · {ship.Decks.Count} decks", "crew-ship");
var budget = Add(head, "crew-office-budget");
AddCrewMetric(budget, "ASSIGNED", ship.TotalCrew.ToString("N0"));
AddCrewMetric(budget, "PAYROLL / SAILING DAY", Money(ship.DailyPayroll));
head.Add(Action("Switch ship", ToggleFleetOverview, "crew-fleet", "crew-fleet"));
var table = new ScrollView(ScrollViewMode.Vertical) { horizontalScrollerVisibility = ScrollerVisibility.Hidden };
table.AddToClassList("crew-table");
office.Add(table);
var columns = Add(table, "crew-columns");
AddText(columns, "DEPARTMENT", "crew-kicker crew-department");
AddText(columns, "STAFF / PLAN", "crew-kicker crew-counts");
AddText(columns, "RECRUIT AT THIS PORT", "crew-kicker crew-row-actions");
foreach (CrewRoleSpec department in CrewMarket.Roles)
{
CrewRole role = department.Role;
var row = Add(table, "crew-row");
var copy = Add(row, "crew-department");
AddDisplay(copy, department.Name, "crew-department-name");
AddText(copy, department.Description, "crew-note");
var coverage = Add(row, "crew-counts");
int assigned = ship.CrewCount(role), planned = CrewMarket.Recommended(ship, role);
AddText(coverage, $"{assigned:N0} / {planned:N0}", assigned < planned ? "crew-count crew-short" : "crew-count");
AddText(coverage, $"{Money(department.DailyWage)} per person / day", "crew-wage");
var actions = Add(row, "crew-row-actions crew-actions");
AddCrewChange(actions, ship, role, 1, $"Hire · {Money(CrewMarket.HireFee(ship, role))}");
AddCrewChange(actions, ship, role, -1, "Release");
}
AddText(office, "Hiring fees are paid here. Payroll is charged when each crossing settles. The sailing roster is set at cast off.",
"crew-office-footer");
}
private void AddCrewMetric(VisualElement parent, string label, string value)
{
var stat = Add(parent, "crew-stat");
AddText(stat, label, "crew-kicker");
AddDisplay(stat, value, "crew-stat-value");
}
private void AddCrewChange(VisualElement parent, Ship ship, CrewRole role, int change, string titleText)
{
bool hiring = change > 0;
string failure = company.CrewChangeBlock(ship, role, change, FleetStatus(ship).Voyage != null);
var button = Action(titleText, () =>
{
string result = company.ChangeCrew(ship, role, change, FleetStatus(ship).Voyage != null);
Apply(result, hiring ? $"Crew member assigned to {ship.Name}." : "Crew member released at the berth.");
}, hiring ? "crew-hire" : "crew-release", $"crew-{(hiring ? "hire" : "release")}-{(int)role}");
button.tooltip = failure ?? (hiring ? "Pay a one-time recruitment fee and add this wage to the ship’s payroll." : "Remove one crew member at this port.");
button.SetEnabled(failure == null);
parent.Add(button);
}
private void ToggleCrewManifest()
{
crewManifestOpen = !crewManifestOpen;
Render();
}
private void DrawCrewManifest(VisualElement parent)
{
for (int i = 0; i < parent.childCount; i++)
parent[i].SetEnabled(false);
var overlay = Add(parent, "crew-manifest-overlay");
var sheet = Add(overlay, "crew-manifest");
sheet.name = "crew-manifest";
var heading = Add(sheet, "crew-heading");
var titleRow = Add(heading, "crew-identity");
AddText(titleRow, Ship.Name.ToUpperInvariant(), "crew-kicker");
AddDisplay(titleRow, "Crew on duty", "crew-title");
heading.Add(Action("Close Esc", ToggleCrewManifest, "crew-fleet", "crew-manifest-close"));
var roster = Add(sheet, "crew-manifest-roster");
foreach (CrewRoleSpec department in CrewMarket.Roles)
{
CrewRole role = department.Role;
int assigned = underway.CrewAssigned is { Length: > 0 }
? underway.CrewAssigned[(int)role] : Ship.CrewCount(role);
int planned = CrewMarket.Recommended(Ship, role);
var row = Add(roster, "crew-manifest-row");
AddText(row, department.Name, "crew-manifest-role");
AddText(row, $"{assigned} / {planned}", assigned < planned ? "crew-count crew-short" : "crew-count");
}
AddText(sheet, $"Payroll for this crossing · {Money(underway.Crew)}", "crew-manifest-payroll");
crewManifestLaundry = AddText(sheet, "", "crew-note");
RefreshCrewManifest();
}
private void RefreshCrewManifest()
{
if (!crewManifestOpen || livePassage == null || crewManifestLaundry?.panel == null)
return;
SetPassageText(crewManifestLaundry, $"Laundry · {livePassage.LaundryCapacity:N0} loads/day against {livePassage.LaundryDemand:N0} needed · {livePassage.LaundryBacklog:N0} waiting");
}
}
}