using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace MarinersHUD
{
[BepInPlugin("com.dixiecapt.sailwind.marinershud", "MarinersHUD", "1.0.1")]
public class MarinersHUDPlugin : BaseUnityPlugin
{
public static class PluginInfo
{
public const string GUID = "com.dixiecapt.sailwind.marinershud";
public const string Name = "MarinersHUD";
public const string Version = "1.0.1";
}
private class ShipProfile
{
public string NameContains;
public float MaxWeightLbs;
public float EmptyWeightLbs;
public bool HasEmptyWeight;
}
private struct HudLine
{
public string Text;
public Color Color;
}
private class HudSection
{
public string Name;
public ConfigEntry<bool> Toggle;
public List<HudLine> Lines = new List<HudLine>();
}
public static BoatDamage CurrentBoatDamage;
private static readonly FieldInfo SelfMassField = AccessTools.Field(typeof(BoatMass), "selfMass");
private static readonly FieldInfo PartsMassField = AccessTools.Field(typeof(BoatMass), "partsMass");
private static readonly FieldInfo ItemsOnBoatField = AccessTools.Field(typeof(BoatMass), "itemsOnBoat");
private static readonly FieldInfo CloudyBorderField = AccessTools.Field(typeof(WeatherStorms), "cloudyBorder");
private static readonly FieldInfo RainBorderField = AccessTools.Field(typeof(WeatherStorms), "rainBorder");
private const float PlayerMassLbs = 160f;
private static readonly string[] CompassPoints = new string[16]
{
"N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW",
"SW", "WSW", "W", "WNW", "NW", "NNW"
};
private ConfigEntry<string> _shipProfilesConfig;
private ConfigEntry<float> _defaultMaxWeightLbsConfig;
private ConfigEntry<float> _lightThresholdPctConfig;
private ConfigEntry<float> _loadedThresholdPctConfig;
private ConfigEntry<float> _overloadedThresholdPctConfig;
private ConfigEntry<bool> _debugReadoutConfig;
private ConfigEntry<bool> _hudVisibleConfig;
private ConfigEntry<bool> _showInstrumentsConfig;
private ConfigEntry<bool> _showCargoConfig;
private ConfigEntry<bool> _showSoundingConfig;
private ConfigEntry<bool> _showStatusConfig;
private ConfigEntry<bool> _showWeatherConfig;
private ConfigEntry<KeyCode> _hudToggleKeyConfig;
private ConfigEntry<KeyCode> _instrumentsToggleKeyConfig;
private ConfigEntry<KeyCode> _cargoToggleKeyConfig;
private ConfigEntry<KeyCode> _soundingToggleKeyConfig;
private ConfigEntry<KeyCode> _statusToggleKeyConfig;
private ConfigEntry<KeyCode> _weatherToggleKeyConfig;
private ConfigEntry<string> _fontNameConfig;
private ConfigEntry<int> _fontSizeConfig;
private ConfigEntry<float> _panelAlphaConfig;
private ConfigEntry<float> _textAlphaConfig;
private ConfigEntry<bool> _textShadowConfig;
private ConfigEntry<bool> _requireChipLogConfig;
private ConfigEntry<bool> _requireCompassConfig;
private ConfigEntry<bool> _requireWindIndicatorConfig;
private ConfigEntry<string> _chipLogNamesConfig;
private ConfigEntry<string> _compassNamesConfig;
private ConfigEntry<string> _windIndicatorNamesConfig;
private readonly List<ShipProfile> _shipProfiles = new List<ShipProfile>();
private bool _snapValid;
private float _snapSpeedKts;
private float _snapHeadingDeg;
private float _snapHeel;
private bool _snapHeelPort;
private float _snapHeelLimit;
private float _snapWindKts;
private float _snapWindFromDeg;
private float _snapHullDamagePct;
private float _snapBilgePct;
private bool _snapSunk;
private float _snapDeadweightLbs;
private float _snapBilgeEqLbs;
private float _snapSelfMass;
private float _snapPartsMass;
private float _snapMaxSafeLbs;
private float _snapBurdenLoadLbs;
private bool _snapBurdenIsTotalBased;
private bool _snapProfileMatched;
private string _snapBoatName = "";
private int _snapConditionSeverity;
private float _stormProximity = 1f;
private bool _stormProximityInit;
private float _conditionHoldTimer;
private float _keelTimer;
private float _snapKeelClearance = 999f;
private float _snapSeaDepth = 999f;
private string _snapKeelHitName = "(no hit)";
private float _snapFreeboard;
private bool _freeboardInitialized;
private float _equipScanTimer;
private bool _hasChipLog;
private bool _hasCompass;
private bool _hasWindIndicator;
private Font _gameFont;
private bool _fontSearched;
private static readonly string[] RiggingTokens = new string[14]
{
"mast", "stay", "shroud", "sail", "yard", "boom", "gaff", "sprit", "rigg", "halyard",
"sheet", "vang", "spar", "topmast"
};
private static readonly string[] HullDeckTokens = new string[7] { "hull", "deck", "gunwale", "gunnel", "bulwark", "reinforced", "walk" };
private Texture2D _panelTexture;
private float _panelTextureAlpha = -1f;
private void Awake()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Expected O, but got Unknown
try
{
BindConfig();
Harmony val = new Harmony("com.dixiecapt.sailwind.marinershud");
val.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"[MarinersHUD] Telemetry system successfully initialized.");
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("[MarinersHUD] Critical failure hook mapping: " + ex.Message));
}
}
private void BindConfig()
{
_shipProfilesConfig = ((BaseUnityPlugin)this).Config.Bind<string>("ShipWeightProfiles", "Profiles", "dhow small=400;dhow medium=800;dhow large=6000;medi small=700;medi medium=10000;medi large=10000;junk small=600;junk medium=4000;junk large=17000;Gallus=400;Caelanor=2000;Gloriana=12000;Chronian=17000;Leopard=20000;Shroud Small=600;Shroud Large=9000;BOAT CUTTER=250;DNG=150", "Format: NameMatch=MaxSafeWeightLbs or NameMatch=MaxSafeWeightLbs:EmptyWeightLbs, ';'-separated.\nNameMatch is a case-insensitive substring of the boat's internal GameObject name.\nMaxSafeWeightLbs is the safe carrying capacity used by the Burden rating.\nEmptyWeightLbs (optional) is the ship's TOTAL weight when empty with stock fittings (read the\nDebug 'Total Weight' line on an empty ship). When provided, Burden is computed from real total\nweight, so heavy shipyard customizations correctly eat into remaining capacity.\nIMPORTANT: entries are checked in order and the FIRST match wins, and matching is against\nthe boat's INTERNAL name, not the shipyard name. Stock hulls are internally named by\nregion+size: 'dhow small/medium/large', 'medi small/medium/large', 'junk small/medium/large'\n(e.g. the Cog is 'BOAT medi small (40)', the Kakam is 'BOAT dhow small (10)').\nThe Aelasyl's internal name is 'BOAT CHRONIAN (187)' - use Chronian, not Aelasyl.\nCapacities for junk small, medi medium/large, Shroud Small/Large, BOAT CUTTER and DNG are\nestimates - verify with the Debug readout and tune to taste.");
_defaultMaxWeightLbsConfig = ((BaseUnityPlugin)this).Config.Bind<float>("ShipWeightProfiles", "DefaultMaxWeightLbs", 5000f, "Capacity used when the boat matches no profile. Burden shows '(no profile)' when in use.");
_lightThresholdPctConfig = ((BaseUnityPlugin)this).Config.Bind<float>("LoadStatusThresholds", "LightBelowPercent", 40f, "Below this % of capacity, Burden shows 'Light'.");
_loadedThresholdPctConfig = ((BaseUnityPlugin)this).Config.Bind<float>("LoadStatusThresholds", "LoadedAbovePercent", 80f, "At or above this % (but under the overload point), Burden shows 'Loaded'.");
_overloadedThresholdPctConfig = ((BaseUnityPlugin)this).Config.Bind<float>("LoadStatusThresholds", "OverloadedAtPercent", 100f, "At or above this % of capacity, Burden shows 'Overloaded'.");
_debugReadoutConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "DebugMassReadout", false, "Adds raw hull/parts/total mass, boat internal name, matched capacity, the sounding-ray hit, and logs the game font names found (for the FontName setting).");
_hudVisibleConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("HUDSections", "HudVisible", true, "Master switch for the whole HUD.");
_showInstrumentsConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("HUDSections", "ShowInstruments", true, "Instruments section (Speed / Heading / Heel).");
_showCargoConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("HUDSections", "ShowCargo", true, "Cargo section (Deadweight / Freeboard / Burden).");
_showSoundingConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("HUDSections", "ShowSounding", true, "Sounding section (Sea Depth / Keel Clearance).");
_showStatusConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("HUDSections", "ShowStatus", true, "Status section (Hull Integrity / Bilge Water).");
_showWeatherConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("HUDSections", "ShowWeather", true, "Weather section (Wind / Conditions).");
_hudToggleKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("HUDSections", "HudToggleKey", (KeyCode)289, "Key that shows/hides the entire HUD. None to disable.");
_instrumentsToggleKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("HUDSections", "InstrumentsToggleKey", (KeyCode)0, "Optional collapse key.");
_cargoToggleKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("HUDSections", "CargoToggleKey", (KeyCode)0, "Optional collapse key.");
_soundingToggleKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("HUDSections", "SoundingToggleKey", (KeyCode)0, "Optional collapse key.");
_statusToggleKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("HUDSections", "StatusToggleKey", (KeyCode)0, "Optional collapse key.");
_weatherToggleKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("HUDSections", "WeatherToggleKey", (KeyCode)0, "Optional collapse key.");
_fontNameConfig = ((BaseUnityPlugin)this).Config.Bind<string>("Appearance", "FontName", "auto", "Font for the HUD. 'auto' picks the first non-Arial font loaded by the game (usually Sailwind's own sign/UI font). 'default' forces the plain IMGUI font. Or give part of a font name - enable DebugMassReadout once to log the available font names to the BepInEx console.");
_fontSizeConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Appearance", "FontSize", 13, "HUD text size.");
_panelAlphaConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "PanelAlpha", 0.18f, "Opacity of the section background panels (0 = invisible, 1 = solid).");
_textAlphaConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "TextAlpha", 0.95f, "Opacity of the HUD text.");
_textShadowConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("Appearance", "TextShadow", true, "Draw a subtle dark drop-shadow behind the text. Makes the HUD readable against a bright daytime sky without making the panels darker.");
_requireChipLogConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("EquipmentRequirements", "RequireChipLogForSpeed", true, "Only show Speed when a chip log is aboard.");
_requireCompassConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("EquipmentRequirements", "RequireCompassForHeading", true, "Only show Heading when a compass is aboard.");
_requireWindIndicatorConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("EquipmentRequirements", "RequireWindIndicatorForWind", true, "Only show Wind when a wind indicator (shipyard windicator, tell tale, wind compass) is on the ship.");
_chipLogNamesConfig = ((BaseUnityPlugin)this).Config.Bind<string>("EquipmentRequirements", "ChipLogItemNames", "chip log,chiplog", "Comma-separated name fragments identifying a chip log item aboard.");
_compassNamesConfig = ((BaseUnityPlugin)this).Config.Bind<string>("EquipmentRequirements", "CompassItemNames", "compass", "Comma-separated name fragments identifying a compass item aboard.");
_windIndicatorNamesConfig = ((BaseUnityPlugin)this).Config.Bind<string>("EquipmentRequirements", "WindIndicatorNames", "windicator,tell tale,telltale,wind indicator,wind compass,windsock", "Comma-separated name fragments identifying a wind indicator anywhere on the boat or its model.");
RebuildShipProfiles();
_shipProfilesConfig.SettingChanged += delegate
{
RebuildShipProfiles();
};
}
private void RebuildShipProfiles()
{
_shipProfiles.Clear();
string text = _shipProfilesConfig.Value ?? "";
string[] array = text.Split(new char[1] { ';' });
foreach (string text2 in array)
{
string text3 = text2.Trim();
if (text3.Length == 0)
{
continue;
}
int num = text3.IndexOf('=');
if (num <= 0 || num == text3.Length - 1)
{
continue;
}
string text4 = text3.Substring(0, num).Trim();
string text5 = text3.Substring(num + 1).Trim();
if (text4.Length == 0)
{
continue;
}
string s = text5;
string text6 = null;
int num2 = text5.IndexOf(':');
if (num2 > 0 && num2 < text5.Length - 1)
{
s = text5.Substring(0, num2).Trim();
text6 = text5.Substring(num2 + 1).Trim();
}
if (float.TryParse(s, out var result))
{
ShipProfile shipProfile = new ShipProfile();
shipProfile.NameContains = text4;
shipProfile.MaxWeightLbs = result;
if (text6 != null && float.TryParse(text6, out var result2))
{
shipProfile.EmptyWeightLbs = result2;
shipProfile.HasEmptyWeight = true;
}
_shipProfiles.Add(shipProfile);
}
}
}
private ShipProfile GetProfile(string boatName)
{
if (!string.IsNullOrEmpty(boatName))
{
foreach (ShipProfile shipProfile in _shipProfiles)
{
if (boatName.IndexOf(shipProfile.NameContains, StringComparison.OrdinalIgnoreCase) >= 0)
{
return shipProfile;
}
}
}
return null;
}
private void GetBurden(float loadLbs, float maxSafeWeightLbs, out string label, out Color color)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
float num = ((maxSafeWeightLbs > 0f) ? (loadLbs / maxSafeWeightLbs * 100f) : 0f);
if (num >= _overloadedThresholdPctConfig.Value)
{
label = "Overloaded";
color = Color.red;
}
else if (num >= _loadedThresholdPctConfig.Value)
{
label = "Loaded";
color = Color.yellow;
}
else if (num >= _lightThresholdPctConfig.Value)
{
label = "Normal";
color = Color.white;
}
else
{
label = "Light";
color = Color.white;
}
}
private static bool KeyPressed(ConfigEntry<KeyCode> entry)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
return entry != null && (int)entry.Value != 0 && Input.GetKeyDown(entry.Value);
}
private static bool NameMatchesAny(string name, string commaList)
{
if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(commaList))
{
return false;
}
string[] array = commaList.Split(new char[1] { ',' });
foreach (string text in array)
{
string text2 = text.Trim();
if (text2.Length != 0 && name.IndexOf(text2, StringComparison.OrdinalIgnoreCase) >= 0)
{
return true;
}
}
return false;
}
private static string CompassPoint(float degrees)
{
degrees %= 360f;
if (degrees < 0f)
{
degrees += 360f;
}
int num = (int)Mathf.Round(degrees / 22.5f) % 16;
return CompassPoints[num];
}
private static string WindWord(float knots)
{
if (knots < 1f)
{
return "Calm";
}
if (knots < 7f)
{
return "Light Air";
}
if (knots < 17f)
{
return "Breeze";
}
if (knots < 27f)
{
return "Fresh Breeze";
}
if (knots < 38f)
{
return "Strong Wind";
}
return "Gale";
}
private void Update()
{
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_0211: Unknown result type (might be due to invalid IL or missing references)
//IL_0216: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Unknown result type (might be due to invalid IL or missing references)
//IL_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_028c: Unknown result type (might be due to invalid IL or missing references)
//IL_0293: Unknown result type (might be due to invalid IL or missing references)
if (KeyPressed(_hudToggleKeyConfig))
{
_hudVisibleConfig.Value = !_hudVisibleConfig.Value;
}
if (KeyPressed(_instrumentsToggleKeyConfig))
{
_showInstrumentsConfig.Value = !_showInstrumentsConfig.Value;
}
if (KeyPressed(_cargoToggleKeyConfig))
{
_showCargoConfig.Value = !_showCargoConfig.Value;
}
if (KeyPressed(_soundingToggleKeyConfig))
{
_showSoundingConfig.Value = !_showSoundingConfig.Value;
}
if (KeyPressed(_statusToggleKeyConfig))
{
_showStatusConfig.Value = !_showStatusConfig.Value;
}
if (KeyPressed(_weatherToggleKeyConfig))
{
_showWeatherConfig.Value = !_showWeatherConfig.Value;
}
_snapValid = false;
if (!GameState.playing || GameState.justStarted || (Object)(object)GameState.lastBoat == (Object)null)
{
return;
}
Transform lastBoat = GameState.lastBoat;
BoatDamage component = ((Component)lastBoat).GetComponent<BoatDamage>();
Rigidbody component2 = ((Component)lastBoat).GetComponent<Rigidbody>();
if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
{
return;
}
Vector3 velocity = component2.velocity;
float num = Vector3.Dot(velocity, lastBoat.forward);
_snapSpeedKts = num * 1.94384f;
if (Mathf.Abs(_snapSpeedKts) < 0.1f)
{
_snapSpeedKts = 0f;
}
Vector3 forward = lastBoat.forward;
forward.y = 0f;
if (((Vector3)(ref forward)).sqrMagnitude > 0.0001f)
{
float num2 = Mathf.Atan2(forward.x, forward.z) * 57.29578f;
if (num2 < 0f)
{
num2 += 360f;
}
_snapHeadingDeg = num2;
}
_snapHeel = Vector3.Angle(lastBoat.up, Vector3.up);
_snapHeelPort = lastBoat.right.y > 0f;
_snapHeelLimit = component.safeAngleLimit;
_snapWindKts = ((Vector3)(ref Wind.currentWind)).magnitude * 1.94384f;
Vector3 val = -Wind.currentWind;
val.y = 0f;
if (((Vector3)(ref val)).sqrMagnitude > 0.0001f)
{
float num3 = Mathf.Atan2(val.x, val.z) * 57.29578f;
if (num3 < 0f)
{
num3 += 360f;
}
_snapWindFromDeg = num3;
}
UpdateConditions();
_snapHullDamagePct = component.hullDamage * 100f;
_snapBilgePct = component.waterLevel * 100f;
_snapSunk = component.sunk;
_snapBoatName = ((Object)lastBoat).name;
float num4 = Mathf.Lerp(1f, 0.66f, (component.waterLevel - 0.5f) * 2f);
_snapBilgeEqLbs = 0f;
if (num4 < 0.999f)
{
_snapBilgeEqLbs = component2.mass * (1f / num4 - 1f);
}
BoatMass component3 = ((Component)lastBoat).GetComponent<BoatMass>();
float num5 = 0f;
float num6 = 0f;
float num7 = 0f;
bool flag = false;
bool flag2 = false;
if ((Object)(object)component3 != (Object)null)
{
num6 = (float)SelfMassField.GetValue(component3);
num7 = (float)PartsMassField.GetValue(component3);
object value = ItemsOnBoatField.GetValue(component3);
if (value is IEnumerable enumerable)
{
foreach (object item in enumerable)
{
ItemRigidbody val2 = (ItemRigidbody)((item is ItemRigidbody) ? item : null);
if ((Object)(object)val2 == (Object)null)
{
continue;
}
Rigidbody body = val2.GetBody();
if (!((Object)(object)body == (Object)null))
{
num5 += body.mass;
string name = ((Object)val2).name;
if (!flag && NameMatchesAny(name, _chipLogNamesConfig.Value))
{
flag = true;
}
if (!flag2 && NameMatchesAny(name, _compassNamesConfig.Value))
{
flag2 = true;
}
}
}
}
}
bool flag3 = (Object)(object)GameState.currentBoat != (Object)null && (Object)(object)GameState.currentBoat.parent == (Object)(object)lastBoat;
_snapDeadweightLbs = num5 + _snapBilgeEqLbs + (flag3 ? 160f : 0f);
_snapSelfMass = num6;
_snapPartsMass = num7;
_hasChipLog = flag;
_hasCompass = flag2;
ShipProfile profile = GetProfile(_snapBoatName);
_snapProfileMatched = profile != null;
_snapMaxSafeLbs = profile?.MaxWeightLbs ?? _defaultMaxWeightLbsConfig.Value;
if (profile != null && profile.HasEmptyWeight)
{
float num8 = num6 + num7 + num5 + _snapBilgeEqLbs + (flag3 ? 160f : 0f);
float num9 = num8 - profile.EmptyWeightLbs;
if (num9 < 0f)
{
num9 = 0f;
}
_snapBurdenLoadLbs = num9;
_snapBurdenIsTotalBased = true;
}
else
{
_snapBurdenLoadLbs = _snapDeadweightLbs;
_snapBurdenIsTotalBased = false;
}
_equipScanTimer -= Time.deltaTime;
if (_equipScanTimer <= 0f)
{
_equipScanTimer = 1f;
_hasWindIndicator = ScanForWindIndicator(lastBoat);
}
_keelTimer -= Time.deltaTime;
if (_keelTimer <= 0f)
{
_keelTimer = 0.2f;
UpdateSounding(lastBoat, component2);
}
_snapValid = true;
}
private void UpdateConditions()
{
float num = 0.4f;
float num2 = 0.1f;
float num3 = 1f;
WeatherStorms instance = WeatherStorms.instance;
if ((Object)(object)instance != (Object)null)
{
try
{
if (CloudyBorderField != null)
{
num = (float)CloudyBorderField.GetValue(instance);
}
if (RainBorderField != null)
{
num2 = (float)RainBorderField.GetValue(instance);
}
}
catch (Exception)
{
}
num3 = WeatherStorms.currentStormDistance;
}
if (!_stormProximityInit)
{
_stormProximity = num3;
_stormProximityInit = true;
}
else
{
_stormProximity = Mathf.Lerp(_stormProximity, num3, Time.deltaTime * 0.6f);
}
float num4 = (num + num2) * 0.5f;
float stormProximity = _stormProximity;
int num5 = ((!(stormProximity >= num + 0.04f)) ? ((stormProximity >= num4 + 0.04f) ? 1 : ((!(stormProximity >= num2 + 0.04f)) ? 3 : 2)) : 0);
if (Mathf.Abs(stormProximity - num) < 0.04f || Mathf.Abs(stormProximity - num4) < 0.04f || Mathf.Abs(stormProximity - num2) < 0.04f)
{
num5 = _snapConditionSeverity;
}
if (num5 != _snapConditionSeverity)
{
_conditionHoldTimer += Time.deltaTime;
if (_conditionHoldTimer >= 2f)
{
_snapConditionSeverity = num5;
_conditionHoldTimer = 0f;
}
}
else
{
_conditionHoldTimer = 0f;
}
}
private bool ScanForWindIndicator(Transform boat)
{
string value = _windIndicatorNamesConfig.Value;
if (ScanChildrenForName(boat, value))
{
return true;
}
BoatRefs component = ((Component)boat).GetComponent<BoatRefs>();
if ((Object)(object)component != (Object)null && (Object)(object)component.boatModel != (Object)null && ScanChildrenForName(component.boatModel, value))
{
return true;
}
return false;
}
private static bool ScanChildrenForName(Transform root, string commaList)
{
Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(false);
for (int i = 0; i < componentsInChildren.Length; i++)
{
if (NameMatchesAny(((Object)componentsInChildren[i]).name, commaList))
{
return true;
}
}
return false;
}
private static bool ContainsToken(string name, string[] tokens)
{
if (string.IsNullOrEmpty(name))
{
return false;
}
for (int i = 0; i < tokens.Length; i++)
{
if (name.IndexOf(tokens[i], StringComparison.OrdinalIgnoreCase) >= 0)
{
return true;
}
}
return false;
}
private static bool IsRiggingName(string name)
{
return ContainsToken(name, RiggingTokens);
}
private static bool IsHullDeckName(string name)
{
return ContainsToken(name, HullDeckTokens);
}
private void UpdateSounding(Transform boat, Rigidbody boatRigidbody)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0242: Unknown result type (might be due to invalid IL or missing references)
//IL_0255: Unknown result type (might be due to invalid IL or missing references)
//IL_025d: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
//IL_02be: Unknown result type (might be due to invalid IL or missing references)
//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Unknown result type (might be due to invalid IL or missing references)
//IL_0505: Unknown result type (might be due to invalid IL or missing references)
//IL_0507: Unknown result type (might be due to invalid IL or missing references)
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
//IL_031d: Unknown result type (might be due to invalid IL or missing references)
//IL_0322: Unknown result type (might be due to invalid IL or missing references)
//IL_0336: Unknown result type (might be due to invalid IL or missing references)
//IL_033b: Unknown result type (might be due to invalid IL or missing references)
//IL_0342: Unknown result type (might be due to invalid IL or missing references)
//IL_0346: Unknown result type (might be due to invalid IL or missing references)
//IL_034b: Unknown result type (might be due to invalid IL or missing references)
//IL_0352: Unknown result type (might be due to invalid IL or missing references)
//IL_0357: Unknown result type (might be due to invalid IL or missing references)
//IL_035c: Unknown result type (might be due to invalid IL or missing references)
//IL_0363: Unknown result type (might be due to invalid IL or missing references)
//IL_0367: Unknown result type (might be due to invalid IL or missing references)
//IL_036c: Unknown result type (might be due to invalid IL or missing references)
//IL_0373: Unknown result type (might be due to invalid IL or missing references)
//IL_0378: Unknown result type (might be due to invalid IL or missing references)
//IL_037d: Unknown result type (might be due to invalid IL or missing references)
//IL_038a: Unknown result type (might be due to invalid IL or missing references)
//IL_0390: Unknown result type (might be due to invalid IL or missing references)
//IL_0395: Unknown result type (might be due to invalid IL or missing references)
//IL_039a: Unknown result type (might be due to invalid IL or missing references)
//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0649: Unknown result type (might be due to invalid IL or missing references)
//IL_0672: Unknown result type (might be due to invalid IL or missing references)
//IL_0696: Unknown result type (might be due to invalid IL or missing references)
_snapKeelClearance = 999f;
_snapSeaDepth = 999f;
_snapKeelHitName = "(no hit)";
Vector3 up = boat.up;
Vector3 position = boat.position;
float num = float.PositiveInfinity;
float num2 = float.NegativeInfinity;
float num3 = float.NegativeInfinity;
float num4 = -1f;
Collider[] componentsInChildren = ((Component)boat).GetComponentsInChildren<Collider>();
Collider[] array = componentsInChildren;
Vector3 val2 = default(Vector3);
foreach (Collider val in array)
{
if ((Object)(object)val == (Object)null || val.isTrigger || !val.enabled)
{
continue;
}
Bounds bounds = val.bounds;
Vector3 center = ((Bounds)(ref bounds)).center;
Vector3 extents = ((Bounds)(ref bounds)).extents;
float num5 = float.PositiveInfinity;
float num6 = float.NegativeInfinity;
for (int j = -1; j <= 1; j += 2)
{
for (int k = -1; k <= 1; k += 2)
{
for (int l = -1; l <= 1; l += 2)
{
((Vector3)(ref val2))..ctor(center.x + (float)j * extents.x, center.y + (float)k * extents.y, center.z + (float)l * extents.z);
float num7 = Vector3.Dot(val2 - position, up);
if (num7 < num5)
{
num5 = num7;
}
if (num7 > num6)
{
num6 = num7;
}
}
}
}
if (num5 < num)
{
num = num5;
}
string name = ((Object)val).name;
if (!IsRiggingName(name))
{
if (IsHullDeckName(name) && num6 > num2)
{
num2 = num6;
}
float num8 = ((Bounds)(ref bounds)).size.x * ((Bounds)(ref bounds)).size.y * ((Bounds)(ref bounds)).size.z;
if (num8 > num4)
{
num4 = num8;
num3 = num6;
}
}
}
if (float.IsPositiveInfinity(num))
{
num = 0f;
}
float num9 = ((!float.IsNegativeInfinity(num2)) ? num2 : num3);
float num10 = position.y + num * up.y;
float num11 = (float.IsNegativeInfinity(num9) ? float.NegativeInfinity : (position.y + num9 * up.y));
float num12 = 0f;
Ocean singleton = Ocean.Singleton;
if ((Object)(object)singleton != (Object)null)
{
Vector3 val3 = boat.forward;
val3.y = 0f;
val3 = ((((Vector3)(ref val3)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val3)).normalized : Vector3.forward);
Vector3 val4 = boat.right;
val4.y = 0f;
val4 = ((((Vector3)(ref val4)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val4)).normalized : Vector3.right);
float num13 = Mathf.Max(2f, (num9 - num) * 1.5f);
float num14 = Mathf.Max(1.5f, num13 * 0.4f);
Vector3 position2 = boat.position;
float num15 = 0f;
int num16 = 0;
Vector3[] array2 = (Vector3[])(object)new Vector3[5]
{
Vector3.zero,
val3 * num13,
val3 * (0f - num13),
val4 * num14,
val4 * (0f - num14)
};
for (int m = 0; m < array2.Length; m++)
{
Vector3 val5 = position2 + array2[m];
num15 += singleton.GetWaterHeightAtLocation2(val5.x, val5.z);
num16++;
}
num12 = num15 / (float)num16;
}
if (!float.IsNegativeInfinity(num11))
{
float num17 = num9 - num;
float num18 = num11 - num12;
if (num18 < 0f)
{
num18 = 0f;
}
if (num17 > 0f && num18 > num17)
{
num18 = num17;
}
if (!_freeboardInitialized)
{
_snapFreeboard = num18;
_freeboardInitialized = true;
}
else
{
float num19 = 1f - Mathf.Exp(-0.1f);
_snapFreeboard = Mathf.Lerp(_snapFreeboard, num18, num19);
}
}
Transform val6 = null;
Transform val7 = null;
BoatRefs component = ((Component)boat).GetComponent<BoatRefs>();
if ((Object)(object)component != (Object)null)
{
val6 = component.walkCol;
val7 = component.boatModel;
}
Vector3 val8 = default(Vector3);
((Vector3)(ref val8))..ctor(boat.position.x, boat.position.y + 5f, boat.position.z);
int num20 = -277;
int num21 = LayerMask.NameToLayer("water");
if (num21 >= 0)
{
num20 &= ~(1 << num21);
}
RaycastHit[] array3 = Physics.RaycastAll(val8, Vector3.down, 300f, num20, (QueryTriggerInteraction)1);
bool flag = false;
float num22 = float.NegativeInfinity;
string snapKeelHitName = "";
for (int n = 0; n < array3.Length; n++)
{
Collider collider = ((RaycastHit)(ref array3[n])).collider;
if ((Object)(object)collider == (Object)null || (Object)(object)collider.attachedRigidbody != (Object)null)
{
continue;
}
Transform transform = ((Component)collider).transform;
if (!transform.IsChildOf(boat) && (!((Object)(object)val6 != (Object)null) || !transform.IsChildOf(val6)) && (!((Object)(object)val7 != (Object)null) || !transform.IsChildOf(val7)) && !(((Component)collider).gameObject.tag == "WalkColBoat"))
{
string text = (((Object)(object)transform.root != (Object)null) ? ((Object)transform.root).name : "");
if (!text.StartsWith("BOAT", StringComparison.OrdinalIgnoreCase) && !text.StartsWith("WALK", StringComparison.OrdinalIgnoreCase) && !(((RaycastHit)(ref array3[n])).point.y > num10 + 0.05f) && (!flag || ((RaycastHit)(ref array3[n])).point.y > num22))
{
flag = true;
num22 = ((RaycastHit)(ref array3[n])).point.y;
snapKeelHitName = ((Object)collider).name;
}
}
}
if (flag)
{
_snapKeelClearance = num10 - num22;
if (_snapKeelClearance < 0f)
{
_snapKeelClearance = 0f;
}
_snapSeaDepth = boat.position.y - num22;
_snapKeelHitName = snapKeelHitName;
}
}
private Texture2D GetPanelTexture()
{
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Expected O, but got Unknown
float num = Mathf.Clamp01(_panelAlphaConfig.Value);
if ((Object)(object)_panelTexture == (Object)null || Mathf.Abs(num - _panelTextureAlpha) > 0.01f)
{
if ((Object)(object)_panelTexture == (Object)null)
{
_panelTexture = new Texture2D(1, 1, (TextureFormat)5, false);
((Object)_panelTexture).hideFlags = (HideFlags)61;
}
_panelTexture.SetPixel(0, 0, new Color(0.09f, 0.07f, 0.04f, num));
_panelTexture.Apply();
_panelTextureAlpha = num;
}
return _panelTexture;
}
private Font GetGameFont()
{
string text = _fontNameConfig.Value ?? "auto";
if (text == "default")
{
return null;
}
if (_fontSearched)
{
return _gameFont;
}
_fontSearched = true;
Object[] array = Resources.FindObjectsOfTypeAll(typeof(Font));
if (_debugReadoutConfig.Value)
{
string text2 = "";
for (int i = 0; i < array.Length; i++)
{
text2 = text2 + ((i > 0) ? ", " : "") + array[i].name;
}
((BaseUnityPlugin)this).Logger.LogInfo((object)("[MarinersHUD] Fonts loaded by the game: " + text2));
}
foreach (Object obj in array)
{
Font val = (Font)(object)((obj is Font) ? obj : null);
if ((Object)(object)val == (Object)null)
{
continue;
}
string text3 = ((Object)val).name ?? "";
if (text != "auto")
{
if (text3.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0)
{
_gameFont = val;
break;
}
}
else if (text3.IndexOf("Arial", StringComparison.OrdinalIgnoreCase) < 0 && text3.Length > 0)
{
_gameFont = val;
break;
}
}
if ((Object)(object)_gameFont != (Object)null)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)("[MarinersHUD] Using game font: " + ((Object)_gameFont).name));
}
return _gameFont;
}
private void OnGUI()
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Expected O, but got Unknown
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Expected O, but got Unknown
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Expected O, but got Unknown
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Expected O, but got Unknown
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Expected O, but got Unknown
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_021b: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_0214: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
//IL_03df: Unknown result type (might be due to invalid IL or missing references)
//IL_0670: Unknown result type (might be due to invalid IL or missing references)
//IL_0699: Unknown result type (might be due to invalid IL or missing references)
//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
//IL_0441: Unknown result type (might be due to invalid IL or missing references)
//IL_043a: Unknown result type (might be due to invalid IL or missing references)
//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
//IL_048f: Unknown result type (might be due to invalid IL or missing references)
//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
//IL_050f: Unknown result type (might be due to invalid IL or missing references)
//IL_0538: Unknown result type (might be due to invalid IL or missing references)
//IL_030f: Unknown result type (might be due to invalid IL or missing references)
//IL_0710: Unknown result type (might be due to invalid IL or missing references)
//IL_0616: Unknown result type (might be due to invalid IL or missing references)
//IL_08d1: Unknown result type (might be due to invalid IL or missing references)
//IL_08db: Expected O, but got Unknown
//IL_08d6: Unknown result type (might be due to invalid IL or missing references)
//IL_0764: Unknown result type (might be due to invalid IL or missing references)
//IL_0769: Unknown result type (might be due to invalid IL or missing references)
//IL_0754: Unknown result type (might be due to invalid IL or missing references)
//IL_0759: Unknown result type (might be due to invalid IL or missing references)
//IL_0744: Unknown result type (might be due to invalid IL or missing references)
//IL_0749: Unknown result type (might be due to invalid IL or missing references)
//IL_0364: Unknown result type (might be due to invalid IL or missing references)
//IL_0798: Unknown result type (might be due to invalid IL or missing references)
//IL_092a: Unknown result type (might be due to invalid IL or missing references)
//IL_0937: Unknown result type (might be due to invalid IL or missing references)
//IL_093c: Unknown result type (might be due to invalid IL or missing references)
//IL_0952: Unknown result type (might be due to invalid IL or missing references)
//IL_0977: Unknown result type (might be due to invalid IL or missing references)
//IL_0854: Unknown result type (might be due to invalid IL or missing references)
//IL_085e: Expected O, but got Unknown
//IL_0859: Unknown result type (might be due to invalid IL or missing references)
//IL_085e: Unknown result type (might be due to invalid IL or missing references)
//IL_0860: Unknown result type (might be due to invalid IL or missing references)
//IL_0871: Unknown result type (might be due to invalid IL or missing references)
//IL_08b3: Unknown result type (might be due to invalid IL or missing references)
//IL_08bd: Expected O, but got Unknown
//IL_08b8: Unknown result type (might be due to invalid IL or missing references)
//IL_09ad: Unknown result type (might be due to invalid IL or missing references)
//IL_0b2e: Unknown result type (might be due to invalid IL or missing references)
//IL_0b19: Unknown result type (might be due to invalid IL or missing references)
//IL_09df: Unknown result type (might be due to invalid IL or missing references)
//IL_09e4: Unknown result type (might be due to invalid IL or missing references)
//IL_09f6: Unknown result type (might be due to invalid IL or missing references)
//IL_09fd: Expected O, but got Unknown
//IL_09ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0a04: Unknown result type (might be due to invalid IL or missing references)
//IL_0a15: Unknown result type (might be due to invalid IL or missing references)
//IL_0a8f: Unknown result type (might be due to invalid IL or missing references)
//IL_0a7a: Unknown result type (might be due to invalid IL or missing references)
if (!_snapValid || !_hudVisibleConfig.Value)
{
return;
}
float num = Mathf.Clamp01(_textAlphaConfig.Value);
GUIStyle val = new GUIStyle();
val.fontSize = _fontSizeConfig.Value;
val.fontStyle = (FontStyle)0;
Font gameFont = GetGameFont();
if ((Object)(object)gameFont != (Object)null)
{
val.font = gameFont;
}
val.normal.textColor = new Color(0.99f, 0.97f, 0.92f, num);
GUIStyle val2 = new GUIStyle(val);
val2.normal.textColor = new Color(0.99f, 0.97f, 0.92f, num * 0.85f);
GUIStyle val3 = new GUIStyle(val);
val3.normal.textColor = new Color(0f, 0f, 0f, num * 0.8f);
bool value = _textShadowConfig.Value;
GUIStyle val4 = new GUIStyle(GUI.skin.button);
val4.fontSize = 9;
val4.padding = new RectOffset(0, 0, 0, 0);
val4.margin = new RectOffset(0, 0, 0, 0);
val4.alignment = (TextAnchor)4;
Color color = ((_snapHeel > _snapHeelLimit) ? Color.yellow : Color.white);
Color color2 = ((_snapHullDamagePct >= 95f) ? Color.red : ((_snapHullDamagePct > 15f) ? Color.yellow : Color.white));
Color color3 = (_snapSunk ? Color.red : ((_snapBilgePct > 15f) ? Color.yellow : Color.white));
Color color4 = ((_snapKeelClearance <= 0.1f) ? Color.red : ((_snapKeelClearance < 2f) ? Color.yellow : Color.white));
Color color5 = ((_snapFreeboard <= 0.15f) ? Color.red : ((_snapFreeboard < 0.6f) ? Color.yellow : Color.white));
GetBurden(_snapBurdenLoadLbs, _snapMaxSafeLbs, out var label, out var color6);
List<HudSection> sections = new List<HudSection>();
HudSection current = null;
Color white = Color.white;
Section("Instruments", _showInstrumentsConfig);
if (_showInstrumentsConfig.Value)
{
if (_hasChipLog || !_requireChipLogConfig.Value)
{
Line("Speed : " + _snapSpeedKts.ToString("F1") + " kts", white);
}
if (_hasCompass || !_requireCompassConfig.Value)
{
Line("Heading : " + _snapHeadingDeg.ToString("000") + "° " + CompassPoint(_snapHeadingDeg), white);
}
string text = ((_snapHeel < 0.05f) ? "Heel : 0.0°" : ("Heel : " + _snapHeel.ToString("F1") + "° " + (_snapHeelPort ? "Port" : "Stbd")));
Line(text, color);
}
Section("Cargo", _showCargoConfig);
if (_showCargoConfig.Value)
{
Line("Deadweight : " + _snapDeadweightLbs.ToString("F0") + " lbs", color6);
Line("Freeboard : " + _snapFreeboard.ToString("F1") + " m", color5);
string text2 = "Burden : " + label;
if (!_snapProfileMatched)
{
text2 += " (no profile)";
}
else if (_snapBurdenIsTotalBased)
{
text2 += " (total wt)";
}
Line(text2, _snapProfileMatched ? color6 : Color.gray);
if (_debugReadoutConfig.Value)
{
Line("Hull: " + _snapSelfMass.ToString("F0") + " Parts: " + _snapPartsMass.ToString("F0"), white);
Line("Total Weight: " + (_snapSelfMass + _snapPartsMass + _snapDeadweightLbs - _snapBilgeEqLbs).ToString("F0"), white);
Line("Bilge Eq: " + _snapBilgeEqLbs.ToString("F0") + " lbs", white);
Line("Boat: " + _snapBoatName, white);
Line("Capacity: " + _snapMaxSafeLbs.ToString("F0") + " lbs", white);
}
}
Section("Sounding", _showSoundingConfig);
if (_showSoundingConfig.Value)
{
Line("Sea Depth : " + ((_snapSeaDepth > 290f) ? "Deep Ocean" : (_snapSeaDepth.ToString("F1") + " m")), white);
string text3 = ((_snapKeelClearance > 290f) ? "Safe" : (_snapKeelClearance.ToString("F1") + " m"));
Line("Keel Clearance : " + text3, color4);
if (_debugReadoutConfig.Value)
{
Line("Sounding Hit: " + _snapKeelHitName, white);
}
}
Section("Status", _showStatusConfig);
if (_showStatusConfig.Value)
{
Line("Hull Integrity : " + (100f - _snapHullDamagePct).ToString("F1") + "%", color2);
Line("Bilge Water : " + _snapBilgePct.ToString("F1") + "%", color3);
}
Section("Weather", _showWeatherConfig);
if (_showWeatherConfig.Value)
{
if (_hasWindIndicator || !_requireWindIndicatorConfig.Value)
{
Line("Wind : " + CompassPoint(_snapWindFromDeg) + " " + WindWord(_snapWindKts), white);
}
string text4;
Color color7 = default(Color);
switch (_snapConditionSeverity)
{
case 3:
text4 = "Tempest";
color7 = Color.red;
break;
case 2:
text4 = "Squally";
color7 = Color.yellow;
break;
case 1:
text4 = "Moderate";
color7 = Color.white;
break;
default:
text4 = "Fair";
((Color)(ref color7))..ctor(0.6f, 1f, 0.6f);
break;
}
Line("Conditions : " + text4, color7);
}
float num2 = 20f;
float num3 = 60f;
float num4 = (float)_fontSizeConfig.Value + 3f;
float num5 = 5f;
float num6 = 3f;
float num7 = 3f;
float num8 = 11f;
float num9 = num8 + 5f;
Texture2D panelTexture = GetPanelTexture();
Rect val7 = default(Rect);
Rect val8 = default(Rect);
foreach (HudSection item2 in sections)
{
bool value2 = item2.Toggle.Value;
float num10;
if (value2)
{
num10 = 0f;
foreach (HudLine line in item2.Lines)
{
Vector2 val5 = val.CalcSize(new GUIContent(line.Text));
if (val5.x > num10)
{
num10 = val5.x;
}
}
if (item2.Lines.Count == 0)
{
num10 = val2.CalcSize(new GUIContent(item2.Name)).x;
}
}
else
{
num10 = val2.CalcSize(new GUIContent(item2.Name)).x;
}
float num11 = num5 + num9 + num10 + num5;
float num12 = (value2 ? ((float)Mathf.Max(1, item2.Lines.Count) * num4 + num6 * 2f) : (num4 + num6 * 2f));
GUI.DrawTexture(new Rect(num2, num3, num11, num12), (Texture)(object)panelTexture);
Color color8 = GUI.color;
GUI.color = new Color(1f, 1f, 1f, 0.35f);
if (GUI.Button(new Rect(num2 + num5, num3 + num6 + (num4 - num8) * 0.5f, num8, num8), value2 ? "-" : "+", val4))
{
item2.Toggle.Value = !value2;
}
GUI.color = color8;
if (value2)
{
for (int i = 0; i < item2.Lines.Count; i++)
{
HudLine hudLine = item2.Lines[i];
GUIStyle val6 = val;
if (hudLine.Color != Color.white)
{
val6 = new GUIStyle(val);
Color color9 = hudLine.Color;
color9.a = num;
val6.normal.textColor = color9;
}
((Rect)(ref val7))..ctor(num2 + num5 + num9, num3 + num6 + (float)i * num4, num10 + 4f, num4 + 4f);
if (value)
{
GUI.Label(new Rect(((Rect)(ref val7)).x + 1f, ((Rect)(ref val7)).y + 1f, ((Rect)(ref val7)).width, ((Rect)(ref val7)).height), hudLine.Text, val3);
}
GUI.Label(val7, hudLine.Text, val6);
}
}
else
{
((Rect)(ref val8))..ctor(num2 + num5 + num9, num3 + num6, num10 + 4f, num4 + 4f);
if (value)
{
GUI.Label(new Rect(((Rect)(ref val8)).x + 1f, ((Rect)(ref val8)).y + 1f, ((Rect)(ref val8)).width, ((Rect)(ref val8)).height), item2.Name, val3);
}
GUI.Label(val8, item2.Name, val2);
}
num3 += num12 + num7;
}
void Line(string text5, Color color10)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
HudLine item = new HudLine
{
Text = text5,
Color = color10
};
current.Lines.Add(item);
}
void Section(string name, ConfigEntry<bool> toggle)
{
current = new HudSection();
current.Name = name;
current.Toggle = toggle;
sections.Add(current);
}
}
}
}