Enable placeable sun deck attractions and finish project rebrand
This commit is contained in:
133
Assets/BigShipTycoon/Runtime/StationInteractions.cs
Normal file
133
Assets/BigShipTycoon/Runtime/StationInteractions.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace BigShipTycoon
|
||||
{
|
||||
public sealed partial class TycoonApp
|
||||
{
|
||||
private VisualElement stationPrompt;
|
||||
private Label stationTitle, stationCommand, stationFeedback, crewCallReadout;
|
||||
private float stationFeedbackUntil;
|
||||
private string stationFeedbackText;
|
||||
|
||||
private void DrawStationInteractions(VisualElement overlay)
|
||||
{
|
||||
stationPrompt = null;
|
||||
if (!passageBridge && !passageExploring)
|
||||
return;
|
||||
|
||||
var reticle = Add(overlay, "station-reticle");
|
||||
reticle.pickingMode = PickingMode.Ignore;
|
||||
stationPrompt = Add(overlay, "station-prompt");
|
||||
stationPrompt.pickingMode = PickingMode.Ignore;
|
||||
stationTitle = AddText(stationPrompt, "", "station-title");
|
||||
stationCommand = AddText(stationPrompt, "", "station-command");
|
||||
stationFeedback = AddText(overlay, "", "station-feedback");
|
||||
stationFeedback.pickingMode = PickingMode.Ignore;
|
||||
UpdateStationInteractions();
|
||||
}
|
||||
|
||||
private void UpdateStationInteractions()
|
||||
{
|
||||
if (stationPrompt == null || livePassage == null)
|
||||
return;
|
||||
|
||||
bool visible = harbor.TryGetFacingStation(out StationKind station);
|
||||
stationPrompt.style.display = visible ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
if (visible)
|
||||
{
|
||||
bool requested = livePassage.CrewCall == station;
|
||||
string action = station == StationKind.Helm && passageHelm.Manual
|
||||
? "Return to autopilot" : livePassage.StationAction(station);
|
||||
string blocker = station == StationKind.Helm ? null : livePassage.StationBlock(station);
|
||||
SetPassageText(stationTitle, requested ? $"{OnboardSession.StationName(station)} · Crew call" : OnboardSession.StationName(station));
|
||||
SetPassageText(stationCommand, blocker ?? $"[F] {action}");
|
||||
stationPrompt.EnableInClassList("station-requested", requested);
|
||||
}
|
||||
|
||||
bool showResult = !string.IsNullOrEmpty(stationFeedbackText) && Time.unscaledTime < stationFeedbackUntil;
|
||||
stationFeedback.style.display = showResult ? DisplayStyle.Flex : DisplayStyle.None;
|
||||
if (showResult)
|
||||
SetPassageText(stationFeedback, stationFeedbackText);
|
||||
}
|
||||
|
||||
private bool UseFacingStation()
|
||||
{
|
||||
if (livePassage == null || !harbor.TryGetFacingStation(out StationKind station))
|
||||
return false;
|
||||
|
||||
if (station == StationKind.Helm)
|
||||
{
|
||||
ToggleHelm();
|
||||
ShowStationResult(passageHelm.Manual ? "Manual helm engaged" : "Autopilot engaged", true);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool worked = livePassage.TryWorkStation(station, out string result);
|
||||
if (worked)
|
||||
AnnounceStation(station);
|
||||
if (worked && (station is >= StationKind.Engine and <= StationKind.Waste or StationKind.Laundry))
|
||||
{
|
||||
int area = station == StationKind.Laundry ? 6 : (int)station - (int)StationKind.Engine;
|
||||
if (area != passageServiceArea)
|
||||
{
|
||||
passageServiceArea = area;
|
||||
Render();
|
||||
}
|
||||
}
|
||||
ShowStationResult(result, worked);
|
||||
RefreshPassageBusiness();
|
||||
return worked;
|
||||
}
|
||||
|
||||
private void ShowStationResult(string result, bool worked)
|
||||
{
|
||||
stationFeedbackText = result;
|
||||
stationFeedbackUntil = Time.unscaledTime + 3.4f;
|
||||
if (worked)
|
||||
passageAudio.Confirm();
|
||||
UpdateStationInteractions();
|
||||
}
|
||||
|
||||
private void UpdateCrewCall()
|
||||
{
|
||||
if (crewCallReadout == null)
|
||||
return;
|
||||
|
||||
string text;
|
||||
if (livePassage.CrewCall is StationKind station)
|
||||
text = $"Crew call · {OnboardSession.StationName(station)} · {StationDeck(station)} · {livePassage.CrewRoundsLeft} rounds";
|
||||
else if (livePassage.CrewRequestsCompleted > 0)
|
||||
text = $"Crew calls answered · {livePassage.CrewRequestsCompleted}";
|
||||
else
|
||||
text = "";
|
||||
|
||||
SetPassageText(crewCallReadout, text);
|
||||
crewCallReadout.style.display = text.Length == 0 ? DisplayStyle.None : DisplayStyle.Flex;
|
||||
crewCallReadout.EnableInClassList("crew-call-urgent", livePassage.CrewRoundsLeft is > 0 and <= 2);
|
||||
}
|
||||
|
||||
private string StationDeck(StationKind station)
|
||||
{
|
||||
if (station <= StationKind.Waste || station == StationKind.Laundry)
|
||||
return "Service deck";
|
||||
|
||||
(Facility room, Facility expansion, Facility premium) = station switch
|
||||
{
|
||||
StationKind.Cabins => (Facility.Cabin, Facility.Suite, Facility.GrandSuite),
|
||||
StationKind.Dining => (Facility.Dining, Facility.Restaurant, Facility.Restaurant),
|
||||
StationKind.Bar => (Facility.Bar, Facility.CocktailLounge, Facility.CocktailLounge),
|
||||
StationKind.Stage => (Facility.Entertainment, Facility.GrandTheater, Facility.GrandTheater),
|
||||
StationKind.Retail => (Facility.Shop, Facility.ShoppingArcade, Facility.ShoppingArcade),
|
||||
StationKind.Casino => (Facility.CasinoLounge, Facility.Casino, Facility.GrandCasino),
|
||||
_ => (Facility.Amenity, Facility.ResortPool, Facility.ResortPool)
|
||||
};
|
||||
for (int i = 0; i < Ship.Decks.Count; i++)
|
||||
foreach (Facility cell in Ship.Decks[i].Cells)
|
||||
if (cell == room || cell == expansion || cell == premium
|
||||
|| station == StationKind.Pool && cell is Facility.Spa or Facility.WaterPark)
|
||||
return $"Deck {i + 1}";
|
||||
return "Guest decks";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user