Animate passenger venues and add port-specific cinematics
This commit is contained in:
@@ -9,10 +9,11 @@ namespace Soundings
|
||||
private const float EyeHeight = 1.64f;
|
||||
private const float DeckCeiling = 2.44f;
|
||||
private const float AisleWidth = 1.80f;
|
||||
private const float ChairSeatHeight = .515f;
|
||||
private const int Bulkhead = 25, Joinery = 26, Alloy = 27, DeckTrim = 28, Carpet = 29,
|
||||
Ivory = 30, LightStrip = 31, Gasket = 32, DisplayDark = 33, ScreenChart = 34,
|
||||
ScreenGreen = 35, ScreenAmber = 36, BridgeFloor = 37, Upholstery = 38, SafetyGreen = 39,
|
||||
ScreenWater = 40, ScreenLand = 41, ScreenRed = 42, WindowGlass = 43;
|
||||
ScreenWater = 40, ScreenLand = 41, ScreenRed = 42, WindowGlass = 43, PoolWater = 44, PoolTile = 45;
|
||||
private static readonly string[] Paint =
|
||||
{
|
||||
"142C3F", "E1DBCA", "B88754", "8A613C", "283846", "678B93", "B45944", "497975",
|
||||
@@ -20,7 +21,7 @@ namespace Soundings
|
||||
"573B2E", "A46C50", "DFAB86", "40577D", "BF7756", "D3B973", "76ADA8", "A684AB", "E3DED0",
|
||||
"B7BFC0", "AD825C", "91A9AF", "284550", "385361", "DCE1DB", "FFF1D7", "202D36",
|
||||
"111D25", "8ED9E0", "65C89B", "E7B868", "3F565C", "416172", "527D65", "29485A", "A8AB71",
|
||||
"D66D57", "80B6C5"
|
||||
"D66D57", "80B6C5", "3796A3", "47878F"
|
||||
};
|
||||
|
||||
private readonly Transform shipRoot;
|
||||
@@ -40,6 +41,10 @@ namespace Soundings
|
||||
private bool bridgeView;
|
||||
private float animationTime;
|
||||
|
||||
internal bool HasActiveGuest(GuestActivity activity) => !bridgeView
|
||||
&& (activeIndex < 0 ? promenade : decks[activeIndex])?.Crowd.activeInHierarchy == true
|
||||
&& passengerCrowd.HasActiveGuest(activity);
|
||||
|
||||
private sealed class Layout
|
||||
{
|
||||
public readonly GameObject Room, Crowd, Interior, Cutaway;
|
||||
@@ -175,12 +180,20 @@ namespace Soundings
|
||||
|
||||
public void HidePassengers()
|
||||
{
|
||||
promenade.Crowd.SetActive(false);
|
||||
HideCrowd(promenade);
|
||||
foreach (Layout deck in decks)
|
||||
deck?.Crowd.SetActive(false);
|
||||
if (deck != null)
|
||||
HideCrowd(deck);
|
||||
}
|
||||
|
||||
public void Tick(OnboardSession session, float delta)
|
||||
private static void HideCrowd(Layout layout)
|
||||
{
|
||||
layout.Crowd.SetActive(false);
|
||||
foreach (DeckGuest guest in layout.People)
|
||||
guest.Initialized = false;
|
||||
}
|
||||
|
||||
public void Tick(OnboardSession session, float delta, Camera view)
|
||||
{
|
||||
if (session == null)
|
||||
return;
|
||||
@@ -191,7 +204,7 @@ namespace Soundings
|
||||
if (!layout.Crowd.activeSelf)
|
||||
layout.Crowd.SetActive(true);
|
||||
layout.CrowdMesh ??= passengerCrowd.CreateMesh(layout.Crowd, length, beam);
|
||||
passengerCrowd.Draw(layout.CrowdMesh, layout.People, session, activeIndex < 0, animationTime, delta);
|
||||
passengerCrowd.Draw(layout.CrowdMesh, layout.People, session, activeIndex < 0, animationTime, delta, view);
|
||||
}
|
||||
|
||||
private Layout BuildPromenade()
|
||||
@@ -204,14 +217,17 @@ namespace Soundings
|
||||
float offset = VesselExterior.DeckOffset(length, deck);
|
||||
float aft = offset - deckLength * .305f;
|
||||
float fore = Mathf.Min(BridgeCenter - 6.0f, offset + deckLength * .17f);
|
||||
float pool = VesselExterior.SunDeckCenter(length, deck);
|
||||
bool hasPool = ship.Count(Facility.Amenity) > 0;
|
||||
int sunDeckService = hasPool ? (int)OnboardService.Amenities : -1;
|
||||
int walkers = 7 + ship.HullIndex * 3;
|
||||
for (int side = -1; side <= 1; side += 2)
|
||||
{
|
||||
for (int i = 0; i < walkers; i++)
|
||||
{
|
||||
float occupancy = Mathf.Lerp(.15f, .95f, i / (float)(walkers - 1));
|
||||
var route = new Vector3(aft, y, side * width * .865f);
|
||||
layout.People.Add(new DeckGuest(route, fore, width * .075f, (i + (side > 0 ? .43f : 0)) / walkers,
|
||||
var route = new Vector3(aft, y, side * width * .895f);
|
||||
layout.People.Add(new DeckGuest(route, fore, .285f, (i + (side > 0 ? .43f : 0)) / walkers,
|
||||
15 + i * 13 + (side > 0 ? 131 : 0), occupancy));
|
||||
}
|
||||
|
||||
@@ -219,13 +235,30 @@ namespace Soundings
|
||||
float heading = side < 0 ? 180 : 0;
|
||||
AddGuest(layout, GuestActivity.Rail, new Vector3(fore + .92f, y, side * rail), 78 + side, heading, -1, .28f);
|
||||
AddGuest(layout, GuestActivity.Photograph, new Vector3(aft - .98f, y, side * (rail - .16f)), 32 + side, heading, -1, .57f);
|
||||
|
||||
float seatZ = side * (width * VesselExterior.LoungerBeamFraction + .105f);
|
||||
for (int chair = 0; chair < 3; chair++)
|
||||
{
|
||||
float x = VesselExterior.LoungerX(pool, chair * 3 + (side > 0 ? 1 : 0));
|
||||
AddGuest(layout, GuestActivity.Lounge, new Vector3(x, y, seatZ), 96 + chair * 7 + side * 4,
|
||||
heading + 180, sunDeckService, .19f + chair * .20f, VesselExterior.LoungerSeatHeight + .065f);
|
||||
}
|
||||
}
|
||||
|
||||
float pool = offset + deckLength * .01f;
|
||||
AddGuest(layout, GuestActivity.Talk, new Vector3(pool - 3.40f, y, -1.14f), 37, 0, (int)OnboardService.Amenities, .20f);
|
||||
AddGuest(layout, GuestActivity.Talk, new Vector3(pool - 3.62f, y, -.20f), 214, 167, (int)OnboardService.Amenities, .44f);
|
||||
AddGuest(layout, GuestActivity.Rest, new Vector3(pool + 1.77f, y, width * .67f + .07f), 35, 180, (int)OnboardService.Amenities, .23f, .26f);
|
||||
AddGuest(layout, GuestActivity.Photograph, new Vector3(pool + .9f, y, -2.32f), 62, 180, (int)OnboardService.Amenities, .64f);
|
||||
AddGuest(layout, GuestActivity.Talk, new Vector3(pool - 3.57f, y, -.61f), 37, 22, sunDeckService, .28f);
|
||||
AddGuest(layout, GuestActivity.Talk, new Vector3(pool - 3.21f, y, .26f), 214, 202, sunDeckService, .44f);
|
||||
if (hasPool)
|
||||
{
|
||||
float waterY = BridgeHeight + VesselExterior.PoolWaterHeight;
|
||||
AddGuest(layout, GuestActivity.Swim, new Vector3(pool, waterY, -.67f), 440, 90, sunDeckService, .20f,
|
||||
swimHalfLength: 1.50f);
|
||||
AddGuest(layout, GuestActivity.Swim, new Vector3(pool - .32f, waterY, .25f), 587, -90, sunDeckService, .53f,
|
||||
swimHalfLength: 1.18f);
|
||||
AddGuest(layout, GuestActivity.Wade, new Vector3(pool + 1.72f, waterY, .79f), 768, -96, sunDeckService, .33f);
|
||||
AddGuest(layout, GuestActivity.Wade, new Vector3(pool + 1.00f, waterY, .91f), 921, 82, sunDeckService, .67f);
|
||||
AddGuest(layout, GuestActivity.Photograph, new Vector3(pool + 2.92f, y, -1.95f), 62, -53,
|
||||
sunDeckService, .64f);
|
||||
}
|
||||
return layout;
|
||||
}
|
||||
|
||||
@@ -530,34 +563,48 @@ namespace Soundings
|
||||
}
|
||||
Seat(x, -.58f, Upholstery);
|
||||
Seat(x, .81f, Upholstery, -1);
|
||||
Guest(GuestActivity.Dine, x, -.61f, side + 1, OnboardService.Meals, side < 0 ? .21f : .56f, .54f);
|
||||
Guest(GuestActivity.Dine, x, .84f, side + 4, OnboardService.Meals, side < 0 ? .75f : .93f, .54f, -1);
|
||||
Guest(GuestActivity.Dine, x, -.61f, side + 1, OnboardService.Meals, side < 0 ? .21f : .56f, ChairSeatHeight);
|
||||
Guest(GuestActivity.Dine, x, .84f, side + 4, OnboardService.Meals, side < 0 ? .75f : .93f, ChairSeatHeight, -1);
|
||||
}
|
||||
if (programVenue)
|
||||
Guest(GuestActivity.Guitar, 0, .32f, 32, OnboardService.Shows, .22f, direction: -1,
|
||||
program: EntertainmentProgram.LiveMusic);
|
||||
break;
|
||||
case Facility.Bar:
|
||||
Solid(Joinery, 0, .48f, depth * .18f, width * .77f, .94f, .81f);
|
||||
Box(Gasket, 0, .974f, depth * .18f, width * .79f, .10f, .92f);
|
||||
Box(8, 0, .20f, depth * .18f - .44f, width * .74f, .050f, .045f);
|
||||
Box(LightStrip, 0, .867f, depth * .18f - .422f, width * .74f, .031f, .043f);
|
||||
float counter = depth * .025f;
|
||||
Solid(Joinery, 0, .48f, counter, width * .76f, .94f, .65f);
|
||||
Box(Gasket, 0, .974f, counter, width * .79f, .10f, .75f);
|
||||
Box(8, 0, .20f, counter - .378f, width * .74f, .050f, .045f);
|
||||
Box(LightStrip, 0, .867f, counter - .35f, width * .74f, .031f, .043f);
|
||||
float display = depth * .44f;
|
||||
Box(DeckTrim, 0, 1.50f, display + .09f, width * .67f, .68f, .10f);
|
||||
Box(Joinery, 0, 1.36f, display, width * .69f, .053f, .22f);
|
||||
Box(LightStrip, 0, 1.80f, display + .047f, width * .66f, .045f, .09f);
|
||||
for (int bottle = -8; bottle <= 8; bottle++)
|
||||
{
|
||||
float x = bottle * width * .035f;
|
||||
int color = Mathf.Abs(bottle) % 3 == 1 ? SafetyGreen : Mathf.Abs(bottle) % 3 == 2 ? 13 : 12;
|
||||
float height = .16f + (Mathf.Abs(bottle) % 4) * .022f;
|
||||
Box(color, x, 1.393f + height * .5f, display - .024f, .067f, height, .063f);
|
||||
Box(Alloy, x, 1.382f + height, display - .024f, .039f, .048f, .040f);
|
||||
}
|
||||
for (int i = -2; i <= 2; i++)
|
||||
{
|
||||
float x = i * width * .115f;
|
||||
Box(i % 2 == 0 ? SafetyGreen : 13, x + .12f, 1.117f, depth * .19f, .07f, .18f, .071f);
|
||||
Box(Alloy, x + .12f, 1.224f, depth * .19f, .055f, .06f, .044f);
|
||||
if (i != 0)
|
||||
{
|
||||
float stool = depth * .18f - .97f;
|
||||
Box(Alloy, x, .057f, stool, .39f, .11f, .39f);
|
||||
Box(Alloy, x, .35f, stool, .077f, .69f, .077f);
|
||||
Box(Upholstery, x, .69f, stool, .38f, .10f, .39f);
|
||||
Box(Alloy, x, .26f, stool, .30f, .035f, .23f);
|
||||
layout.WalkSpace.Block(pos + new Vector3(x, 0, stool * facing), new Vector3(.39f, .76f, .40f));
|
||||
Guest(GuestActivity.Drink, x, stool, i + 4, OnboardService.Drinks, i is 1 or -1 ? .35f : .73f, .80f);
|
||||
}
|
||||
if (i == 0)
|
||||
continue;
|
||||
float stool = counter - .83f;
|
||||
Box(Alloy, x, .057f, stool, .39f, .11f, .39f);
|
||||
Box(Alloy, x, .35f, stool, .077f, .69f, .077f);
|
||||
Box(Upholstery, x, .69f, stool, .38f, .10f, .39f);
|
||||
Box(Alloy, x, .26f, stool + .035f, .30f, .035f, .25f);
|
||||
Box(8, x, 1.028f, counter - .223f, .154f, .008f, .154f);
|
||||
layout.WalkSpace.Block(pos + new Vector3(x, 0, stool * facing), new Vector3(.39f, .76f, .40f));
|
||||
Guest(GuestActivity.Drink, x, stool, i + 4, OnboardService.Drinks, i is 1 or -1 ? .25f : .76f, .775f);
|
||||
}
|
||||
Box(SafetyGreen, width * .14f, 1.116f, counter + .13f, .07f, .18f, .071f);
|
||||
Box(Alloy, width * .14f, 1.224f, counter + .13f, .055f, .06f, .044f);
|
||||
Guest(GuestActivity.TendBar, 0, counter + .72f, 11, OnboardService.Drinks, .08f, direction: -1);
|
||||
break;
|
||||
case Facility.Entertainment:
|
||||
Solid(Gasket, 0, .19f, depth * .307f, width * .82f, .38f, .99f);
|
||||
@@ -573,7 +620,7 @@ namespace Soundings
|
||||
float z = -.37f + row * .62f;
|
||||
Seat(x, z, 10);
|
||||
Guest(GuestActivity.Watch, x, z, 46 + i + row * 5, OnboardService.Shows,
|
||||
row == 0 ? .29f + Mathf.Abs(i) * .13f : .59f + Mathf.Abs(i) * .13f, .54f);
|
||||
row == 0 ? .29f + Mathf.Abs(i) * .13f : .59f + Mathf.Abs(i) * .13f, ChairSeatHeight);
|
||||
}
|
||||
Guest(GuestActivity.Perform, 0, depth * .31f, 30, OnboardService.Shows, .06f, direction: -1, lift: .42f);
|
||||
if (programVenue)
|
||||
@@ -587,16 +634,26 @@ namespace Soundings
|
||||
}
|
||||
break;
|
||||
case Facility.Amenity:
|
||||
Solid(Ivory, 0, .18f, depth * .18f, width * .65f, .33f, depth * .44f);
|
||||
Box(ScreenChart, 0, .356f, depth * .18f, width * .57f, .023f, depth * .36f);
|
||||
for (int i = -4; i <= 4; i++)
|
||||
Box(15, i * width * .062f, .370f, depth * .18f, .021f, .004f, depth * .34f);
|
||||
Vector2 basin = new(Mathf.Min(2.58f, width * .295f), depth * .24f);
|
||||
const float poolLevel = .44f;
|
||||
float poolZ = depth * .13f;
|
||||
Vector3 poolFoot = pos + Vector3.forward * (poolZ * facing);
|
||||
VesselExterior.PoolBasin(shape.Mesh(Ivory), shape.Mesh(PoolTile), shape.Mesh(PoolWater), poolFoot, basin, .56f, poolLevel);
|
||||
VesselExterior.PoolRails(shape.Mesh(Alloy), poolFoot + new Vector3(-basin.x * .69f, .18f, -basin.y * facing), -facing);
|
||||
layout.WalkSpace.Block(poolFoot, new Vector3((basin.x + .23f) * 2f, .56f, (basin.y + .23f) * 2f));
|
||||
Guest(GuestActivity.Wade, basin.x * .37f, poolZ - basin.y * .12f, 7, OnboardService.Amenities, .12f,
|
||||
lift: poolLevel);
|
||||
Guest(GuestActivity.Wade, -basin.x * .25f, poolZ + basin.y * .24f, 51, OnboardService.Amenities, .57f,
|
||||
direction: -1, lift: poolLevel);
|
||||
for (int side = -1; side <= 1; side += 2)
|
||||
{
|
||||
Solid(Joinery, side * width * .308f, .25f, -depth * .25f, 1.41f, .34f, .53f);
|
||||
Box(Ivory, side * width * .308f, .451f, -depth * .25f, 1.35f, .105f, .49f);
|
||||
Guest(side > 0 ? GuestActivity.Read : GuestActivity.Rest, side * width * .308f, -depth * .25f,
|
||||
side + 3, OnboardService.Amenities, side < 0 ? .30f : .75f, .60f);
|
||||
float seatX = side * width * .401f;
|
||||
float bench = -depth * .36f;
|
||||
Solid(Joinery, seatX, .20f, bench, .94f, .36f, .46f);
|
||||
Box(Upholstery, seatX, .418f, bench, .92f, .089f, .46f);
|
||||
Box(Upholstery, seatX, .61f, bench - .211f, .93f, .36f, .072f);
|
||||
Guest(side > 0 ? GuestActivity.Read : GuestActivity.Rest, seatX, bench,
|
||||
side + 3, OnboardService.Amenities, side < 0 ? .30f : .75f, .483f);
|
||||
}
|
||||
break;
|
||||
case Facility.Tank:
|
||||
@@ -906,8 +963,8 @@ namespace Soundings
|
||||
private float BridgeCenter => VesselExterior.BridgeCenter(length, ship.Decks.Count);
|
||||
|
||||
private static void AddGuest(Layout layout, GuestActivity activity, Vector3 station, int seed, float heading,
|
||||
int service, float occupancy, float seatHeight = 0, EntertainmentProgram? program = null) =>
|
||||
layout.People.Add(new DeckGuest(activity, station, seed, heading, service, occupancy, seatHeight, program));
|
||||
int service, float occupancy, float seatHeight = 0, EntertainmentProgram? program = null, float swimHalfLength = 0) =>
|
||||
layout.People.Add(new DeckGuest(activity, station, seed, heading, service, occupancy, seatHeight, program, swimHalfLength));
|
||||
|
||||
private static void Chair(Geometry shape, Vector3 at, int color, int side)
|
||||
{
|
||||
@@ -951,12 +1008,13 @@ namespace Soundings
|
||||
2 or Joinery => Harbor.SurfaceFinish.Timber,
|
||||
Carpet or BridgeFloor or Upholstery or 11 => Harbor.SurfaceFinish.Fabric,
|
||||
Alloy => Harbor.SurfaceFinish.Alloy,
|
||||
PoolWater => Harbor.SurfaceFinish.Pool,
|
||||
_ => Harbor.SurfaceFinish.Paint
|
||||
};
|
||||
material.SetFloat("_Finish", (float)surfaceFinish);
|
||||
if (id == 0)
|
||||
material.SetFloat("_Waterline", 1);
|
||||
material.SetFloat("_Roughness", metal ? .39f : .76f);
|
||||
material.SetFloat("_Roughness", id == PoolWater ? .16f : metal ? .39f : .76f);
|
||||
material.SetFloat("_Metal", metal ? .45f : .04f);
|
||||
material.SetFloat("_Weather", id is Carpet or BridgeFloor or Upholstery ? .57f : .12f);
|
||||
material.SetFloat("_Emissive", id switch
|
||||
|
||||
@@ -48,6 +48,7 @@ namespace Soundings
|
||||
internal bool PassageUsesPerspective => sailing && cameraMode == CameraMode.Orbit && !viewCamera.orthographic;
|
||||
internal Vector3 FirstPersonPosition => freePosition;
|
||||
internal bool FirstPersonPositionIsClear => walkSpace != null && walkSpace.CanStand(freePosition);
|
||||
internal bool HasActiveGuest(GuestActivity activity) => decks?.HasActiveGuest(activity) == true;
|
||||
internal Vector3 OrbitTarget => OrbitFocus(orbitOffset);
|
||||
internal float OrbitVerticalSpan => viewCamera.orthographic ? viewCamera.orthographicSize * 2f
|
||||
: 2f * Vector3.Distance(OrbitTarget, viewCamera.transform.position) * HalfFieldOfView(viewCamera.fieldOfView);
|
||||
@@ -269,8 +270,8 @@ namespace Soundings
|
||||
|
||||
public void UpdatePassengers(OnboardSession session, float delta)
|
||||
{
|
||||
if (sailing && decks != null && cameraMode != CameraMode.Service)
|
||||
decks.Tick(session, delta);
|
||||
if ((sailing || PortCinematicActive) && decks != null && cameraMode != CameraMode.Service)
|
||||
decks.Tick(session, delta, viewCamera);
|
||||
}
|
||||
|
||||
internal void SetRudder(float degrees) => decks?.SetRudder(degrees);
|
||||
@@ -364,7 +365,7 @@ namespace Soundings
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (!viewCamera.enabled)
|
||||
if (!viewCamera.enabled || PortCinematicActive)
|
||||
return;
|
||||
if (cameraMode != CameraMode.Orbit)
|
||||
{
|
||||
@@ -469,6 +470,11 @@ namespace Soundings
|
||||
|
||||
private void ComposeCamera()
|
||||
{
|
||||
if (PortCinematicActive)
|
||||
{
|
||||
ComposePortCinematic();
|
||||
return;
|
||||
}
|
||||
if (cameraMode == CameraMode.Orbit)
|
||||
{
|
||||
viewCamera.orthographic = !sailing;
|
||||
@@ -558,7 +564,9 @@ namespace Soundings
|
||||
water.SetVector("_ViewRight", view.right);
|
||||
water.SetVector("_ViewUp", view.up);
|
||||
water.SetVector("_ViewSize", new Vector4(viewHeight * aspect, viewHeight, viewCamera.orthographic ? 1 : 0, 0));
|
||||
if (backplateRatio <= 0 || sailing)
|
||||
if (PortCinematicActive && portMatteAspect > 0)
|
||||
FitPortMatte(aspect);
|
||||
if (PortCinematicActive || backplateRatio <= 0 || sailing)
|
||||
return;
|
||||
float backdropScale = Mathf.Lerp(.86f, 1, Mathf.Clamp01(zoom));
|
||||
float cropX = Mathf.Min(1, aspect / backplateRatio) * .95f * backdropScale;
|
||||
@@ -574,7 +582,8 @@ namespace Soundings
|
||||
|
||||
public void Show(Ship ship)
|
||||
{
|
||||
SetHarbor(Market.Ports[ship?.Port ?? 0].Region);
|
||||
if (!PortCinematicActive)
|
||||
SetHarbor(Market.Ports[ship?.Port ?? 0].Region);
|
||||
if (ship == null)
|
||||
{
|
||||
if (lastHull == -1)
|
||||
@@ -728,6 +737,7 @@ namespace Soundings
|
||||
{
|
||||
ReleaseFrame();
|
||||
ReleaseShip();
|
||||
ReleasePortQuay();
|
||||
wake?.Dispose();
|
||||
foreach (Material material in materials.Values)
|
||||
Destroy(material);
|
||||
|
||||
219
Assets/Soundings/Runtime/HarborCinematic.cs
Normal file
219
Assets/Soundings/Runtime/HarborCinematic.cs
Normal file
@@ -0,0 +1,219 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Soundings
|
||||
{
|
||||
public sealed partial class Harbor
|
||||
{
|
||||
internal const float PortCinematicDuration = 4.2f;
|
||||
private const float QuayLength = 174f, QuayWidth = 12f;
|
||||
private readonly List<Mesh> quayMeshes = new();
|
||||
private readonly List<Material> quayFinishes = new();
|
||||
private GameObject portQuay;
|
||||
private int cinematicPort = -1;
|
||||
private bool portArrival;
|
||||
private float portFrame;
|
||||
private Vector3 resumeVesselPosition, resumeWaterPosition;
|
||||
private Quaternion resumeVesselRotation;
|
||||
private Vector4 resumeHull, resumeCourse;
|
||||
|
||||
internal bool PortCinematicActive => cinematicPort >= 0;
|
||||
|
||||
internal bool BeginPortCinematic(int port, bool arriving)
|
||||
{
|
||||
if (PortCinematicActive || vessel == null || port < 0 || port >= Market.Ports.Count)
|
||||
return false;
|
||||
|
||||
ShowDeck(-1);
|
||||
cinematicPort = port;
|
||||
portArrival = arriving;
|
||||
portFrame = 0;
|
||||
resumeVesselPosition = vessel.localPosition;
|
||||
resumeVesselRotation = vessel.localRotation;
|
||||
resumeWaterPosition = waterSurface.localPosition;
|
||||
resumeHull = water.GetVector("_HullSpan");
|
||||
resumeCourse = water.GetVector("_HullCourse");
|
||||
|
||||
portQuay ??= BuildPortQuay();
|
||||
portQuay.transform.localPosition = new Vector3(vesselLength * .27f, 0, vesselBeam + 2.05f + QuayWidth * .5f);
|
||||
Vector3 quay = portQuay.transform.position;
|
||||
water.SetVector("_PortBerth", new Vector4(quay.x, quay.z, QuayLength * .5f, QuayWidth * .5f));
|
||||
portQuay.SetActive(true);
|
||||
ShowPortScenery(port);
|
||||
water.SetFloat("_Underway", 0);
|
||||
water.SetFloat("_PortMotion", 1);
|
||||
water.SetFloat("_WeatherSeverity", 0);
|
||||
Shader.SetGlobalFloat("_SoundingsSeaSailing", 0);
|
||||
waterSurface.localPosition = Vector3.zero;
|
||||
wake.Reset();
|
||||
|
||||
// Start with the wake the arriving ship already laid beyond the mouth of the berth.
|
||||
if (portArrival)
|
||||
for (int i = 7; i > 0; i--)
|
||||
UpdatePortWake(-i * .047f);
|
||||
PresentPortCinematic(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
internal void PresentPortCinematic(float elapsed)
|
||||
{
|
||||
if (!PortCinematicActive)
|
||||
return;
|
||||
|
||||
portFrame = Mathf.Clamp01(elapsed / PortCinematicDuration);
|
||||
var (center, heading, knots) = PortMotion(portFrame);
|
||||
float heave = Mathf.Sin(elapsed * 1.87f + .7f) * .052f;
|
||||
float roll = Mathf.Sin(elapsed * 1.24f + 1.1f) * .29f;
|
||||
vessel.SetLocalPositionAndRotation(new Vector3(center.x, heave, center.y), Quaternion.Euler(roll, heading, 0));
|
||||
water.SetVector("_HullSpan", new Vector4(vesselLength, vesselBeam, center.x, center.y));
|
||||
Vector2 course = PortBow(heading);
|
||||
water.SetVector("_HullCourse", new Vector4(course.x, -course.y, Mathf.Clamp01(knots / 19f), 0));
|
||||
float wakeTime = 3f + portFrame * PortCinematicDuration;
|
||||
water.SetFloat("_SeaTime", wakeTime);
|
||||
wake.Update(center, course, knots, vesselLength, vesselBeam, wakeTime, 0);
|
||||
ComposePortCinematic();
|
||||
}
|
||||
|
||||
internal void EndPortCinematic()
|
||||
{
|
||||
if (!PortCinematicActive)
|
||||
return;
|
||||
|
||||
cinematicPort = -1;
|
||||
portQuay.SetActive(false);
|
||||
portScenery?.SetVisible(false);
|
||||
portMatteAspect = 0;
|
||||
wake.Reset();
|
||||
water.SetFloat("_PortMotion", 0);
|
||||
water.SetFloat("_PortMatteActive", 0);
|
||||
water.SetFloat("_Underway", sailing ? 1 : 0);
|
||||
water.SetFloat("_WeatherSeverity", sailing ? seaSeverity : 0);
|
||||
water.SetFloat("_SeaTime", seaTime);
|
||||
Shader.SetGlobalFloat("_SoundingsSeaSailing", sailing ? 1 : 0);
|
||||
if (vessel != null)
|
||||
vessel.SetLocalPositionAndRotation(resumeVesselPosition, resumeVesselRotation);
|
||||
waterSurface.localPosition = resumeWaterPosition;
|
||||
water.SetVector("_HullSpan", resumeHull);
|
||||
water.SetVector("_HullCourse", resumeCourse);
|
||||
SetHarbor(Market.Ports[displayedShip?.Port ?? 0].Region);
|
||||
ResetOrbit(true);
|
||||
}
|
||||
|
||||
private (Vector2 Center, float Heading, float Knots) PortMotion(float t)
|
||||
{
|
||||
float run = Mathf.Min(35f, vesselLength * .38f);
|
||||
if (portArrival)
|
||||
{
|
||||
float slowing = t * (2f - t);
|
||||
float approach = Mathf.SmoothStep(0, 1, t);
|
||||
return (new Vector2((slowing - .88f) * run, -(1f - approach) * (8.5f + vesselBeam * .31f)),
|
||||
-12f * (1f - approach), Mathf.Lerp(11.8f, .35f, Mathf.Clamp01(t)));
|
||||
}
|
||||
|
||||
float leaving = t * (.21f + t * .79f);
|
||||
float castOff = Mathf.SmoothStep(0, 1, t);
|
||||
return (new Vector2((leaving - .35f) * run, -castOff * (9f + vesselBeam * .31f)),
|
||||
castOff * 10.5f, Mathf.Lerp(1.4f, 12.6f, t));
|
||||
}
|
||||
|
||||
private static Vector2 PortBow(float heading)
|
||||
{
|
||||
float radians = heading * Mathf.Deg2Rad;
|
||||
return new Vector2(Mathf.Cos(radians), -Mathf.Sin(radians));
|
||||
}
|
||||
|
||||
private void UpdatePortWake(float t)
|
||||
{
|
||||
var (center, heading, knots) = PortMotion(t);
|
||||
wake.Update(center, PortBow(heading), knots, vesselLength, vesselBeam, 3f + t * PortCinematicDuration, 0);
|
||||
}
|
||||
|
||||
private void ComposePortCinematic()
|
||||
{
|
||||
// Keep the ship ahead of the lens and the quay in frame as the camera tracks along the water.
|
||||
float glide = Mathf.SmoothStep(0, 1, portFrame);
|
||||
float angle = portArrival ? Mathf.Lerp(-28f, 31f, glide) : Mathf.Lerp(32f, -25f, glide);
|
||||
float elevation = portArrival ? Mathf.Lerp(10.8f, 8.9f, glide) : Mathf.Lerp(8.0f, 12.2f, glide);
|
||||
float distance = vesselLength * (portArrival ? Mathf.Lerp(1.49f, 1.25f, glide) : Mathf.Lerp(1.23f, 1.44f, glide));
|
||||
distance *= Mathf.Max(1, 1.63f / ViewAspect);
|
||||
Quaternion facing = Quaternion.Euler(elevation, -angle, 0);
|
||||
Vector3 focus = vessel.position;
|
||||
focus.x = focus.x * .64f + vesselLength * (portArrival ? .021f : .048f);
|
||||
focus.y = vesselTop * .32f;
|
||||
focus.z -= .85f;
|
||||
viewCamera.orthographic = false;
|
||||
viewCamera.nearClipPlane = OrbitNearClip;
|
||||
viewCamera.fieldOfView = Mathf.Lerp(37.5f, 40.5f, portArrival ? 1f - glide : glide);
|
||||
viewCamera.transform.SetPositionAndRotation(focus + facing * Vector3.back * distance, facing);
|
||||
FitViewport();
|
||||
}
|
||||
|
||||
private GameObject BuildPortQuay()
|
||||
{
|
||||
var quay = new GameObject("Cinematic berth");
|
||||
quay.transform.SetParent(transform, false);
|
||||
var concrete = new HarborMesh();
|
||||
var caps = new HarborMesh();
|
||||
var fenders = new HarborMesh();
|
||||
var steel = new HarborMesh();
|
||||
var paint = new HarborMesh();
|
||||
var lantern = new HarborMesh();
|
||||
float edge = -QuayWidth * .5f;
|
||||
concrete.Box(new Vector3(0, .5f, 0), new Vector3(QuayLength, 1.32f, QuayWidth));
|
||||
caps.Box(new Vector3(0, 1.24f, 0), new Vector3(QuayLength + .3f, .19f, QuayWidth + .20f));
|
||||
caps.Box(new Vector3(0, 1.43f, edge + .10f), new Vector3(QuayLength, .24f, .48f));
|
||||
paint.Box(new Vector3(0, 1.34f, edge + .61f), new Vector3(QuayLength - .35f, .026f, .085f));
|
||||
steel.Box(new Vector3(0, 1.41f, -edge - .37f), new Vector3(QuayLength - .3f, .16f, .19f));
|
||||
for (int station = -9; station <= 9; station++)
|
||||
{
|
||||
float x = station * 9.52f;
|
||||
fenders.Box(new Vector3(x, .61f, edge - .079f), new Vector3(.64f, 1.04f, .29f));
|
||||
if (station < 9)
|
||||
fenders.Box(new Vector3(x + 4.76f, 1.33f, 0), new Vector3(.031f, .021f, QuayWidth - 1.6f));
|
||||
Vector3 foot = new Vector3(x, 1.33f, edge + 1.54f);
|
||||
steel.Rod(foot, foot + Vector3.up * .48f, .14f, 8, true);
|
||||
steel.Rod(foot + new Vector3(-.23f, .42f, 0), foot + new Vector3(.23f, .42f, 0), .10f, 8, true);
|
||||
paint.Rod(foot + Vector3.up * .38f, foot + Vector3.up * .50f, .16f, 8, true);
|
||||
if (station % 3 == 0)
|
||||
{
|
||||
var lamp = new Vector3(x, 1.37f, -edge - .6f);
|
||||
steel.Rod(lamp, lamp + Vector3.up * 4.45f, .066f, 8, true);
|
||||
steel.Rod(lamp + Vector3.up * 4.43f, lamp + new Vector3(0, 4.62f, -.83f), .058f, 8);
|
||||
steel.Box(lamp + new Vector3(0, 4.60f, -.82f), new Vector3(.31f, .13f, .52f));
|
||||
lantern.Box(lamp + new Vector3(0, 4.53f, -.83f), new Vector3(.23f, .027f, .39f));
|
||||
}
|
||||
}
|
||||
AddQuayBatch(quay.transform, concrete, "Weathered quay wall", new Color(.43f, .45f, .43f));
|
||||
AddQuayBatch(quay.transform, caps, "Concrete coping", new Color(.59f, .56f, .48f));
|
||||
AddQuayBatch(quay.transform, fenders, "Rubber fenders and joints", new Color(.15f, .17f, .16f));
|
||||
AddQuayBatch(quay.transform, steel, "Mooring and lighting hardware", new Color(.23f, .28f, .29f));
|
||||
AddQuayBatch(quay.transform, paint, "Berth safety marking", new Color(.74f, .57f, .26f));
|
||||
AddQuayBatch(quay.transform, lantern, "Quay lamps", new Color(.98f, .83f, .51f), .70f);
|
||||
return quay;
|
||||
}
|
||||
|
||||
private void AddQuayBatch(Transform quay, HarborMesh geometry, string name, Color color, float emission = 0)
|
||||
{
|
||||
var model = new GameObject(name, typeof(MeshFilter), typeof(MeshRenderer)) { layer = 8 };
|
||||
model.transform.SetParent(quay, false);
|
||||
Mesh mesh = geometry.Bake();
|
||||
var material = new Material(surface) { color = color, name = name };
|
||||
material.SetFloat("_Roughness", .81f);
|
||||
material.SetFloat("_Weather", .54f);
|
||||
material.SetFloat("_Emissive", emission);
|
||||
model.GetComponent<MeshFilter>().sharedMesh = mesh;
|
||||
model.GetComponent<MeshRenderer>().sharedMaterial = material;
|
||||
quayMeshes.Add(mesh);
|
||||
quayFinishes.Add(material);
|
||||
}
|
||||
|
||||
private void ReleasePortQuay()
|
||||
{
|
||||
portScenery?.Release();
|
||||
foreach (Mesh mesh in quayMeshes)
|
||||
Destroy(mesh);
|
||||
foreach (Material material in quayFinishes)
|
||||
Destroy(material);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Soundings/Runtime/HarborCinematic.cs.meta
Normal file
2
Assets/Soundings/Runtime/HarborCinematic.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c13c854ce764bc19aa761172310ce5f
|
||||
402
Assets/Soundings/Runtime/HarborPortLandmarks.cs
Normal file
402
Assets/Soundings/Runtime/HarborPortLandmarks.cs
Normal file
@@ -0,0 +1,402 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Soundings
|
||||
{
|
||||
public sealed partial class Harbor
|
||||
{
|
||||
private sealed partial class PortScenery
|
||||
{
|
||||
private void BuildLandmarks()
|
||||
{
|
||||
Vector3 fore = WaterfrontPoint(0, 10);
|
||||
Vector3 town = WaterfrontPoint(0, 48);
|
||||
fore.y = Mathf.Max(fore.y, 1.48f);
|
||||
town.y = Mathf.Max(town.y, 2.6f);
|
||||
switch (port)
|
||||
{
|
||||
case 0: // Miami terminal and the bay skyline.
|
||||
CruiseTerminal(fore, 45, 13, true);
|
||||
Palm(fore + new Vector3(-30, 0, -2.1f), 6.2f, 1.1f);
|
||||
Palm(fore + new Vector3(29, 0, -1.6f), 5.6f, 4.2f);
|
||||
Tower(town + new Vector3(-31, 0, 29), 12, 13, 29, Coat.Trim);
|
||||
Tower(town + new Vector3(8, 0, 36), 15, 12, 38, Coat.WallCool);
|
||||
Tower(town + new Vector3(42, 0, 27), 18, 12, 23, Coat.Wall);
|
||||
break;
|
||||
case 1: // Nassau's pastel wharf and festival amphitheatre.
|
||||
NassauWaterfront(fore);
|
||||
break;
|
||||
case 2: // Key West Customs House above the open Mallory Square wharf.
|
||||
House(town + new Vector3(-9, 0, -18), 19, 13, 11, Coat.Brick);
|
||||
Gable(town + new Vector3(-9, 11.3f, -18), 19.6f, 13.5f, 5.6f, Coat.Brick);
|
||||
House(fore + new Vector3(24, 0, 4), 16, 10, 4.6f, Coat.Wall);
|
||||
Box(Coat.Wood, fore + new Vector3(-20, -.56f, -8), 21, .72f, 14);
|
||||
Palm(fore + new Vector3(4, 0, 9), 5.8f, 1.4f);
|
||||
Palm(fore + new Vector3(12, 0, 6), 5.3f, 2.8f);
|
||||
break;
|
||||
case 3: // Cozumel's narrow finger pier reaches across a shallow reef shelf.
|
||||
FingerPier(fore + new Vector3(-31, 0, -11), 27);
|
||||
House(fore + new Vector3(-16, 0, 6), 21, 9, 4, Coat.WallWarm);
|
||||
House(fore + new Vector3(14, 0, 1), 16, 8, 7, Coat.WallCool);
|
||||
House(fore + new Vector3(37, 0, 7), 18, 11, 5, Coat.Wall);
|
||||
Palm(fore + new Vector3(-3, 0, 4), 6.7f, 2.6f);
|
||||
Palm(fore + new Vector3(26, 0, -2), 5.8f, 0);
|
||||
break;
|
||||
case 4: // El Morro's seaward bastions and round sentry turrets.
|
||||
Fort(fore + new Vector3(-17, 0, 3), 47, 18, 7.4f);
|
||||
Fort(town + new Vector3(-9, 0, -18), 35, 15, 9.3f);
|
||||
Flag(town + new Vector3(-10, 9.7f, -19), 5);
|
||||
break;
|
||||
case 5: // Bermuda Dockyard's long limestone Clocktower building.
|
||||
House(fore + new Vector3(0, 0, 6), 36, 12, 7, Coat.Wall);
|
||||
ClockTower(fore + new Vector3(-14.4f, 0, 4), 4, 16.8f);
|
||||
ClockTower(fore + new Vector3(14.4f, 0, 4), 4, 16.8f);
|
||||
FingerPier(fore + new Vector3(28, 0, -7), 18);
|
||||
break;
|
||||
case 6: // Ponta Delgada's basalt waterfront fort and limewashed frontage.
|
||||
Fort(fore + new Vector3(-23, 0, 3), 29, 19, 4.4f);
|
||||
House(fore + new Vector3(18, 0, 12), 23, 12, 7.2f, Coat.Trim);
|
||||
for (int gate = -1; gate <= 1; gate++)
|
||||
StoneArch(fore + new Vector3(gate * 5.2f + 17, 0, 1.7f), 3.75f, 4.1f, 1.2f, Coat.Rock);
|
||||
break;
|
||||
case 7: // Lisbon's tiled hillside framed by the Pantheon dome.
|
||||
DenseTerraces(town + new Vector3(-49, 0, -13), 8);
|
||||
Box(Coat.Trim, new Vector3(26, town.y + 5.7f, town.z + 8), 17, 11.4f, 14);
|
||||
Dome(new Vector3(26, town.y + 11.4f, town.z + 8), 5.8f, 6.3f, Coat.Trim);
|
||||
break;
|
||||
case 8: // Barcelona's Adossat terminal and the ridge above the old port.
|
||||
CruiseTerminal(fore + new Vector3(-15, 0, 0), 42, 14, false);
|
||||
DenseTerraces(town + new Vector3(5, 0, 0), 6);
|
||||
Box(Coat.Trim, town + new Vector3(28, 16, 38), 25, 4.0f, 14);
|
||||
break;
|
||||
case 9: // Port Said's straight canal wharf and old lighthouse.
|
||||
Lighthouse(fore + new Vector3(16, 0, -1), 3.35f, 20.5f);
|
||||
House(fore + new Vector3(-17, 0, 3), 23, 10, 6.5f, Coat.Wall);
|
||||
ContainerCrane(fore + new Vector3(-40, 0, 1), 17);
|
||||
break;
|
||||
case 10: // Salalah's cargo port below a bare escarpment.
|
||||
for (int crane = -1; crane <= 1; crane++)
|
||||
ContainerCrane(fore + new Vector3(crane * 30, 0, 0), 19 + crane * 2);
|
||||
Containers(fore + new Vector3(-35, 0, 10));
|
||||
Box(Coat.Trim, town + new Vector3(13, 2.3f, -15), 52, 4.6f, 12);
|
||||
break;
|
||||
case 11: // Mumbai's monumental waterfront arch near the old pier.
|
||||
StoneArch(fore + new Vector3(-9, 0, 4), 10.8f, 13.8f, 7.9f, Coat.WallWarm);
|
||||
for (int side = -1; side <= 1; side += 2)
|
||||
{
|
||||
Vector3 pavilion = fore + new Vector3(-9 + side * 7.1f, 0, 4);
|
||||
Box(Coat.WallWarm, pavilion + Vector3.up * 6.7f, 3.6f, 13.4f, 6.3f);
|
||||
Dome(pavilion + Vector3.up * 13.4f, 1.7f, 1.9f, Coat.Trim);
|
||||
}
|
||||
House(fore + new Vector3(25, 0, 10), 25, 14, 9.4f, Coat.Wall);
|
||||
break;
|
||||
case 12: // Singapore's three bay towers joined by a single elevated deck.
|
||||
for (int tower = -1; tower <= 1; tower++)
|
||||
Tower(town + new Vector3(tower * 14 - 7, 0, 16), 9.5f, 11, 32, Coat.Trim);
|
||||
Box(Coat.Trim, town + new Vector3(-5, 37.3f, 16), 47, 2.5f, 12);
|
||||
Box(Coat.Trim, town + new Vector3(19.7f, 37.2f, 16), 4.1f, 2.3f, 9.5f);
|
||||
CruiseTerminal(fore + new Vector3(12, 0, 0), 34, 10, false);
|
||||
break;
|
||||
case 13: // Benoa's mangrove shoreline and split Balinese gate.
|
||||
Pavilions(fore + new Vector3(-19, 0, 6), 3, 15, 3.0f);
|
||||
for (int side = -1; side <= 1; side += 2)
|
||||
{
|
||||
Vector3 gate = fore + new Vector3(13 + side * 3.2f, 0, 0);
|
||||
for (int tier = 0; tier < 7; tier++)
|
||||
Box(tier % 3 == 0 ? Coat.Brick : Coat.WallWarm, gate + Vector3.up * (tier * 1.1f + .5f), 4.2f - tier * .42f, 1.15f, 4.2f - tier * .37f);
|
||||
}
|
||||
break;
|
||||
case 14: // Sydney's white sail roofs and steel harbour arch.
|
||||
SydneySails(fore + new Vector3(-20, 0, 1));
|
||||
BridgeArch(town + new Vector3(45, 0, 28), 85, 21, false);
|
||||
break;
|
||||
case 15: // Auckland's long Queens Wharf shed and distant tower.
|
||||
House(fore + new Vector3(-14, 0, 3), 38, 11.5f, 7.3f, Coat.Trim);
|
||||
Gable(fore + new Vector3(-14, 7.64f, 3), 39, 12.2f, 3.4f, Coat.Trim);
|
||||
Needle(town + new Vector3(19, 0, 34));
|
||||
break;
|
||||
case 16: // Papeete's open waterfront terraces and steep tropical roofs.
|
||||
Pavilions(fore + new Vector3(-30, 0, 5), 4, 17, 5.1f);
|
||||
FingerPier(fore + new Vector3(11, 0, -5), 14);
|
||||
break;
|
||||
case 17: // Honolulu's Aloha Tower against a volcanic ridge.
|
||||
ClockTower(fore + new Vector3(-12, 0, 2), 6.3f, 25.5f);
|
||||
CruiseTerminal(fore + new Vector3(20, 0, 4), 31, 11, false);
|
||||
break;
|
||||
case 18: // San Diego's long pier pavilion and a sweeping bay crossing.
|
||||
CruiseTerminal(fore + new Vector3(-15, 0, 1), 35, 11, false);
|
||||
BridgeArch(town + new Vector3(43, 0, 31), 112, 14, true);
|
||||
break;
|
||||
case 19: // Puerto Vallarta's sheltered marina below the Sierra Madre.
|
||||
FingerPier(fore + new Vector3(-28, 0, -5), 22);
|
||||
DenseTerraces(town + new Vector3(-44, 0, -16), 9);
|
||||
ClockTower(fore + new Vector3(20, 0, 8), 4.1f, 14.3f);
|
||||
break;
|
||||
case 20: // Balboa's canal port and the Bridge of the Americas.
|
||||
BridgeArch(town + new Vector3(12, 0, 57), 127, 30, false);
|
||||
ContainerCrane(fore + new Vector3(-29, 0, 2), 18);
|
||||
ContainerCrane(fore + new Vector3(28, 0, 19), 21);
|
||||
Containers(fore + new Vector3(12, 0, 14));
|
||||
break;
|
||||
case 21: // Cartagena's low seaside fort and distant high-rise peninsula.
|
||||
Fort(fore + new Vector3(-18, 0, 2), 43, 17, 5.1f);
|
||||
Tower(town + new Vector3(23, 0, 33), 10, 11, 27, Coat.Wall);
|
||||
Tower(town + new Vector3(36, 0, 35), 12, 13, 31, Coat.Trim);
|
||||
Tower(town + new Vector3(49, 0, 42), 9, 10, 21, Coat.WallCool);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void CruiseTerminal(Vector3 foot, float width, float depth, bool landmarkRoof)
|
||||
{
|
||||
Box(Coat.Trim, foot + Vector3.up * .27f, width * 1.025f, .54f, depth + 1.1f);
|
||||
Box(Coat.WallCool, foot + Vector3.up * 3.35f, width, 6.2f, depth);
|
||||
Box(Coat.Glass, foot + new Vector3(0, 3.3f, -depth * .5f - .045f), width * .92f, 4.6f, .11f);
|
||||
for (int mullion = -11; mullion <= 11; mullion++)
|
||||
{
|
||||
float x = mullion * width * .039f;
|
||||
Box(Coat.Trim, foot + new Vector3(x, 3.3f, -depth * .5f - .115f), .11f, 4.6f, .13f);
|
||||
if (mullion % 5 == 0)
|
||||
Box(Coat.GlassLit, foot + new Vector3(x + width * .015f, 2.46f, -depth * .5f - .12f), width * .020f, 1.2f, .02f);
|
||||
}
|
||||
Box(Coat.Steel, foot + new Vector3(0, 3.9f, -depth * .5f - .11f), width * .92f, .10f, .16f);
|
||||
Box(Coat.Trim, foot + new Vector3(0, 5.84f, -1.01f), width + 1.2f, .23f, depth + 2.6f);
|
||||
if (landmarkRoof)
|
||||
{
|
||||
TerminalRoof(foot + new Vector3(-width * .23f, 6.4f, -.38f), width * .57f, depth + 1.9f, 4.2f, .20f);
|
||||
TerminalRoof(foot + new Vector3(width * .23f, 6.4f, -.38f), width * .54f, depth + 1.9f, 5.6f, -.22f);
|
||||
}
|
||||
else
|
||||
Box(Coat.Roof, foot + new Vector3(0, 6.43f, -.44f), width + 1f, .38f, depth + 1.8f);
|
||||
}
|
||||
|
||||
private void TerminalRoof(Vector3 foot, float width, float depth, float rise, float lean)
|
||||
{
|
||||
Vector3 left = foot + new Vector3(-width * .5f, 0, -depth * .5f);
|
||||
Vector3 right = foot + new Vector3(width * .5f, 0, -depth * .5f);
|
||||
Vector3 ridge = foot + new Vector3(width * lean, rise, -depth * .5f);
|
||||
Vector3 rear = new(0, -.55f, depth);
|
||||
MeshFor(Coat.Trim).Quad(left, left + rear, ridge + rear, ridge);
|
||||
MeshFor(Coat.Trim).Quad(right + rear, right, ridge, ridge + rear);
|
||||
MeshFor(Coat.Glass).Quad(right, left, ridge, ridge);
|
||||
MeshFor(Coat.Steel).Rod(left, ridge, .11f, 6);
|
||||
MeshFor(Coat.Steel).Rod(ridge, right, .11f, 6);
|
||||
}
|
||||
|
||||
private void NassauWaterfront(Vector3 foot)
|
||||
{
|
||||
House(foot + new Vector3(-34, 0, 5), 15, 10, 7, Coat.WallWarm);
|
||||
House(foot + new Vector3(-15, 0, 8), 17, 13, 8.7f, Coat.WallCool);
|
||||
House(foot + new Vector3(23, 0, 12), 19, 11, 8, Coat.Trim);
|
||||
House(foot + new Vector3(44, 0, 6), 16, 12, 6.2f, Coat.WallWarm);
|
||||
Vector3 stage = foot + new Vector3(3, 0, 2);
|
||||
MeshFor(Coat.Wood).Disc(stage + Vector3.up * .24f, Vector3.right * 10.2f, Vector3.back * 5.2f, 24);
|
||||
for (int tier = 0; tier < 3; tier++)
|
||||
{
|
||||
float radius = 8.5f + tier * .91f;
|
||||
for (int bay = 0; bay < 12; bay++)
|
||||
{
|
||||
float a = bay * Mathf.PI / 12, b = (bay + 1) * Mathf.PI / 12;
|
||||
Vector3 from = stage + new Vector3(Mathf.Cos(a) * radius, .45f + tier * .40f, Mathf.Sin(a) * radius * .54f);
|
||||
Vector3 to = stage + new Vector3(Mathf.Cos(b) * radius, .45f + tier * .40f, Mathf.Sin(b) * radius * .54f);
|
||||
BoxAlong(Coat.Trim, from, to, .43f, .75f);
|
||||
}
|
||||
}
|
||||
Palm(foot + new Vector3(-25, 0, -2), 6.2f, .1f);
|
||||
Palm(foot + new Vector3(32, 0, 1), 6.4f, 1.1f);
|
||||
}
|
||||
|
||||
private void FingerPier(Vector3 foot, float length)
|
||||
{
|
||||
Box(Coat.Wood, foot + Vector3.up * .11f, 4.9f, .30f, length);
|
||||
for (int post = -2; post <= 2; post++)
|
||||
for (int side = -1; side <= 1; side += 2)
|
||||
Box(Coat.Wood, foot + new Vector3(side * 2.36f, -.74f, post * length * .205f), .22f, 1.55f, .22f);
|
||||
}
|
||||
|
||||
private void Fort(Vector3 foot, float width, float depth, float height)
|
||||
{
|
||||
Box(Coat.Sandy, foot + Vector3.up * (height * .44f), width, height * .89f, depth);
|
||||
Box(Coat.Ground, foot + Vector3.up * (height * .91f), width * .89f, .18f, depth * .89f);
|
||||
Box(Coat.Rock, foot + new Vector3(0, height * .94f, -depth * .487f), width, height * .14f, .59f);
|
||||
for (int side = -1; side <= 1; side += 2)
|
||||
{
|
||||
Vector3 turret = foot + new Vector3(side * width * .46f, 0, -depth * .48f);
|
||||
MeshFor(Coat.Sandy).Rod(turret, turret + Vector3.up * (height + 1.2f), 1.66f, 13, true);
|
||||
Dome(turret + Vector3.up * (height + .80f), 1.81f, .72f, Coat.Rock);
|
||||
Box(Coat.Glass, turret + new Vector3(0, height + .09f, -1.68f), .32f, .61f, .14f);
|
||||
}
|
||||
}
|
||||
|
||||
private void Flag(Vector3 foot, float height)
|
||||
{
|
||||
MeshFor(Coat.Steel).Rod(foot, foot + Vector3.up * height, .055f, 7);
|
||||
MeshFor(Coat.Brick).Quad(foot + Vector3.up * height, foot + new Vector3(2.1f, height - .22f, .19f),
|
||||
foot + new Vector3(2.1f, height - 1.2f, .19f), foot + Vector3.up * (height - .94f));
|
||||
}
|
||||
|
||||
private void ClockTower(Vector3 foot, float width, float height)
|
||||
{
|
||||
Box(Coat.Wall, foot + Vector3.up * (height * .43f), width, height * .86f, width);
|
||||
Box(Coat.Trim, foot + Vector3.up * (height * .77f), width * 1.09f, height * .12f, width * 1.09f);
|
||||
Box(Coat.Steel, foot + new Vector3(0, height * .777f, -width * .548f), width * .38f, width * .38f, .14f);
|
||||
MeshFor(Coat.Trim).Disc(foot + new Vector3(0, height * .777f, -width * .564f), Vector3.left * width * .16f, Vector3.up * width * .16f, 16);
|
||||
MeshFor(Coat.Steel).Rod(foot + new Vector3(0, height * .777f, -width * .575f), foot + new Vector3(.26f, height * .777f + .41f, -width * .575f), .037f, 6);
|
||||
Gable(foot + Vector3.up * (height * .86f), width * 1.12f, width * 1.11f, height * .125f, Coat.Trim);
|
||||
}
|
||||
|
||||
private void StoneArch(Vector3 foot, float opening, float height, float depth, Coat material)
|
||||
{
|
||||
float radius = opening * .5f;
|
||||
float archY = height - radius - 1.3f;
|
||||
float pier = Mathf.Max(1.05f, opening * .20f);
|
||||
for (int side = -1; side <= 1; side += 2)
|
||||
Box(material, foot + new Vector3(side * (radius + pier * .50f), archY * .50f, 0), pier, archY, depth);
|
||||
for (int wedge = 0; wedge < 13; wedge++)
|
||||
{
|
||||
float a = wedge * Mathf.PI / 13, b = (wedge + 1) * Mathf.PI / 13;
|
||||
Vector3 outerA = foot + new Vector3(Mathf.Cos(a) * (radius + pier), archY + Mathf.Sin(a) * (radius + 1.15f), -depth * .5f);
|
||||
Vector3 outerB = foot + new Vector3(Mathf.Cos(b) * (radius + pier), archY + Mathf.Sin(b) * (radius + 1.15f), -depth * .5f);
|
||||
Vector3 innerA = foot + new Vector3(Mathf.Cos(a) * radius, archY + Mathf.Sin(a) * radius, -depth * .5f);
|
||||
Vector3 innerB = foot + new Vector3(Mathf.Cos(b) * radius, archY + Mathf.Sin(b) * radius, -depth * .5f);
|
||||
MeshFor(wedge % 4 == 0 ? Coat.Trim : material).Quad(innerA, innerB, outerB, outerA);
|
||||
MeshFor(material).Quad(innerB, innerA, innerA + Vector3.forward * depth, innerB + Vector3.forward * depth);
|
||||
}
|
||||
Box(Coat.Trim, foot + Vector3.up * (height + .12f), opening + pier * 2.2f, .36f, depth + .18f);
|
||||
}
|
||||
|
||||
private void DenseTerraces(Vector3 basePoint, int houses)
|
||||
{
|
||||
float setback = Mathf.Max(17, basePoint.z - Shore(basePoint.x));
|
||||
for (int home = 0; home < houses; home++)
|
||||
{
|
||||
float x = basePoint.x + home * 10f, inland = setback + home % 3 * 8;
|
||||
Vector3 ground = WaterfrontPoint(x, inland);
|
||||
ground.y = Mathf.Max(basePoint.y, ground.y);
|
||||
House(ground, 7.6f, 9.8f, 5.5f + home % 3 * 1.7f, home % 2 == 0 ? Coat.Wall : Coat.WallWarm);
|
||||
}
|
||||
}
|
||||
|
||||
private void Dome(Vector3 foot, float radius, float height, Coat material)
|
||||
{
|
||||
Vector2[] ring = new Vector2[14];
|
||||
for (int side = 0; side < ring.Length; side++)
|
||||
{
|
||||
float angle = 2 * Mathf.PI * side / ring.Length;
|
||||
ring[side] = new Vector2(foot.x + Mathf.Cos(angle) * radius, foot.z + Mathf.Sin(angle) * radius);
|
||||
}
|
||||
MeshFor(material).Loft(ring, new Vector2(foot.x, foot.z), true, new Vector3(1, foot.y, 1),
|
||||
new Vector3(.93f, foot.y + height * .43f, .93f), new Vector3(.63f, foot.y + height * .76f, .63f),
|
||||
new Vector3(.23f, foot.y + height * .96f, .23f), new Vector3(.042f, foot.y + height, .042f));
|
||||
}
|
||||
|
||||
private void Lighthouse(Vector3 foot, float radius, float height)
|
||||
{
|
||||
foreach (var (low, high, coat) in new[] { (0f, .31f, Coat.Trim), (.31f, .47f, Coat.Steel),
|
||||
(.47f, .66f, Coat.Trim), (.66f, .84f, Coat.Steel), (.84f, .91f, Coat.Trim), (.91f, .98f, Coat.GlassLit) })
|
||||
MeshFor(coat).Rod(foot + Vector3.up * (low * height), foot + Vector3.up * (high * height),
|
||||
radius * (1 - low * .26f), 8, true);
|
||||
Dome(foot + Vector3.up * (.98f * height), radius * .84f, height * .102f, Coat.Steel);
|
||||
}
|
||||
|
||||
private void ContainerCrane(Vector3 foot, float height)
|
||||
{
|
||||
float width = height * .44f;
|
||||
for (int side = -1; side <= 1; side += 2)
|
||||
{
|
||||
Vector3 stanchion = foot + Vector3.right * (width * .5f * side);
|
||||
MeshFor(Coat.Accent).Rod(stanchion, stanchion + Vector3.up * height, .21f, 7);
|
||||
}
|
||||
Vector3 peak = foot + Vector3.up * (height * .92f);
|
||||
Box(Coat.Accent, peak, width + .59f, .42f, .55f);
|
||||
MeshFor(Coat.Accent).Rod(peak, peak + new Vector3(width * .46f, height * .12f, -height * .64f), .18f, 7);
|
||||
MeshFor(Coat.Steel).Rod(peak + new Vector3(width * .46f, height * .12f, -height * .64f),
|
||||
peak + new Vector3(width * .46f, -height * .39f, -height * .64f), .037f, 6);
|
||||
}
|
||||
|
||||
private void Containers(Vector3 foot)
|
||||
{
|
||||
for (int container = 0; container < 9; container++)
|
||||
{
|
||||
Coat paint = container % 3 == 0 ? Coat.Brick : container % 3 == 1 ? Coat.WallCool : Coat.Steel;
|
||||
Vector3 stack = foot + new Vector3(container % 5 * 5.28f, container / 5 * 2.02f + 1, 0);
|
||||
Box(paint, stack, 5.16f, 1.96f, 2.18f);
|
||||
}
|
||||
}
|
||||
|
||||
private void Pavilions(Vector3 foot, int count, float spacing, float peak)
|
||||
{
|
||||
for (int pavilion = 0; pavilion < count; pavilion++)
|
||||
{
|
||||
Vector3 at = foot + Vector3.right * (spacing * pavilion);
|
||||
for (int side = -1; side <= 1; side += 2)
|
||||
for (int end = -1; end <= 1; end += 2)
|
||||
{
|
||||
Vector3 pillar = at + new Vector3(side * 3.6f, 0, end * 2.55f);
|
||||
MeshFor(Coat.Wood).Rod(pillar, pillar + Vector3.up * 2.8f, .12f, 7);
|
||||
}
|
||||
Gable(at + Vector3.up * 2.8f, 8.8f, 7, peak, Coat.Wood);
|
||||
if (port == 13)
|
||||
Gable(at + Vector3.up * 4.16f, 6.7f, 5.35f, peak * .90f, Coat.Wood);
|
||||
}
|
||||
}
|
||||
|
||||
private void SydneySails(Vector3 foot)
|
||||
{
|
||||
Box(Coat.Sandy, foot + Vector3.up * .64f, 30, 1.28f, 10);
|
||||
for (int sail = 0; sail < 5; sail++)
|
||||
{
|
||||
Vector3 basePoint = foot + new Vector3(sail * 5.2f - 11.2f, 1.24f, sail % 2 * 1.4f);
|
||||
float rise = 6.3f + 1.65f * (sail % 3);
|
||||
Vector3 left = basePoint + new Vector3(-3.8f, 0, -2.5f), rear = basePoint + new Vector3(-3.8f, 0, 3.1f);
|
||||
for (int segment = 1; segment <= 9; segment++)
|
||||
{
|
||||
float step = segment / 9f;
|
||||
float y = rise * Mathf.Sin(step * 1.57f);
|
||||
float x = Mathf.Lerp(-3.8f, 3.4f, step);
|
||||
Vector3 newLeft = basePoint + new Vector3(x, y, Mathf.Lerp(-2.5f, -.32f, step * step));
|
||||
Vector3 newRear = basePoint + new Vector3(x, y, Mathf.Lerp(3.1f, .24f, step * step));
|
||||
MeshFor(Coat.Trim).Quad(left, rear, newRear, newLeft);
|
||||
MeshFor(Coat.Trim).Quad(left, newLeft, newLeft - Vector3.up * y, left - Vector3.up * ((segment - 1) / 9f * rise));
|
||||
left = newLeft;
|
||||
rear = newRear;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void BridgeArch(Vector3 foot, float span, float rise, bool lowBridge)
|
||||
{
|
||||
float road = lowBridge ? 8f : rise * .32f;
|
||||
Box(Coat.Steel, foot + Vector3.up * road, span + 12, .43f, 3.2f);
|
||||
for (int side = -1; side <= 1; side += 2)
|
||||
{
|
||||
Vector3 prior = foot + new Vector3(-span * .5f, 0, side * 1.45f);
|
||||
for (int section = 1; section <= 16; section++)
|
||||
{
|
||||
float t = section / 16f;
|
||||
float y = 4f * rise * t * (1 - t);
|
||||
var next = foot + new Vector3((t - .5f) * span, y, side * 1.45f);
|
||||
MeshFor(Coat.Steel).Rod(prior, next, .29f, 7);
|
||||
if (section % 2 == 0)
|
||||
MeshFor(Coat.Steel).Rod(next, new Vector3(next.x, foot.y + road, next.z), .088f, 6);
|
||||
prior = next;
|
||||
}
|
||||
Box(Coat.Rock, foot + new Vector3(side * span * .47f, road * .5f, 0), 3.6f, road + .25f, 5.9f);
|
||||
}
|
||||
}
|
||||
|
||||
private void Needle(Vector3 foot)
|
||||
{
|
||||
MeshFor(Coat.Trim).Rod(foot, foot + Vector3.up * 35f, 1.12f, 10, true);
|
||||
MeshFor(Coat.Glass).Rod(foot + Vector3.up * 31f, foot + Vector3.up * 35.3f, 2.68f, 12, true);
|
||||
Dome(foot + Vector3.up * 35.3f, 2.71f, 1.7f, Coat.Trim);
|
||||
MeshFor(Coat.Steel).Rod(foot + Vector3.up * 36.6f, foot + Vector3.up * 44f, .24f, 8, true);
|
||||
}
|
||||
|
||||
private void BoxAlong(Coat coat, Vector3 start, Vector3 end, float height, float width)
|
||||
{
|
||||
Vector3 span = end - start;
|
||||
MeshFor(coat).Box((start + end) * .5f, new Vector3(span.magnitude + .05f, height, width), span.normalized);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Soundings/Runtime/HarborPortLandmarks.cs.meta
Normal file
2
Assets/Soundings/Runtime/HarborPortLandmarks.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3a0afdd4de54e338592a3540096453d
|
||||
38
Assets/Soundings/Runtime/HarborPortProfiles.cs
Normal file
38
Assets/Soundings/Runtime/HarborPortProfiles.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
namespace Soundings
|
||||
{
|
||||
public sealed partial class Harbor
|
||||
{
|
||||
// Styles follow Market.Ports so recorded itineraries keep the same waterfronts.
|
||||
private static readonly PortProfile[] PortProfiles =
|
||||
{
|
||||
// Miami, Nassau, Key West, Cozumel
|
||||
new(PortTerrain.Flat, PortArchitecture.Modern, height: 5, density: .88f, trees: .28f, ground: "879783", facade: "B9C6CA", roof: "526D83", sky: "E2A87E"),
|
||||
new(PortTerrain.LowHills, PortArchitecture.Caribbean, height: 15, density: .64f, trees: .62f, ground: "A0AD7B", facade: "E4BA9B", roof: "A65C63", sky: "F4D8B0"),
|
||||
new(PortTerrain.Flat, PortArchitecture.Maritime, height: 4, density: .44f, trees: .74f, ground: "889569", facade: "E3D8BF", roof: "775A49", sky: "EDAD83"),
|
||||
new(PortTerrain.Flat, PortArchitecture.Caribbean, height: 6, density: .43f, trees: .64f, ground: "80965C", facade: "EDCEB2", roof: "AD7968", sky: "FADEB9"),
|
||||
// San Juan, Bermuda, Ponta Delgada, Lisbon
|
||||
new(PortTerrain.Cliffs, PortArchitecture.Colonial, height: 43, density: .73f, trees: .43f, ground: "859267", facade: "DCBB97", roof: "9D6049", sky: "F0BC9B"),
|
||||
new(PortTerrain.LowHills, PortArchitecture.Maritime, height: 19, density: .39f, trees: .46f, ground: "8B966A", facade: "DBCBC6", roof: "E4E5D9", sky: "E4C9AF"),
|
||||
new(PortTerrain.Volcanic, PortArchitecture.Mediterranean, height: 57, density: .55f, trees: .42f, ground: "66856E", facade: "E0DBCE", roof: "965745", sky: "C5C8BA"),
|
||||
new(PortTerrain.LowHills, PortArchitecture.Mediterranean, height: 36, density: .83f, trees: .27f, ground: "9B9B72", facade: "E1C3A1", roof: "A75F46", sky: "E7AA83"),
|
||||
// Barcelona, Port Said, Salalah, Mumbai
|
||||
new(PortTerrain.LowHills, PortArchitecture.Mediterranean, height: 38, density: .82f, trees: .31f, ground: "8D9280", facade: "D9B69B", roof: "84675D", sky: "F0BA97"),
|
||||
new(PortTerrain.Flat, PortArchitecture.Industrial, height: 6, density: .69f, trees: .12f, ground: "B4A681", facade: "CBBD9B", roof: "897C69", sky: "E7C19E"),
|
||||
new(PortTerrain.Desert, PortArchitecture.Arabian, height: 67, density: .27f, trees: .17f, ground: "B79E79", facade: "E1CFB1", roof: "A68D76", sky: "EDD1A4"),
|
||||
new(PortTerrain.LowHills, PortArchitecture.SouthAsian, height: 25, density: .94f, trees: .24f, ground: "868563", facade: "C9B39E", roof: "957A60", sky: "C9B6A0"),
|
||||
// Singapore, Benoa, Sydney, Auckland
|
||||
new(PortTerrain.LowHills, PortArchitecture.Modern, height: 13, density: .96f, trees: .58f, ground: "76916F", facade: "A5C4CB", roof: "47737E", sky: "E6C0B4"),
|
||||
new(PortTerrain.LowHills, PortArchitecture.Tropical, height: 24, density: .31f, trees: .81f, ground: "698961", facade: "C2A382", roof: "625349", sky: "E2B394"),
|
||||
new(PortTerrain.LowHills, PortArchitecture.Modern, height: 21, density: .74f, trees: .46f, ground: "81977C", facade: "C4CDD1", roof: "6E8191", sky: "E6C0AE"),
|
||||
new(PortTerrain.Volcanic, PortArchitecture.Modern, height: 41, density: .68f, trees: .48f, ground: "74917A", facade: "B0BFC0", roof: "647984", sky: "BCC8C7"),
|
||||
// Papeete, Honolulu, San Diego, Puerto Vallarta
|
||||
new(PortTerrain.Mountains, PortArchitecture.Pacific, height: 86, density: .34f, trees: .86f, ground: "568264", facade: "DEC6A7", roof: "837565", sky: "EFC4AC"),
|
||||
new(PortTerrain.Volcanic, PortArchitecture.Modern, height: 71, density: .76f, trees: .53f, ground: "788F62", facade: "DFDBCA", roof: "8C9AA0", sky: "F5D3A4"),
|
||||
new(PortTerrain.LowHills, PortArchitecture.Modern, height: 29, density: .73f, trees: .26f, ground: "A09972", facade: "C5CED0", roof: "618292", sky: "ECA983"),
|
||||
new(PortTerrain.Mountains, PortArchitecture.Colonial, height: 75, density: .56f, trees: .66f, ground: "6B8865", facade: "E2BC9A", roof: "A76751", sky: "EEC5A1"),
|
||||
// Balboa, Cartagena
|
||||
new(PortTerrain.Mountains, PortArchitecture.Industrial, height: 49, density: .43f, trees: .77f, ground: "668A69", facade: "C4BDA7", roof: "87918B", sky: "BEC2AC"),
|
||||
new(PortTerrain.LowHills, PortArchitecture.Colonial, height: 24, density: .78f, trees: .43f, ground: "8D9369", facade: "EBC496", roof: "AB6A4F", sky: "F6C49F")
|
||||
};
|
||||
}
|
||||
}
|
||||
2
Assets/Soundings/Runtime/HarborPortProfiles.cs.meta
Normal file
2
Assets/Soundings/Runtime/HarborPortProfiles.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5228769113533f9be9840a4363a671e6
|
||||
418
Assets/Soundings/Runtime/HarborPortScenery.cs
Normal file
418
Assets/Soundings/Runtime/HarborPortScenery.cs
Normal file
@@ -0,0 +1,418 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Soundings
|
||||
{
|
||||
public sealed partial class Harbor
|
||||
{
|
||||
private enum PortTerrain { Flat, LowHills, Cliffs, Mountains, Volcanic, Desert }
|
||||
private enum PortArchitecture { Modern, Caribbean, Maritime, Colonial, Mediterranean, Industrial, Arabian, SouthAsian, Tropical, Pacific }
|
||||
|
||||
private readonly struct PortProfile
|
||||
{
|
||||
public readonly PortTerrain Terrain;
|
||||
public readonly PortArchitecture Architecture;
|
||||
public readonly float Height, Density, Trees;
|
||||
public readonly Color Ground, Facade, Roof, Sky;
|
||||
|
||||
public PortProfile(PortTerrain terrain, PortArchitecture architecture, float height, float density, float trees,
|
||||
string ground, string facade, string roof, string sky)
|
||||
{
|
||||
Terrain = terrain;
|
||||
Architecture = architecture;
|
||||
Height = height;
|
||||
Density = density;
|
||||
Trees = trees;
|
||||
Ground = PortColor(ground);
|
||||
Facade = PortColor(facade);
|
||||
Roof = PortColor(roof);
|
||||
Sky = PortColor(sky);
|
||||
}
|
||||
}
|
||||
|
||||
private static readonly string[] PortMatteNames = { "Miami", "Nassau", "KeyWest" };
|
||||
private readonly Texture2D[] portMattes = new Texture2D[PortMatteNames.Length];
|
||||
private readonly bool[] portMattesLoaded = new bool[PortMatteNames.Length];
|
||||
private PortScenery portScenery;
|
||||
private int sceneryPort = -1;
|
||||
private float portMatteAspect;
|
||||
|
||||
private static Color PortColor(string hex) => ColorUtility.TryParseHtmlString("#" + hex, out Color color) ? color : Color.grey;
|
||||
|
||||
private void ShowPortScenery(int port)
|
||||
{
|
||||
PortProfile profile = PortProfiles[port];
|
||||
Texture2D matte = PortMatte(port);
|
||||
portMatteAspect = matte == null ? 0f : (float)matte.width / matte.height;
|
||||
water.SetFloat("_PortMatteActive", matte == null ? 0f : 1f);
|
||||
if (matte != null)
|
||||
{
|
||||
portScenery?.SetVisible(false);
|
||||
water.SetTexture("_PortMatte", matte);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (sceneryPort != port)
|
||||
{
|
||||
portScenery?.Release();
|
||||
portScenery = new PortScenery(transform, port, profile);
|
||||
sceneryPort = port;
|
||||
}
|
||||
portScenery.SetVisible(true);
|
||||
}
|
||||
water.SetColor("_PortSky", profile.Sky);
|
||||
water.SetFloat("_PortShallows", port switch
|
||||
{
|
||||
1 or 3 => .89f,
|
||||
13 or 16 => .73f,
|
||||
2 or 4 or 5 or 17 or 19 or 21 => .56f,
|
||||
7 or 12 or 14 or 18 => .31f,
|
||||
_ => .19f
|
||||
});
|
||||
quayFinishes[0].color = Color.Lerp(new Color(.41f, .44f, .45f), profile.Facade, .35f);
|
||||
quayFinishes[1].color = Color.Lerp(new Color(.53f, .52f, .47f), profile.Facade, .5f);
|
||||
}
|
||||
|
||||
private Texture2D PortMatte(int port)
|
||||
{
|
||||
if (port >= PortMatteNames.Length)
|
||||
return null;
|
||||
if (!portMattesLoaded[port])
|
||||
{
|
||||
portMattesLoaded[port] = true;
|
||||
portMattes[port] = Resources.Load<Texture2D>("Art/Ports/" + PortMatteNames[port]);
|
||||
}
|
||||
return portMattes[port];
|
||||
}
|
||||
|
||||
private void FitPortMatte(float aspect)
|
||||
{
|
||||
float cropX = Mathf.Min(1, aspect / portMatteAspect) * .91f;
|
||||
float cropY = Mathf.Min(1, portMatteAspect / aspect) * .91f;
|
||||
float pan = Mathf.Lerp(-.041f, .057f, portFrame) * (portArrival ? -1 : 1);
|
||||
float shiftX = Mathf.Clamp(pan, -.46f * (1 - cropX), .46f * (1 - cropX));
|
||||
float shiftY = Mathf.Lerp(-.088f, -.108f, portArrival ? 1f - portFrame : portFrame);
|
||||
shiftY = Mathf.Clamp(shiftY, -.49f * (1 - cropY), .49f * (1 - cropY));
|
||||
water.SetVector("_PortMatteCrop", new Vector4(cropX, cropY, shiftX, shiftY));
|
||||
}
|
||||
|
||||
internal static bool AllPortsHaveScenery => PortProfiles.Length == Market.Ports.Count;
|
||||
|
||||
private sealed partial class PortScenery
|
||||
{
|
||||
private enum Coat { Ground, Rock, Sandy, Street, Wall, WallWarm, WallCool, Trim, Roof, Glass, GlassLit, Steel, Foliage, FoliageLight, Wood, Accent, Brick }
|
||||
|
||||
private const float ShoreCenter = 46f;
|
||||
private readonly PortProfile profile;
|
||||
private readonly int port;
|
||||
private readonly GameObject root;
|
||||
private readonly Dictionary<Coat, HarborMesh> batches = new();
|
||||
private readonly List<Mesh> meshes = new();
|
||||
private readonly List<Material> materials = new();
|
||||
|
||||
public PortScenery(Transform parent, int port, PortProfile profile)
|
||||
{
|
||||
this.port = port;
|
||||
this.profile = profile;
|
||||
root = new GameObject(Market.Ports[port].Name + " waterfront");
|
||||
root.transform.SetParent(parent, false);
|
||||
BuildCoast();
|
||||
BuildDistrict();
|
||||
BuildLandmarks();
|
||||
|
||||
Shader surface = Resources.Load<Shader>("PortScenerySurface");
|
||||
foreach (var (coat, geometry) in batches)
|
||||
{
|
||||
Mesh mesh = geometry.Bake();
|
||||
var material = new Material(surface) { name = "Waterfront " + coat, color = ColorFor(coat) };
|
||||
material.SetFloat("_Detail", coat switch
|
||||
{
|
||||
Coat.Ground or Coat.Rock or Coat.Sandy => 1,
|
||||
Coat.Roof or Coat.Brick => 2,
|
||||
Coat.Glass or Coat.GlassLit => 3,
|
||||
Coat.Foliage or Coat.FoliageLight => 4,
|
||||
_ => 0
|
||||
});
|
||||
material.SetFloat("_Glow", coat == Coat.GlassLit ? .28f : 0f);
|
||||
material.SetColor("_HazeColor", Color.Lerp(new Color(.47f, .60f, .70f), profile.Sky, .30f));
|
||||
var draw = new GameObject(coat.ToString(), typeof(MeshFilter), typeof(MeshRenderer)) { layer = 8 };
|
||||
draw.transform.SetParent(root.transform, false);
|
||||
draw.GetComponent<MeshFilter>().sharedMesh = mesh;
|
||||
draw.GetComponent<MeshRenderer>().sharedMaterial = material;
|
||||
meshes.Add(mesh);
|
||||
materials.Add(material);
|
||||
}
|
||||
batches.Clear();
|
||||
}
|
||||
|
||||
public void SetVisible(bool visible) => root.SetActive(visible);
|
||||
|
||||
public void Release()
|
||||
{
|
||||
root.SetActive(false);
|
||||
Object.Destroy(root);
|
||||
foreach (Mesh mesh in meshes)
|
||||
Object.Destroy(mesh);
|
||||
foreach (Material material in materials)
|
||||
Object.Destroy(material);
|
||||
}
|
||||
|
||||
private HarborMesh MeshFor(Coat coat)
|
||||
{
|
||||
if (!batches.TryGetValue(coat, out HarborMesh mesh))
|
||||
batches.Add(coat, mesh = new HarborMesh());
|
||||
return mesh;
|
||||
}
|
||||
|
||||
private Color ColorFor(Coat coat) => coat switch
|
||||
{
|
||||
Coat.Ground => profile.Ground,
|
||||
Coat.Rock => Color.Lerp(profile.Ground, PortColor("5D6770"), .45f),
|
||||
Coat.Sandy => Color.Lerp(profile.Ground, PortColor("DFCAA4"), .69f),
|
||||
Coat.Street => Color.Lerp(profile.Facade, PortColor("565C60"), .58f),
|
||||
Coat.Wall => profile.Facade,
|
||||
Coat.WallWarm => Color.Lerp(profile.Facade, PortColor("E19B72"), .58f),
|
||||
Coat.WallCool => Color.Lerp(profile.Facade, PortColor("99BBC1"), .57f),
|
||||
Coat.Trim => Color.Lerp(profile.Facade, new Color(.9f, .89f, .82f), .67f),
|
||||
Coat.Roof => profile.Roof,
|
||||
Coat.Glass => new Color(.16f, .28f, .35f),
|
||||
Coat.GlassLit => new Color(.76f, .52f, .31f),
|
||||
Coat.Steel => new Color(.27f, .33f, .35f),
|
||||
Coat.Foliage => Color.Lerp(profile.Ground, PortColor("324F37"), .57f),
|
||||
Coat.FoliageLight => Color.Lerp(profile.Ground, PortColor("7C9148"), .57f),
|
||||
Coat.Wood => new Color(.41f, .30f, .21f),
|
||||
Coat.Accent => new Color(.75f, .57f, .26f),
|
||||
_ => new Color(.49f, .24f, .17f)
|
||||
};
|
||||
|
||||
private float Shore(float x)
|
||||
{
|
||||
float bank = Mathf.Sin(x * .015f + port * .76f) * 5.3f + Mathf.Sin(x * .032f - port) * 2.6f;
|
||||
float headland = profile.Terrain switch
|
||||
{
|
||||
PortTerrain.Cliffs => -13f * Mathf.SmoothStep(0, 1, Mathf.InverseLerp(33, 165, Mathf.Abs(x))),
|
||||
PortTerrain.Volcanic => -9f * Mathf.Sin(x * .011f),
|
||||
PortTerrain.Desert => 6f * Mathf.Cos(x * .010f),
|
||||
_ => 0
|
||||
};
|
||||
return ShoreCenter + bank + headland;
|
||||
}
|
||||
|
||||
private float GroundHeight(float x, float inland)
|
||||
{
|
||||
float town = Mathf.SmoothStep(-.18f, 2.55f, Mathf.InverseLerp(-5f, 19f, inland));
|
||||
float depth = Mathf.SmoothStep(0, 1, Mathf.InverseLerp(23, 178, inland));
|
||||
float wave = Mathf.PerlinNoise(x * .010f + port * 3.3f, inland * .013f + 17.6f);
|
||||
float ridge = 1 - Mathf.Clamp01(Mathf.Abs(wave - .58f) * 2.3f);
|
||||
float silhouette = profile.Terrain switch
|
||||
{
|
||||
PortTerrain.Flat => depth * (.07f + .15f * wave),
|
||||
PortTerrain.LowHills => depth * (.18f + .62f * wave),
|
||||
PortTerrain.Cliffs => depth * (.33f + .65f * ridge) + .18f * Mathf.SmoothStep(0, 1, Mathf.InverseLerp(65, 190, Mathf.Abs(x))) * Mathf.SmoothStep(0, 1, inland / 34f),
|
||||
PortTerrain.Mountains => depth * (.19f + .93f * ridge * ridge),
|
||||
PortTerrain.Volcanic => depth * (.09f + .26f * wave) + PortCone(x, inland),
|
||||
_ => depth * (.17f + .56f * wave)
|
||||
};
|
||||
return town + profile.Height * silhouette;
|
||||
}
|
||||
|
||||
private float PortCone(float x, float inland)
|
||||
{
|
||||
float peakX = port is 16 or 17 ? 84 : -68;
|
||||
Vector2 a = new((x - peakX) / 98, (inland - 143) / 123);
|
||||
Vector2 b = new((x + peakX * .68f) / 111, (inland - 206) / 142);
|
||||
return Mathf.Max(0, 1f - a.magnitude) * .98f + Mathf.Max(0, 1f - b.magnitude) * .63f;
|
||||
}
|
||||
|
||||
private Vector3 WaterfrontPoint(float x, float inland) => new(x, GroundHeight(x, inland), Shore(x) + inland);
|
||||
|
||||
private void BuildCoast()
|
||||
{
|
||||
float[] rows = { -6, 0, 3, 8, 16, 30, 46, 63, 82, 104, 126, 148, 175, 208, 240, 286, 346, 440, 600 };
|
||||
for (int across = -33; across < 33; across++)
|
||||
{
|
||||
for (int row = 0; row < rows.Length - 1; row++)
|
||||
{
|
||||
float a = across * 13.4f, b = (across + 1) * 13.4f;
|
||||
Coat tone = row < 2 ? Coat.Sandy : row < 4 && profile.Terrain == PortTerrain.Cliffs ? Coat.Rock : Coat.Ground;
|
||||
MeshFor(tone).Quad(WaterfrontPoint(a, rows[row]), WaterfrontPoint(a, rows[row + 1]),
|
||||
WaterfrontPoint(b, rows[row + 1]), WaterfrontPoint(b, rows[row]));
|
||||
}
|
||||
}
|
||||
|
||||
// Developed waterfronts carry a hard quay edge under the first street and a narrower promenade behind it.
|
||||
float frontage = Mathf.Lerp(103, 231, profile.Density);
|
||||
Vector3 quay = new(0, .59f, ShoreCenter + 6.8f);
|
||||
MeshFor(Coat.Rock).Box(quay, new Vector3(frontage * 2, 1.36f, 20.8f));
|
||||
MeshFor(Coat.Street).Box(quay + new Vector3(0, .77f, 0), new Vector3(frontage * 2 + .28f, .23f, 21f));
|
||||
for (int post = -12; post <= 12; post++)
|
||||
{
|
||||
float x = post * frontage / 12;
|
||||
MeshFor(Coat.Wood).Box(new Vector3(x, .50f, quay.z - 10.52f), new Vector3(.38f, 1.23f, .31f));
|
||||
}
|
||||
|
||||
for (int block = -23; block < 23; block++)
|
||||
{
|
||||
float x0 = block * 11f, x1 = (block + 1) * 11f;
|
||||
Vector3 a = WaterfrontPoint(x0, 7.5f), b = WaterfrontPoint(x1, 7.5f);
|
||||
Vector3 c = WaterfrontPoint(x0, 14.6f), d = WaterfrontPoint(x1, 14.6f);
|
||||
float level = Mathf.Max(Mathf.Max(a.y, b.y), Mathf.Max(c.y, d.y)) + .05f;
|
||||
a.y = b.y = c.y = d.y = level;
|
||||
MeshFor(Coat.Street).Quad(a, c, d, b);
|
||||
Vector3 stripe = Vector3.Lerp(Vector3.Lerp(a, c, .46f), Vector3.Lerp(b, d, .46f), .42f);
|
||||
Box(Coat.Trim, stripe + Vector3.up * .013f, 3.2f, .026f, .115f);
|
||||
}
|
||||
}
|
||||
|
||||
private void BuildDistrict()
|
||||
{
|
||||
int frontage = Mathf.RoundToInt(Mathf.Lerp(10, 17, profile.Density));
|
||||
for (int row = 0; row < 3; row++)
|
||||
{
|
||||
for (int i = -frontage; i <= frontage; i++)
|
||||
{
|
||||
if (Mathf.Abs(i) <= (row == 0 ? 3 : 1))
|
||||
continue;
|
||||
float seed = SignedNoise(i, row);
|
||||
if (seed < .30f - profile.Density * .23f)
|
||||
continue;
|
||||
float x = i * 18.4f + (seed - .5f) * 6f - row * 4f;
|
||||
float inland = 15f + row * 26f;
|
||||
Vector3 location = WaterfrontPoint(x, inland);
|
||||
float storeys = Mathf.Lerp(1, 3.5f, seed) + row * .26f;
|
||||
bool towers = profile.Architecture is PortArchitecture.Modern or PortArchitecture.Pacific or PortArchitecture.SouthAsian;
|
||||
float height = 2.75f * storeys;
|
||||
if (towers && row > 0 && seed > .48f)
|
||||
height += (seed - .35f) * (profile.Architecture == PortArchitecture.Modern ? 65 : 39) * row;
|
||||
Coat walls = i % 3 == 0 ? Coat.WallWarm : i % 3 == 1 ? Coat.WallCool : Coat.Wall;
|
||||
float width = 8 + seed * 7;
|
||||
if (height > 19)
|
||||
{
|
||||
Vector3 skyline = WaterfrontPoint(x * 1.20f + row * 4f, inland + 61 + row * 5);
|
||||
Tower(skyline, width * 1.10f, 9 + seed * 8, height * .87f, walls);
|
||||
}
|
||||
else
|
||||
House(location, width, 7.5f + seed * 3f, height, walls);
|
||||
}
|
||||
}
|
||||
|
||||
int palms = Mathf.RoundToInt(profile.Trees * 41);
|
||||
for (int tree = 0; tree < palms; tree++)
|
||||
{
|
||||
float x = (tree - palms * .5f) * 13.7f + SignedNoise(tree, 1) * 5.2f;
|
||||
bool behind = Mathf.Abs(x) < 54 || tree % 3 == 0;
|
||||
Vector3 place = WaterfrontPoint(x, behind ? 46 + SignedNoise(tree, 4) * 21 : 8);
|
||||
place.y = Mathf.Max(place.y, 1.56f);
|
||||
if (profile.Architecture is PortArchitecture.Mediterranean or PortArchitecture.Maritime or PortArchitecture.Industrial)
|
||||
StreetTree(place, 3.4f + SignedNoise(tree, 2) * 2f);
|
||||
else
|
||||
Palm(place, 3.6f + SignedNoise(tree, 2) * 3.1f, tree * .73f);
|
||||
}
|
||||
}
|
||||
|
||||
private float SignedNoise(int x, int row) => Mathf.PerlinNoise(x * .629f + 21f + port * 4.7f, row * 3.88f + 6.6f);
|
||||
|
||||
private void Box(Coat coat, Vector3 center, float width, float height, float depth) =>
|
||||
MeshFor(coat).Box(center, new Vector3(width, height, depth));
|
||||
|
||||
private void House(Vector3 foot, float width, float depth, float height, Coat walls)
|
||||
{
|
||||
Box(Coat.Rock, foot + Vector3.up * .18f, width + .40f, .48f, depth + .35f);
|
||||
Box(walls, foot + Vector3.up * (height * .5f + .32f), width, height, depth);
|
||||
Box(Coat.Trim, foot + Vector3.up * (height + .29f), width + .3f, .22f, depth + .3f);
|
||||
if (profile.Architecture is PortArchitecture.Arabian or PortArchitecture.Modern or PortArchitecture.Industrial or PortArchitecture.SouthAsian)
|
||||
{
|
||||
Box(Coat.Roof, foot + Vector3.up * (height + .49f), width + .33f, .23f, depth + .33f);
|
||||
Box(Coat.Trim, foot + new Vector3(0, height + .78f, depth * .42f), width + .11f, .47f, .25f);
|
||||
}
|
||||
else
|
||||
Gable(foot + Vector3.up * (height + .37f), width + .46f, depth + .47f, Mathf.Min(2.33f, width * .18f), walls);
|
||||
Facade(foot, width, depth, height, false);
|
||||
}
|
||||
|
||||
private void Tower(Vector3 foot, float width, float depth, float height, Coat walls)
|
||||
{
|
||||
Box(Coat.Trim, foot + Vector3.up * 1.28f, width + 1.15f, 2.56f, depth + 1.1f);
|
||||
Box(walls, foot + Vector3.up * (height * .5f + 2f), width, height, depth);
|
||||
Box(Coat.Glass, foot + new Vector3(0, height * .5f + 2.2f, -depth * .5f - .015f), width * .9f, height * .95f, .035f);
|
||||
Box(Coat.Glass, foot + new Vector3(-width * .5f, height * .5f + 2.2f, 0), .036f, height * .95f, depth * .90f);
|
||||
Box(Coat.Glass, foot + new Vector3(width * .5f, height * .5f + 2.2f, 0), .036f, height * .95f, depth * .90f);
|
||||
Box(Coat.Trim, foot + Vector3.up * (height + 2f), width + .26f, .42f, depth + .2f);
|
||||
Box(walls, foot + Vector3.up * (height + 2.95f), width * .62f, 1.85f, depth * .66f);
|
||||
for (int bay = -2; bay <= 2; bay++)
|
||||
Box(Coat.Steel, foot + new Vector3(bay * width * .17f, height * .5f + 2.17f, -depth * .5f - .045f), .095f, height * .94f, .08f);
|
||||
Facade(foot + Vector3.up * 2.2f, width, depth, height, true);
|
||||
}
|
||||
|
||||
private void Facade(Vector3 foot, float width, float depth, float height, bool tower)
|
||||
{
|
||||
int bays = Mathf.Clamp(Mathf.RoundToInt(width / 2.55f), 2, 8);
|
||||
int floors = Mathf.Max(1, Mathf.FloorToInt(height / (tower ? 3.2f : 2.65f)));
|
||||
float gap = width * .85f / bays;
|
||||
float step = height / floors;
|
||||
for (int level = 0; level < floors; level++)
|
||||
{
|
||||
float y = (level + .57f) * step + .14f;
|
||||
if (tower)
|
||||
{
|
||||
Box(Coat.Steel, foot + new Vector3(0, y + .91f, -depth * .5f - .05f), width * .93f, .075f, .09f);
|
||||
if (level % 4 != 2)
|
||||
continue;
|
||||
Box(Coat.GlassLit, foot + new Vector3((level % 5 - 2) * width * .155f, y, -depth * .5f - .044f), width * .14f, step * .58f, .03f);
|
||||
continue;
|
||||
}
|
||||
for (int bay = 0; bay < bays; bay++)
|
||||
{
|
||||
float x = (bay + .5f - bays * .5f) * gap;
|
||||
Coat windows = (bay + level * 3 + Mathf.RoundToInt(foot.x)) % 7 == 0 ? Coat.GlassLit : Coat.Glass;
|
||||
Box(Coat.Trim, foot + new Vector3(x, y, -depth * .5f - .03f), gap * .62f, step * .64f, .13f);
|
||||
Box(windows, foot + new Vector3(x, y + .03f, -depth * .5f - .102f), gap * .50f, step * .54f, .03f);
|
||||
}
|
||||
for (int side = -1; side <= 1; side += 2)
|
||||
Box(Coat.Glass, foot + new Vector3(side * (width * .5f + .02f), y, -.8f), .054f, step * .54f, depth * .29f);
|
||||
}
|
||||
}
|
||||
|
||||
private void Gable(Vector3 ridgeBase, float width, float depth, float rise, Coat endWall)
|
||||
{
|
||||
Vector3 a = ridgeBase + new Vector3(-width * .5f, 0, -depth * .5f);
|
||||
Vector3 b = ridgeBase + new Vector3(width * .5f, 0, -depth * .5f);
|
||||
Vector3 c = ridgeBase + new Vector3(width * .5f, 0, depth * .5f);
|
||||
Vector3 d = ridgeBase + new Vector3(-width * .5f, 0, depth * .5f);
|
||||
Vector3 crownFront = ridgeBase + new Vector3(0, rise, -depth * .5f);
|
||||
Vector3 crownBack = ridgeBase + new Vector3(0, rise, depth * .5f);
|
||||
MeshFor(Coat.Roof).Quad(a, d, crownBack, crownFront);
|
||||
MeshFor(Coat.Roof).Quad(c, b, crownFront, crownBack);
|
||||
MeshFor(endWall).Quad(b, a, crownFront, crownFront);
|
||||
MeshFor(endWall).Quad(d, c, crownBack, crownBack);
|
||||
MeshFor(Coat.Trim).Rod(a, crownFront, .074f);
|
||||
MeshFor(Coat.Trim).Rod(crownFront, b, .074f);
|
||||
}
|
||||
|
||||
private void Palm(Vector3 foot, float height, float turn)
|
||||
{
|
||||
Vector3 neck = foot + new Vector3(.27f * Mathf.Sin(turn), height, .27f * Mathf.Cos(turn));
|
||||
MeshFor(Coat.Wood).Rod(foot, neck, .13f, 8);
|
||||
for (int frond = 0; frond < 7; frond++)
|
||||
{
|
||||
float angle = frond * 2.39f + turn;
|
||||
Vector3 stem = new(Mathf.Cos(angle), 0, Mathf.Sin(angle));
|
||||
Vector3 side = Vector3.Cross(stem, Vector3.up);
|
||||
Vector3 mid = neck + stem * (1.10f + .14f * (frond % 3)) + Vector3.up * .45f;
|
||||
Vector3 tip = neck + stem * (2.05f + .15f * (frond % 3)) - Vector3.up * .18f;
|
||||
HarborMesh leaf = MeshFor(frond % 2 == 0 ? Coat.Foliage : Coat.FoliageLight);
|
||||
leaf.Quad(neck, mid + side * .32f, tip, mid - side * .32f);
|
||||
leaf.Quad(neck, mid - side * .28f, tip - Vector3.up * .14f, mid + side * .28f);
|
||||
}
|
||||
}
|
||||
|
||||
private void StreetTree(Vector3 foot, float height)
|
||||
{
|
||||
MeshFor(Coat.Wood).Rod(foot, foot + Vector3.up * height, .13f, 7);
|
||||
Vector3 crown = foot + Vector3.up * (height - .25f);
|
||||
MeshFor(Coat.Foliage).Radome(crown, height * .30f);
|
||||
MeshFor(Coat.FoliageLight).Radome(crown + new Vector3(.38f, .43f, -.37f), height * .24f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Soundings/Runtime/HarborPortScenery.cs.meta
Normal file
2
Assets/Soundings/Runtime/HarborPortScenery.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3fc63edd3a37462b870008ee22882852
|
||||
@@ -4,20 +4,20 @@ using UnityEngine.Rendering;
|
||||
|
||||
namespace Soundings
|
||||
{
|
||||
internal enum GuestActivity { Walk, Rail, Talk, Photograph, Read, Dine, Drink, Watch, Perform, Rest, Guitar, Revue }
|
||||
internal enum GuestActivity { Walk, Rail, Talk, Photograph, Read, Dine, Drink, Watch, Perform, Rest, Guitar, Revue, Swim, Wade, TendBar, Lounge }
|
||||
|
||||
internal sealed class DeckGuest
|
||||
{
|
||||
internal readonly GuestActivity Activity;
|
||||
internal readonly Vector3 Station;
|
||||
internal readonly int Service, Seed;
|
||||
internal readonly float Heading, RequiredOccupancy, SeatHeight, RouteEnd, LaneRadius, RouteStart;
|
||||
internal readonly float Heading, RequiredOccupancy, SeatHeight, RouteEnd, LaneRadius, RouteStart, SwimHalfLength;
|
||||
internal readonly EntertainmentProgram? Program;
|
||||
internal float Presence;
|
||||
internal bool Initialized;
|
||||
|
||||
internal DeckGuest(GuestActivity activity, Vector3 station, int seed, float heading, int service, float occupancy,
|
||||
float seatHeight, EntertainmentProgram? program = null)
|
||||
float seatHeight, EntertainmentProgram? program = null, float swimHalfLength = 0)
|
||||
{
|
||||
Activity = activity;
|
||||
Station = station;
|
||||
@@ -27,6 +27,7 @@ namespace Soundings
|
||||
RequiredOccupancy = occupancy;
|
||||
SeatHeight = seatHeight;
|
||||
Program = program;
|
||||
SwimHalfLength = swimHalfLength;
|
||||
}
|
||||
|
||||
internal DeckGuest(Vector3 start, float end, float laneRadius, float phase, int seed, float occupancy)
|
||||
@@ -38,7 +39,7 @@ namespace Soundings
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class PassengerCrowd : System.IDisposable
|
||||
internal sealed partial class PassengerCrowd : System.IDisposable
|
||||
{
|
||||
private static readonly Color32[] Shirts =
|
||||
{
|
||||
@@ -63,18 +64,20 @@ namespace Soundings
|
||||
private static readonly Color32 Paper = new(219, 202, 161, 255);
|
||||
private static readonly Color32 Dark = new(46, 57, 61, 255);
|
||||
private static readonly Color32 Glass = new(188, 160, 110, 255);
|
||||
private static readonly Primitive Globe = new(8, 4);
|
||||
private static readonly Primitive Joint = new(6, 3);
|
||||
private readonly List<Vector3> vertices = new(22000);
|
||||
private readonly List<Vector3> normals = new(22000);
|
||||
private readonly List<Color32> colors = new(22000);
|
||||
private readonly List<Vector4> surface = new(22000);
|
||||
private readonly List<int> indices = new(76000);
|
||||
private readonly List<Mesh> meshes = new();
|
||||
private readonly Dictionary<Mesh, Transform> meshes = new();
|
||||
private readonly Material material;
|
||||
|
||||
private Matrix4x4 guestMatrix;
|
||||
private Quaternion guestRotation;
|
||||
private byte coverage;
|
||||
private int activeActivities;
|
||||
|
||||
internal bool HasActiveGuest(GuestActivity activity) => (activeActivities & (1 << (int)activity)) != 0;
|
||||
|
||||
internal PassengerCrowd()
|
||||
{
|
||||
@@ -88,16 +91,19 @@ namespace Soundings
|
||||
root.AddComponent<MeshFilter>().sharedMesh = mesh;
|
||||
root.AddComponent<MeshRenderer>().sharedMaterial = material;
|
||||
mesh.bounds = new Bounds(Vector3.up * 16, new Vector3(length, 40, beam * 2));
|
||||
meshes.Add(mesh);
|
||||
meshes.Add(mesh, root.transform);
|
||||
return mesh;
|
||||
}
|
||||
|
||||
internal void Draw(Mesh mesh, List<DeckGuest> people, OnboardSession session, bool outside, float clock, float delta)
|
||||
internal void Draw(Mesh mesh, List<DeckGuest> people, OnboardSession session, bool outside, float clock, float delta, Camera view)
|
||||
{
|
||||
vertices.Clear();
|
||||
normals.Clear();
|
||||
colors.Clear();
|
||||
surface.Clear();
|
||||
indices.Clear();
|
||||
activeActivities = 0;
|
||||
Transform crowd = meshes[mesh];
|
||||
float voyageOccupancy = Mathf.Clamp01(session.Quote.Guests / (float)Mathf.Max(1, session.Ship.Beds));
|
||||
EntertainmentProgram? playing = session.PerformanceActive ? session.Quote.Plan?.Program : null;
|
||||
float promenadeAvailability = session.Quote.Weather switch
|
||||
@@ -112,14 +118,16 @@ namespace Soundings
|
||||
if (guest.Service >= 0)
|
||||
{
|
||||
OnboardSample service = session.Get((OnboardService)guest.Service);
|
||||
occupancy = service.Served / (float)Mathf.Max(1, service.Capacity);
|
||||
occupancy = guest.Activity == GuestActivity.TendBar && service.Capacity > 0
|
||||
? 1 : service.Served / (float)Mathf.Max(1, service.Capacity);
|
||||
}
|
||||
if (guest.Program.HasValue)
|
||||
occupancy = guest.Program == playing ? 1 : 0;
|
||||
else if (guest.Activity == GuestActivity.Perform && playing.HasValue)
|
||||
occupancy = 0;
|
||||
if (outside)
|
||||
occupancy *= promenadeAvailability;
|
||||
occupancy *= guest.Activity is GuestActivity.Swim or GuestActivity.Wade
|
||||
&& session.Quote.Weather != WeatherCondition.Calm ? 0 : promenadeAvailability;
|
||||
float goal = Mathf.SmoothStep(0, 1, Mathf.InverseLerp(guest.RequiredOccupancy - .13f,
|
||||
guest.RequiredOccupancy + .13f, occupancy));
|
||||
if (session.Quote.Guests == 0 || occupancy <= 0)
|
||||
@@ -132,7 +140,11 @@ namespace Soundings
|
||||
else
|
||||
guest.Presence = Mathf.MoveTowards(guest.Presence, goal, delta * .47f);
|
||||
if (guest.Presence > .012f)
|
||||
RenderGuest(guest, clock);
|
||||
{
|
||||
if (guest.Presence > .25f)
|
||||
activeActivities |= 1 << (int)guest.Activity;
|
||||
RenderGuest(guest, clock, crowd, view);
|
||||
}
|
||||
}
|
||||
|
||||
Bounds bounds = mesh.bounds;
|
||||
@@ -140,90 +152,11 @@ namespace Soundings
|
||||
mesh.SetVertices(vertices);
|
||||
mesh.SetNormals(normals);
|
||||
mesh.SetColors(colors);
|
||||
mesh.SetUVs(0, surface);
|
||||
mesh.SetTriangles(indices, 0, false);
|
||||
mesh.bounds = bounds;
|
||||
}
|
||||
|
||||
private void RenderGuest(DeckGuest guest, float clock)
|
||||
{
|
||||
int seed = guest.Seed;
|
||||
float variation = Hash(seed);
|
||||
float stature = Mathf.Lerp(.91f, 1.075f, variation);
|
||||
float time = clock + Hash(seed + 15) * 80;
|
||||
bool walking = guest.Activity == GuestActivity.Walk;
|
||||
float gait = 0;
|
||||
float heading = guest.Heading;
|
||||
Vector3 station = guest.Station;
|
||||
if (walking)
|
||||
{
|
||||
float speed = guest.Station.z < 0 ? .91f : .97f;
|
||||
float distance = clock * speed;
|
||||
station = WalkRoute(guest, distance, out heading);
|
||||
gait = (distance + guest.RouteStart * 5) / (.90f * stature);
|
||||
}
|
||||
guestRotation = Quaternion.Euler(0, heading, 0);
|
||||
guestMatrix = Matrix4x4.TRS(station, guestRotation, Vector3.one * stature);
|
||||
coverage = (byte)Mathf.RoundToInt(guest.Presence * 255f);
|
||||
|
||||
Color32 shirt = Shirts[seed % Shirts.Length];
|
||||
Color32 pants = Trousers[(seed / 4 + seed) % Trousers.Length];
|
||||
Color32 skin = Skin[(seed / 2 + seed) % Skin.Length];
|
||||
Color32 hair = Hair[(seed / 3 + seed) % Hair.Length];
|
||||
bool seated = guest.SeatHeight > 0;
|
||||
float breathe = Mathf.Sin(time * 2.2f) * .013f;
|
||||
float step = walking ? Mathf.Sin(gait * Mathf.PI * 2) : 0;
|
||||
float armSwing = walking ? Mathf.Cos(gait * Mathf.PI * 2) : 0;
|
||||
float sway = walking ? .031f * step : .02f * Mathf.Sin(time * 1.25f);
|
||||
float hipY = seated ? guest.SeatHeight / stature : .862f + (walking ? .018f * Mathf.Cos(gait * Mathf.PI * 4) : breathe * .2f);
|
||||
Vector3 pelvis = new(sway, hipY, 0);
|
||||
Vector3 chest = pelvis + new Vector3(-sway * .54f, .382f + breathe, seated ? .083f : .022f + Mathf.Abs(step) * .021f);
|
||||
Vector3 neck = chest + new Vector3(0, .195f, .016f);
|
||||
float glance = Mathf.Sin(time * .66f) * (walking ? .16f : .39f);
|
||||
Quaternion headTurn = Quaternion.Euler(Mathf.Sin(time * 1.02f) * 5, glance * Mathf.Rad2Deg, 0);
|
||||
Vector3 face = neck + new Vector3(.02f * Mathf.Sin(time), .115f, .018f);
|
||||
|
||||
Ellipsoid(Globe, pelvis + Vector3.up * .11f, new Vector3(.176f, .178f, .12f), Quaternion.identity, pants);
|
||||
Ellipsoid(Globe, Vector3.Lerp(pelvis, chest, .66f) + Vector3.up * .058f,
|
||||
new Vector3(.205f + variation * .021f, .284f, .127f), Quaternion.Euler(seated ? 12 : 3, step * 8, -step * 3), shirt);
|
||||
Ellipsoid(Joint, neck - Vector3.up * .017f, new Vector3(.057f, .103f, .060f), Quaternion.identity, skin);
|
||||
Ellipsoid(Globe, face, new Vector3(.102f, .136f, .103f), headTurn, skin);
|
||||
Ellipsoid(Globe, face + headTurn * new Vector3(0, .067f, -.022f),
|
||||
new Vector3(.104f, seed % 3 == 0 ? .104f : .079f, .104f), headTurn, hair);
|
||||
Ellipsoid(Joint, face + headTurn * new Vector3(0, -.011f, .099f), new Vector3(.024f, .029f, .026f), headTurn, skin);
|
||||
if (seed % 4 == 2 || guest.Activity == GuestActivity.Rail)
|
||||
{
|
||||
for (int side = -1; side <= 1; side += 2)
|
||||
Ellipsoid(Joint, face + headTurn * new Vector3(side * .044f, .026f, .086f),
|
||||
new Vector3(.042f, .025f, .018f), headTurn, Dark);
|
||||
}
|
||||
if (guest.Activity == GuestActivity.Guitar)
|
||||
{
|
||||
Quaternion guitar = Quaternion.Euler(-13, 0, 22);
|
||||
Ellipsoid(Globe, pelvis + new Vector3(.10f, .285f, .225f), new Vector3(.194f, .206f, .055f), guitar, Paper);
|
||||
Ellipsoid(Joint, pelvis + new Vector3(.062f, .31f, .279f), new Vector3(.051f, .053f, .013f), guitar, Dark);
|
||||
Limb(pelvis + new Vector3(.002f, .329f, .229f), pelvis + new Vector3(-.337f, .563f, .252f), .037f, Shoes);
|
||||
}
|
||||
|
||||
for (int side = -1; side <= 1; side += 2)
|
||||
{
|
||||
Vector3 hip = pelvis + new Vector3(side * .102f, 0, 0);
|
||||
Vector3 foot = Foot(side, walking, seated, gait, hipY);
|
||||
Vector3 knee = seated ? new Vector3(side * .130f, hipY - .08f, .37f) : Bend(hip, foot, .43f, Vector3.forward);
|
||||
Limb(hip, knee, .086f, pants);
|
||||
Limb(knee, foot, .065f, pants);
|
||||
Ellipsoid(Joint, foot + new Vector3(0, -.034f, .061f), new Vector3(.079f, .070f, .159f), Quaternion.identity, Shoes);
|
||||
|
||||
Vector3 shoulder = chest + new Vector3(side * .18f, .088f, 0);
|
||||
Vector3 hand = ArmGesture(guest.Activity, side, hipY, time, armSwing, face);
|
||||
Vector3 elbow = Bend(shoulder, hand, .30f, new Vector3(.55f * side, -.58f, -.60f));
|
||||
Limb(shoulder, elbow, .067f, shirt);
|
||||
Limb(elbow, hand, .043f, skin);
|
||||
Ellipsoid(Joint, hand, new Vector3(.046f, .061f, .047f), Quaternion.identity, skin);
|
||||
if (side > 0)
|
||||
RenderProp(guest.Activity, hand);
|
||||
}
|
||||
}
|
||||
|
||||
private static Vector3 WalkRoute(DeckGuest guest, float distance, out float heading)
|
||||
{
|
||||
float length = guest.RouteEnd - guest.Station.x;
|
||||
@@ -255,119 +188,6 @@ namespace Soundings
|
||||
return anchor + new Vector3(-radius * Mathf.Sin(lastArc), 0, radius * Mathf.Cos(lastArc));
|
||||
}
|
||||
|
||||
private static Vector3 Foot(int side, bool walking, bool seated, float gait, float hipY)
|
||||
{
|
||||
if (seated)
|
||||
return new Vector3(side * .135f, Mathf.Max(.095f, hipY - .49f), .42f);
|
||||
if (!walking)
|
||||
return new Vector3(side * .124f, .104f, side * .057f);
|
||||
|
||||
const float stance = .59f;
|
||||
float phase = Mathf.Repeat(gait + (side > 0 ? .5f : 0), 1);
|
||||
float z = .266f - phase * .90f;
|
||||
float height = 0;
|
||||
if (phase >= stance)
|
||||
{
|
||||
float swing = (phase - stance) / (1 - stance);
|
||||
z = Mathf.SmoothStep(-.265f, .266f, swing);
|
||||
height = .128f * Mathf.Sin(Mathf.PI * swing);
|
||||
}
|
||||
return new Vector3(side * .107f, .104f + height, z);
|
||||
}
|
||||
|
||||
private static Vector3 Bend(Vector3 root, Vector3 tip, float length, Vector3 direction)
|
||||
{
|
||||
Vector3 axis = tip - root;
|
||||
float half = axis.magnitude * .5f;
|
||||
if (half < .001f)
|
||||
return root;
|
||||
axis /= half * 2;
|
||||
Vector3 plane = (direction - axis * Vector3.Dot(axis, direction)).normalized;
|
||||
return (root + tip) * .5f + plane * Mathf.Sqrt(Mathf.Max(0, length * length - half * half));
|
||||
}
|
||||
|
||||
private static Vector3 ArmGesture(GuestActivity activity, int side, float hipY, float time, float stride, Vector3 face)
|
||||
{
|
||||
float beat = Mathf.Repeat(time * .167f + (side < 0 ? .47f : 0), 1);
|
||||
float action = Mathf.SmoothStep(0, 1, Mathf.InverseLerp(.61f, .85f, beat))
|
||||
* (1 - Mathf.SmoothStep(0, 1, Mathf.InverseLerp(.89f, 1, beat)));
|
||||
switch (activity)
|
||||
{
|
||||
case GuestActivity.Walk:
|
||||
return new Vector3(side * .25f, .914f + Mathf.Abs(stride) * .037f, side * stride * .245f);
|
||||
case GuestActivity.Rail:
|
||||
return new Vector3(side * .19f, hipY + .25f, .37f);
|
||||
case GuestActivity.Read:
|
||||
return new Vector3(side * .12f, hipY + .33f, .37f);
|
||||
case GuestActivity.Dine:
|
||||
case GuestActivity.Drink:
|
||||
Vector3 table = new(side * .16f, hipY + .27f, activity == GuestActivity.Dine ? .43f : .35f);
|
||||
return side > 0 ? Vector3.Lerp(table, face + new Vector3(.056f, -.047f, .134f), action) : table;
|
||||
case GuestActivity.Watch:
|
||||
float applause = action * (.63f + .37f * Mathf.Sin(time * 19f));
|
||||
return new Vector3(side * Mathf.Lerp(.19f, .047f, applause), hipY + .15f + action * .32f, .28f + action * .10f);
|
||||
case GuestActivity.Photograph:
|
||||
return Vector3.Lerp(new Vector3(side * .125f, hipY + .28f, .29f),
|
||||
face + new Vector3(side * .098f, -.045f, .24f), action);
|
||||
case GuestActivity.Talk:
|
||||
return new Vector3(side * (.248f + action * .18f), hipY + .12f + action * .34f, .13f + action * .14f);
|
||||
case GuestActivity.Perform:
|
||||
return side > 0 ? face + new Vector3(.065f, -.067f, .17f)
|
||||
: new Vector3(-.28f - action * .26f, hipY + .21f + action * .41f, .13f + action * .17f);
|
||||
case GuestActivity.Guitar:
|
||||
return side > 0 ? new Vector3(.108f, hipY + .30f + Mathf.Sin(time * 12.7f) * .080f, .302f)
|
||||
: new Vector3(-.25f + Mathf.Sin(time * 2.8f) * .045f, hipY + .52f, .268f);
|
||||
case GuestActivity.Revue:
|
||||
float arc = time * 3.2f + side * 1.1f;
|
||||
return new Vector3(side * (.32f + Mathf.Cos(arc) * .16f), hipY + .52f + Mathf.Sin(arc) * .35f, .24f);
|
||||
default:
|
||||
return new Vector3(side * .21f, hipY + .15f, .23f);
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderProp(GuestActivity activity, Vector3 hand)
|
||||
{
|
||||
if (activity is GuestActivity.Drink or GuestActivity.Photograph or GuestActivity.Read or GuestActivity.Perform)
|
||||
{
|
||||
Vector3 size = activity switch
|
||||
{
|
||||
GuestActivity.Drink => new Vector3(.052f, .091f, .052f),
|
||||
GuestActivity.Read => new Vector3(.136f, .081f, .023f),
|
||||
GuestActivity.Photograph => new Vector3(.063f, .105f, .019f),
|
||||
_ => new Vector3(.037f, .103f, .037f)
|
||||
};
|
||||
Color32 color = activity == GuestActivity.Drink ? Glass : activity == GuestActivity.Read ? Paper : Dark;
|
||||
Ellipsoid(Joint, hand + new Vector3(-size.x * .5f, size.y * .54f, size.z + .025f), size,
|
||||
activity == GuestActivity.Read ? Quaternion.Euler(-37, 0, 0) : Quaternion.identity, color);
|
||||
}
|
||||
}
|
||||
|
||||
private void Limb(Vector3 from, Vector3 to, float radius, Color32 color)
|
||||
{
|
||||
Vector3 direction = to - from;
|
||||
float distance = direction.magnitude;
|
||||
if (distance > .001f)
|
||||
Ellipsoid(Joint, (from + to) * .5f, new Vector3(radius, distance * .55f + radius * .33f, radius),
|
||||
Quaternion.FromToRotation(Vector3.up, direction / distance), color);
|
||||
}
|
||||
|
||||
private void Ellipsoid(Primitive primitive, Vector3 center, Vector3 size, Quaternion rotation, Color32 color)
|
||||
{
|
||||
int offset = vertices.Count;
|
||||
Matrix4x4 position = guestMatrix * Matrix4x4.TRS(center, rotation, size);
|
||||
Quaternion orient = guestRotation * rotation;
|
||||
Vector3 inverseSize = new(1f / size.x, 1f / size.y, 1f / size.z);
|
||||
color.a = coverage;
|
||||
foreach (Vector3 point in primitive.Points)
|
||||
{
|
||||
vertices.Add(position.MultiplyPoint3x4(point));
|
||||
normals.Add(orient * Vector3.Scale(point, inverseSize).normalized);
|
||||
colors.Add(color);
|
||||
}
|
||||
foreach (int index in primitive.Indices)
|
||||
indices.Add(offset + index);
|
||||
}
|
||||
|
||||
private static float Hash(int seed)
|
||||
{
|
||||
uint value = unchecked((uint)seed + 105789u);
|
||||
@@ -378,41 +198,10 @@ namespace Soundings
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (Mesh mesh in meshes)
|
||||
foreach (Mesh mesh in meshes.Keys)
|
||||
Object.Destroy(mesh);
|
||||
Object.Destroy(material);
|
||||
}
|
||||
|
||||
private sealed class Primitive
|
||||
{
|
||||
internal readonly Vector3[] Points;
|
||||
internal readonly int[] Indices;
|
||||
|
||||
internal Primitive(int sides, int bands)
|
||||
{
|
||||
Points = new Vector3[sides * (bands + 1)];
|
||||
Indices = new int[sides * bands * 6];
|
||||
for (int band = 0; band <= bands; band++)
|
||||
{
|
||||
float vertical = (band / (float)bands - .5f) * Mathf.PI;
|
||||
for (int side = 0; side < sides; side++)
|
||||
{
|
||||
float azimuth = side * Mathf.PI * 2 / sides;
|
||||
Points[band * sides + side] = new Vector3(Mathf.Cos(azimuth) * Mathf.Cos(vertical), Mathf.Sin(vertical),
|
||||
Mathf.Sin(azimuth) * Mathf.Cos(vertical));
|
||||
if (band == bands)
|
||||
continue;
|
||||
int a = band * sides + side, b = band * sides + (side + 1) % sides;
|
||||
int offset = a * 6;
|
||||
Indices[offset] = a;
|
||||
Indices[offset + 1] = a + sides;
|
||||
Indices[offset + 2] = b + sides;
|
||||
Indices[offset + 3] = a;
|
||||
Indices[offset + 4] = b + sides;
|
||||
Indices[offset + 5] = b;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
681
Assets/Soundings/Runtime/PassengerFigure.cs
Normal file
681
Assets/Soundings/Runtime/PassengerFigure.cs
Normal file
@@ -0,0 +1,681 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Soundings
|
||||
{
|
||||
internal sealed partial class PassengerCrowd
|
||||
{
|
||||
private const float StepCycle = 1.10f;
|
||||
private const float Turn = 2 * Mathf.PI;
|
||||
private float passengerClock;
|
||||
private enum FigureDetail { Hidden, Distant, Near, Close }
|
||||
private enum Surface { Cloth, Skin, Hair, Accessory, Water, Contact }
|
||||
|
||||
private static readonly Color32 WakeTint = new(175, 221, 219, 255);
|
||||
private static readonly Color32 ShadowTint = new(39, 53, 59, 255);
|
||||
private static readonly Color32 StaffShirt = new(222, 222, 209, 255);
|
||||
private static readonly Color32 Apron = new(49, 69, 75, 255);
|
||||
private static readonly Color32 Linen = new(214, 207, 188, 255);
|
||||
private static readonly Color32 EyeWhite = new(221, 213, 200, 255);
|
||||
private static readonly Color32 EyeDark = new(52, 58, 55, 255);
|
||||
private static readonly Color32 LipShade = new(126, 67, 64, 255);
|
||||
private static readonly Color32 Strap = new(24, 43, 50, 255);
|
||||
private static readonly Vector2[] Loose = Circle(6);
|
||||
private static readonly Vector2[] Regular = Circle(9);
|
||||
private static readonly Vector2[] Fine = Circle(12);
|
||||
private static readonly Form Orb = Form.Sphere(12, 7);
|
||||
private static readonly Form SmallOrb = Form.Sphere(8, 4);
|
||||
private static readonly Form Torso = new(16, new[]
|
||||
{
|
||||
new Ring(-.024f, .104f, .069f), new Ring(.024f, .163f, .100f),
|
||||
new Ring(.117f, .154f, .095f), new Ring(.200f, .145f, .100f, .012f),
|
||||
new Ring(.290f, .167f, .113f, .014f), new Ring(.376f, .183f, .110f, .008f),
|
||||
new Ring(.422f, .181f, .084f), new Ring(.451f, .132f, .068f),
|
||||
new Ring(.471f, .078f, .053f, .009f), new Ring(.475f, .056f, .045f, .012f)
|
||||
});
|
||||
private static readonly Form Hips = new(12, new[]
|
||||
{
|
||||
new Ring(-.097f, .084f, .061f), new Ring(-.050f, .149f, .100f, -.007f),
|
||||
new Ring(.014f, .169f, .105f), new Ring(.078f, .155f, .098f), new Ring(.105f, .134f, .083f)
|
||||
});
|
||||
private static readonly Form Head = new(24, new[]
|
||||
{
|
||||
new Ring(-.126f, .015f, .024f, .013f), new Ring(-.115f, .039f, .049f, .022f, .006f),
|
||||
new Ring(-.092f, .062f, .066f, .013f, .008f), new Ring(-.066f, .077f, .078f, .001f, .008f),
|
||||
new Ring(-.049f, .083f, .081f, -.002f, .011f), new Ring(-.028f, .088f, .084f, -.006f, .022f),
|
||||
new Ring(-.012f, .091f, .085f, -.007f, .034f), new Ring(.010f, .092f, .085f, -.008f, .025f),
|
||||
new Ring(.027f, .092f, .085f, -.010f, .016f), new Ring(.047f, .094f, .087f, -.011f, .007f),
|
||||
new Ring(.074f, .094f, .087f, -.013f), new Ring(.105f, .086f, .080f, -.015f),
|
||||
new Ring(.131f, .066f, .058f, -.021f), new Ring(.150f, .032f, .030f, -.026f),
|
||||
new Ring(.157f, .001f, .001f, -.030f)
|
||||
});
|
||||
private static readonly Form HairCrop = Form.Hair(20, 5, .025f, .0f);
|
||||
private static readonly Form HairWaves = Form.Hair(22, 6, .041f, .009f);
|
||||
private static readonly Form HairTie = Form.Hair(20, 5, .043f, -.007f);
|
||||
private static readonly Form Footwear = new(12, new[]
|
||||
{
|
||||
new Ring(-.038f, .055f, .122f, .045f), new Ring(-.027f, .064f, .140f, .048f),
|
||||
new Ring(.004f, .066f, .140f, .045f), new Ring(.041f, .059f, .116f, .036f),
|
||||
new Ring(.063f, .049f, .054f, -.018f), new Ring(.073f, .030f, .033f, -.016f)
|
||||
});
|
||||
|
||||
private static readonly float[] LegStations = { 0, .13f, .30f, .42f, .50f, .60f, .74f, .88f, 1 };
|
||||
private static readonly float[] LegRadii = { .084f, .093f, .081f, .068f, .058f, .057f, .060f, .042f, .035f };
|
||||
private static readonly float[] ArmStations = { 0, .13f, .29f, .43f, .50f, .60f, .76f, .90f, 1 };
|
||||
private static readonly float[] ArmRadii = { .060f, .070f, .061f, .049f, .046f, .045f, .040f, .031f, .025f };
|
||||
|
||||
private void RenderGuest(DeckGuest guest, float clock, Transform crowd, Camera view)
|
||||
{
|
||||
passengerClock = clock;
|
||||
int seed = guest.Seed & 0x7fffffff;
|
||||
float variation = Hash(seed);
|
||||
float stature = Mathf.Lerp(.89f, 1.09f, variation);
|
||||
float build = Mathf.Lerp(.88f, 1.14f, Hash(seed + 91));
|
||||
float time = clock + Hash(seed + 15) * 65;
|
||||
GuestActivity activity = guest.Activity;
|
||||
bool walking = activity == GuestActivity.Walk;
|
||||
bool swimming = activity == GuestActivity.Swim;
|
||||
bool inWater = swimming || activity == GuestActivity.Wade;
|
||||
bool staff = activity == GuestActivity.TendBar;
|
||||
bool lounging = activity == GuestActivity.Lounge;
|
||||
bool seated = guest.SeatHeight > 0;
|
||||
float heading = guest.Heading;
|
||||
float gait = 0;
|
||||
Vector3 station = guest.Station;
|
||||
if (walking)
|
||||
{
|
||||
float distance = clock * Mathf.Lerp(.84f, 1.13f, Hash(seed + 55));
|
||||
station = WalkRoute(guest, distance, out heading);
|
||||
gait = (distance / (StepCycle * stature)) + guest.RouteStart;
|
||||
}
|
||||
else if (swimming)
|
||||
station = SwimRoute(guest, clock, out heading);
|
||||
|
||||
FigureDetail detail = ViewDetail(view, crowd.TransformPoint(station + Vector3.up * (inWater ? .21f : seated ? .63f : .87f)), stature);
|
||||
if (detail == FigureDetail.Hidden)
|
||||
return;
|
||||
|
||||
guestRotation = Quaternion.Euler(0, heading, 0);
|
||||
guestMatrix = Matrix4x4.TRS(station, guestRotation, Vector3.one * stature);
|
||||
coverage = (byte)Mathf.RoundToInt(guest.Presence * 255f);
|
||||
Color32 shirt = staff ? StaffShirt : Shirts[seed % Shirts.Length];
|
||||
Color32 pants = inWater ? Shirts[(seed / 4 + seed + 3) % Shirts.Length] : staff ? Apron : Trousers[(seed / 4 + seed) % Trousers.Length];
|
||||
Color32 skin = Skin[(seed / 2 + seed) % Skin.Length];
|
||||
Color32 hair = Hair[(seed / 3 + seed) % Hair.Length];
|
||||
bool sleeveless = inWater;
|
||||
bool swimTop = inWater && seed % 4 > 1;
|
||||
float sleeveEnd = staff ? .36f : inWater ? 0 : .26f;
|
||||
float trouserEnd = inWater ? .29f : !staff && seed % 5 < 2 ? .48f : 1f;
|
||||
Color32 shoes = seed % 4 is 0 or 3 && !staff ? Linen : Shoes;
|
||||
|
||||
float phase = gait * Turn;
|
||||
float breath = Mathf.Sin(time * 1.72f) * .008f;
|
||||
float sway = walking ? .027f * Mathf.Sin(phase) : .021f * Mathf.Sin(time * .83f);
|
||||
float hipY = seated ? (guest.SeatHeight + (lounging ? .043f : .077f)) / stature : .873f;
|
||||
hipY += walking ? -.010f + .022f * Mathf.Cos(phase * 2) : breath * .23f;
|
||||
float chestPitch = lounging ? -54 : seated ? 12 : walking ? 5 : 2.4f;
|
||||
float chestTurn = walking ? Mathf.Sin(phase) * 7.2f : Mathf.Sin(time * .94f) * 3.8f;
|
||||
float chestRoll = walking ? Mathf.Cos(phase) * 2.8f : Mathf.Sin(time * .83f) * 1.9f;
|
||||
if (swimming)
|
||||
{
|
||||
hipY = -.100f + breath * 2.5f;
|
||||
chestPitch = 84;
|
||||
chestTurn = Mathf.Sin(time * 5.1f) * 4;
|
||||
chestRoll = Mathf.Sin(time * 4.55f) * 17;
|
||||
}
|
||||
else if (inWater)
|
||||
hipY = -.185f + Mathf.Sin(time * 2) * .033f;
|
||||
else if (activity == GuestActivity.Rail)
|
||||
chestPitch = 15 + Mathf.Sin(time * .53f) * 3;
|
||||
else if (activity == GuestActivity.Revue)
|
||||
hipY += .048f * Mathf.Sin(time * 6.4f);
|
||||
|
||||
Vector3 pelvis = new(sway, hipY, 0);
|
||||
Quaternion trunk = Quaternion.Euler(chestPitch, chestTurn, chestRoll);
|
||||
Vector3 headCenter = pelvis + trunk * new Vector3(0, .636f + breath, .012f);
|
||||
if (swimming)
|
||||
headCenter.y += .082f;
|
||||
float focus = activity switch
|
||||
{
|
||||
GuestActivity.Read => 23f, GuestActivity.Dine => 9f, GuestActivity.Drink => 5f,
|
||||
GuestActivity.TendBar => 12f, GuestActivity.Photograph => -2f, GuestActivity.Lounge => -11f,
|
||||
_ => seated ? -3f : 0
|
||||
};
|
||||
float spot = Mathf.Sin(time * .67f) * (walking ? 12 : 23);
|
||||
float breathingTurn = Mathf.SmoothStep(0, 1, Mathf.InverseLerp(.39f, .82f, Mathf.Sin(time * 2.12f)));
|
||||
Quaternion face = swimming ? Quaternion.Euler(66 - 18 * breathingTurn, spot * .45f, 53 * breathingTurn)
|
||||
: Quaternion.Euler(focus + Mathf.Sin(time * 1.09f) * 3.2f, spot + chestTurn * .3f, -chestRoll * .56f);
|
||||
|
||||
if (!inWater && detail >= FigureDetail.Near)
|
||||
ContactShadow(seated ? .19f : .105f, seated ? .37f : .275f);
|
||||
Shell(Hips, pelvis, new Vector3(build, 1, build), Quaternion.Euler(lounging ? -24 : chestPitch * .48f,
|
||||
-chestTurn * .64f, chestRoll * -.56f), pants, Surface.Cloth);
|
||||
Shell(Torso, pelvis, new Vector3(build, 1 + breath * 1.5f, Mathf.Lerp(.94f, 1.08f, build)), trunk,
|
||||
inWater && !swimTop ? skin : shirt, inWater && !swimTop ? Surface.Skin : Surface.Cloth);
|
||||
Vector3 throat = pelvis + trunk * new Vector3(0, .512f, .018f);
|
||||
Span(throat - trunk * new Vector3(0, .06f, .004f), headCenter - face * (Vector3.up * .089f), .051f, skin, Surface.Skin);
|
||||
DrawFace(detail, headCenter, face, seed, skin, hair, inWater && seed % 3 == 0);
|
||||
if (detail >= FigureDetail.Near && !inWater)
|
||||
DressDetails(pelvis, trunk, shirt, build, staff, seed);
|
||||
if (activity == GuestActivity.Guitar)
|
||||
Guitar(pelvis);
|
||||
|
||||
Vector2[] division = detail == FigureDetail.Close ? Fine : detail == FigureDetail.Near ? Regular : Loose;
|
||||
float pour = staff ? PourBeat(time) : 0;
|
||||
for (int side = -1; side <= 1; side += 2)
|
||||
{
|
||||
float footPhase = Mathf.Repeat(gait + (side > 0 ? .5f : 0), 1);
|
||||
var (foot, toe) = FootPose(side, walking, seated, lounging, swimming, footPhase, hipY, time);
|
||||
Vector3 hip = pelvis + Quaternion.Euler(0, -chestTurn * .54f, 0) * new Vector3(side * .096f * build, -.025f, 0);
|
||||
Vector3 knee = lounging ? new Vector3(side * .106f, hipY + .025f, .342f)
|
||||
: SolveBend(hip, ref foot, .432f, .415f, swimming ? Vector3.down : new Vector3(side * .18f, 0, 1));
|
||||
Sweep(hip, knee, foot, LegStations, LegRadii, division, build, pants, skin, trouserEnd);
|
||||
Shell(Footwear, foot + new Vector3(0, -.026f, 0), inWater ? new Vector3(.85f, .68f, .95f) : Vector3.one,
|
||||
Quaternion.Euler(toe, side * (walking ? 2.2f : 5f), 0), inWater ? skin : shoes, inWater ? Surface.Skin : Surface.Accessory);
|
||||
|
||||
Vector3 shoulder = pelvis + trunk * new Vector3(side * .171f * build, .398f, .001f);
|
||||
float focusPhase = staff ? pour : ActivityBeat(time, side);
|
||||
Vector3 hand = HandTarget(activity, side, hipY, time, footPhase, headCenter, focusPhase, shoulder, swimTop);
|
||||
Vector3 bendDirection = swimming ? new Vector3(side * .85f, .48f, -.10f) : new Vector3(side * .36f, -.82f, -.62f);
|
||||
Vector3 elbow = SolveBend(shoulder, ref hand, .293f, .258f, bendDirection);
|
||||
Sweep(shoulder, elbow, hand, ArmStations, ArmRadii, division, Mathf.Lerp(.88f, 1.09f, build), shirt,
|
||||
skin, sleeveless ? 0 : sleeveEnd);
|
||||
var handRotation = Quaternion.FromToRotation(Vector3.up, (hand - elbow).normalized);
|
||||
Vector3 palm = hand + handRotation * (Vector3.up * .034f);
|
||||
Shell(detail == FigureDetail.Close ? Orb : SmallOrb, palm, new Vector3(.032f, .055f, .021f), handRotation, skin, Surface.Skin);
|
||||
if (detail == FigureDetail.Close)
|
||||
Shell(SmallOrb, palm + handRotation * new Vector3(-side * .027f, .002f, .008f),
|
||||
new Vector3(.015f, .035f, .014f), handRotation * Quaternion.Euler(0, 0, side * -22), skin, Surface.Skin);
|
||||
if (side > 0)
|
||||
HeldObject(activity, palm, yaw: chestTurn, lift: focusPhase);
|
||||
else if (staff)
|
||||
Shell(SmallOrb, palm + new Vector3(.022f, .034f, .015f), new Vector3(.034f, .048f, .035f),
|
||||
Quaternion.identity, Glass, Surface.Accessory);
|
||||
}
|
||||
if (inWater)
|
||||
PoolRipples(swimming, time);
|
||||
}
|
||||
|
||||
private static FigureDetail ViewDetail(Camera view, Vector3 center, float stature)
|
||||
{
|
||||
Vector3 point = view.WorldToViewportPoint(center);
|
||||
if (point.z <= .06f)
|
||||
return FigureDetail.Hidden;
|
||||
float frameHeight = view.targetTexture != null ? view.targetTexture.height : Screen.height;
|
||||
float span = view.orthographic ? 2 * view.orthographicSize
|
||||
: 2 * point.z * Mathf.Tan(view.fieldOfView * Mathf.Deg2Rad * .5f);
|
||||
float height = 1.78f * stature / Mathf.Max(.1f, span);
|
||||
float margin = .025f + height * .62f;
|
||||
if (point.x < -margin / view.aspect || point.x > 1 + margin / view.aspect || point.y < -margin || point.y > 1 + margin)
|
||||
return FigureDetail.Hidden;
|
||||
float pixels = frameHeight * height;
|
||||
return pixels > 250 ? FigureDetail.Close : pixels > 76 ? FigureDetail.Near : FigureDetail.Distant;
|
||||
}
|
||||
|
||||
private static Vector3 SwimRoute(DeckGuest guest, float clock, out float heading)
|
||||
{
|
||||
float limit = Mathf.Max(.1f, guest.SwimHalfLength);
|
||||
float phase = Mathf.Repeat(clock * .78f / (limit * Turn) + Hash(guest.Seed + 29), 1);
|
||||
float turn = Mathf.SmoothStep(0, 1, Mathf.InverseLerp(.437f, .563f, phase));
|
||||
float turnaround = phase < .25f ? Mathf.SmoothStep(-1, 0, Mathf.InverseLerp(-.055f, .055f, phase))
|
||||
: Mathf.SmoothStep(0, 1, Mathf.InverseLerp(.945f, 1.055f, phase));
|
||||
heading = guest.Heading + (turn + turnaround) * 180;
|
||||
return guest.Station + Quaternion.Euler(0, guest.Heading, 0) * new Vector3(0, 0, -Mathf.Cos(phase * Turn) * limit);
|
||||
}
|
||||
|
||||
private static (Vector3 Foot, float Toe) FootPose(int side, bool walking, bool seated, bool lounging, bool swimming,
|
||||
float phase, float hip, float clock)
|
||||
{
|
||||
if (swimming)
|
||||
return (new Vector3(side * .092f, hip - .13f + .081f * Mathf.Sin(clock * 8.5f + side * 1.57f), -.79f), -81);
|
||||
if (lounging)
|
||||
return (new Vector3(side * .102f, hip - .06f, .72f), -18);
|
||||
if (seated)
|
||||
return (new Vector3(side * .122f, Mathf.Max(.075f, hip - .50f), .434f), -3);
|
||||
if (!walking)
|
||||
return (new Vector3(side * .107f, .065f, side * .066f), 0);
|
||||
|
||||
const float stance = .605f;
|
||||
const float heel = .331f;
|
||||
float z = heel - phase * StepCycle;
|
||||
if (phase < stance)
|
||||
{
|
||||
float toe = -13 * (1 - Mathf.SmoothStep(0, 1, phase / .18f)) + 22 * Mathf.SmoothStep(0, 1, (phase - .43f) / .175f);
|
||||
float ankleLift = .036f * Mathf.Abs(toe) / 22;
|
||||
return (new Vector3(side * .101f, .065f + ankleLift, z), toe);
|
||||
}
|
||||
float swing = (phase - stance) / (1 - stance);
|
||||
float lifted = Mathf.Sin(Mathf.PI * swing);
|
||||
z = Mathf.Lerp(heel - stance * StepCycle, heel, Mathf.SmoothStep(0, 1, swing));
|
||||
float rollHeight = Mathf.Lerp(.036f, .036f * 13 / 22, swing);
|
||||
return (new Vector3(side * .101f, .065f + .128f * lifted + rollHeight, z),
|
||||
Mathf.Lerp(22, -13, swing) + 11 * lifted);
|
||||
}
|
||||
|
||||
private static Vector3 SolveBend(Vector3 root, ref Vector3 tip, float upper, float lower, Vector3 toward)
|
||||
{
|
||||
Vector3 difference = tip - root;
|
||||
float requested = difference.magnitude;
|
||||
if (requested < .001f)
|
||||
return root + toward.normalized * upper;
|
||||
Vector3 axis = difference / requested;
|
||||
float distance = Mathf.Min(requested, upper + lower - .002f);
|
||||
tip = root + axis * distance;
|
||||
float along = Mathf.Clamp((distance * distance + upper * upper - lower * lower) / (2 * distance), -upper, upper);
|
||||
Vector3 bend = Vector3.ProjectOnPlane(toward, axis).normalized;
|
||||
return root + axis * along + bend * Mathf.Sqrt(upper * upper - along * along);
|
||||
}
|
||||
|
||||
private static float ActivityBeat(float clock, int side)
|
||||
{
|
||||
float phase = Mathf.Repeat(clock * (side > 0 ? .174f : .136f) + (side < 0 ? .23f : 0), 1);
|
||||
return Mathf.SmoothStep(0, 1, (phase - .22f) / .16f) * (1 - Mathf.SmoothStep(0, 1, (phase - .54f) / .21f));
|
||||
}
|
||||
|
||||
private static float PourBeat(float clock)
|
||||
{
|
||||
float phase = Mathf.Repeat(clock * .19f, 1);
|
||||
return Mathf.SmoothStep(0, 1, (phase - .24f) / .16f) * (1 - Mathf.SmoothStep(0, 1, (phase - .63f) / .15f));
|
||||
}
|
||||
|
||||
private static Vector3 HandTarget(GuestActivity activity, int side, float hip, float time, float footPhase,
|
||||
Vector3 head, float beat, Vector3 shoulder, bool swimTop)
|
||||
{
|
||||
switch (activity)
|
||||
{
|
||||
case GuestActivity.Walk:
|
||||
return new Vector3(side * .198f, hip - .070f + .063f * Mathf.Abs(Mathf.Cos(footPhase * Turn)),
|
||||
-.175f * Mathf.Cos(footPhase * Turn) + .023f);
|
||||
case GuestActivity.Rail:
|
||||
return new Vector3(side * .145f, hip + .167f + .008f * Mathf.Sin(time * 1.6f), .42f);
|
||||
case GuestActivity.Read:
|
||||
return new Vector3(side * (.091f + .025f * beat), hip + .294f + .026f * beat, .354f);
|
||||
case GuestActivity.Dine:
|
||||
case GuestActivity.Drink:
|
||||
Vector3 table = new(side * .146f, hip + (activity == GuestActivity.Dine ? .165f : .178f),
|
||||
.43f);
|
||||
Vector3 lips = head + new Vector3(.036f, -.047f, .104f);
|
||||
return side > 0 ? Vector3.Lerp(table, lips, beat) : table + new Vector3(.022f * beat, .006f, -.037f * beat);
|
||||
case GuestActivity.TendBar:
|
||||
return side > 0 ? new Vector3(.19f + .12f * Mathf.Sin(time * 1.35f) * (1 - beat), hip + .14f + .22f * beat, .50f - .069f * beat)
|
||||
: new Vector3(-.119f + .072f * Mathf.Sin(time * 1.55f) * (1 - beat), hip + .158f, .49f);
|
||||
case GuestActivity.Watch:
|
||||
float clap = beat * (.66f + .34f * Mathf.Sin(time * 17f));
|
||||
return new Vector3(side * Mathf.Lerp(.155f, .031f, clap), hip + .108f + beat * .25f, .295f + beat * .055f);
|
||||
case GuestActivity.Photograph:
|
||||
return Vector3.Lerp(new Vector3(side * .082f, hip + .28f, .285f), head + new Vector3(side * .065f, -.034f, .182f), beat);
|
||||
case GuestActivity.Talk:
|
||||
return new Vector3(side * (.203f + beat * .147f), hip - .065f + beat * (.29f + .04f * Mathf.Sin(time * 5.2f)),
|
||||
.075f + .25f * beat);
|
||||
case GuestActivity.Perform:
|
||||
return side > 0 ? head + new Vector3(.061f, -.104f, .09f)
|
||||
: new Vector3(-.223f - beat * .259f, hip + .17f + beat * .41f, .12f + beat * .12f);
|
||||
case GuestActivity.Guitar:
|
||||
return side > 0 ? new Vector3(.109f + Mathf.Sin(time * 10.4f) * .046f, hip + .26f + Mathf.Sin(time * 10.4f) * .065f, .30f)
|
||||
: new Vector3(-.25f + Mathf.Sin(time * 2.35f) * .032f, hip + .46f, .27f);
|
||||
case GuestActivity.Revue:
|
||||
float rhythm = time * 3.19f + side * 1.17f;
|
||||
return new Vector3(side * (.276f + Mathf.Cos(rhythm) * .214f), hip + .42f + Mathf.Sin(rhythm) * .38f, .24f);
|
||||
case GuestActivity.Lounge:
|
||||
return new Vector3(side * .207f, hip + .067f + .018f * beat, .185f);
|
||||
case GuestActivity.Swim:
|
||||
float stroke = Mathf.Repeat(time * .91f + (side > 0 ? .5f : 0), 1);
|
||||
float recover = stroke / .40f;
|
||||
float pull = (stroke - .40f) / .60f;
|
||||
if (stroke < .40f)
|
||||
return new Vector3(side * (.305f - .067f * recover), shoulder.y + .044f + .297f * Mathf.Sin(recover * Mathf.PI),
|
||||
Mathf.Lerp(shoulder.z - .46f, shoulder.z + .44f, Mathf.SmoothStep(0, 1, recover)));
|
||||
float arc = Mathf.Sin(pull * Mathf.PI);
|
||||
return new Vector3(side * (Mathf.Lerp(.238f, .305f, pull) + .04f * arc), shoulder.y + .044f - .205f * arc,
|
||||
Mathf.Lerp(shoulder.z + .44f, shoulder.z - .46f, Mathf.SmoothStep(0, 1, pull)));
|
||||
case GuestActivity.Wade:
|
||||
float tread = time * 2.58f + side * 1.8f;
|
||||
return new Vector3(side * (.267f + .11f * Mathf.Cos(tread)), .033f + .061f * Mathf.Sin(tread),
|
||||
.17f + (swimTop ? .105f : .15f) * Mathf.Sin(tread));
|
||||
default:
|
||||
return new Vector3(side * .148f, hip + .063f, .27f);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawFace(FigureDetail detail, Vector3 center, Quaternion angle, int seed, Color32 skin, Color32 hair, bool cap)
|
||||
{
|
||||
float width = Mathf.Lerp(.90f, 1.08f, Hash(seed + 540));
|
||||
Shell(detail == FigureDetail.Distant ? Orb : Head, center, detail == FigureDetail.Distant
|
||||
? new Vector3(.091f * width, .133f, .089f) : new Vector3(width, 1, 1), angle, skin, Surface.Skin);
|
||||
int style = seed % 7;
|
||||
if (cap)
|
||||
{
|
||||
Shell(HairCrop, center, new Vector3(1.04f, .98f, 1.04f), angle, Shirts[seed % Shirts.Length], Surface.Cloth);
|
||||
}
|
||||
else if (style != 6)
|
||||
{
|
||||
Form shape = style is 2 or 5 ? HairWaves : style == 4 ? HairTie : HairCrop;
|
||||
Shell(shape, center, new Vector3(width, 1, 1), angle, hair, Surface.Hair);
|
||||
if (style == 4)
|
||||
Shell(Orb, center + angle * new Vector3(.014f, .023f, -.116f), new Vector3(.055f, .066f, .053f), angle,
|
||||
hair, Surface.Hair);
|
||||
}
|
||||
if (detail == FigureDetail.Distant)
|
||||
return;
|
||||
float blink = Mathf.Repeat(TimeForBlink(seed), 1);
|
||||
bool spectacles = !cap && seed % 11 == 2;
|
||||
for (int side = -1; side <= 1; side += 2)
|
||||
{
|
||||
var ear = new Vector3(side * .084f * width, -.016f, -.018f);
|
||||
Shell(SmallOrb, center + angle * ear, new Vector3(.018f, .033f, .023f), angle * Quaternion.Euler(0, 0, side * -12), skin, Surface.Skin);
|
||||
if (detail != FigureDetail.Close)
|
||||
continue;
|
||||
Shell(SmallOrb, center + angle * (ear + new Vector3(side * .010f, .001f, .012f)), new Vector3(.007f, .020f, .008f),
|
||||
angle, Color32.Lerp(skin, LipShade, .24f), Surface.Skin);
|
||||
float x = side * .037f * width;
|
||||
Quaternion eyes = angle * Quaternion.Euler(0, side * 14, side * 1.4f);
|
||||
if (spectacles)
|
||||
{
|
||||
Shell(SmallOrb, center + angle * new Vector3(x * 1.12f, .029f, .081f), new Vector3(.032f, .020f, .011f),
|
||||
eyes, Dark, Surface.Accessory);
|
||||
continue;
|
||||
}
|
||||
float open = blink < .036f ? .25f + .75f * Mathf.Abs(blink / .018f - 1) : 1;
|
||||
var eye = new Vector3(x, .026f, .070f);
|
||||
Shell(SmallOrb, center + angle * (eye), new Vector3(.019f, .008f, .010f), eyes,
|
||||
Color32.Lerp(skin, Dark, .43f), Surface.Skin);
|
||||
Shell(SmallOrb, center + angle * (eye + Vector3.forward * .005f), new Vector3(.014f, .0054f * open, .007f), eyes,
|
||||
EyeWhite, Surface.Accessory);
|
||||
Shell(SmallOrb, center + angle * (eye + new Vector3(.001f, 0, .0107f)), new Vector3(.0054f, .0052f * open, .0034f), eyes,
|
||||
EyeDark, Surface.Accessory);
|
||||
Shell(SmallOrb, center + angle * new Vector3(x, .044f, .073f), new Vector3(.018f, .0031f, .005f), eyes,
|
||||
Color32.Lerp(hair, skin, .19f), Surface.Hair);
|
||||
}
|
||||
if (detail == FigureDetail.Close)
|
||||
{
|
||||
Shell(SmallOrb, center + angle * new Vector3(0, -.049f, .091f), new Vector3(.024f, .0045f, .007f), angle,
|
||||
Color32.Lerp(skin, LipShade, .37f), Surface.Skin);
|
||||
if (spectacles)
|
||||
Span(center + angle * new Vector3(-.020f, .033f, .095f), center + angle * new Vector3(.020f, .033f, .095f),
|
||||
.005f, Dark, Surface.Accessory);
|
||||
}
|
||||
}
|
||||
|
||||
private float TimeForBlink(int seed) => passengerClock * Mathf.Lerp(.152f, .250f, Hash(seed + 217)) + Hash(seed + 40);
|
||||
|
||||
private void DressDetails(Vector3 pelvis, Quaternion trunk, Color32 shirt, float build, bool staff, int seed)
|
||||
{
|
||||
var lean = pelvis + trunk * new Vector3(0, .307f, .114f);
|
||||
if (staff)
|
||||
{
|
||||
Shell(SmallOrb, lean + trunk * new Vector3(0, -.137f, .001f), new Vector3(.116f * build, .228f, .021f), trunk, Apron, Surface.Cloth);
|
||||
Shell(SmallOrb, lean + trunk * new Vector3(0, .076f, -.005f), new Vector3(.055f, .075f, .020f), trunk,
|
||||
Color32.Lerp(shirt, Linen, .52f), Surface.Cloth);
|
||||
Shell(SmallOrb, lean + trunk * new Vector3(.094f, .093f, .001f), new Vector3(.024f, .010f, .011f), trunk,
|
||||
Linen, Surface.Accessory);
|
||||
}
|
||||
else if (seed % 3 == 1)
|
||||
{
|
||||
Color32 trim = Color32.Lerp(shirt, Linen, .25f);
|
||||
for (int side = -1; side <= 1; side += 2)
|
||||
Span(pelvis + trunk * new Vector3(side * .041f, .468f, .051f), pelvis + trunk * new Vector3(side * .021f, .400f, .093f),
|
||||
.016f, trim, Surface.Cloth);
|
||||
for (int i = 0; i < 2; i++)
|
||||
Shell(SmallOrb, pelvis + trunk * new Vector3(0, .365f - i * .046f, .123f), Vector3.one * .007f, trunk,
|
||||
trim, Surface.Accessory);
|
||||
}
|
||||
}
|
||||
|
||||
private void HeldObject(GuestActivity activity, Vector3 palm, float yaw, float lift)
|
||||
{
|
||||
switch (activity)
|
||||
{
|
||||
case GuestActivity.Drink:
|
||||
Quaternion tilt = Quaternion.Euler(-15 - 37 * lift, yaw, 7);
|
||||
Vector3 bowl = palm + tilt * new Vector3(-.017f, .047f, .021f);
|
||||
Shell(SmallOrb, bowl, new Vector3(.035f, .042f, .035f), tilt, Glass, Surface.Accessory);
|
||||
Shell(SmallOrb, bowl + tilt * (Vector3.up * .020f), new Vector3(.029f, .015f, .029f), tilt, Paper, Surface.Accessory);
|
||||
Span(bowl - tilt * (Vector3.up * .031f), bowl - tilt * (Vector3.up * .077f), .008f, Linen, Surface.Accessory);
|
||||
Shell(SmallOrb, bowl - tilt * (Vector3.up * .076f), new Vector3(.026f, .004f, .026f), tilt, Linen, Surface.Accessory);
|
||||
break;
|
||||
case GuestActivity.Dine:
|
||||
Span(palm + new Vector3(-.012f, 0, -.02f), palm + new Vector3(-.013f, .021f * lift, .095f), .006f, Linen, Surface.Accessory);
|
||||
break;
|
||||
case GuestActivity.Read:
|
||||
Shell(SmallOrb, palm + new Vector3(-.068f, .038f, .028f), new Vector3(.106f, .065f, .011f), Quaternion.Euler(-45, yaw, 0),
|
||||
Paper, Surface.Accessory);
|
||||
break;
|
||||
case GuestActivity.Photograph:
|
||||
Shell(SmallOrb, palm + new Vector3(-.036f, .044f, .009f), new Vector3(.037f, .065f, .009f), Quaternion.Euler(-12 + lift * 23, yaw, 0),
|
||||
Strap, Surface.Accessory);
|
||||
break;
|
||||
case GuestActivity.Perform:
|
||||
Span(palm + new Vector3(-.009f, -.029f, .023f), palm + new Vector3(-.035f, .105f, .030f), .019f, Dark, Surface.Accessory);
|
||||
break;
|
||||
case GuestActivity.TendBar:
|
||||
float phase = Mathf.Repeat(passengerClock * .19f, 1);
|
||||
Quaternion bottle = Quaternion.Euler(-28 - 48 * lift, yaw + phase * 5, -11 + lift * 87);
|
||||
Shell(Orb, palm + bottle * new Vector3(-.023f, .067f, 0), new Vector3(.031f, .084f, .031f), bottle,
|
||||
Apron, Surface.Accessory);
|
||||
Span(palm + bottle * new Vector3(-.023f, .120f, 0), palm + bottle * new Vector3(-.023f, .183f, 0),
|
||||
.019f, Apron, Surface.Accessory);
|
||||
Shell(SmallOrb, palm + bottle * new Vector3(-.023f, .079f, 0), new Vector3(.032f, .027f, .032f), bottle,
|
||||
Paper, Surface.Accessory);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void Guitar(Vector3 pelvis)
|
||||
{
|
||||
Quaternion angle = Quaternion.Euler(-11, -5, 20);
|
||||
Shell(Orb, pelvis + new Vector3(.104f, .269f, .211f), new Vector3(.153f, .167f, .054f), angle, Paper, Surface.Accessory);
|
||||
Shell(Orb, pelvis + new Vector3(-.005f, .364f, .227f), new Vector3(.107f, .115f, .043f), angle, Paper, Surface.Accessory);
|
||||
Shell(SmallOrb, pelvis + new Vector3(.055f, .332f, .277f), new Vector3(.032f, .035f, .008f), angle, Dark, Surface.Accessory);
|
||||
Span(pelvis + new Vector3(.034f, .306f, .255f), pelvis + new Vector3(-.328f, .559f, .264f), .023f, Shoes, Surface.Accessory);
|
||||
}
|
||||
|
||||
private void ContactShadow(float width, float length)
|
||||
{
|
||||
int start = vertices.Count;
|
||||
byte alpha = (byte)(coverage * .38f);
|
||||
Emit(new Vector3(0, .012f, .042f), Vector3.up, ShadowTint, Surface.Contact, alpha);
|
||||
foreach (Vector2 point in Fine)
|
||||
Emit(new Vector3(point.x * width, .012f, .042f + point.y * length), Vector3.up, ShadowTint, Surface.Contact, 0);
|
||||
for (int edge = 0; edge < Fine.Length; edge++)
|
||||
{
|
||||
indices.Add(start);
|
||||
indices.Add(start + 1 + edge);
|
||||
indices.Add(start + 1 + (edge + 1) % Fine.Length);
|
||||
}
|
||||
}
|
||||
|
||||
private void PoolRipples(bool swimming, float time)
|
||||
{
|
||||
for (int ring = 0; ring < 2; ring++)
|
||||
{
|
||||
float age = Mathf.Repeat(time * (swimming ? 1.83f : .99f) + ring * .5f, 1);
|
||||
float span = Mathf.Lerp(.24f, .61f, age);
|
||||
float depth = span * (swimming ? .51f : .64f);
|
||||
float wakeZ = swimming ? -.36f - age * .22f : -.016f;
|
||||
int start = vertices.Count;
|
||||
byte alpha = (byte)(coverage * Mathf.Sin(age * Mathf.PI) * (swimming ? .55f : .34f));
|
||||
const int sections = 10;
|
||||
for (int step = 0; step <= sections; step++)
|
||||
{
|
||||
float phase = Mathf.Lerp(swimming ? .94f : .49f, swimming ? 5.20f : 5.89f, step / (float)sections);
|
||||
float x = Mathf.Sin(phase), z = Mathf.Cos(phase);
|
||||
float thickness = .018f * (.78f + .22f * Mathf.Sin(phase * 3 + time));
|
||||
Emit(new Vector3(x * span, .016f, wakeZ + z * depth), Vector3.up, WakeTint, Surface.Water, alpha);
|
||||
Emit(new Vector3(x * (span + thickness), .016f, wakeZ + z * (depth + thickness)), Vector3.up, WakeTint, Surface.Water, alpha);
|
||||
if (step > 0)
|
||||
{
|
||||
int a = start + (step - 1) * 2;
|
||||
TrianglePair(a, a + 1, a + 3, a + 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Sweep(Vector3 top, Vector3 middle, Vector3 bottom, float[] stations, float[] radii, Vector2[] division,
|
||||
float build, Color32 cloth, Color32 skin, float covered)
|
||||
{
|
||||
int start = vertices.Count;
|
||||
Vector3 upper = (middle - top).normalized;
|
||||
Vector3 lower = (bottom - middle).normalized;
|
||||
for (int i = 0; i < stations.Length; i++)
|
||||
{
|
||||
float t = stations[i];
|
||||
Vector3 center = t < .5f ? Vector3.Lerp(top, middle, 2 * t) : Vector3.Lerp(middle, bottom, 2 * t - 1);
|
||||
float round = Mathf.SmoothStep(0, 1, (t - .31f) / .37f);
|
||||
Vector3 axis = Vector3.Lerp(upper, lower, round).normalized;
|
||||
Vector3 across = Vector3.ProjectOnPlane(Mathf.Abs(axis.x) < .91f ? Vector3.right : Vector3.forward, axis).normalized;
|
||||
Vector3 depth = Vector3.Cross(across, axis);
|
||||
float radius = radii[i] * build;
|
||||
bool dressed = t <= covered && covered > 0;
|
||||
Color32 color = dressed ? cloth : skin;
|
||||
foreach (Vector2 point in division)
|
||||
{
|
||||
Vector3 offset = across * point.x + depth * point.y;
|
||||
Emit(center + radius * offset, offset, color, dressed ? Surface.Cloth : Surface.Skin, coverage);
|
||||
}
|
||||
}
|
||||
RingFaces(start, division.Length, stations.Length);
|
||||
}
|
||||
|
||||
private void Span(Vector3 from, Vector3 to, float radius, Color32 color, Surface kind)
|
||||
{
|
||||
Vector3 direction = to - from;
|
||||
float length = direction.magnitude;
|
||||
if (length > .001f)
|
||||
Shell(SmallOrb, (from + to) * .5f, new Vector3(radius, length * .66f, radius), Quaternion.FromToRotation(Vector3.up,
|
||||
direction / length), color, kind);
|
||||
}
|
||||
|
||||
private void Shell(Form form, Vector3 center, Vector3 size, Quaternion rotation, Color32 color, Surface kind)
|
||||
{
|
||||
int start = vertices.Count;
|
||||
Matrix4x4 position = Matrix4x4.TRS(center, rotation, size);
|
||||
Vector3 inverse = new(1 / size.x, 1 / size.y, 1 / size.z);
|
||||
for (int i = 0; i < form.Points.Length; i++)
|
||||
{
|
||||
Vector3 point = position.MultiplyPoint3x4(form.Points[i]);
|
||||
Vector3 normal = rotation * Vector3.Scale(form.Normals[i], inverse).normalized;
|
||||
Emit(point, normal, color, kind, coverage);
|
||||
}
|
||||
foreach (int index in form.Indices)
|
||||
indices.Add(start + index);
|
||||
}
|
||||
|
||||
private void Emit(Vector3 point, Vector3 normal, Color32 color, Surface kind, byte alpha)
|
||||
{
|
||||
color.a = alpha;
|
||||
colors.Add(color);
|
||||
vertices.Add(guestMatrix.MultiplyPoint3x4(point));
|
||||
normals.Add(guestRotation * normal);
|
||||
surface.Add(new Vector4(point.x, point.y, point.z, (int)kind));
|
||||
}
|
||||
|
||||
private void RingFaces(int start, int sides, int rings)
|
||||
{
|
||||
for (int ring = 0; ring < rings - 1; ring++)
|
||||
for (int i = 0; i < sides; i++)
|
||||
{
|
||||
int a = start + ring * sides + i;
|
||||
int b = start + ring * sides + (i + 1) % sides;
|
||||
TrianglePair(a, b, b + sides, a + sides);
|
||||
}
|
||||
}
|
||||
|
||||
private void TrianglePair(int a, int b, int c, int d)
|
||||
{
|
||||
indices.Add(a);
|
||||
indices.Add(b);
|
||||
indices.Add(c);
|
||||
indices.Add(a);
|
||||
indices.Add(c);
|
||||
indices.Add(d);
|
||||
}
|
||||
|
||||
private static Vector2[] Circle(int sides)
|
||||
{
|
||||
var points = new Vector2[sides];
|
||||
for (int i = 0; i < sides; i++)
|
||||
{
|
||||
float angle = Turn * i / sides;
|
||||
points[i] = new Vector2(Mathf.Sin(angle), Mathf.Cos(angle));
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
private readonly struct Ring
|
||||
{
|
||||
internal readonly float Height, Width, Depth, Shift, Nose;
|
||||
|
||||
internal Ring(float height, float width, float depth, float shift = 0, float nose = 0)
|
||||
{
|
||||
Height = height;
|
||||
Width = width;
|
||||
Depth = depth;
|
||||
Shift = shift;
|
||||
Nose = nose;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class Form
|
||||
{
|
||||
internal readonly Vector3[] Points, Normals;
|
||||
internal readonly int[] Indices;
|
||||
|
||||
internal Form(int sides, Ring[] rings) : this(sides, rings.Length, (band, angle) =>
|
||||
{
|
||||
Ring ring = rings[band];
|
||||
float front = Mathf.Pow(Mathf.Max(0, 1 - Mathf.Abs(angle.x) * 2.6f), 2) * Mathf.Max(0, angle.y);
|
||||
return new Vector3(ring.Width * angle.x, ring.Height, ring.Shift + ring.Depth * angle.y + ring.Nose * front);
|
||||
}) { }
|
||||
|
||||
private Form(int sides, int bands, System.Func<int, Vector2, Vector3> point)
|
||||
{
|
||||
Points = new Vector3[sides * bands];
|
||||
Normals = new Vector3[Points.Length];
|
||||
Indices = new int[sides * (bands - 1) * 6];
|
||||
Vector2[] circle = Circle(sides);
|
||||
for (int band = 0; band < bands; band++)
|
||||
for (int side = 0; side < sides; side++)
|
||||
{
|
||||
int a = band * sides + side;
|
||||
Points[a] = point(band, circle[side]);
|
||||
if (band == bands - 1)
|
||||
continue;
|
||||
int b = band * sides + (side + 1) % sides;
|
||||
int index = a * 6;
|
||||
Indices[index] = a;
|
||||
Indices[index + 1] = b;
|
||||
Indices[index + 2] = b + sides;
|
||||
Indices[index + 3] = a;
|
||||
Indices[index + 4] = b + sides;
|
||||
Indices[index + 5] = a + sides;
|
||||
}
|
||||
for (int i = 0; i < Indices.Length; i += 3)
|
||||
{
|
||||
int a = Indices[i], b = Indices[i + 1], c = Indices[i + 2];
|
||||
Vector3 normal = Vector3.Cross(Points[b] - Points[a], Points[c] - Points[a]);
|
||||
Normals[a] += normal;
|
||||
Normals[b] += normal;
|
||||
Normals[c] += normal;
|
||||
}
|
||||
for (int i = 0; i < Normals.Length; i++)
|
||||
Normals[i].Normalize();
|
||||
}
|
||||
|
||||
internal static Form Sphere(int sides, int bands) => new(sides, bands + 1, (band, angle) =>
|
||||
{
|
||||
float latitude = (band / (float)bands - .5f) * Mathf.PI * .9999f;
|
||||
return new Vector3(angle.x * Mathf.Cos(latitude), Mathf.Sin(latitude), angle.y * Mathf.Cos(latitude));
|
||||
});
|
||||
|
||||
internal static Form Hair(int sides, int bands, float fringe, float wave) => new(sides, bands + 1, (band, angle) =>
|
||||
{
|
||||
float heading = Mathf.Atan2(angle.x, angle.y);
|
||||
float slope = .19f + .77f * angle.y + Mathf.Abs(angle.x) * fringe * 6 + wave * 19 * Mathf.Sin(heading * 3 + .67f);
|
||||
float latitude = Mathf.Lerp(slope, 1.5707f, band / (float)bands);
|
||||
float part = 1 + .03f * Mathf.Cos(heading * 6.9f + latitude * 1.31f);
|
||||
return new Vector3(.102f * angle.x * Mathf.Cos(latitude) * part, .041f + Mathf.Sin(latitude) * (.122f + wave),
|
||||
-.026f + .103f * angle.y * Mathf.Cos(latitude) * part);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Soundings/Runtime/PassengerFigure.cs.meta
Normal file
2
Assets/Soundings/Runtime/PassengerFigure.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 962f929589ab7880d80f2b6b00ceab30
|
||||
96
Assets/Soundings/Runtime/PortCinematics.cs
Normal file
96
Assets/Soundings/Runtime/PortCinematics.cs
Normal file
@@ -0,0 +1,96 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace Soundings
|
||||
{
|
||||
public sealed partial class SoundingsApp
|
||||
{
|
||||
private int cinematicPort;
|
||||
private bool cinematicArrival;
|
||||
private float cinematicTime;
|
||||
private VisualElement cinematicFade;
|
||||
private Label cinematicCaption;
|
||||
|
||||
private bool StartPortCinematic(int port, bool arrival)
|
||||
{
|
||||
if (!harbor.BeginPortCinematic(port, arrival))
|
||||
return false;
|
||||
|
||||
cinematicPort = port;
|
||||
cinematicArrival = arrival;
|
||||
cinematicTime = 0;
|
||||
Render();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void UpdatePortCinematic(float delta)
|
||||
{
|
||||
cinematicTime += delta;
|
||||
if (cinematicTime >= Harbor.PortCinematicDuration)
|
||||
{
|
||||
EndPortCinematic();
|
||||
return;
|
||||
}
|
||||
|
||||
float progress = cinematicTime / Harbor.PortCinematicDuration;
|
||||
float knots = cinematicArrival ? Mathf.Lerp(9, 0, progress) : Mathf.Lerp(1, 10, progress);
|
||||
passageAudio.Mix(delta, true, knots, underway.Weather, false, false);
|
||||
PresentPortCinematicFrame(delta);
|
||||
}
|
||||
|
||||
private void PresentPortCinematicFrame(float delta)
|
||||
{
|
||||
harbor.PresentPortCinematic(cinematicTime);
|
||||
harbor.UpdatePassengers(livePassage, delta);
|
||||
UpdatePortCinematicTitles();
|
||||
}
|
||||
|
||||
private void EndPortCinematic()
|
||||
{
|
||||
if (!harbor.PortCinematicActive)
|
||||
return;
|
||||
|
||||
harbor.EndPortCinematic();
|
||||
cinematicFade = null;
|
||||
cinematicCaption = null;
|
||||
if (cinematicArrival)
|
||||
CompleteDocking();
|
||||
else
|
||||
{
|
||||
PresentVessel(0);
|
||||
Render();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawPortCinematic()
|
||||
{
|
||||
var screen = Add(root, "port-cinematic");
|
||||
screen.name = "port-cinematic";
|
||||
AddHarbor(Add(screen, "harbor-viewport"));
|
||||
var top = Add(screen, "port-cinematic-bar port-cinematic-top");
|
||||
var bottom = Add(screen, "port-cinematic-bar port-cinematic-bottom");
|
||||
top.pickingMode = bottom.pickingMode = PickingMode.Ignore;
|
||||
var titleCard = Add(bottom, "port-cinematic-title-card");
|
||||
PortSpec port = Market.Ports[cinematicPort];
|
||||
string maneuver = cinematicArrival ? "ARRIVAL" : "DEPARTURE";
|
||||
AddText(titleCard, $"{maneuver} · {Ship.Name}", "port-cinematic-kicker");
|
||||
AddDisplay(titleCard, port.Name, "port-cinematic-title").name = "port-cinematic-name";
|
||||
cinematicCaption = AddText(bottom, "", "port-cinematic-caption");
|
||||
cinematicFade = Add(screen, "port-cinematic-fade");
|
||||
cinematicFade.pickingMode = PickingMode.Ignore;
|
||||
Button skip = Action("Skip · Esc", EndPortCinematic, "port-cinematic-skip", "port-cinematic-skip");
|
||||
skip.tooltip = "Skip this port cinematic";
|
||||
bottom.Add(skip);
|
||||
UpdatePortCinematicTitles();
|
||||
}
|
||||
|
||||
private void UpdatePortCinematicTitles()
|
||||
{
|
||||
float timeLeft = Harbor.PortCinematicDuration - cinematicTime;
|
||||
cinematicFade.style.opacity = 1 - Mathf.SmoothStep(0, 1, Mathf.Min(cinematicTime / .28f, timeLeft / .32f));
|
||||
string caption = passageAudio.Caption ?? "";
|
||||
if (cinematicCaption.text != caption)
|
||||
cinematicCaption.text = caption;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Soundings/Runtime/PortCinematics.cs.meta
Normal file
2
Assets/Soundings/Runtime/PortCinematics.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4ace61514e7c0702fbd67610f3b5965d
|
||||
61
Assets/Soundings/Runtime/PortClipExport.cs
Normal file
61
Assets/Soundings/Runtime/PortClipExport.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Soundings
|
||||
{
|
||||
public sealed partial class SoundingsApp
|
||||
{
|
||||
private const int PortClipFrameRate = 24;
|
||||
private bool holdCinematicClock;
|
||||
|
||||
private IEnumerator ExportPortClips(string output)
|
||||
{
|
||||
Directory.CreateDirectory(output);
|
||||
Time.captureFramerate = PortClipFrameRate;
|
||||
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();
|
||||
Time.captureFramerate = 0;
|
||||
holdCinematicClock = false;
|
||||
Debug.Log("Soundings port clips exported to " + output);
|
||||
Application.Quit(0);
|
||||
}
|
||||
|
||||
private IEnumerator WritePortFrames(string output, string name)
|
||||
{
|
||||
if (!harbor.PortCinematicActive)
|
||||
throw new IOException("No port cinematic started for " + name);
|
||||
|
||||
float step = 1f / PortClipFrameRate;
|
||||
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++)
|
||||
{
|
||||
cinematicTime = frame * step;
|
||||
PresentPortCinematicFrame(step);
|
||||
yield return rendered;
|
||||
Texture2D image = ScreenCapture.CaptureScreenshotAsTexture();
|
||||
try
|
||||
{
|
||||
if (frame == 0)
|
||||
File.WriteAllText(Path.Combine(output, name + ".txt"), $"{image.width} {image.height} {image.format} {PortClipFrameRate}");
|
||||
byte[] bytes = image.GetRawTextureData();
|
||||
stream.Write(bytes, 0, bytes.Length);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Destroy(image);
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Soundings/Runtime/PortClipExport.cs.meta
Normal file
2
Assets/Soundings/Runtime/PortClipExport.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7bb44b4f955e3b6e9008ed5f079b788
|
||||
@@ -38,7 +38,10 @@ namespace Soundings
|
||||
private void Initialize()
|
||||
{
|
||||
System.Globalization.CultureInfo.CurrentCulture = System.Globalization.CultureInfo.GetCultureInfo("en-US");
|
||||
autoSmoke = Array.IndexOf(Environment.GetCommandLineArgs(), "-soundings-smoke") >= 0;
|
||||
string[] arguments = Environment.GetCommandLineArgs();
|
||||
int clipArgument = Array.IndexOf(arguments, "-soundings-port-clips");
|
||||
bool exportClips = clipArgument >= 0 && clipArgument + 1 < arguments.Length;
|
||||
autoSmoke = exportClips || Array.IndexOf(arguments, "-soundings-smoke") >= 0;
|
||||
Application.targetFrameRate = 60;
|
||||
harbor = gameObject.AddComponent<Harbor>();
|
||||
harbor.Initialize();
|
||||
@@ -66,7 +69,9 @@ namespace Soundings
|
||||
}
|
||||
company = autoSmoke ? null : Load();
|
||||
Render();
|
||||
if (autoSmoke)
|
||||
if (exportClips)
|
||||
StartCoroutine(ExportPortClips(arguments[clipArgument + 1]));
|
||||
else if (autoSmoke)
|
||||
StartCoroutine(VisualSmoke());
|
||||
}
|
||||
|
||||
@@ -196,6 +201,8 @@ namespace Soundings
|
||||
|
||||
if (title || company == null)
|
||||
DrawTitle();
|
||||
else if (harbor.PortCinematicActive)
|
||||
DrawPortCinematic();
|
||||
else
|
||||
{
|
||||
RefreshGuide();
|
||||
|
||||
@@ -6,6 +6,8 @@ namespace Soundings
|
||||
internal sealed class VesselExterior
|
||||
{
|
||||
internal const float DeckBase = 5.38f, DeckSpacing = 2.62f;
|
||||
internal const float PoolHalfLength = 2.61f, PoolHalfWidth = 1.43f, PoolWaterHeight = .24f;
|
||||
internal const float LoungerSeatHeight = .32f, LoungerBeamFraction = .67f;
|
||||
private const int HullStations = 36, DeckStations = 28, BridgeStations = 20;
|
||||
internal enum Paint
|
||||
{
|
||||
@@ -299,7 +301,7 @@ namespace Soundings
|
||||
Coat(Paint.Pearl).Radome(radome + Vector3.up * .90f, .54f);
|
||||
}
|
||||
|
||||
BuildSunDeck(offset + deckLength * .01f, top, deckBeam);
|
||||
BuildSunDeck(SunDeckCenter(length, deck), top, deckBeam);
|
||||
}
|
||||
|
||||
private void BuildBridgeWing(float bridge, float top, int side)
|
||||
@@ -322,40 +324,69 @@ namespace Soundings
|
||||
|
||||
private void BuildSunDeck(float pool, float top, float deckBeam)
|
||||
{
|
||||
Vector2 center = new Vector2(pool, 0);
|
||||
Vector2[] coping = RoundedRectangle(center, 2.88f, 1.70f, .41f);
|
||||
Coat(Paint.Pearl).Loft(coping, center, true, new Vector3(1, top, 1),
|
||||
new Vector3(1, top + .18f, 1), new Vector3(.989f, top + .23f, .987f));
|
||||
Coat(Paint.BlueGlass).Loft(RoundedRectangle(center, 2.68f, 1.50f, .32f), center, true,
|
||||
new Vector3(1, top + .234f, 1));
|
||||
Coat(Paint.Pool).Loft(RoundedRectangle(center, 2.61f, 1.43f, .27f), center, true,
|
||||
new Vector3(1, top + .24f, 1));
|
||||
bool hasPool = ship.Count(Facility.Amenity) > 0;
|
||||
if (hasPool)
|
||||
PoolBasin(Coat(Paint.Pearl), Coat(Paint.BlueGlass), Coat(Paint.Pool), new Vector3(pool, top, 0),
|
||||
new Vector2(PoolHalfLength, PoolHalfWidth), .37f, PoolWaterHeight);
|
||||
|
||||
for (int side = -1; side <= 1; side += 2)
|
||||
{
|
||||
float railZ = side * 1.58f;
|
||||
for (int rail = -1; rail <= 1; rail += 2)
|
||||
{
|
||||
var foot = new Vector3(pool - 2.08f + rail * .24f, top + .035f, railZ + side * .37f);
|
||||
var elbow = foot + new Vector3(0, .68f, side * -.05f);
|
||||
var end = foot + new Vector3(0, .32f, side * -.64f);
|
||||
Coat(Paint.Steel).Rod(foot, elbow, .026f, 8, true);
|
||||
Coat(Paint.Steel).Rod(elbow, end, .026f, 8, true);
|
||||
}
|
||||
if (hasPool)
|
||||
PoolRails(Coat(Paint.Steel), new Vector3(pool - 2.08f, top, side * PoolHalfWidth), side);
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
float x = pool - 3.00f + i * .94f;
|
||||
BuildLounger(x, top, deckBeam * .67f, side);
|
||||
}
|
||||
BuildLounger(LoungerX(pool, i), top, deckBeam * LoungerBeamFraction, side);
|
||||
BuildParasol(new Vector3(pool + 3.81f, top, side * deckBeam * .55f), side > 0);
|
||||
}
|
||||
}
|
||||
|
||||
internal static void PoolBasin(HarborMesh coping, HarborMesh tile, HarborMesh water, Vector3 foot,
|
||||
Vector2 halfSize, float rimHeight, float waterHeight)
|
||||
{
|
||||
Vector2 center = new Vector2(foot.x, foot.z);
|
||||
float radius = Mathf.Min(.31f, halfSize.y * .45f);
|
||||
const float surround = .23f;
|
||||
Vector2[] inner = RoundedRectangle(center, halfSize.x, halfSize.y, radius);
|
||||
Vector2[] outer = RoundedRectangle(center, halfSize.x + surround, halfSize.y + surround, radius + surround);
|
||||
float rim = foot.y + rimHeight;
|
||||
float surface = foot.y + waterHeight;
|
||||
coping.Loft(outer, center, false, new Vector3(1f, foot.y, 1f), new Vector3(1f, rim, 1f));
|
||||
water.Loft(inner, center, true, new Vector3(1f, surface, 1f));
|
||||
for (int i = 0; i < outer.Length; i++)
|
||||
{
|
||||
int next = (i + 1) % outer.Length;
|
||||
coping.Quad(HarborMesh.Point(outer[next], rim), HarborMesh.Point(outer[i], rim),
|
||||
HarborMesh.Point(inner[i], rim), HarborMesh.Point(inner[next], rim));
|
||||
tile.Quad(HarborMesh.Point(inner[i], surface), HarborMesh.Point(inner[next], surface),
|
||||
HarborMesh.Point(inner[next], rim), HarborMesh.Point(inner[i], rim));
|
||||
}
|
||||
}
|
||||
|
||||
internal static void PoolRails(HarborMesh steel, Vector3 edge, int side)
|
||||
{
|
||||
for (int rail = -1; rail <= 1; rail += 2)
|
||||
{
|
||||
Vector3 foot = edge + new Vector3(rail * .23f, .03f, side * .36f);
|
||||
Vector3 elbow = foot + new Vector3(0, .72f, -side * .13f);
|
||||
Vector3 end = foot + new Vector3(0, .31f, -side * .55f);
|
||||
steel.Rod(foot, elbow, .028f, 8, true);
|
||||
steel.Rod(elbow, end, .028f, 8, true);
|
||||
}
|
||||
for (int rung = 0; rung < 2; rung++)
|
||||
{
|
||||
Vector3 left = edge + new Vector3(-.23f, .14f + rung * .18f, -side * .15f);
|
||||
steel.Rod(left, left + Vector3.right * .46f, .024f, 8, true);
|
||||
}
|
||||
}
|
||||
|
||||
internal static float SunDeckCenter(float length, int deck) => DeckOffset(length, deck) + DeckLength(length, deck) * .01f;
|
||||
|
||||
internal static float LoungerX(float center, int index) => center - 3f + index * .94f;
|
||||
|
||||
private void BuildLounger(float x, float top, float sideDistance, int side)
|
||||
{
|
||||
Vector3 seat = new Vector3(x, top + .32f, side * sideDistance);
|
||||
Vector3 head = seat + new Vector3(0, .38f, side * .57f);
|
||||
Coat(Paint.DeckCanvas).Box(seat + Vector3.back * (side * .14f), new Vector3(.54f, .077f, .88f));
|
||||
Vector3 seat = new Vector3(x, top + LoungerSeatHeight, side * sideDistance);
|
||||
Vector3 head = seat + new Vector3(0, .38f, side * .64f);
|
||||
Coat(Paint.DeckCanvas).Box(seat + Vector3.back * (side * .31f), new Vector3(.54f, .077f, 1.22f));
|
||||
Vector3 halfWidth = Vector3.right * .262f;
|
||||
Vector3 hinge = seat + Vector3.forward * (side * .30f);
|
||||
Coat(Paint.DeckCanvas).Quad(hinge - halfWidth, side > 0 ? head - halfWidth : hinge + halfWidth,
|
||||
@@ -364,9 +395,9 @@ namespace Soundings
|
||||
for (int rail = -1; rail <= 1; rail += 2)
|
||||
{
|
||||
Vector3 edge = Vector3.right * (rail * .29f);
|
||||
frame.Rod(seat + edge + Vector3.forward * (side * -.56f), hinge + edge, .026f);
|
||||
frame.Rod(seat + edge + Vector3.back * (side * .92f), hinge + edge, .026f);
|
||||
frame.Rod(hinge + edge, head + edge, .026f);
|
||||
frame.Rod(seat + edge + Vector3.back * (side * .37f), seat + edge + new Vector3(0, -.32f, side * -.46f), .026f);
|
||||
frame.Rod(seat + edge + Vector3.back * (side * .67f), seat + edge + new Vector3(0, -.32f, side * -.76f), .026f);
|
||||
frame.Rod(hinge + edge, hinge + edge + new Vector3(0, -.32f, side * .10f), .026f);
|
||||
}
|
||||
frame.Rod(head - halfWidth, head + halfWidth, .023f);
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace Soundings
|
||||
|
||||
string directory = args[index + 1];
|
||||
Directory.CreateDirectory(directory);
|
||||
if (!CheckSmoke(Harbor.AllPortsHaveScenery, "Every destination has a port scenery profile"))
|
||||
yield break;
|
||||
for (int port = 0; port < Market.Ports.Count; port++)
|
||||
{
|
||||
if (!CheckSmoke(PassageAudio.LoadPortClip("Departure", port) is { length: > 1 }
|
||||
@@ -77,12 +79,26 @@ namespace Soundings
|
||||
yield break;
|
||||
if (!SubmitSmoke("dispatch") || !CheckSmoke(underway != null && livePassage != null && Ship.Port == 0
|
||||
&& company.Voyages == 0 && PassageDuration(underway) >= 120 && livePassage.Assisted && underway.Weather == WeatherCondition.Calm
|
||||
&& guideContext == GuideStep.AtSea && root.Q<Button>("guide-skip") != null
|
||||
&& underway.Plan?.FoodUnits == 1120 && underway.Plan.Program == EntertainmentProgram.LiveMusic,
|
||||
"Cast off into an assisted live crossing"))
|
||||
yield break;
|
||||
if (!CheckSmoke(passageAudio.CurrentAnnouncement == PassageAnnouncement.Departure
|
||||
&& passageAudio.Caption.Contains("next port of call is Nassau"), "Cast off names Nassau on the ship's PA"))
|
||||
if (!CheckSmoke(harbor.PortCinematicActive && Harbor.PortCinematicDuration < 5
|
||||
&& root.Q<Label>("port-cinematic-name")?.text == "Miami"
|
||||
&& passageAudio.CurrentAnnouncement == PassageAnnouncement.Departure
|
||||
&& passageAudio.Caption.Contains("next port of call is Nassau"), "Cast off at Miami with a short cinematic and named PA"))
|
||||
yield break;
|
||||
Vector3 departureStart = harbor.PassageWorldPosition;
|
||||
yield return new WaitForSecondsRealtime(1.3f);
|
||||
if (!CheckSmoke(harbor.PortCinematicActive && passageHelm.Progress == 0
|
||||
&& Vector3.Distance(departureStart, harbor.PassageWorldPosition) > 1,
|
||||
"Departure moves the ship through the harbor before starting the voyage clock")
|
||||
|| !CheckSmoke(harbor.HasActiveGuest(GuestActivity.Swim) && harbor.HasActiveGuest(GuestActivity.Wade)
|
||||
&& harbor.HasActiveGuest(GuestActivity.Lounge), "Guests swim, wade, and use the pool loungers in calm weather"))
|
||||
yield break;
|
||||
holdCinematicClock = true;
|
||||
yield return CapturePortAndSkipSmoke(directory, "03a-departure-cinematic");
|
||||
if (!CheckSmoke(!harbor.PortCinematicActive
|
||||
&& guideContext == GuideStep.AtSea && root.Q<Button>("guide-skip") != null, "Skipping the shot hands control to the voyage"))
|
||||
yield break;
|
||||
int mealPrice = livePassage.GetPrice(OnboardService.Meals);
|
||||
int provisions = livePassage.ProvisionsRemaining;
|
||||
@@ -142,6 +158,10 @@ namespace Soundings
|
||||
if (!SubmitSmoke("passage-deck-1") || !CheckSmoke(passageDeck == 1, "Inspect the second guest deck"))
|
||||
yield break;
|
||||
yield return CaptureSmoke(directory, "06-guest-deck");
|
||||
if (!CheckSmoke(harbor.HasActiveGuest(GuestActivity.Drink) && harbor.HasActiveGuest(GuestActivity.TendBar)
|
||||
&& harbor.HasActiveGuest(GuestActivity.Dine) && harbor.HasActiveGuest(GuestActivity.Watch),
|
||||
"The fitted bar, dining room, and entertainment venue are active"))
|
||||
yield break;
|
||||
float deckOverview = harbor.OrbitVerticalSpan;
|
||||
harbor.Zoom(-90, new Vector2(.57f, .46f));
|
||||
yield return new WaitForSecondsRealtime(.65f);
|
||||
@@ -152,6 +172,10 @@ namespace Soundings
|
||||
harbor.Zoom(-19, new Vector2(.43f, .49f));
|
||||
yield return new WaitForSecondsRealtime(.55f);
|
||||
yield return CaptureSmoke(directory, "06-guest-deck-close-up");
|
||||
harbor.ResetView(true);
|
||||
harbor.Zoom(-19, new Vector2(.67f, .39f));
|
||||
yield return new WaitForSecondsRealtime(.55f);
|
||||
yield return CaptureSmoke(directory, "06-bar-service-close-up");
|
||||
if (!SubmitSmoke("passage-bridge") || !CheckSmoke(passageBridge && harbor.FirstPersonPositionIsClear, "Enter the first-person bridge"))
|
||||
yield break;
|
||||
yield return CaptureSmoke(directory, "06a-bridge");
|
||||
@@ -221,8 +245,18 @@ namespace Soundings
|
||||
yield return new WaitForSecondsRealtime(.15f);
|
||||
if (!CheckSmoke(passageHelm.Position == pausedPosition, "Paused passage clock") || !SubmitSmoke("resume-game"))
|
||||
yield break;
|
||||
if (!SubmitSmoke("dock-now") || !CheckSmoke(Ship.Port == 1 && company.Voyages == 1 && page == 4 && guideContext == GuideStep.Review
|
||||
&& company.History[0].Plan.FoodUnits == 1120 && company.History[0].Onboard.CrewCalls == 1, "Arrival settles once and records the orders and crew call"))
|
||||
if (!SubmitSmoke("dock-now") || !CheckSmoke(harbor.PortCinematicActive && Ship.Port == 1 && company.Voyages == 1
|
||||
&& root.Q<Label>("port-cinematic-name")?.text == "Nassau", "Arrival shot opens on the destination after settlement"))
|
||||
yield break;
|
||||
FinishVoyage();
|
||||
yield return new WaitForSecondsRealtime(1.4f);
|
||||
if (!CheckSmoke(harbor.PortCinematicActive && company.Voyages == 1, "Arrival cannot settle the voyage twice"))
|
||||
yield break;
|
||||
yield return CaptureSmoke(directory, "07-arrival-cinematic");
|
||||
yield return new WaitUntil(() => !harbor.PortCinematicActive);
|
||||
if (!CheckSmoke(underway == null && page == 4 && guideContext == GuideStep.Review
|
||||
&& company.History[0].Plan.FoodUnits == 1120 && company.History[0].Onboard.CrewCalls == 1,
|
||||
"Arrival hands off to the logbook with the passenger orders and crew call"))
|
||||
yield break;
|
||||
yield return CaptureSmoke(directory, "07-logbook");
|
||||
if (!SubmitSmoke("voyage-0") || !SubmitSmoke("log-accounts") || !SubmitSmoke("log-voyages")
|
||||
@@ -263,6 +297,10 @@ namespace Soundings
|
||||
&& livePassage.Get(OnboardService.Amenities).Capacity == 0 && passageAudio.Caption.Contains("Miami"),
|
||||
"Depart for the first planned call in a storm"))
|
||||
yield break;
|
||||
yield return new WaitUntil(() => !harbor.PortCinematicActive);
|
||||
if (!CheckSmoke(!harbor.HasActiveGuest(GuestActivity.Swim) && !harbor.HasActiveGuest(GuestActivity.Wade),
|
||||
"Storm conditions close the pool"))
|
||||
yield break;
|
||||
SelectPassageDeck(2);
|
||||
if (!CheckSmoke(passageDeck == 2, "Visit the newly fitted third deck during the next crossing"))
|
||||
yield break;
|
||||
@@ -282,7 +320,7 @@ namespace Soundings
|
||||
&& passageAudio.Caption.Contains("approaching Miami"), "The ship announces its approach to Miami before docking"))
|
||||
yield break;
|
||||
yield return CaptureSmoke(directory, "11b-approaching-miami");
|
||||
float timeout = Time.realtimeSinceStartup + 15;
|
||||
float timeout = Time.realtimeSinceStartup + 20;
|
||||
while (underway != null && Time.realtimeSinceStartup < timeout)
|
||||
yield return null;
|
||||
if (!CheckSmoke(underway == null && Ship.Port == 0 && company.Voyages == 2
|
||||
@@ -300,15 +338,20 @@ namespace Soundings
|
||||
|| !CheckSmoke(underway.Origin == 0 && underway.Destination == 2 && passageAudio.Caption.Contains("Key West"),
|
||||
"Fuel at the intermediate stop and cast off with the correct new port name"))
|
||||
yield break;
|
||||
if (!SubmitSmoke("port-cinematic-skip"))
|
||||
yield break;
|
||||
MovePassageToSmoke(.9f);
|
||||
UpdatePortApproach();
|
||||
if (!CheckSmoke(passageAudio.CurrentAnnouncement == PassageAnnouncement.Approach
|
||||
&& passageAudio.Caption.Contains("approaching Key West"), "The second leg announces Key West")
|
||||
|| !SubmitSmoke("dock-now") || !CheckSmoke(Ship.Port == 2 && company.Voyages == 3
|
||||
&& Ship.Itinerary is { CompletedStops: 2, HasNext: false }
|
||||
&& company.History[0].ItineraryLeg == 2 && company.History[0].ItineraryStartDay == company.History[1].ItineraryStartDay,
|
||||
&& company.History[0].ItineraryLeg == 2 && company.History[0].ItineraryStartDay == company.History[1].ItineraryStartDay
|
||||
&& root.Q<Label>("port-cinematic-name")?.text == "Key West",
|
||||
"Complete the itinerary with two linked ledger records"))
|
||||
yield break;
|
||||
holdCinematicClock = true;
|
||||
yield return CapturePortAndSkipSmoke(directory, "11d-key-west-cinematic", 1.4f);
|
||||
yield return CaptureSmoke(directory, "11d-itinerary-complete");
|
||||
|
||||
if (!SubmitSmoke("company-menu") || !SubmitSmoke("return-title") || !SubmitSmoke("start-financed") || !SubmitSmoke("replace")
|
||||
@@ -361,7 +404,13 @@ namespace Soundings
|
||||
yield break;
|
||||
yield return CaptureSmoke(directory, "16-ocean-class-hull");
|
||||
if (!SubmitSmoke("plan-voyage") || !SubmitSmoke("port-1") || !SubmitSmoke("dispatch")
|
||||
|| !SubmitSmoke("passage-deck-7") || !CheckSmoke(passageDeck == 7, "Select the eighth deck during the voyage"))
|
||||
|| !CheckSmoke(harbor.PortCinematicActive && Ship.Name == "MV Crownhaven" && Ship.Decks.Count == 8,
|
||||
"A custom eight-deck flagship casts off in the live cinematic"))
|
||||
yield break;
|
||||
holdCinematicClock = true;
|
||||
yield return CapturePortAndSkipSmoke(directory, "16b-ocean-class-departure", 1.4f);
|
||||
if (!SubmitSmoke("passage-deck-7")
|
||||
|| !CheckSmoke(passageDeck == 7, "Select the eighth deck during the voyage"))
|
||||
yield break;
|
||||
yield return CaptureSmoke(directory, "17-ocean-class-cutaway");
|
||||
harbor.Zoom(-90, new Vector2(.48f, .53f));
|
||||
@@ -410,6 +459,18 @@ namespace Soundings
|
||||
return condition;
|
||||
}
|
||||
|
||||
private IEnumerator CapturePortAndSkipSmoke(string directory, string name, float time = -1f)
|
||||
{
|
||||
if (time >= 0)
|
||||
{
|
||||
cinematicTime = time;
|
||||
PresentPortCinematicFrame(time);
|
||||
}
|
||||
yield return CaptureSmoke(directory, name);
|
||||
SubmitSmoke("port-cinematic-skip");
|
||||
holdCinematicClock = false;
|
||||
}
|
||||
|
||||
private static IEnumerator CaptureSmoke(string directory, string name)
|
||||
{
|
||||
yield return null;
|
||||
|
||||
@@ -17,6 +17,17 @@ namespace Soundings
|
||||
if (root == null)
|
||||
return;
|
||||
|
||||
if (harbor.PortCinematicActive)
|
||||
{
|
||||
if (holdCinematicClock)
|
||||
return;
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
EndPortCinematic();
|
||||
else
|
||||
UpdatePortCinematic(Time.unscaledDeltaTime);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
if (!paused && underway != null && voyageMapOpen)
|
||||
@@ -227,7 +238,8 @@ namespace Soundings
|
||||
harbor.ShowDeck(passageDeck);
|
||||
harbor.UpdatePassengers(livePassage, 0);
|
||||
passageAudio.Begin(quote.Destination);
|
||||
Render();
|
||||
if (!StartPortCinematic(quote.Origin, false))
|
||||
Render();
|
||||
}
|
||||
|
||||
private void SelectPassageDeck(int index)
|
||||
@@ -297,12 +309,38 @@ namespace Soundings
|
||||
|
||||
private void FinishVoyage()
|
||||
{
|
||||
if (underway == null || paused)
|
||||
if (underway == null || paused || harbor.PortCinematicActive)
|
||||
return;
|
||||
Voyage voyage = underway;
|
||||
livePassage.AdvanceTo(1);
|
||||
string failure = company.Sail(Ship, voyage.Destination, livePassage);
|
||||
if (failure != null)
|
||||
{
|
||||
Notify(failure, true);
|
||||
CompleteDocking();
|
||||
return;
|
||||
}
|
||||
|
||||
ResetItinerary();
|
||||
selectedVoyage = 0;
|
||||
ledgerRecordOffset = 0;
|
||||
ledgerAccounts = false;
|
||||
page = 4;
|
||||
ReviewGuideVoyage();
|
||||
string arrival = $"Arrived in {Market.Ports[voyage.Destination].Name}.";
|
||||
if (voyage.ItineraryLeg > 0)
|
||||
arrival += Ship.Itinerary is { HasNext: true } itinerary
|
||||
? $" Next call is {Market.Ports[itinerary.NextPort].Name}."
|
||||
: " Itinerary complete.";
|
||||
Notify(arrival);
|
||||
Save();
|
||||
passageAudio.AnnounceApproach();
|
||||
if (!StartPortCinematic(voyage.Destination, true))
|
||||
CompleteDocking();
|
||||
}
|
||||
|
||||
private void CompleteDocking()
|
||||
{
|
||||
underway = null;
|
||||
livePassage = null;
|
||||
passageHelm = null;
|
||||
@@ -312,22 +350,7 @@ namespace Soundings
|
||||
serviceReadout = null;
|
||||
SetPassageFreeLook(false);
|
||||
harbor.EndPassage();
|
||||
|
||||
if (failure == null)
|
||||
{
|
||||
ResetItinerary();
|
||||
selectedVoyage = 0;
|
||||
ledgerRecordOffset = 0;
|
||||
ledgerAccounts = false;
|
||||
page = 4;
|
||||
ReviewGuideVoyage();
|
||||
}
|
||||
string arrival = $"Arrived in {Market.Ports[voyage.Destination].Name}.";
|
||||
if (failure == null && voyage.ItineraryLeg > 0)
|
||||
arrival += Ship.Itinerary is { HasNext: true } itinerary
|
||||
? $" Next call is {Market.Ports[itinerary.NextPort].Name}."
|
||||
: " Itinerary complete.";
|
||||
Apply(failure, arrival);
|
||||
Render();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user