using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using ModSaveBackups;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using cakeslice;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Sail-a-dex")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("raddude")]
[assembly: AssemblyProduct("Sail-a-dex")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("165a01b3-48da-400d-a25f-d6d01b2b3120")]
[assembly: AssemblyFileVersion("1.4.5.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.5.0")]
[module: UnverifiableCode]
namespace sailadex;
internal class PassageDude
{
public class FerryTravelPatches
{
[HarmonyPostfix]
public static void TeleportPlayerPatch()
{
if (Plugin.statsUIEnabled.Value)
{
StatsUI.instance.PlayerTeleported();
}
}
}
public static void PatchMod()
{
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
Type type2 = (from type in AppDomain.CurrentDomain.GetAssemblies().SelectMany((Assembly asm) => asm.GetTypes())
where type.IsClass && type.Name == "FerryTravel"
select type).Single();
MethodInfo methodInfo = AccessTools.Method(type2, "TeleportPlayer", (Type[])null, (Type[])null);
MethodInfo methodInfo2 = AccessTools.Method(typeof(FerryTravelPatches), "TeleportPlayerPatch", (Type[])null, (Type[])null);
Plugin.harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
}
internal class RandomEncounters
{
public class EncounterGeneratorPatches
{
[HarmonyPostfix]
public static void FlotsamCountPatch()
{
if (flotsamEnabled)
{
StatsUI.instance.IncrementIntStat("FlotsamEncounters");
}
}
[HarmonyPostfix]
public static void DenseFogCountPatch()
{
if (denseFogEnabled)
{
StatsUI.instance.IncrementIntStat("DenseFogEncounters");
}
}
[HarmonyPostfix]
public static void SeaLifeCountPatch()
{
if (isSeaLifeEnabled)
{
StatsUI.instance.IncrementIntStat("SeaLifeEncounters");
}
}
}
internal static BaseUnityPlugin pluginInstance;
internal static bool isSeaLifeEnabled;
internal static bool flotsamEnabled;
internal static bool denseFogEnabled;
public static void PatchMod()
{
//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Expected O, but got Unknown
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Expected O, but got Unknown
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Expected O, but got Unknown
BaseUnityPlugin privateField = pluginInstance.GetPrivateField<BaseUnityPlugin>("seaLifeModInstance");
ConfigEntry<bool> privateField2 = pluginInstance.GetPrivateField<ConfigEntry<bool>>("controlSeaLifeMod");
isSeaLifeEnabled = (Object)(object)privateField != (Object)null && privateField2.Value;
flotsamEnabled = pluginInstance.GetPrivateField<ConfigEntry<bool>>("enableFlotsam").Value;
denseFogEnabled = pluginInstance.GetPrivateField<ConfigEntry<bool>>("enableDenseFog").Value;
Type type2 = (from type in AppDomain.CurrentDomain.GetAssemblies().SelectMany((Assembly asm) => asm.GetTypes())
where type.IsClass && type.Name == "EncounterGenerator"
select type).Single();
MethodInfo methodInfo = AccessTools.Method(type2, "GenerateFlotsam", (Type[])null, (Type[])null);
MethodInfo methodInfo2 = AccessTools.Method(typeof(EncounterGeneratorPatches), "FlotsamCountPatch", (Type[])null, (Type[])null);
Plugin.harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
MethodInfo methodInfo3 = AccessTools.Method(type2, "GenerateDenseFog", (Type[])null, (Type[])null);
MethodInfo methodInfo4 = AccessTools.Method(typeof(EncounterGeneratorPatches), "DenseFogCountPatch", (Type[])null, (Type[])null);
Plugin.harmony.Patch((MethodBase)methodInfo3, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
MethodInfo methodInfo5 = AccessTools.Method(type2, "GenerateWhale", (Type[])null, (Type[])null);
MethodInfo methodInfo6 = AccessTools.Method(typeof(EncounterGeneratorPatches), "SeaLifeCountPatch", (Type[])null, (Type[])null);
Plugin.harmony.Patch((MethodBase)methodInfo5, new HarmonyMethod(methodInfo6), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
}
internal class EventPatches
{
[HarmonyPatch(typeof(FishingRodFish))]
private class FishingRodFishPatches
{
[HarmonyPrefix]
[HarmonyPatch("CollectFish")]
public static void CollectFishPatch(FishingRodFish __instance, GameObject ___currentFish)
{
if (Plugin.fishCaughtUIEnabled.Value)
{
FishCaughtUI.instance.RegisterCatch(___currentFish);
}
}
}
[HarmonyPatch(typeof(IslandMarketWarehouseArea))]
private class IslandMarketWarehouseAreaPatches
{
[HarmonyPostfix]
[HarmonyPatch("OnTriggerEnter")]
public static void OnTriggerEnterPatch(IslandMarketWarehouseArea __instance, IslandMarket ___market, Collider other)
{
if (Plugin.portsVisitedUIEnabled.Value && ((Component)other).CompareTag("Player"))
{
PortsVisitedUI.instance.RegisterVisit(___market.GetPortName());
}
if (Plugin.statsUIEnabled.Value && ((Component)other).CompareTag("Player"))
{
StatsUI.instance.IncrementPortVisited(___market.GetPortName());
}
}
}
[HarmonyPatch(typeof(ShipItem))]
private class ShipItemPatches
{
[HarmonyPostfix]
[HarmonyPatch("EnterBoat")]
public static void EnterBoatPatch()
{
if (Plugin.statsUIEnabled.Value && GameState.playing)
{
StatsUI.instance.RegisterCurrentMass();
}
}
[HarmonyPostfix]
[HarmonyPatch("ExitBoat")]
public static void ExitBoatPatch()
{
if (Plugin.statsUIEnabled.Value && GameState.playing)
{
StatsUI.instance.RegisterCurrentMass();
}
}
}
[HarmonyPatch(typeof(PickupableBoatMooringRope))]
private class PickupableBoatMooringRopePatches
{
[HarmonyPrefix]
[HarmonyPatch("OnPickup")]
public static void OnPickupPrePatch(Rigidbody ___boatRigidbody, out string __state)
{
__state = (from r in ((Component)___boatRigidbody).gameObject.GetComponent<BoatMooringRopes>().ropes
where (Object)(object)r.GetPrivateField<SpringJoint>("mooredToSpring") != (Object)null
select ((Object)((Component)r.GetPrivateField<SpringJoint>("mooredToSpring")).transform.parent).name).FirstOrDefault();
}
[HarmonyPostfix]
[HarmonyPatch("OnPickup")]
public static void OnPickupPatch(Rigidbody ___boatRigidbody, string __state)
{
if (Plugin.statsUIEnabled.Value && !GameState.currentlyLoading && GameState.playing && !((Component)___boatRigidbody).gameObject.GetComponent<BoatMooringRopes>().AnyRopeMoored())
{
Plugin.logger.LogDebug((object)$"Unmoor from {__state} Day: {GameState.day} Time: {Sun.sun.globalTime}");
StatsUI.instance.RegisterUnderway(__state);
}
}
[HarmonyPostfix]
[HarmonyPatch("MoorTo")]
public static void MoorToPatch(Rigidbody ___boatRigidbody)
{
if (!Plugin.statsUIEnabled.Value || GameState.currentlyLoading || !GameState.playing)
{
return;
}
if (!((Object)(object)((Component)___boatRigidbody).transform == (Object)(object)GameState.lastBoat))
{
Transform transform = ((Component)___boatRigidbody).transform;
Transform currentBoat = GameState.currentBoat;
if (!((Object)(object)transform == (Object)(object)((currentBoat != null) ? currentBoat.parent : null)))
{
return;
}
}
if (((Component)___boatRigidbody).gameObject.GetComponent<BoatMooringRopes>().AnyRopeMoored())
{
string text = (from r in ((Component)___boatRigidbody).gameObject.GetComponent<BoatMooringRopes>().ropes
where (Object)(object)r.GetPrivateField<SpringJoint>("mooredToSpring") != (Object)null
select ((Object)((Component)r.GetPrivateField<SpringJoint>("mooredToSpring")).transform.parent).name).FirstOrDefault();
Plugin.logger.LogDebug((object)$"Moored at: {text} Day: {GameState.day} Time: {Sun.sun.globalTime} ");
StatsUI.instance.RegisterMoored(text);
StatsUI.instance.UpdateMilesText();
}
}
}
[HarmonyPatch(typeof(ShipItemBottle))]
private class ShipItemBottlePatches
{
[HarmonyPostfix]
[HarmonyPatch("Drink")]
public static void DrinkPatch(float ___health)
{
if (Plugin.statsUIEnabled.Value && ___health > 0f)
{
StatsUI.instance.IncrementIntStat("DrinksTaken");
}
}
}
[HarmonyPatch(typeof(ShipItemFood))]
private class ShipItemFoodPatches
{
[HarmonyPrefix]
[HarmonyPatch("EatFood")]
public static void EatFoodPatch()
{
if (Plugin.statsUIEnabled.Value && !(PlayerNeeds.instance.eatCooldown > 0f))
{
StatsUI.instance.IncrementIntStat("FoodsEaten");
}
}
}
[HarmonyPatch(typeof(ShipItemPipe))]
private class ShipItemPipePatches
{
[HarmonyPrefix]
[HarmonyPatch("StopSmoking")]
public static void StopSmokingPatch(float ___currentInhaleDuration)
{
if (Plugin.statsUIEnabled.Value && ___currentInhaleDuration > 0f)
{
StatsUI.instance.IncrementIntStat("TimesSmoked");
}
}
}
[HarmonyPatch(typeof(Sleep))]
private class SleepPatches
{
[HarmonyPostfix]
[HarmonyPatch("EnterBed")]
public static void EnterBedPatch()
{
if (Plugin.statsUIEnabled.Value)
{
StatsUI.instance.IncrementIntStat("TimesSlept");
if (Plugin.updateMilesSailed.Value == "sleep")
{
StatsUI.instance.UpdateMilesText();
}
}
}
}
[HarmonyPatch(typeof(PlayerMissions))]
private class PlayerMissionsPatches
{
[HarmonyPostfix]
[HarmonyPatch("CompleteMission")]
public static void CompleteMissionPatch()
{
if (Plugin.statsUIEnabled.Value)
{
StatsUI.instance.IncrementIntStat("MissionsCompleted");
}
}
}
[HarmonyPatch(typeof(Port))]
private class PortPatches
{
[HarmonyPostfix]
[HarmonyPatch("Update")]
public static void UpdatePatch(bool ___teleportPlayer)
{
if (Plugin.statsUIEnabled.Value && ___teleportPlayer)
{
StatsUI.instance.PlayerTeleported();
}
}
}
[HarmonyPatch(typeof(BoatMass))]
private class BoatMassPatches
{
[HarmonyPostfix]
[HarmonyPatch("FixedUpdate")]
public static void FixedUpdatePatch()
{
if (Plugin.statsUIEnabled.Value && (Object)(object)GameState.currentBoat != (Object)null)
{
StatsUI.instance.TrackDistance();
}
}
[HarmonyPostfix]
[HarmonyPatch("UpdateMass")]
public static void UpdateMassPatch(Rigidbody ___body)
{
if (Plugin.statsUIEnabled.Value && (Object)(object)GameState.currentBoat != (Object)null)
{
StatsUI.instance.RegisterTotalMass(___body.mass);
}
}
}
[HarmonyPatch(typeof(WeatherStorms))]
private class WeatherStormPatches
{
[HarmonyPostfix]
[HarmonyPatch("GetNormalizedDistance")]
public static void GetNormalizedDistancePatch(float __result)
{
if (Plugin.statsUIEnabled.Value && (Object)(object)GameState.currentBoat != (Object)null && !((Component)GameState.currentBoat.parent).gameObject.GetComponent<BoatMooringRopes>().AnyRopeMoored() && __result <= WeatherStorms.instance.GetPrivateField<float>("rainBorder"))
{
StatsUI.instance.IncrementStormsWeathered();
}
if (__result > WeatherStorms.instance.GetPrivateField<float>("cloudyBorder"))
{
StatsUI.instance.ClearLastStorm();
}
}
}
}
public class FishCaughtUI : MonoBehaviour
{
public static FishCaughtUI instance;
public Dictionary<string, int> caughtFish;
public TextMesh[] fishNameTMs;
public TextMesh[] caughtCountTMs;
public Dictionary<string, bool> fishBadges;
public Dictionary<string, GameObject> fishBadgeGOs;
private void Awake()
{
instance = this;
caughtFish = new Dictionary<string, int>();
fishBadges = new Dictionary<string, bool>();
fishBadgeGOs = new Dictionary<string, GameObject>();
string[] fishNames = Names.fishNames;
foreach (string text in fishNames)
{
caughtFish.Add(text, 0);
fishBadges.Add(text + "25", value: false);
fishBadges.Add(text + "50", value: false);
fishBadges.Add(text + "100", value: false);
}
string[] totalFishBadgeNames = Names.totalFishBadgeNames;
foreach (string key in totalFishBadgeNames)
{
fishBadges.Add(key, value: false);
}
}
public void RegisterCatch(GameObject fish)
{
string name = ((ShipItem)fish.GetComponent<ShipItemFood>()).name;
if (!caughtFish.ContainsKey(name))
{
Plugin.logger.LogWarning((object)("Fish caught " + name + " is not in fish caught log"));
return;
}
caughtFish[name]++;
CheckBadges(name);
Plugin.logger.LogDebug((object)("Caught: " + name));
}
public void UpdatePage()
{
UpdateTexts();
UpdateBadges();
}
private void UpdateTexts()
{
int num = 0;
int num2 = 0;
foreach (KeyValuePair<string, int> item in caughtFish)
{
if (Plugin.fishNamesHidden.Value)
{
fishNameTMs[num].text = ((item.Value > 0) ? item.Key : "???");
}
else
{
fishNameTMs[num].text = item.Key;
}
caughtCountTMs[num].text = item.Value.ToString();
num2 += item.Value;
num++;
}
fishNameTMs[fishNameTMs.Length - 1].text = "Total";
caughtCountTMs[caughtCountTMs.Length - 1].text = num2.ToString() ?? "";
}
public void CheckBadges(string fishName)
{
CheckIndividualFishBadges(fishName);
CheckAllFishBadges();
}
public void CheckIndividualFishBadges(string fishName)
{
int[] array = new int[3] { 25, 50, 100 };
int[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
int num = array2[i];
if (!fishBadges[fishName + num] && caughtFish[fishName] >= num)
{
if (Plugin.notificationsEnabled.Value)
{
NotificationUiQueue.instance.QueueNotification($"Caught {num} {fishName}");
}
fishBadges[fishName + num] = true;
}
}
}
public void CheckAllFishBadges()
{
int num = caughtFish.Values.Sum();
int[] array = new int[3] { 50, 250, 500 };
for (int i = 0; i < array.Length; i++)
{
if (!fishBadges[Names.totalFishBadgeNames[i]] && num >= array[i])
{
if (Plugin.notificationsEnabled.Value)
{
NotificationUiQueue.instance.QueueNotification($"Caught {array[i]} fish");
}
fishBadges[Names.totalFishBadgeNames[i]] = true;
}
}
if (!fishBadges[Names.totalFishBadgeNames[3]] && !caughtFish.Values.Where((int v) => v.Equals(0)).Any())
{
if (Plugin.notificationsEnabled.Value)
{
NotificationUiQueue.instance.QueueNotification("Caught all fish");
}
fishBadges[Names.totalFishBadgeNames[3]] = true;
}
}
private void UpdateBadges()
{
foreach (KeyValuePair<string, bool> fishBadge in fishBadges)
{
fishBadgeGOs[fishBadge.Key].SetActive(fishBadge.Value);
}
}
}
internal class LogUIPatches
{
[HarmonyPatch(typeof(MissionListUI))]
private class MissionListUIPatches
{
[HarmonyPrefix]
[HarmonyPatch("ToggleMenu")]
public static void TogglePatch()
{
//IL_0090: 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_012a: Unknown result type (might be due to invalid IL or missing references)
bookmarks[0].SetActive(false);
bookmarks[1].SetActive(false);
bookmarks[2].SetActive(false);
Stack<float> stack = new Stack<float>();
stack.Push(-0.515f);
stack.Push(-0.387f);
stack.Push(-0.26f);
if (Plugin.fishCaughtUIEnabled.Value)
{
bookmarks[0].transform.localPosition = new Vector3(stack.Pop(), 0.0027f, -0.4566f);
bookmarks[0].SetActive(true);
}
if (Plugin.portsVisitedUIEnabled.Value)
{
bookmarks[1].transform.localPosition = new Vector3(stack.Pop(), 0.0028f, -0.4566f);
bookmarks[1].SetActive(true);
}
if (Plugin.statsUIEnabled.Value)
{
bookmarks[2].transform.localPosition = new Vector3(stack.Pop(), -0.0032f, -0.4566f);
bookmarks[2].SetActive(true);
}
}
[HarmonyPostfix]
[HarmonyPatch("HideUI")]
public static void HideUIPatches(MissionListUI __instance)
{
fishCaughtUI.SetActive(false);
portsVisitedUI.SetActive(false);
statsUI.SetActive(false);
}
[HarmonyPostfix]
[HarmonyPatch("SwitchMode")]
public static void SwitchModePatches(MissionListMode mode)
{
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: 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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected I4, but got Unknown
fishCaughtUI.SetActive(false);
portsVisitedUI.SetActive(false);
statsUI.SetActive(false);
switch (mode - 5)
{
case 0:
fishCaughtUI.SetActive(true);
FishCaughtUI.instance.UpdatePage();
break;
case 1:
portsVisitedUI.SetActive(true);
PortsVisitedUI.instance.UpdatePage();
break;
case 2:
statsUI.SetActive(true);
StatsUI.instance.UpdatePage();
break;
}
}
[HarmonyPrefix]
[HarmonyPatch("Start")]
public static void StartPatch(MissionListUI __instance, GameObject ___modeButtons, GameObject ___reputationUI)
{
AssetsLoader.Start();
bookmarks = UIBuilder.MakeBookmarks(___modeButtons);
fishCaughtUI = UIBuilder.MakeFishCaughtUI(___reputationUI);
portsVisitedUI = UIBuilder.MakePortsVisitedUI(___reputationUI);
statsUI = UIBuilder.MakeStatsUI(___reputationUI);
}
}
[HarmonyPatch(typeof(NotificationUi))]
private class NotificationUiPatches
{
[HarmonyPostfix]
[HarmonyPatch("Start")]
public static void StartPatch(NotificationUi ___instance)
{
if (Plugin.notificationsEnabled.Value)
{
((Component)___instance).gameObject.AddComponent<NotificationUiQueue>();
}
}
}
private static GameObject fishCaughtUI;
private static GameObject portsVisitedUI;
private static GameObject statsUI;
private static List<GameObject> bookmarks;
}
internal class UIBuilder
{
internal const MissionListMode fishCaught = 5;
internal const MissionListMode portsVisited = 6;
internal const MissionListMode stats = 7;
internal static List<GameObject> MakeBookmarks(GameObject modeButtons)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
List<GameObject> list = new List<GameObject>();
GameObject gameObject = ((Component)modeButtons.transform.GetChild(9)).gameObject;
GameObject val = Object.Instantiate<GameObject>(gameObject);
val.transform.parent = modeButtons.transform;
val.transform.localRotation = gameObject.transform.localRotation;
val.transform.localScale = gameObject.transform.localScale;
((Object)val).name = "bookmark fish caught";
((Component)val.transform.GetChild(0)).gameObject.GetComponent<TextMesh>().text = "fish caught";
GPButtonLogMode component = val.GetComponent<GPButtonLogMode>();
Traverse.Create((object)component).Field("mode").SetValue((object)(MissionListMode)5);
Object.Destroy((Object)(object)val.GetComponent<Outline>());
list.Add(val);
GameObject val2 = Object.Instantiate<GameObject>(gameObject);
val2.transform.parent = modeButtons.transform;
val2.transform.localRotation = gameObject.transform.localRotation;
val2.transform.localScale = gameObject.transform.localScale;
((Object)val2).name = "bookmark ports visited";
((Component)val2.transform.GetChild(0)).gameObject.GetComponent<TextMesh>().text = "ports visited";
GPButtonLogMode component2 = val2.GetComponent<GPButtonLogMode>();
Traverse.Create((object)component2).Field("mode").SetValue((object)(MissionListMode)6);
Object.Destroy((Object)(object)val2.GetComponent<Outline>());
list.Add(val2);
GameObject val3 = Object.Instantiate<GameObject>(gameObject);
val3.transform.parent = modeButtons.transform;
val3.transform.localRotation = gameObject.transform.localRotation;
val3.transform.localScale = gameObject.transform.localScale;
((Object)val3).name = "bookmark stats";
((Component)val3.transform.GetChild(0)).gameObject.GetComponent<TextMesh>().text = "stats & transit";
GPButtonLogMode component3 = val3.GetComponent<GPButtonLogMode>();
Traverse.Create((object)component3).Field("mode").SetValue((object)(MissionListMode)7);
Object.Destroy((Object)(object)val3.GetComponent<Outline>());
list.Add(val3);
return list;
}
internal static GameObject MakeFishCaughtUI(GameObject repUI)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: 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_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_029e: Unknown result type (might be due to invalid IL or missing references)
//IL_042d: Unknown result type (might be due to invalid IL or missing references)
//IL_0432: Unknown result type (might be due to invalid IL or missing references)
//IL_043c: Unknown result type (might be due to invalid IL or missing references)
//IL_0454: Unknown result type (might be due to invalid IL or missing references)
//IL_046c: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
//IL_0339: Unknown result type (might be due to invalid IL or missing references)
//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
//IL_050d: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(repUI);
Object.Destroy((Object)(object)val.GetComponent<ReputationUI>());
val.transform.parent = repUI.transform.parent;
val.transform.localPosition = repUI.transform.localPosition;
val.transform.localRotation = repUI.transform.localRotation;
val.transform.localScale = repUI.transform.localScale;
((Object)val).name = "fish caught ui";
Object.Destroy((Object)(object)((Component)val.transform.GetChild(2)).gameObject);
Object.Destroy((Object)(object)((Component)val.transform.GetChild(1)).gameObject);
val.AddComponent<FishCaughtUI>();
GameObject gameObject = ((Component)val.transform.GetChild(0)).gameObject;
gameObject.GetComponent<TextMesh>().font = ((Component)gameObject.transform.GetChild(1)).GetComponent<TextMesh>().font;
((Renderer)gameObject.GetComponent<MeshRenderer>()).material = ((Renderer)((Component)gameObject.transform.GetChild(1)).GetComponent<MeshRenderer>()).material;
((Object)((Component)gameObject.transform.GetChild(1)).gameObject).name = "caught count";
Transform child = gameObject.transform.GetChild(1);
Vector3 localPosition = gameObject.transform.GetChild(1).localPosition;
child.localPosition = new Vector3(55f, 0f, ((Vector3)(ref localPosition))[2]);
((Component)gameObject.transform.GetChild(1)).GetComponent<TextMesh>().fontSize = 50;
TextMesh[] array = (TextMesh[])(object)new TextMesh[Names.fishNames.Length + 1];
TextMesh[] array2 = (TextMesh[])(object)new TextMesh[Names.fishNames.Length + 1];
for (int i = 0; i < Names.fishNames.Length; i++)
{
GameObject val2 = Object.Instantiate<GameObject>(gameObject);
Object.Destroy((Object)(object)((Component)val2.transform.GetChild(4)).gameObject);
Object.Destroy((Object)(object)((Component)val2.transform.GetChild(3)).gameObject);
Object.Destroy((Object)(object)((Component)val2.transform.GetChild(2)).gameObject);
Object.Destroy((Object)(object)((Component)val2.transform.GetChild(0)).gameObject);
val2.GetComponent<TextMesh>().fontSize = 50;
((Object)val2).name = Names.fishNames[i];
val2.transform.parent = gameObject.transform.parent;
Transform transform = val2.transform;
float num = 0.24f - 0.0375f * (float)i;
localPosition = gameObject.transform.localPosition;
transform.localPosition = new Vector3(0.8f, num, ((Vector3)(ref localPosition))[2]);
val2.transform.localRotation = gameObject.transform.localRotation;
val2.transform.localScale = gameObject.transform.localScale;
array2[i] = val2.GetComponent<TextMesh>();
array[i] = ((Component)val2.transform.GetChild(1)).GetComponent<TextMesh>();
string[] array3 = new string[3] { "25", "50", "100" };
for (int j = 0; j < array3.Length; j++)
{
string text = ((Object)val2).name + array3[j];
GameObject value = CreateBadgeObject(text, val2.transform, new Vector3(12f, 12f, 1f), new Vector3(75f + (float)j * 13f, 0f, 0f));
FishCaughtUI.instance.fishBadgeGOs.Add(text, value);
}
}
GameObject val3 = Object.Instantiate<GameObject>(gameObject);
Object.Destroy((Object)(object)((Component)val3.transform.GetChild(4)).gameObject);
Object.Destroy((Object)(object)((Component)val3.transform.GetChild(3)).gameObject);
Object.Destroy((Object)(object)((Component)val3.transform.GetChild(2)).gameObject);
Object.Destroy((Object)(object)((Component)val3.transform.GetChild(0)).gameObject);
((Object)val3).name = "totalCaught";
val3.transform.parent = gameObject.transform.parent;
Transform transform2 = val3.transform;
localPosition = gameObject.transform.localPosition;
transform2.localPosition = new Vector3(0.8f, -0.21f, ((Vector3)(ref localPosition))[2]);
val3.transform.localRotation = gameObject.transform.localRotation;
val3.transform.localScale = gameObject.transform.localScale;
array2[Names.fishNames.Length] = val3.GetComponent<TextMesh>();
array[Names.fishNames.Length] = ((Component)val3.transform.GetChild(1)).GetComponent<TextMesh>();
string[] array4 = new string[4] { "caught50", "caught250", "caught500", "caughtAll" };
for (int k = 0; k < array4.Length; k++)
{
string text2 = array4[k];
GameObject value2 = CreateBadgeObject(text2, val3.transform, new Vector3(15f, 15f, 1f), new Vector3(15f + (float)k * 20f, -13f, 0f));
FishCaughtUI.instance.fishBadgeGOs.Add(text2, value2);
}
Object.Destroy((Object)(object)gameObject);
FishCaughtUI.instance.fishNameTMs = array2;
FishCaughtUI.instance.caughtCountTMs = array;
Plugin.logger.LogInfo((object)"Loaded fish caught UI");
return val;
}
internal static GameObject MakePortsVisitedUI(GameObject repUI)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: 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_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_02af: Unknown result type (might be due to invalid IL or missing references)
//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
//IL_0571: Unknown result type (might be due to invalid IL or missing references)
//IL_0585: Unknown result type (might be due to invalid IL or missing references)
//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
//IL_033d: 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_0353: Unknown result type (might be due to invalid IL or missing references)
//IL_0358: 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_0382: Unknown result type (might be due to invalid IL or missing references)
//IL_039b: Unknown result type (might be due to invalid IL or missing references)
//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
//IL_040e: Unknown result type (might be due to invalid IL or missing references)
//IL_0413: Unknown result type (might be due to invalid IL or missing references)
//IL_0424: Unknown result type (might be due to invalid IL or missing references)
//IL_0429: Unknown result type (might be due to invalid IL or missing references)
//IL_0444: Unknown result type (might be due to invalid IL or missing references)
//IL_0449: Unknown result type (might be due to invalid IL or missing references)
//IL_0453: Unknown result type (might be due to invalid IL or missing references)
//IL_046c: Unknown result type (might be due to invalid IL or missing references)
//IL_0485: Unknown result type (might be due to invalid IL or missing references)
//IL_050a: Unknown result type (might be due to invalid IL or missing references)
//IL_051e: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(repUI);
Object.Destroy((Object)(object)val.GetComponent<ReputationUI>());
val.transform.parent = repUI.transform.parent;
val.transform.localPosition = repUI.transform.localPosition;
val.transform.localRotation = repUI.transform.localRotation;
val.transform.localScale = repUI.transform.localScale;
((Object)val).name = "ports visited ui";
val.AddComponent<PortsVisitedUI>();
Transform child = val.transform.GetChild(0);
Vector3 localPosition = val.transform.GetChild(0).localPosition;
child.localPosition = new Vector3(0.75f, 0.22f, ((Vector3)(ref localPosition))[2]);
Transform child2 = val.transform.GetChild(1);
localPosition = val.transform.GetChild(1).localPosition;
child2.localPosition = new Vector3(0.75f, 0.01f, ((Vector3)(ref localPosition))[2]);
Transform child3 = val.transform.GetChild(2);
localPosition = val.transform.GetChild(2).localPosition;
child3.localPosition = new Vector3(0.02f, 0.22f, ((Vector3)(ref localPosition))[2]);
GameObject val2 = Object.Instantiate<GameObject>(((Component)val.transform.GetChild(1)).gameObject);
val2.transform.parent = val.transform;
Transform transform = val2.transform;
localPosition = val.transform.GetChild(1).localPosition;
transform.localPosition = new Vector3(0.02f, -0.065f, ((Vector3)(ref localPosition))[2]);
val2.transform.localRotation = val.transform.GetChild(1).localRotation;
val2.transform.localScale = val.transform.GetChild(1).localScale;
((Object)val2).name = "lagoon";
val2.GetComponent<TextMesh>().text = "Fire Fish Lagoon";
TextMesh[] array = (TextMesh[])(object)new TextMesh[Names.portNames.Length];
TextMesh[] array2 = (TextMesh[])(object)new TextMesh[Names.portNames.Length];
int num = 0;
int[] array3 = new int[4] { 7, 6, 10, 4 };
for (int i = 0; i < 4; i++)
{
Transform child4 = val.transform.GetChild(i);
Object.Destroy((Object)(object)((Component)child4.GetChild(1)).gameObject);
Object.Destroy((Object)(object)((Component)child4.GetChild(2)).gameObject);
Object.Destroy((Object)(object)((Component)child4.GetChild(4)).gameObject);
GameObject gameObject = ((Component)child4.GetChild(0)).gameObject;
GameObject gameObject2 = ((Component)child4.GetChild(3)).gameObject;
((Object)gameObject).name = "port1";
gameObject.transform.localPosition = new Vector3(5f, -8f, -0.1f);
((Object)gameObject2).name = "visited port1";
gameObject2.transform.localPosition = new Vector3(70f, -9f, 0f);
array[num] = gameObject.GetComponent<TextMesh>();
array2[num] = gameObject2.GetComponent<TextMesh>();
num++;
for (int j = 1; j < array3[i]; j++)
{
GameObject val3 = Object.Instantiate<GameObject>(gameObject);
val3.transform.parent = gameObject.transform.parent;
Transform transform2 = val3.transform;
localPosition = gameObject.transform.localPosition;
float num2 = ((Vector3)(ref localPosition))[0];
localPosition = gameObject.transform.localPosition;
float num3 = ((Vector3)(ref localPosition))[1] - 7.5f * (float)j;
localPosition = gameObject.transform.localPosition;
transform2.localPosition = new Vector3(num2, num3, ((Vector3)(ref localPosition))[2]);
val3.transform.localRotation = gameObject.transform.localRotation;
val3.transform.localScale = gameObject.transform.localScale;
((Object)val3).name = "port" + (j + 1);
GameObject val4 = Object.Instantiate<GameObject>(gameObject2);
val4.transform.parent = gameObject2.transform.parent;
Transform transform3 = val4.transform;
localPosition = gameObject2.transform.localPosition;
float num4 = ((Vector3)(ref localPosition))[0];
localPosition = gameObject2.transform.localPosition;
float num5 = ((Vector3)(ref localPosition))[1] - 7.5f * (float)j;
localPosition = gameObject2.transform.localPosition;
transform3.localPosition = new Vector3(num4, num5, ((Vector3)(ref localPosition))[2]);
val4.transform.localRotation = gameObject2.transform.localRotation;
val4.transform.localScale = gameObject2.transform.localScale;
((Object)val4).name = "visited port" + (j + 1);
array[num] = val3.GetComponent<TextMesh>();
array2[num] = val4.GetComponent<TextMesh>();
num++;
}
string text = ((Object)child4).name + "Badge";
GameObject value = CreateBadgeObject(text, child4, new Vector3(15f, 15f, 1f), new Vector3(-8f, -2f, 0f));
PortsVisitedUI.instance.portBadgeGOs.Add(text, value);
}
string text2 = "allPortsBadge";
GameObject val5 = CreateBadgeObject(text2, val.transform, new Vector3(0.1f, 0.0675f, 1f), new Vector3(0.55f, -0.22f, -0.007f));
val5.transform.localEulerAngles = new Vector3(0f, 180f, 0f);
PortsVisitedUI.instance.portBadgeGOs.Add(text2, val5);
PortsVisitedUI.instance.portNameTMs = array;
PortsVisitedUI.instance.portVisitedTMs = array2;
Plugin.logger.LogInfo((object)"Loaded ports visited UI");
return val;
}
internal static GameObject MakeStatsUI(GameObject repUI)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0219: Unknown result type (might be due to invalid IL or missing references)
//IL_043f: Unknown result type (might be due to invalid IL or missing references)
//IL_0520: Unknown result type (might be due to invalid IL or missing references)
//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(repUI);
Object.Destroy((Object)(object)val.GetComponent<ReputationUI>());
val.transform.parent = repUI.transform.parent;
val.transform.localPosition = repUI.transform.localPosition;
val.transform.localRotation = repUI.transform.localRotation;
val.transform.localScale = repUI.transform.localScale;
((Object)val).name = "stats ui";
Object.Destroy((Object)(object)((Component)val.transform.GetChild(2)).gameObject);
Object.Destroy((Object)(object)((Component)val.transform.GetChild(1)).gameObject);
val.AddComponent<StatsUI>();
GameObject gameObject = ((Component)val.transform.GetChild(0)).gameObject;
gameObject.GetComponent<TextMesh>().font = ((Component)gameObject.transform.GetChild(1)).GetComponent<TextMesh>().font;
gameObject.GetComponent<TextMesh>().fontSize = 45;
((Renderer)gameObject.GetComponent<MeshRenderer>()).material = ((Renderer)((Component)gameObject.transform.GetChild(1)).GetComponent<MeshRenderer>()).material;
((Object)((Component)gameObject.transform.GetChild(0)).gameObject).name = "current value";
gameObject.transform.GetChild(0).localPosition = new Vector3(38f, 0f, 0f);
((Component)gameObject.transform.GetChild(0)).GetComponent<TextMesh>().font = ((Component)gameObject.transform.GetChild(1)).GetComponent<TextMesh>().font;
((Component)gameObject.transform.GetChild(0)).GetComponent<TextMesh>().fontSize = 45;
((Component)gameObject.transform.GetChild(0)).GetComponent<TextMesh>().anchor = (TextAnchor)3;
((Renderer)((Component)gameObject.transform.GetChild(0)).GetComponent<MeshRenderer>()).material = ((Renderer)((Component)gameObject.transform.GetChild(1)).GetComponent<MeshRenderer>()).material;
((Object)((Component)gameObject.transform.GetChild(1)).gameObject).name = "record value";
gameObject.transform.GetChild(1).localPosition = new Vector3(80f, 0f, 0f);
((Component)gameObject.transform.GetChild(1)).GetComponent<TextMesh>().fontSize = 45;
((Component)gameObject.transform.GetChild(1)).GetComponent<TextMesh>().anchor = (TextAnchor)3;
((Component)gameObject.transform.GetChild(1)).GetComponent<TextMesh>().fontStyle = (FontStyle)0;
Dictionary<string, TextMesh> statTMs = new Dictionary<string, TextMesh>();
AddTrackedStat(gameObject, "CargoMass", 0.215f, statTMs);
AddTrackedStat(gameObject, "TotalMass", 0.185f, statTMs);
AddTrackedStat(gameObject, "UnderwayTime", 0.155f, statTMs);
AddTrackedStat(gameObject, "MilesSailed", 0.08f, statTMs, ltime: true);
int num = 0;
string[] intStatNames = Names.intStatNames;
foreach (string text in intStatNames)
{
if (!(text == "UnderwayDay") && (!(text == "FlotsamEncounters") || (!((Object)(object)RandomEncounters.pluginInstance == (Object)null) && RandomEncounters.flotsamEnabled)) && (!(text == "DenseFogEncounters") || (!((Object)(object)RandomEncounters.pluginInstance == (Object)null) && RandomEncounters.denseFogEnabled)) && (!(text == "SeaLifeEncounters") || (!((Object)(object)RandomEncounters.pluginInstance == (Object)null) && RandomEncounters.isSeaLifeEnabled)))
{
AddTrackedStat(gameObject, text, 0.05f - 0.03f * (float)num, statTMs, ltime: true);
num++;
}
}
int num2 = 0;
string[] regionTransitNames = Names.regionTransitNames;
foreach (string name in regionTransitNames)
{
AddTrackedStat(gameObject, name, 0.215f - 0.03f * (float)num2, statTMs, ltime: false, transit: true);
num2++;
}
StatsUI.instance.statTMs = statTMs;
((Object)gameObject).name = "stats header";
gameObject.GetComponent<TextMesh>().text = "Stat Current Record";
gameObject.transform.localPosition = new Vector3(0.82f, 0.24f, -0.007f);
gameObject.GetComponent<TextMesh>().fontSize = 50;
gameObject.GetComponent<TextMesh>().fontStyle = (FontStyle)1;
Object.Destroy((Object)(object)((Component)gameObject.transform.GetChild(4)).gameObject);
Object.Destroy((Object)(object)((Component)gameObject.transform.GetChild(3)).gameObject);
Object.Destroy((Object)(object)((Component)gameObject.transform.GetChild(2)).gameObject);
Object.Destroy((Object)(object)((Component)gameObject.transform.GetChild(1)).gameObject);
Object.Destroy((Object)(object)((Component)gameObject.transform.GetChild(0)).gameObject);
GameObject val2 = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent);
((Object)val2).name = "lifetime stats header";
val2.GetComponent<TextMesh>().text = "Lifetime Stats";
val2.transform.localPosition = new Vector3(0.82f, 0.105f, -0.007f);
Object.Destroy((Object)(object)((Component)val2.transform.GetChild(4)).gameObject);
Object.Destroy((Object)(object)((Component)val2.transform.GetChild(3)).gameObject);
Object.Destroy((Object)(object)((Component)val2.transform.GetChild(2)).gameObject);
Object.Destroy((Object)(object)((Component)val2.transform.GetChild(1)).gameObject);
Object.Destroy((Object)(object)((Component)val2.transform.GetChild(0)).gameObject);
GameObject val3 = Object.Instantiate<GameObject>(gameObject, gameObject.transform.parent);
((Object)val3).name = "transit times header";
val3.GetComponent<TextMesh>().text = "Transit Times Last Record";
val3.transform.localPosition = new Vector3(0.12f, 0.24f, -0.007f);
Object.Destroy((Object)(object)((Component)val3.transform.GetChild(4)).gameObject);
Object.Destroy((Object)(object)((Component)val3.transform.GetChild(3)).gameObject);
Object.Destroy((Object)(object)((Component)val3.transform.GetChild(2)).gameObject);
Object.Destroy((Object)(object)((Component)val3.transform.GetChild(1)).gameObject);
Object.Destroy((Object)(object)((Component)val3.transform.GetChild(0)).gameObject);
Plugin.logger.LogInfo((object)"Loaded stats & transit UI");
return val;
}
private static void AddTrackedStat(GameObject templateGO, string name, float yPos, Dictionary<string, TextMesh> statTMs, bool ltime = false, bool transit = false)
{
//IL_00e1: 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_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
float num = (transit ? 0.12f : 0.82f);
string text = (transit ? "last" : "current");
GameObject val = Object.Instantiate<GameObject>(templateGO);
Object.Destroy((Object)(object)((Component)val.transform.GetChild(4)).gameObject);
Object.Destroy((Object)(object)((Component)val.transform.GetChild(3)).gameObject);
Object.Destroy((Object)(object)((Component)val.transform.GetChild(2)).gameObject);
if (ltime)
{
Object.Destroy((Object)(object)((Component)val.transform.GetChild(1)).gameObject);
val.transform.GetChild(0).localPosition = new Vector3(41f, 0f, 0f);
}
((Object)val).name = name;
val.transform.parent = templateGO.transform.parent;
Transform transform = val.transform;
Vector3 localPosition = templateGO.transform.localPosition;
transform.localPosition = new Vector3(num, yPos, ((Vector3)(ref localPosition))[2]);
val.transform.localRotation = templateGO.transform.localRotation;
val.transform.localScale = templateGO.transform.localScale;
statTMs[name] = val.GetComponent<TextMesh>();
statTMs[text + name] = ((Component)val.transform.GetChild(0)).GetComponent<TextMesh>();
if (!ltime)
{
statTMs["record" + name] = ((Component)val.transform.GetChild(1)).GetComponent<TextMesh>();
}
}
private static GameObject CreateBadgeObject(string name, Transform parent, Vector3 scale, Vector3 position)
{
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.CreatePrimitive((PrimitiveType)5);
val.layer = 5;
Object.Destroy((Object)(object)val.GetComponent<MeshCollider>());
((Renderer)val.GetComponent<MeshRenderer>()).shadowCastingMode = (ShadowCastingMode)0;
val.transform.SetParent(parent, false);
val.transform.localScale = scale;
val.transform.localPosition = position;
((Object)val).name = name;
((Renderer)val.GetComponent<MeshRenderer>()).material = AssetsLoader.materials[name];
return val;
}
}
internal class AssetsLoader
{
public static AudioClip notificationSound;
public static Dictionary<string, Material> materials;
public static Dictionary<string, Texture2D> textures;
public static void Start()
{
materials = new Dictionary<string, Material>();
textures = new Dictionary<string, Texture2D>();
LoadAudio();
LoadFishBadges();
LoadPortBadges();
}
private static void LoadAudio()
{
List<AudioClip> list = new List<AudioClip>();
GetAudioClip("twoBells", list);
Debug.Log((object)$"AudioClips length {list.Count}");
notificationSound = list[0];
}
private static void GetAudioClip(string fileName, List<AudioClip> audioClips)
{
string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Plugin.instance).Info.Location), "assets", "sounds", fileName + ".wav");
UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("file://" + text, (AudioType)20);
audioClip.SendWebRequest();
while (!audioClip.isDone)
{
}
if (audioClip.isNetworkError)
{
Debug.Log((object)audioClip.error);
return;
}
AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip);
((Object)content).name = fileName;
audioClips.Add(content);
}
private static void LoadFishBadges()
{
string path = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Plugin.instance).Info.Location), "assets", "badges", "fish");
int[] array = new int[3] { 25, 50, 100 };
string[] fishNames = Names.fishNames;
foreach (string text in fishNames)
{
for (int j = 0; j < 3; j++)
{
string text2 = text + array[j];
Texture2D val = LoadTexture(Path.Combine(path, text2 + ".png"));
textures.Add(text2, val);
materials.Add(text2, CreateMaterial(val));
}
}
string[] totalFishBadgeNames = Names.totalFishBadgeNames;
foreach (string text3 in totalFishBadgeNames)
{
string text2 = text3;
Texture2D val = LoadTexture(Path.Combine(path, text2 + ".png"));
textures.Add(text2, val);
materials.Add(text2, CreateMaterial(val));
}
Plugin.logger.LogInfo((object)"Fishing badges loaded.");
}
private static void LoadPortBadges()
{
string path = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)Plugin.instance).Info.Location), "assets", "badges", "ports");
string[] portBadgeNames = Names.portBadgeNames;
foreach (string text in portBadgeNames)
{
Texture2D val = LoadTexture(Path.Combine(path, text + ".png"));
textures.Add(text, val);
materials.Add(text, CreateMaterial(val));
}
Plugin.logger.LogInfo((object)"Port badges loaded.");
}
private static Texture2D LoadTexture(string path)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
byte[] array = (File.Exists(path) ? File.ReadAllBytes(path) : null);
Texture2D val = new Texture2D(1, 1);
if (array == null)
{
Plugin.logger.LogError((object)("Failed to load " + path));
return val;
}
ImageConversion.LoadImage(val, array);
return val;
}
private static Material CreateMaterial(Texture2D tex)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
Material val = new Material(Shader.Find("Standard"))
{
renderQueue = 2001,
mainTexture = (Texture)(object)tex
};
val.EnableKeyword("_ALPHATEST_ON");
val.SetShaderPassEnabled("ShadowCaster", false);
return val;
}
}
internal static class Helper
{
public static T GetPrivateField<T>(this object obj, string field)
{
return (T)Traverse.Create(obj).Field(field).GetValue();
}
}
internal static class Names
{
public static string[] fishNames = new string[12]
{
"templefish", "sunspot fish", "tuna", "shimmertail", "salmon", "eel", "blackfin hunter", "trout", "north fish", "swamp snapper",
"blue bubbler", "fire fish"
};
public static string[] totalFishBadgeNames = new string[4] { "caught50", "caught250", "caught500", "caughtAll" };
public static string[] alankhPorts = new string[7] { "Gold Rock City", "Al'Nilem", "Neverdin", "Albacore Town", "Alchemist's Island", "Al'Ankh Academy", "Oasis" };
public static string[] emeraldPorts = new string[6] { "Dragon Cliffs", "Sanctuary", "Crab Beach", "New Port", "Sage Hills", "Serpent Isle" };
public static string[] mediPorts = new string[10] { "Fort Aestrin", "Sunspire", "Mount Malefic", "Siren Song", "Eastwind", "Firefly Grotto", "Aestra Abbey", "Fey Valley", "Happy Bay", "Chronos" };
public static string[] lagoonPorts = new string[4] { "Kicia Bay", "Fire Fish Town", "On'na", "Sen'na" };
public static string[] portNames = new string[27]
{
"Gold Rock City", "Al'Nilem", "Neverdin", "Albacore Town", "Alchemist's Island", "Al'Ankh Academy", "Oasis", "Dragon Cliffs", "Sanctuary", "Crab Beach",
"New Port", "Sage Hills", "Serpent Isle", "Fort Aestrin", "Sunspire", "Mount Malefic", "Siren Song", "Eastwind", "Firefly Grotto", "Aestra Abbey",
"Fey Valley", "Happy Bay", "Chronos", "Kicia Bay", "Fire Fish Town", "On'na", "Sen'na"
};
public static string[] capitals = new string[4] { "grc", "dc", "fa", "kb" };
public static string[] portBadgeNames = new string[5] { "alankhBadge", "emeraldBadge", "mediBadge", "lagoonBadge", "allPortsBadge" };
public static string[] floatStatNames = new string[4] { "CargoMass", "TotalMass", "UnderwayTime", "MilesSailed" };
public static string[] intStatNames = new string[11]
{
"UnderwayDay", "PortsVisited", "MissionsCompleted", "DrinksTaken", "FoodsEaten", "TimesSmoked", "TimesSlept", "StormsWeathered", "FlotsamEncounters", "DenseFogEncounters",
"SeaLifeEncounters"
};
public static string[] transitNames = new string[12]
{
"GrcDc", "GrcFa", "GrcKb", "DcGrc", "DcFa", "DcKb", "FaGrc", "FaDc", "FaKb", "KbGrc",
"KbDc", "KbFa"
};
public static string[] regions = new string[4] { "Aa", "Ea", "Ae", "Ffl" };
public static string[] regionTransitNames = new string[12]
{
"AaEa", "AaAe", "AaFfl", "EaAa", "EaAe", "EaFfl", "AeAa", "AeEa", "AeFfl", "FflAa",
"FflEa", "FflAe"
};
public static string[] alankhIslands = new string[9] { "island 1 A (gold rock)", "island 2 A (AlNilem)", "island 3 A (Neverdin)", "island 4 A (fish island)", "island 5 A (clear mind)", "island 6 A (lion fang)", "island 7 A (alchemist's island)", "island 8 A (academy)", "island 20 A (Oasis)" };
public static string[] emeraldIslands = new string[6] { "island 9 E (dragon cliffs)", "island 10 E (sanctuary)", "island 11 E (crab beach)", "island 12 E (New Port)", "island 13 E (Sage Hills)", "island 22 E (serpent isle)" };
public static string[] mediIslands = new string[11]
{
"island 15 M (Fort)", "island 16 M (Sunspire)", "island 17 M (Mount Malefic)", "island 18 M (HappyBay)", "island 19 M (Eastwind)", "island 21 M (Siren Song)", "island 33 M cave church", "island 34 M monastery", "island 35 M valley", "island 23 M oracle",
"island 25 (chronos)"
};
public static string[] lagoonIslands = new string[5] { "island 26 Lagoon Temple", "island 27 Lagoon Shipyard", "island 28 Lagoon Senna", "island 29 Lagoon Onna", "island 31 Lagoon Fisherman" };
}
public class NotificationUiQueue : MonoBehaviour
{
public static NotificationUiQueue instance;
private float timer;
private Queue<string> queue;
private AudioSource audioSource;
public void Start()
{
instance = this;
queue = new Queue<string>();
timer = 0f;
audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
audioSource.volume = Plugin.notificationSoundVolume.Value;
audioSource.spatialBlend = 1f;
audioSource.minDistance = 10f;
audioSource.maxDistance = 20f;
}
private void Update()
{
if (timer > 0f)
{
timer -= Time.deltaTime;
return;
}
timer = 0f;
if (queue.Count > 0)
{
NotificationUi.instance.ShowNotification(queue.Dequeue());
if (Plugin.notificationSoundVolume.Value > 0f)
{
audioSource.PlayOneShot(AssetsLoader.notificationSound);
}
timer = 3f;
}
}
public void QueueNotification(string message)
{
queue.Enqueue(message);
}
}
[BepInPlugin("com.raddude82.sailadex", "Sail-A-Dex", "1.4.5")]
[BepInDependency("com.raddude82.modsavebackups", "1.1.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string PLUGIN_GUID = "com.raddude82.sailadex";
public const string PLUGIN_NAME = "Sail-A-Dex";
public const string PLUGIN_VERSION = "1.4.5";
public const string MODSAVEBACKUPS_GUID = "com.raddude82.modsavebackups";
public const string MODSAVEBACKUPS_VERSION = "1.1.1";
public const string PASSAGEDUDE_GUID = "pr0skynesis.passagedude";
public const string RANDOMENCOUNTERS_GUID = "com.raddude82.randomencounters";
internal static ConfigEntry<bool> fishNamesHidden;
internal static ConfigEntry<bool> portNamesHidden;
internal static ConfigEntry<bool> fishCaughtUIEnabled;
internal static ConfigEntry<bool> portsVisitedUIEnabled;
internal static ConfigEntry<bool> statsUIEnabled;
internal static ConfigEntry<bool> notificationsEnabled;
internal static ConfigEntry<float> notificationSoundVolume;
internal static ConfigEntry<string> updateMilesSailed;
internal static Plugin instance;
internal static ManualLogSource logger;
internal static Harmony harmony;
private void Awake()
{
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Expected O, but got Unknown
fishNamesHidden = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Hide Fish Names Before Caught", true, "true = fish names will be hidden before being caught for the first time.");
portNamesHidden = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Hide Port Names Before Visited", false, "true = port names will be hidden before visited for the first time.");
fishCaughtUIEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Enable Fish Caught UI", true, "true = UI for how many fish you caught will be enabled.");
portsVisitedUIEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Enable Ports Visited UI", true, "true = UI for which ports you have visited will be enabled.");
statsUIEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Enable Stats UI", true, "true = UI for various stats will be enabled.");
notificationsEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Enable Notifications", true, "true = notifications on badge earned will be enabled.");
notificationSoundVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Notification Volume", 0.2f, "Above 1f is loud and not recommended. Set to 0f to disable.");
updateMilesSailed = ((BaseUnityPlugin)this).Config.Bind<string>("Settings", "Miles Sailed Updates", "moored", new ConfigDescription("Miles sailed text will be updated once moored, going to sleeping or moored, or in real time.", (AcceptableValueBase)(object)new AcceptableValueList<string>(new string[3] { "moored", "sleep", "realtime" }), Array.Empty<object>()));
instance = this;
logger = ((BaseUnityPlugin)this).Logger;
harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.raddude82.sailadex");
foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
{
BepInPlugin metadata = pluginInfo.Value.Metadata;
if (metadata.GUID.Equals("pr0skynesis.passagedude"))
{
logger.LogInfo((object)"pr0skynesis.passagedude found");
PassageDude.PatchMod();
}
if (metadata.GUID.Equals("com.raddude82.randomencounters"))
{
logger.LogInfo((object)"com.raddude82.randomencounters found");
RandomEncounters.pluginInstance = pluginInfo.Value.Instance;
RandomEncounters.PatchMod();
}
}
}
}
public class PortsVisitedUI : MonoBehaviour
{
public static PortsVisitedUI instance;
public Dictionary<string, bool> visitedPorts;
public TextMesh[] portNameTMs;
public TextMesh[] portVisitedTMs;
public Dictionary<string, bool> portBadges;
public Dictionary<string, GameObject> portBadgeGOs;
private void Awake()
{
instance = this;
visitedPorts = new Dictionary<string, bool>();
portBadges = new Dictionary<string, bool>();
portBadgeGOs = new Dictionary<string, GameObject>();
string[] portNames = Names.portNames;
foreach (string key in portNames)
{
visitedPorts.Add(key, value: false);
}
string[] portBadgeNames = Names.portBadgeNames;
foreach (string key2 in portBadgeNames)
{
portBadges.Add(key2, value: false);
}
}
public void RegisterVisit(string portName)
{
if (visitedPorts.ContainsKey(portName) && !visitedPorts[portName])
{
visitedPorts[portName] = true;
CheckBadges();
}
Plugin.logger.LogDebug((object)("Visited: " + portName));
}
public void UpdatePage()
{
UpdateTexts();
UpdateBadges();
}
private void UpdateTexts()
{
int num = 0;
foreach (KeyValuePair<string, bool> visitedPort in visitedPorts)
{
if (Plugin.portNamesHidden.Value)
{
portNameTMs[num].text = (visitedPort.Value ? visitedPort.Key : "???");
}
else
{
portNameTMs[num].text = visitedPort.Key;
}
portVisitedTMs[num].text = (visitedPort.Value ? "✓" : "✗");
num++;
}
}
public void CheckBadges()
{
bool flag = Names.alankhPorts.All((string p) => visitedPorts[p]);
bool flag2 = Names.emeraldPorts.All((string p) => visitedPorts[p]);
bool flag3 = Names.mediPorts.All((string p) => visitedPorts[p]);
bool flag4 = Names.lagoonPorts.All((string p) => visitedPorts[p]);
if (!portBadges["alankhBadge"] && flag)
{
if (Plugin.notificationsEnabled.Value)
{
NotificationUiQueue.instance.QueueNotification("Visited all Al'Ankh ports");
}
portBadges["alankhBadge"] = true;
}
if (!portBadges["emeraldBadge"] && flag2)
{
if (Plugin.notificationsEnabled.Value)
{
NotificationUiQueue.instance.QueueNotification("Visited all Emerald\nArchipelago ports");
}
portBadges["emeraldBadge"] = true;
}
if (!portBadges["mediBadge"] && flag3)
{
if (Plugin.notificationsEnabled.Value)
{
NotificationUiQueue.instance.QueueNotification("Visited all Aestrin ports");
}
portBadges["mediBadge"] = true;
}
if (!portBadges["lagoonBadge"] && flag4)
{
if (Plugin.notificationsEnabled.Value)
{
NotificationUiQueue.instance.QueueNotification("Visited all Fire\nFish Lagoon ports");
}
portBadges["lagoonBadge"] = true;
}
if (!portBadges["allPortsBadge"] && flag && flag2 && flag3 && flag4)
{
if (Plugin.notificationsEnabled.Value)
{
NotificationUiQueue.instance.QueueNotification("Visited all ports");
}
portBadges["allPortsBadge"] = true;
}
}
public void UpdateBadges()
{
foreach (KeyValuePair<string, bool> portBadge in portBadges)
{
portBadgeGOs[portBadge.Key].SetActive(portBadge.Value);
}
}
}
internal class SaveLoadPatches
{
[HarmonyPatch(typeof(SaveLoadManager))]
private class SaveLoadManagerPatches
{
[HarmonyPostfix]
[HarmonyPatch("SaveModData")]
public static void DoSaveGamePatch()
{
SailadexSaveContainer sailadexSaveContainer = new SailadexSaveContainer();
sailadexSaveContainer.caughtFish = FishCaughtUI.instance.caughtFish.ToDictionary((KeyValuePair<string, int> entry) => entry.Key, (KeyValuePair<string, int> entry) => entry.Value);
sailadexSaveContainer.fishBadges = FishCaughtUI.instance.fishBadges.ToDictionary((KeyValuePair<string, bool> entry) => entry.Key, (KeyValuePair<string, bool> entry) => entry.Value);
sailadexSaveContainer.visitedPorts = PortsVisitedUI.instance.visitedPorts.ToDictionary((KeyValuePair<string, bool> entry) => entry.Key, (KeyValuePair<string, bool> entry) => entry.Value);
sailadexSaveContainer.portBadges = PortsVisitedUI.instance.portBadges.ToDictionary((KeyValuePair<string, bool> entry) => entry.Key, (KeyValuePair<string, bool> entry) => entry.Value);
sailadexSaveContainer.floatStats = StatsUI.instance.floatStats.ToDictionary((KeyValuePair<string, float> entry) => entry.Key, (KeyValuePair<string, float> entry) => entry.Value);
sailadexSaveContainer.intStats = StatsUI.instance.intStats.ToDictionary((KeyValuePair<string, int> entry) => entry.Key, (KeyValuePair<string, int> entry) => entry.Value);
sailadexSaveContainer.boolArrayStats = StatsUI.instance.boolArrayStats.ToDictionary((KeyValuePair<string, bool[]> entry) => entry.Key, (KeyValuePair<string, bool[]> entry) => entry.Value);
ModSave.Save(((BaseUnityPlugin)Plugin.instance).Info, (object)sailadexSaveContainer);
}
[HarmonyPostfix]
[HarmonyPatch("LoadModData")]
public static void LoadModDataPatch()
{
SailadexSaveContainer sailadexSaveContainer = default(SailadexSaveContainer);
if (!ModSave.Load<SailadexSaveContainer>(((BaseUnityPlugin)Plugin.instance).Info, ref sailadexSaveContainer))
{
Plugin.logger.LogWarning((object)"Save file loading failed. If this is the first time loading this save with this mod, this is normal.");
return;
}
if (sailadexSaveContainer.caughtFish != null)
{
ConvertFishNames(sailadexSaveContainer.caughtFish, FishCaughtUI.instance.caughtFish);
}
if (sailadexSaveContainer.fishBadges != null)
{
LoadDictionary(sailadexSaveContainer.fishBadges, FishCaughtUI.instance.fishBadges);
}
if (sailadexSaveContainer.visitedPorts != null)
{
LoadDictionary(sailadexSaveContainer.visitedPorts, PortsVisitedUI.instance.visitedPorts);
}
if (sailadexSaveContainer.portBadges != null)
{
LoadDictionary(sailadexSaveContainer.portBadges, PortsVisitedUI.instance.portBadges);
}
if (sailadexSaveContainer.floatStats != null)
{
if (sailadexSaveContainer.floatStats.ContainsKey("recordGrcDcTransitTime"))
{
ConvertTransitFloats(sailadexSaveContainer.floatStats);
}
LoadDictionary(sailadexSaveContainer.floatStats, StatsUI.instance.floatStats);
}
if (sailadexSaveContainer.intStats != null)
{
if (sailadexSaveContainer.intStats.ContainsKey("recordGrcDcTransitDay"))
{
ConvertTransitInts(sailadexSaveContainer.intStats);
}
LoadDictionary(sailadexSaveContainer.intStats, StatsUI.instance.intStats);
}
if (sailadexSaveContainer.boolArrayStats == null)
{
return;
}
if (sailadexSaveContainer.boolArrayStats.ContainsKey("grcTransit"))
{
ConvertTransitBools(sailadexSaveContainer.boolArrayStats);
}
foreach (KeyValuePair<string, bool[]> boolArrayStat in sailadexSaveContainer.boolArrayStats)
{
if (StatsUI.instance.boolArrayStats.ContainsKey(boolArrayStat.Key))
{
StatsUI.instance.boolArrayStats[boolArrayStat.Key] = (bool[])boolArrayStat.Value.Clone();
}
else
{
Plugin.logger.LogWarning((object)("LoadData: " + boolArrayStat.Key + " not found in game"));
}
}
}
public static void LoadDictionary<T>(Dictionary<string, T> saveDict, Dictionary<string, T> gameDict)
{
foreach (KeyValuePair<string, T> item in saveDict)
{
if (gameDict.ContainsKey(item.Key))
{
gameDict[item.Key] = item.Value;
}
else
{
Plugin.logger.LogWarning((object)("LoadData: " + item.Key + " not found in game"));
}
}
}
public static void ConvertFishNames(Dictionary<string, int> oldFishCount, Dictionary<string, int> newFishCount)
{
if (!oldFishCount.ContainsKey("31 templefish (A)"))
{
LoadDictionary(oldFishCount, newFishCount);
return;
}
Plugin.logger.LogDebug((object)"Converting fishNames in fish caught counts");
foreach (KeyValuePair<string, int> item in oldFishCount)
{
string text = item.Key;
if (Regex.IsMatch(text, "^\\d"))
{
text = text.Substring(3, text.IndexOf("(") - 4);
}
newFishCount[text] = item.Value;
}
}
public static void ConvertTransitInts(Dictionary<string, int> transitInts)
{
Plugin.logger.LogDebug((object)"Converting transit ints");
for (int i = 0; i < Names.regionTransitNames.Length; i++)
{
transitInts["last" + Names.regionTransitNames[i] + "TransitDay"] = transitInts["last" + Names.transitNames[i] + "TransitDay"];
transitInts["record" + Names.regionTransitNames[i] + "TransitDay"] = transitInts["record" + Names.transitNames[i] + "TransitDay"];
transitInts.Remove("last" + Names.transitNames[i] + "TransitDay");
transitInts.Remove("record" + Names.transitNames[i] + "TransitDay");
}
for (int j = 0; j < Names.regions.Length; j++)
{
transitInts[Names.regions[j] + "UnderwayDay"] = transitInts[Names.capitals[j] + "UnderwayDay"];
transitInts.Remove(Names.capitals[j] + "UnderwayDay");
}
}
public static void ConvertTransitFloats(Dictionary<string, float> transitFloats)
{
Plugin.logger.LogDebug((object)"Converting transit floats");
for (int i = 0; i < Names.regionTransitNames.Length; i++)
{
transitFloats["last" + Names.regionTransitNames[i] + "TransitTime"] = transitFloats["last" + Names.transitNames[i] + "TransitTime"];
transitFloats["record" + Names.regionTransitNames[i] + "TransitTime"] = transitFloats["record" + Names.transitNames[i] + "TransitTime"];
transitFloats.Remove("last" + Names.transitNames[i] + "TransitTime");
transitFloats.Remove("record" + Names.transitNames[i] + "TransitTime");
}
for (int j = 0; j < Names.regions.Length; j++)
{
transitFloats[Names.regions[j] + "UnderwayTime"] = transitFloats[Names.capitals[j] + "UnderwayTime"];
transitFloats.Remove(Names.capitals[j] + "UnderwayTime");
}
}
public static void ConvertTransitBools(Dictionary<string, bool[]> transitBools)
{
Plugin.logger.LogDebug((object)"Converting transit bools");
for (int i = 0; i < Names.regions.Length; i++)
{
transitBools[Names.regions[i] + "Transit"] = (bool[])transitBools[Names.capitals[i] + "Transit"].Clone();
transitBools.Remove(Names.capitals[i] + "Transit");
}
}
}
}
[Serializable]
public class SailadexSaveContainer
{
public Dictionary<string, int> caughtFish;
public Dictionary<string, bool> visitedPorts;
public Dictionary<string, bool> fishBadges;
public Dictionary<string, bool> portBadges;
public Dictionary<string, float> floatStats;
public Dictionary<string, int> intStats;
public Dictionary<string, bool[]> boolArrayStats;
}
public class StatsUI : MonoBehaviour
{
public static StatsUI instance;
public Dictionary<string, float> floatStats;
public Dictionary<string, int> intStats;
public Dictionary<string, bool[]> boolArrayStats;
public Dictionary<string, TextMesh> statTMs;
private Vector3 lastPosition;
private string lastPortVisited;
private int trackerTimer;
private string lastStorm;
private void Awake()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
instance = this;
floatStats = new Dictionary<string, float>();
intStats = new Dictionary<string, int>();
boolArrayStats = new Dictionary<string, bool[]>();
statTMs = new Dictionary<string, TextMesh>();
lastPosition = default(Vector3);
lastPortVisited = "";
trackerTimer = 1000;
lastStorm = "";
string[] floatStatNames = Names.floatStatNames;
foreach (string text in floatStatNames)
{
floatStats.Add(text, 0f);
floatStats.Add("current" + text, 0f);
floatStats.Add("record" + text, 0f);
}
string[] intStatNames = Names.intStatNames;
foreach (string text2 in intStatNames)
{
intStats.Add(text2, 0);
intStats.Add("current" + text2, 0);
intStats.Add("record" + text2, 0);
}
string[] regionTransitNames = Names.regionTransitNames;
foreach (string text3 in regionTransitNames)
{
floatStats.Add("last" + text3 + "TransitTime", 0f);
intStats.Add("last" + text3 + "TransitDay", 0);
floatStats.Add("record" + text3 + "TransitTime", 0f);
intStats.Add("record" + text3 + "TransitDay", 0);
}
string[] regions = Names.regions;
foreach (string text4 in regions)
{
floatStats.Add(text4 + "UnderwayTime", 0f);
intStats.Add(text4 + "UnderwayDay", 0);
boolArrayStats.Add(text4 + "Transit", new bool[4]);
}
}
public void RegisterCurrentMass()
{
Transform currentBoat = GameState.currentBoat;
if (!((Object)(object)((currentBoat != null) ? currentBoat.parent : null) == (Object)null) || !((Object)(object)GameState.lastBoat == (Object)null))
{
GameObject val = (((Object)(object)GameState.currentBoat != (Object)null) ? ((Component)GameState.currentBoat.parent).gameObject : ((Component)GameState.lastBoat).gameObject);
floatStats["currentCargoMass"] = (from item in val.GetComponent<BoatMass>().GetPrivateField<List<ItemRigidbody>>("itemsOnBoat")
where (Object)(object)((Component)item.GetShipItem()).GetComponent<Good>() != (Object)null && (((Component)item.GetShipItem()).GetComponent<Good>().sizeDescription.Contains("crate") || ((Component)item.GetShipItem()).GetComponent<Good>().sizeDescription.Contains("package") || ((Component)item.GetShipItem()).GetComponent<Good>().sizeDescription.Contains("barrel") || ((Component)item.GetShipItem()).GetComponent<Good>().sizeDescription.Contains("bundle"))
select item).Sum((ItemRigidbody item) => item.GetBody().mass);
}
}
public void RegisterTotalMass(float totalMass)
{
floatStats["currentTotalMass"] = totalMass;
}
public void RegisterUnderway(string islandName)
{
if (islandName == null || islandName == "")
{
return;
}
if (floatStats["recordCargoMass"] < floatStats["currentCargoMass"])
{
floatStats["recordCargoMass"] = floatStats["currentCargoMass"];
}
if (floatStats["recordTotalMass"] < floatStats["currentTotalMass"])
{
floatStats["recordTotalMass"] = floatStats["currentTotalMass"];
}
floatStats["UnderwayTime"] = Sun.sun.globalTime;
intStats["UnderwayDay"] = GameState.day;
if (islandName == "island 18 M (HappyBay)")
{
return;
}
if (Names.alankhIslands.Contains(islandName))
{
floatStats["AaUnderwayTime"] = Sun.sun.globalTime;
intStats["AaUnderwayDay"] = GameState.day;
for (int i = 0; i < 4; i++)
{
boolArrayStats["AaTransit"][i] = false;
}
}
else if (Names.emeraldIslands.Contains(islandName))
{
floatStats["EaUnderwayTime"] = Sun.sun.globalTime;
intStats["EaUnderwayDay"] = GameState.day;
for (int j = 0; j < 4; j++)
{
boolArrayStats["EaTransit"][j] = false;
}
}
else if (Names.mediIslands.Contains(islandName))
{
floatStats["AeUnderwayTime"] = Sun.sun.globalTime;
intStats["AeUnderwayDay"] = GameState.day;
for (int k = 0; k < 4; k++)
{
boolArrayStats["AeTransit"][k] = false;
}
}
else if (Names.lagoonIslands.Contains(islandName))
{
floatStats["FflUnderwayTime"] = Sun.sun.globalTime;
intStats["FflUnderwayDay"] = GameState.day;
for (int l = 0; l < 4; l++)
{
boolArrayStats["FflTransit"][l] = false;
}
}
}
public void RegisterMoored(string islandName)
{
if (islandName == null || islandName == "")
{
return;
}
UpdateStats();
if (intStats["currentUnderwayDay"] > intStats["recordUnderwayDay"] || (intStats["currentUnderwayDay"] == intStats["recordUnderwayDay"] && floatStats["currentUnderwayTime"] > floatStats["recordUnderwayTime"]))
{
intStats["recordUnderwayDay"] = intStats["currentUnderwayDay"];
floatStats["recordUnderwayTime"] = floatStats["currentUnderwayTime"];
}
floatStats["UnderwayTime"] = 0f;
intStats["UnderwayDay"] = 0;
if (islandName == "island 18 M (HappyBay)")
{
return;
}
if (Names.alankhIslands.Contains(islandName))
{
if (!boolArrayStats["EaTransit"][0] && (floatStats["EaUnderwayTime"] > 0f || intStats["EaUnderwayDay"] > 0))
{
CheckTransitTime("Ea", "EaAa", 0);
}
if (!boolArrayStats["AeTransit"][0] && (floatStats["AeUnderwayTime"] > 0f || intStats["AeUnderwayDay"] > 0))
{
CheckTransitTime("Ae", "AeAa", 0);
}
if (!boolArrayStats["FflTransit"][0] && (floatStats["FflUnderwayTime"] > 0f || intStats["FflUnderwayDay"] > 0))
{
CheckTransitTime("Ffl", "FflAa", 0);
}
}
else if (Names.emeraldIslands.Contains(islandName))
{
if (!boolArrayStats["AaTransit"][1] && (floatStats["AaUnderwayTime"] > 0f || intStats["AaUnderwayDay"] > 0))
{
CheckTransitTime("Aa", "AaEa", 1);
}
if (!boolArrayStats["AeTransit"][1] && (floatStats["AeUnderwayTime"] > 0f || intStats["AeUnderwayDay"] > 0))
{
CheckTransitTime("Ae", "AeEa", 1);
}
if (!boolArrayStats["FflTransit"][1] && (floatStats["FflUnderwayTime"] > 0f || intStats["FflUnderwayDay"] > 0))
{
CheckTransitTime("Ffl", "FflEa", 1);
}
}
else if (Names.mediIslands.Contains(islandName))
{
if (!boolArrayStats["AaTransit"][2] && (floatStats["AaUnderwayTime"] > 0f || intStats["AaUnderwayDay"] > 0))
{
CheckTransitTime("Aa", "AaAe", 2);
}
if (!boolArrayStats["EaTransit"][2] && (floatStats["EaUnderwayTime"] > 0f || intStats["EaUnderwayDay"] > 0))
{
CheckTransitTime("Ea", "EaAe", 2);
}
if (!boolArrayStats["FflTransit"][2] && (floatStats["FflUnderwayTime"] > 0f || intStats["FflUnderwayDay"] > 0))
{
CheckTransitTime("Ffl", "FflAe", 2);
}
}
else if (Names.lagoonIslands.Contains(islandName))
{
if (!boolArrayStats["AaTransit"][3] && (floatStats["AaUnderwayTime"] > 0f || intStats["AaUnderwayDay"] > 0))
{
CheckTransitTime("Aa", "AaFfl", 3);
}
if (!boolArrayStats["EaTransit"][3] && (floatStats["EaUnderwayTime"] > 0f || intStats["EaUnderwayDay"] > 0))
{
CheckTransitTime("Ea", "EaFfl", 3);
}
if (!boolArrayStats["AeTransit"][3] && (floatStats["AeUnderwayTime"] > 0f || intStats["AeUnderwayDay"] > 0))
{
CheckTransitTime("Ae", "AeFfl", 3);
}
}
}
public void CheckTransitTime(string underwayKey, string transitCode, int destInt)
{
int num = GameState.day - intStats[underwayKey + "UnderwayDay"];
float num2 = Sun.sun.globalTime - floatStats[underwayKey + "UnderwayTime"];
if (num2 < 0f)
{
num2 += 24f;
num--;
}
intStats["last" + transitCode + "TransitDay"] = num;
floatStats["last" + transitCode + "TransitTime"] = num2;
if ((intStats["record" + transitCode + "TransitDay"] == 0 && floatStats["record" + transitCode + "TransitTime"] == 0f) || intStats["record" + transitCode + "TransitDay"] > num || (intStats["record" + transitCode + "TransitDay"] == num && floatStats["record" + transitCode + "TransitTime"] > num2))
{
intStats["record" + transitCode + "TransitDay"] = num;
floatStats["record" + transitCode + "TransitTime"] = num2;
if (Plugin.notificationsEnabled.Value)
{
NotificationUiQueue.instance.QueueNotification("Fastest " + AddTo(transitCode) + " time");
}
}
boolArrayStats[underwayKey + "Transit"][destInt] = true;
}
public void IncrementIntStat(string statName)
{
intStats["current" + statName]++;
}
public void UpdatePage()
{
UpdateStats();
UpdateTexts();
}
private void UpdateStats()
{
if (intStats["UnderwayDay"] > 0 || floatStats["UnderwayTime"] > 0f)
{
intStats["currentUnderwayDay"] = GameState.day - intStats["UnderwayDay"];
floatStats["currentUnderwayTime"] = Sun.sun.globalTime - floatStats["UnderwayTime"];
}
if (floatStats["currentUnderwayTime"] < 0f)
{
floatStats["currentUnderwayTime"] += 24f;
intStats["currentUnderwayDay"]--;
}
}
private void UpdateTexts()
{
string[] floatStatNames = Names.floatStatNames;
foreach (string text in floatStatNames)
{
switch (text)
{
case "UnderwayTime":
statTMs[text].text = AddSpace(text);
statTMs["currentUnderwayTime"].text = UnderwayText(intStats["currentUnderwayDay"], floatStats["currentUnderwayTime"]);
statTMs["recordUnderwayTime"].text = UnderwayText(intStats["recordUnderwayDay"], floatStats["recordUnderwayTime"]);
break;
case "CargoMass":
statTMs[text].text = AddSpace(text);
statTMs["currentCargoMass"].text = ((floatStats["currentCargoMass"] == 0f) ? "-" : string.Format("{0:#,##0.#} lbs", floatStats["currentCargoMass"]));
statTMs["recordCargoMass"].text = ((floatStats["recordCargoMass"] == 0f) ? "-" : string.Format("{0:#,##0.#} lbs", floatStats["recordCargoMass"]));
break;
case "TotalMass":
statTMs[text].text = AddSpace(text);
statTMs["currentTotalMass"].text = ((floatStats["currentTotalMass"] == 0f) ? "-" : string.Format("{0:#,##0.#} lbs", floatStats["currentTotalMass"]));
statTMs["recordTotalMass"].text = ((floatStats["recordTotalMass"] == 0f) ? "-" : string.Format("{0:#,##0.#} lbs", floatStats["recordTotalMass"]));
break;
case "MilesSailed":
statTMs[text].text = AddSpace(text);
if (Plugin.updateMilesSailed.Value == "realtime")
{
statTMs["currentMilesSailed"].text = string.Format("{0:#,##0.#}", floatStats["currentMilesSailed"]);
}
else
{
statTMs["currentMilesSailed"].text = string.Format("{0:#,##0.#}", floatStats["MilesSailed"]);
}
break;
default:
statTMs[text].text = AddSpace(text);
statTMs["current" + text].text = floatStats["current" + text].ToString();
statTMs["record" + text].text = floatStats["record" + text].ToString();
break;
}
}
string[] intStatNames = Names.intStatNames;
foreach (string text2 in intStatNames)
{
if (!(text2 == "UnderwayDay") && (!(text2 == "FlotsamEncounters") || (!((Object)(object)RandomEncounters.pluginInstance == (Object)null) && RandomEncounters.flotsamEnabled)) && (!(text2 == "DenseFogEncounters") || (!((Object)(object)RandomEncounters.pluginInstance == (Object)null) && RandomEncounters.denseFogEnabled)) && (!(text2 == "SeaLifeEncounters") || (!((Object)(object)RandomEncounters.pluginInstance == (Object)null) && RandomEncounters.isSeaLifeEnabled)))
{
statTMs[text2].text = AddSpace(text2);
statTMs["current" + text2].text = string.Format("{0:#,##0}", intStats["current" + text2]);
}
}
string[] regionTransitNames = Names.regionTransitNames;
foreach (string text3 in regionTransitNames)
{
statTMs[text3].text = AddTo(text3);
statTMs["last" + text3].text = UnderwayText(intStats["last" + text3 + "TransitDay"], floatStats["last" + text3 + "TransitTime"]);
statTMs["record" + text3].text = UnderwayText(intStats["record" + text3 + "TransitDay"], floatStats["record" + text3 + "TransitTime"]);
}
}
private string UnderwayText(int underwayDay, float underwayTime)
{
if (underwayDay == 0 && underwayTime == 0f)
{
return "-";
}
if (underwayDay > 0)
{
string arg = ((underwayDay == 1) ? "Day" : "Days");
return $"{underwayDay} {arg} {underwayTime:0.0} Hours";
}
return $"{underwayTime:0.0} Hours";
}
private string AddSpace(string name)
{
return Regex.Replace(name, "([a-z])([A-Z])", "$1 $2");
}
private string AddTo(string name)
{
string text = AddSpace(name);
return text.ToUpper().Insert(text.IndexOf(' '), " to");
}
public void PlayerTeleported()
{
Plugin.logger.LogInfo((object)"Player teleported, resetting current transits");
string[] regions = Names.regions;
foreach (string text in regions)
{
int num = 0;
for (int j = 0; j < 4; j++)
{
if (j != num)
{
boolArrayStats[text + "Transit"][j] = true;
}
num++;
}
}
}
public void TrackDistance()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: 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_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
Vector3 globeCoords = FloatingOriginManager.instance.GetGlobeCoords(GameState.currentBoat);
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(globeCoords.x, 0f, globeCoords.z);
if (lastPosition == Vector3.zero)
{
lastPosition = val;
return;
}
if (trackerTimer > 1)
{
trackerTimer--;
return;
}
floatStats["currentMilesSailed"] += Vector3.Distance(lastPosition, val) * 61f;
lastPosition = val;
trackerTimer = 1000;
}
public void UpdateMilesText()
{
floatStats["MilesSailed"] = floatStats["currentMilesSailed"];
}
public void IncrementPortVisited(string port)
{
if (!(lastPortVisited == port))
{
IncrementIntStat("PortsVisited");
lastPortVisited = port;
}
}
public void IncrementStormsWeathered()
{
string name = ((Object)WeatherStorms.instance.GetCurrentStorm()).name;
if (!(lastStorm == name))
{
Plugin.logger.LogDebug((object)("Weathering " + name));
IncrementIntStat("StormsWeathered");
lastStorm = name;
}
}
public void ClearLastStorm()
{
if (!Utility.IsNullOrWhiteSpace(lastStorm))
{
Plugin.logger.LogDebug((object)"Storm cleared");
lastStorm = "";
}
}
}