Add MEGA Ocean Liner, split decks, and detailed ship materials
This commit is contained in:
@@ -7,6 +7,7 @@ namespace BigShipTycoon
|
||||
{
|
||||
private bool sunDeckEditing, sunMoving;
|
||||
private Ship sunPlanningShip;
|
||||
private SunDeckZone sunZone;
|
||||
private SunAttraction sunTool;
|
||||
private int sunRotation, sunSelection = -1;
|
||||
private System.Action refreshSunPlacement;
|
||||
@@ -14,14 +15,14 @@ namespace BigShipTycoon
|
||||
private static readonly (SunPoolStyle Style, string Label, string Id)[] SunPools =
|
||||
{
|
||||
(SunPoolStyle.Compact, "Compact", "compact"), (SunPoolStyle.Family, "Family", "family"),
|
||||
(SunPoolStyle.Resort, "Resort", "resort")
|
||||
(SunPoolStyle.Resort, "Resort", "resort"), (SunPoolStyle.Lagoon, "Lagoon", "lagoon")
|
||||
};
|
||||
|
||||
private static readonly (SunAttraction Kind, string Label, string Id)[] SunAttractions =
|
||||
{
|
||||
(SunAttraction.Pool, "Pool", "pool"), (SunAttraction.MiniGolf, "Mini golf", "golf"),
|
||||
(SunAttraction.Theater, "Outdoor theater", "theater"), (SunAttraction.GoKarts, "Go-karts", "karts"),
|
||||
(SunAttraction.RollerCoaster, "Roller coaster", "coaster")
|
||||
(SunAttraction.RollerCoaster, "Roller coaster", "coaster"), (SunAttraction.SkyGarden, "Sky garden", "garden")
|
||||
};
|
||||
|
||||
private void DrawSunDeckEditor(VisualElement work, Ship ship)
|
||||
@@ -29,29 +30,42 @@ namespace BigShipTycoon
|
||||
if (sunPlanningShip != ship)
|
||||
{
|
||||
sunPlanningShip = ship;
|
||||
sunZone = SunDeckZone.Sky;
|
||||
ResetSunTool();
|
||||
}
|
||||
|
||||
var grid = new SunDeckGrid(ship);
|
||||
SunDeckPlan plan = ship.SunDeckPlan;
|
||||
var grid = new SunDeckGrid(ship, zone: sunZone);
|
||||
SunDeckPlan plan = ship.SunDeckFor(sunZone);
|
||||
SunPoolStyle pool = grid.SelectedPool;
|
||||
if (sunSelection >= grid.Existing.Count)
|
||||
ResetSunTool();
|
||||
|
||||
var board = Add(work, "work-draft");
|
||||
board.generateVisualContent += context => DrawDeckOutline(context, ship.Hull.Columns);
|
||||
bool terrace = sunZone == SunDeckZone.AftTerrace;
|
||||
board.generateVisualContent += context =>
|
||||
{
|
||||
if (terrace)
|
||||
DrawDraftGrid(context.painter2D, context.visualElement.contentRect, 26);
|
||||
else
|
||||
DrawDeckOutline(context, ship.Hull.Columns);
|
||||
};
|
||||
var markings = Add(board, "work-draft-markings");
|
||||
markings.pickingMode = PickingMode.Ignore;
|
||||
AddText(markings, "STERN", "work-caption");
|
||||
AddText(markings, "SUN DECK", "work-caption");
|
||||
AddText(markings, "BOW →", "work-caption");
|
||||
var diagram = Add(board, "sun-deck-diagram");
|
||||
AddText(markings, terrace ? "AFT TERRACE" : ship.HasAftTerrace ? "SKY DECK" : "SUN DECK", "work-caption");
|
||||
AddText(markings, terrace ? "STAIRS TO SKY DECK →" : "BOW →", "work-caption");
|
||||
var diagram = Add(board, terrace ? "sun-deck-diagram sun-terrace-diagram" : "sun-deck-diagram");
|
||||
var status = AddText(Add(board, "work-placement"), "", "work-placement-text");
|
||||
status.name = "sun-placement-status";
|
||||
refreshSunPlacement = DrawSunGrid(diagram, status, ship, grid, pool);
|
||||
|
||||
var fittings = Add(work, "work-fittings sun-deck-panel");
|
||||
var capacity = Add(fittings, "work-capacity-strip");
|
||||
if (ship.HasAftTerrace)
|
||||
{
|
||||
AddSunZone(capacity, SunDeckZone.Sky, "Sky deck", "sun-zone-sky");
|
||||
AddSunZone(capacity, SunDeckZone.AftTerrace, "Aft terrace", "sun-zone-terrace");
|
||||
}
|
||||
AddText(capacity, $"{ship.PoolCapacity:N0} amenity admissions", "work-capacity");
|
||||
AddText(capacity, $"{ship.Entertainment:N0} show seats", "work-capacity");
|
||||
|
||||
@@ -59,10 +73,12 @@ namespace BigShipTycoon
|
||||
int existingPool = grid.PoolIndex;
|
||||
foreach (var option in SunAttractions)
|
||||
{
|
||||
if (option.Kind == SunAttraction.SkyGarden && !ship.HasAftTerrace)
|
||||
continue;
|
||||
bool isPool = option.Kind == SunAttraction.Pool;
|
||||
int minimumHull = SunDeckPlan.RequiredHull(option.Kind);
|
||||
string requirement = ship.HullIndex < minimumHull ? $"Requires a {Market.Hulls[minimumHull].Name} hull" : null;
|
||||
int cost = isPool && existingPool >= 0 ? 0 : Company.SunDeckPlacementPrice(ship, new SunDeckPlacement(option.Kind, 0, 0));
|
||||
int cost = isPool && existingPool >= 0 ? 0 : Company.SunDeckPlacementPrice(ship, new SunDeckPlacement(option.Kind, 0, 0), zone: sunZone);
|
||||
string detail = requirement != null ? $" · {Market.Hulls[minimumHull].Name}" : cost > 0 ? $" {Money(cost)}" : "";
|
||||
Button choose = Action(option.Label + detail, () =>
|
||||
{
|
||||
@@ -117,7 +133,7 @@ namespace BigShipTycoon
|
||||
actions.Add(move);
|
||||
Button remove = Action("Remove", () =>
|
||||
{
|
||||
string failure = company.RemoveSunDeck(ship, sunSelection);
|
||||
string failure = company.RemoveSunDeck(ship, sunSelection, sunZone);
|
||||
if (failure == null)
|
||||
ResetSunTool();
|
||||
Apply(failure, "Sun deck fitting removed.");
|
||||
@@ -128,10 +144,12 @@ namespace BigShipTycoon
|
||||
var trim = SunDeckOptions(fittings, "Pool");
|
||||
foreach (var option in SunPools)
|
||||
{
|
||||
if (option.Style == SunPoolStyle.Lagoon && !ship.HasAftTerrace)
|
||||
continue;
|
||||
var next = plan;
|
||||
next.Pool = option.Style;
|
||||
AddSunOption(trim, ship, next, option.Label, "sun-pool-" + option.Id, pool == option.Style,
|
||||
option.Style == SunPoolStyle.Resort ? Market.Regional : 0);
|
||||
SunDeckPlan.RequiredHull(option.Style));
|
||||
}
|
||||
var rectangle = plan;
|
||||
rectangle.Shape = SunPoolShape.Rectangle;
|
||||
@@ -172,8 +190,11 @@ namespace BigShipTycoon
|
||||
diagram.Add(cell);
|
||||
}
|
||||
|
||||
AddSunDiagramFit(diagram, grid.Area, grid.Funnels, "Funnels", "sun-diagram-fixed");
|
||||
AddSunDiagramFit(diagram, grid.Area, grid.Bridge, "Bridge", "sun-diagram-fixed");
|
||||
if (sunZone == SunDeckZone.Sky)
|
||||
{
|
||||
AddSunDiagramFit(diagram, grid.Area, grid.Funnels, "Funnels", "sun-diagram-fixed");
|
||||
AddSunDiagramFit(diagram, grid.Area, grid.Bridge, "Bridge", "sun-diagram-fixed");
|
||||
}
|
||||
for (int i = 0; i < grid.Existing.Count; i++)
|
||||
{
|
||||
var placed = grid.Existing[i];
|
||||
@@ -181,7 +202,7 @@ namespace BigShipTycoon
|
||||
string classes = placed.Kind switch
|
||||
{
|
||||
SunAttraction.Pool => "sun-diagram-pool",
|
||||
SunAttraction.MiniGolf => "sun-diagram-golf",
|
||||
SunAttraction.MiniGolf or SunAttraction.SkyGarden => "sun-diagram-golf",
|
||||
SunAttraction.Theater => "sun-diagram-theater",
|
||||
_ => "sun-diagram-ride"
|
||||
};
|
||||
@@ -193,7 +214,7 @@ namespace BigShipTycoon
|
||||
{
|
||||
var water = new VisualElement { pickingMode = PickingMode.Ignore };
|
||||
water.AddToClassList("sun-diagram-basin");
|
||||
water.EnableInClassList("sun-diagram-oval", ship.SunDeckPlan.Shape == SunPoolShape.Oval);
|
||||
water.EnableInClassList("sun-diagram-oval", ship.SunDeckFor(sunZone).Shape == SunPoolShape.Oval);
|
||||
water.EnableInClassList("sun-diagram-turned", (placed.Rotation & 1) != 0);
|
||||
fitting.Insert(0, water);
|
||||
}
|
||||
@@ -211,7 +232,7 @@ namespace BigShipTycoon
|
||||
if (show)
|
||||
{
|
||||
var fitting = new SunDeckPlacement(sunTool, cursor.x, cursor.y, sunRotation);
|
||||
string block = company.SunDeckPlacementBlock(ship, fitting, sunMoving ? sunSelection : -1);
|
||||
string block = company.SunDeckPlacementBlock(ship, fitting, sunMoving ? sunSelection : -1, sunZone);
|
||||
preview.EnableInClassList("sun-diagram-invalid", block != null);
|
||||
PositionSunFit(preview, grid.Area, grid.Bounds(fitting, pool));
|
||||
status.text = block ?? $"{(sunMoving ? "Move" : "Place")} {SunFittingName(sunTool)} {SunDirection(sunRotation)}";
|
||||
@@ -243,12 +264,12 @@ namespace BigShipTycoon
|
||||
}
|
||||
|
||||
var next = new SunDeckPlacement(sunTool, cell.x, cell.y, sunRotation);
|
||||
string failure = company.PlaceSunDeck(ship, next, sunMoving ? sunSelection : -1);
|
||||
string failure = company.PlaceSunDeck(ship, next, sunMoving ? sunSelection : -1, sunZone);
|
||||
string feedback = $"{SunFittingName(sunTool)} {(sunMoving ? "moved" : "fitted")}.";
|
||||
if (failure == null)
|
||||
{
|
||||
ResetSunTool();
|
||||
var updated = new SunDeckGrid(ship);
|
||||
var updated = new SunDeckGrid(ship, zone: sunZone);
|
||||
sunSelection = updated.At(cell.x, cell.y, updated.SelectedPool);
|
||||
}
|
||||
Apply(failure, feedback);
|
||||
@@ -266,10 +287,10 @@ namespace BigShipTycoon
|
||||
}
|
||||
if (sunSelection < 0)
|
||||
return;
|
||||
var grid = new SunDeckGrid(Ship);
|
||||
var grid = new SunDeckGrid(Ship, zone: sunZone);
|
||||
var next = grid.Existing[sunSelection];
|
||||
next.Rotation = (next.Rotation + 1) & 3;
|
||||
Apply(company.PlaceSunDeck(Ship, next, sunSelection), $"{SunFittingName(next.Kind)} rotated.");
|
||||
Apply(company.PlaceSunDeck(Ship, next, sunSelection, sunZone), $"{SunFittingName(next.Kind)} rotated.");
|
||||
}
|
||||
|
||||
private void ResetSunTool()
|
||||
@@ -297,14 +318,27 @@ namespace BigShipTycoon
|
||||
return row;
|
||||
}
|
||||
|
||||
private void AddSunZone(VisualElement parent, SunDeckZone zone, string label, string id)
|
||||
{
|
||||
Button button = Action(label, () =>
|
||||
{
|
||||
sunZone = zone;
|
||||
ResetSunTool();
|
||||
Notify(null);
|
||||
Render();
|
||||
}, "sun-deck-choice", id);
|
||||
button.EnableInClassList("sun-deck-selected", sunZone == zone);
|
||||
parent.Add(button);
|
||||
}
|
||||
|
||||
private void AddSunOption(VisualElement row, Ship ship, SunDeckPlan next, string label, string id, bool selected,
|
||||
int minimumHull = 0)
|
||||
{
|
||||
next.CustomLayout = true;
|
||||
string requirement = ship.HullIndex < minimumHull ? $"Requires a {Market.Hulls[minimumHull].Name} hull" : null;
|
||||
int cost = Company.SunDeckCost(ship, next);
|
||||
int cost = Company.SunDeckCost(ship, next, sunZone);
|
||||
string detail = requirement == null && cost > 0 ? $" {Money(cost)}" : "";
|
||||
Button option = Action(label + detail, () => Apply(company.ChangeSunDeck(ship, next), "Sun deck refitted."), "sun-deck-choice", id);
|
||||
Button option = Action(label + detail, () => Apply(company.ChangeSunDeck(ship, next, sunZone), "Sun deck refitted."), "sun-deck-choice", id);
|
||||
option.EnableInClassList("sun-deck-selected", selected);
|
||||
option.SetEnabled(requirement == null && company.AvailableCash >= cost);
|
||||
option.tooltip = requirement ?? (cost > 0 ? $"Refit cost {Money(cost)}" : "");
|
||||
|
||||
Reference in New Issue
Block a user