Make voyages active with dockside orders, crew calls, and ship PA
This commit is contained in:
42
Assets/Soundings/Runtime/OnboardPerformances.cs
Normal file
42
Assets/Soundings/Runtime/OnboardPerformances.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
|
||||
namespace Soundings
|
||||
{
|
||||
public sealed partial class OnboardSession
|
||||
{
|
||||
private int performanceStarted = -1;
|
||||
private EntertainmentProgram BookedProgram => Quote.Plan?.Program ?? EntertainmentProgram.Shipboard;
|
||||
private int PerformanceRounds => PortPlanning.ShowRounds(BookedProgram);
|
||||
public bool PerformanceActive => performanceStarted >= 0 && tick < performanceStarted + PerformanceRounds;
|
||||
internal bool CanAdvancePerformance => BookedProgram != EntertainmentProgram.Shipboard && performanceStarted < 0
|
||||
&& tick + PerformanceRounds < ticks;
|
||||
internal string PerformanceLabel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (BookedProgram == EntertainmentProgram.Shipboard)
|
||||
return "Shipboard sets";
|
||||
string title = PortPlanning.ProgramLabel(BookedProgram);
|
||||
if (PerformanceActive)
|
||||
return $"{title} · now playing ({performanceStarted + PerformanceRounds - tick} rounds)";
|
||||
return $"{title} · {(performanceStarted < 0 ? "up next" : "finished")}";
|
||||
}
|
||||
}
|
||||
|
||||
internal bool TryAdvancePerformance()
|
||||
{
|
||||
if (!CanAdvancePerformance)
|
||||
return false;
|
||||
performanceStarted = tick;
|
||||
Measure(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void AdvancePerformance()
|
||||
{
|
||||
if (BookedProgram != EntertainmentProgram.Shipboard && performanceStarted < 0
|
||||
&& tick >= Math.Min(ticks - PerformanceRounds, ticks * PortPlanning.ShowTime(BookedProgram)))
|
||||
performanceStarted = tick;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user