Fix port cinematics and expand ship attractions

This commit is contained in:
josh
2026-11-28 18:39:32 -05:00
parent 2c85a5ba00
commit 56fafba6d9
37 changed files with 936 additions and 101 deletions

View File

@@ -16,15 +16,26 @@ namespace Soundings
holdCinematicClock = true;
StartCompany(false);
yield return null;
BeginVoyage(company.Forecast(Ship, 1));
yield return WritePortFrames(output, "Departure-Miami");
EndPortCinematic();
FinishVoyage();
yield return WritePortFrames(output, "Arrival-Nassau");
EndPortCinematic();
if (company.Permit(2) is string permitFailure)
throw new IOException(permitFailure);
foreach (int destination in new[] { 1, 2, 0 })
{
Voyage quote = company.Forecast(Ship, destination);
if (Ship.Fuel < quote.RequiredFuel && company.Refuel(Ship, quote.RequiredFuel - Ship.Fuel) is string fuelFailure)
throw new IOException(fuelFailure);
string origin = Market.Ports[Ship.Port].Name.Replace(" ", "");
string arrival = Market.Ports[destination].Name.Replace(" ", "");
BeginVoyage(company.Forecast(Ship, destination));
yield return WritePortFrames(output, "Departure-" + origin);
EndPortCinematic();
FinishVoyage();
yield return WritePortFrames(output, "Arrival-" + arrival);
EndPortCinematic();
}
Time.captureFramerate = 0;
holdCinematicClock = false;
Debug.Log("Soundings port clips exported to " + output);
Debug.Log("Big Ship Tycoon port clips exported to " + output);
Application.Quit(0);
}
@@ -37,24 +48,39 @@ namespace Soundings
int frames = Mathf.CeilToInt(Harbor.PortCinematicDuration * PortClipFrameRate);
using var stream = File.Create(Path.Combine(output, name + ".raw"));
var rendered = new WaitForEndOfFrame();
for (int frame = 0; frame < frames; frame++)
int width = Screen.width, height = Screen.height;
var target = new RenderTexture(width, height, 0, RenderTextureFormat.ARGB32);
var image = new Texture2D(width, height, TextureFormat.RGBA32, false);
var bytes = new byte[width * height * 4];
try
{
cinematicTime = frame * step;
PresentPortCinematicFrame(step);
yield return rendered;
Texture2D image = ScreenCapture.CaptureScreenshotAsTexture();
try
File.WriteAllText(Path.Combine(output, name + ".txt"), $"{width} {height} {image.format} {PortClipFrameRate}");
for (int frame = 0; frame < frames; frame++)
{
if (frame == 0)
File.WriteAllText(Path.Combine(output, name + ".txt"), $"{image.width} {image.height} {image.format} {PortClipFrameRate}");
byte[] bytes = image.GetRawTextureData();
cinematicTime = frame * step;
PresentPortCinematicFrame(step);
yield return rendered;
ScreenCapture.CaptureScreenshotIntoRenderTexture(target);
RenderTexture previous = RenderTexture.active;
try
{
RenderTexture.active = target;
image.ReadPixels(new Rect(0, 0, width, height), 0, 0, false);
}
finally
{
RenderTexture.active = previous;
}
image.GetRawTextureData<byte>().CopyTo(bytes);
stream.Write(bytes, 0, bytes.Length);
yield return null;
}
finally
{
Destroy(image);
}
yield return null;
}
finally
{
target.Release();
Destroy(target);
Destroy(image);
}
}
}