44 lines
1.8 KiB
C#
44 lines
1.8 KiB
C#
using UnityEngine;
|
|
|
|
namespace BigShipTycoon
|
|
{
|
|
public enum SunDeckZone { Sky, AftTerrace }
|
|
|
|
internal static class MegaDeckGeometry
|
|
{
|
|
internal static (float Length, float Beam, float Offset) ForShip(Ship ship, int deck, int deckCount)
|
|
{
|
|
float length = ship.Hull.Length, halfBeam = ship.Hull.Beam * .5f;
|
|
return ship.HullIndex == Market.Mega ? Footprint(length, halfBeam, deck, deckCount)
|
|
: (VesselExterior.DeckLength(length, deck), VesselExterior.DeckHalfBeam(halfBeam, deck),
|
|
VesselExterior.DeckOffset(length, deck));
|
|
}
|
|
|
|
internal static (float Length, float Beam, float Offset) Footprint(float length, float halfBeam, int deck, int deckCount)
|
|
{
|
|
bool sky = deck == deckCount - 1;
|
|
float aft = sky ? -.215f : -.444f + deck * .0018f;
|
|
float fore = .458f - deck * .0041f;
|
|
float width = halfBeam * (.952f - deck * .010f - (sky ? .027f : 0));
|
|
return ((fore - aft) * length, width, (fore + aft) * length * .5f);
|
|
}
|
|
|
|
internal static Rect TerraceArea(float length, float halfBeam, int deckCount)
|
|
{
|
|
float width = halfBeam * .49f;
|
|
return new Rect(-length * .367f, -width, length * .134f, 2 * width);
|
|
}
|
|
|
|
internal static float BridgeCenter(Ship ship, int deckCount)
|
|
{
|
|
if (ship.HullIndex != Market.Mega)
|
|
return VesselExterior.BridgeCenter(ship.Hull.Length, deckCount);
|
|
var (length, _, offset) = ForShip(ship, deckCount - 1, deckCount);
|
|
return offset + length * .285f;
|
|
}
|
|
|
|
internal static float RoofHeight(int count, SunDeckZone zone) => VesselExterior.DeckBase
|
|
+ (count - (zone == SunDeckZone.AftTerrace ? 1 : 0)) * VesselExterior.DeckSpacing;
|
|
}
|
|
}
|