using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("exploration")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("exploration")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e0e0269c-cf5e-4bcf-8a4f-0ae4db9f957a")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace exploration;
[HarmonyPatch(typeof(Mast))]
public class OpaqueSailPatch
{
[HarmonyPostfix]
[HarmonyPatch("AttachInitialSail")]
public static void Postfix(Mast __instance)
{
foreach (GameObject sail in __instance.sails)
{
Main.UpdateShaders(sail.transform);
}
}
}
[BepInPlugin("com.winter.ageofexploration", "Age of Exploration", "0.2.3")]
public class Plugin : BaseUnityPlugin
{
public const string pluginGuid = "com.winter.ageofexploration";
public const string pluginName = "Age of Exploration";
public const string pluginVersion = "0.2.3";
private void Awake()
{
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.winter.ageofexploration");
}
}
public class GPButtonCustomDoor : GoPointerButton
{
public Transform importedActualBoat;
public BoatEmbarkCollider embarkCol;
private Transform walkCol;
public float slideDistance;
private bool open;
private bool inMotion;
public InteriorEffectsTrigger[] interiorAudios;
public float angle;
public void Setup()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
((Component)this).transform.parent = importedActualBoat;
BoxCollider component = ((Component)this).GetComponent<BoxCollider>();
BoxCollider val = new GameObject("trapdoor").AddComponent<BoxCollider>();
val.center = component.center;
val.size = component.size;
((Component)val).transform.parent = embarkCol.walkCollider;
((Component)val).transform.localPosition = ((Component)this).transform.localPosition;
((Component)val).transform.localRotation = ((Component)this).transform.localRotation;
((Component)val).transform.localScale = ((Component)this).transform.localScale;
walkCol = ((Component)val).transform;
}
public bool IsOpen()
{
return open;
}
public override void OnActivate()
{
if (!inMotion)
{
if (open)
{
((MonoBehaviour)this).StartCoroutine(OpenOrClose(-1));
}
else
{
((MonoBehaviour)this).StartCoroutine(OpenOrClose(1));
}
}
}
private IEnumerator OpenOrClose(int direction)
{
inMotion = true;
if (direction > 0)
{
open = true;
}
else
{
open = false;
}
float progress = 0f;
while (progress < angle)
{
float num = Time.deltaTime * 125f;
if (progress + num > angle)
{
num = angle - progress;
}
if (slideDistance != 0f)
{
((Component)this).transform.Translate(Vector3.up * (float)direction * num * slideDistance / angle, (Space)1);
walkCol.localPosition = ((Component)this).transform.localPosition;
}
else
{
((Component)this).transform.Rotate(Vector3.up, num * (0f - (float)direction), (Space)1);
walkCol.localRotation = ((Component)this).transform.localRotation;
}
progress += num;
yield return (object)new WaitForEndOfFrame();
}
inMotion = false;
}
}
internal class Main
{
[HarmonyPatch(typeof(FloatingOriginManager))]
public static class FloatingOriginManagerPatches
{
[HarmonyPrefix]
[HarmonyPatch("Start")]
public static void StartPatch(FloatingOriginManager __instance)
{
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
if (!(((Object)__instance).name == "_shifting world"))
{
return;
}
LoadAssets();
if (Object.op_Implicit((Object)(object)santaAsset))
{
try
{
santa = Object.Instantiate<GameObject>(santaAsset, ((Component)__instance).transform);
embarkSanta = GameObject.Find("WALK boat santa maria");
Transform transform = GameObject.Find("walk cols").transform;
embarkSanta.transform.SetParent(transform);
embarkSanta.transform.localPosition = new Vector3(-450f, 0f, -200f);
UpdateShaders(santa.transform);
santa.transform.localRotation = Quaternion.Euler(0f, -104f, 0f);
Transform transform2 = GameObject.Find("island 21 M (Siren Song)/dock_mooring M (3)").transform;
Transform transform3 = GameObject.Find("island 21 M (Siren Song)/dock_mooring M (2)").transform;
santa.GetComponent<BoatMooringRopes>().mooringFront = transform2;
santa.GetComponent<BoatMooringRopes>().mooringBack = transform3;
Debug.LogWarning((object)"[Age of Exploration] Santa Maria loaded");
}
catch (Exception arg)
{
Debug.LogError((object)$"[Age of Exploration] Could not load Santa Maria due to exception:\n{arg}");
}
}
if (Object.op_Implicit((Object)(object)asturiasAsset))
{
try
{
asturias = Object.Instantiate<GameObject>(asturiasAsset, ((Component)__instance).transform);
embarkAsturias = ((Component)asturias.transform.Find("WALK boat asturias")).gameObject;
Transform transform4 = GameObject.Find("walk cols").transform;
embarkAsturias.transform.SetParent(transform4);
embarkAsturias.transform.localPosition = new Vector3(-550f, 0f, -200f);
UpdateShaders(asturias.transform);
asturias.transform.localRotation = Quaternion.Euler(0f, 85f, 0f);
Transform boatModel = asturias.GetComponent<BoatRefs>().boatModel;
BoatEmbarkCollider component = ((Component)((Component)boatModel).transform.Find("embark (player)")).gameObject.GetComponent<BoatEmbarkCollider>();
GPButtonCustomDoor gPButtonCustomDoor = ((Component)asturias.transform.Find("boat asturias/structure_container/TRIM/gunport (1)")).gameObject.AddComponent<GPButtonCustomDoor>();
gPButtonCustomDoor.angle = 135f;
gPButtonCustomDoor.importedActualBoat = boatModel;
gPButtonCustomDoor.embarkCol = component;
gPButtonCustomDoor.Setup();
GPButtonCustomDoor gPButtonCustomDoor2 = ((Component)asturias.transform.Find("boat asturias/structure_container/TRIM/gunport (2)")).gameObject.AddComponent<GPButtonCustomDoor>();
gPButtonCustomDoor2.angle = 135f;
gPButtonCustomDoor2.importedActualBoat = boatModel;
gPButtonCustomDoor2.embarkCol = component;
gPButtonCustomDoor2.Setup();
GPButtonCustomDoor gPButtonCustomDoor3 = ((Component)asturias.transform.Find("boat asturias/structure_container/TRIM/door (1)")).gameObject.AddComponent<GPButtonCustomDoor>();
gPButtonCustomDoor3.angle = 120f;
gPButtonCustomDoor3.importedActualBoat = boatModel;
gPButtonCustomDoor3.embarkCol = component;
gPButtonCustomDoor3.Setup();
GPButtonCustomDoor gPButtonCustomDoor4 = ((Component)asturias.transform.Find("boat asturias/structure_container/TRIM/door (2)")).gameObject.AddComponent<GPButtonCustomDoor>();
gPButtonCustomDoor4.angle = 120f;
gPButtonCustomDoor4.importedActualBoat = boatModel;
gPButtonCustomDoor4.embarkCol = component;
gPButtonCustomDoor4.Setup();
Transform transform5 = GameObject.Find("island 19 M (Eastwind)/dock_mooring M (5)").transform;
Transform transform6 = GameObject.Find("island 19 M (Eastwind)/dock_mooring M (3)").transform;
asturias.GetComponent<BoatMooringRopes>().mooringFront = transform5;
asturias.GetComponent<BoatMooringRopes>().mooringBack = transform6;
Debug.LogWarning((object)"[Age of Exploration] Asturias loaded");
}
catch (Exception arg2)
{
Debug.LogError((object)$"[Age of Exploration] Could not load Asturias due to exception:\n{arg2}");
}
}
}
}
public static GameObject santa;
public static GameObject santaAsset;
public static GameObject embarkSanta;
public static GameObject asturias;
public static GameObject asturiasAsset;
public static GameObject embarkAsturias;
public static GameObject huelva;
public static GameObject huelvaAsset;
public static GameObject huelvaShelf;
public static GameObject huelvaShelfAsset;
public static bool aoeInstalled;
private static void LoadAssets()
{
string location = Assembly.GetExecutingAssembly().Location;
string directoryName = Path.GetDirectoryName(location);
if (File.Exists(Path.Combine(directoryName, "explorationbridge.dll")))
{
Assembly.LoadFrom(Path.Combine(directoryName, "explorationbridge.dll"));
}
if (!File.Exists(Path.Combine(directoryName, "exploration")))
{
Debug.LogError((object)"Age of Exploration not installed correctly");
aoeInstalled = false;
return;
}
AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(directoryName, "exploration"));
Object obj = val.LoadAsset("Assets/Exploration/BOAT SANTA MARIA (222).prefab");
santaAsset = (GameObject)(object)((obj is GameObject) ? obj : null);
Object obj2 = val.LoadAsset("Assets/Exploration/BOAT ASTURIAS (227).prefab");
asturiasAsset = (GameObject)(object)((obj2 is GameObject) ? obj2 : null);
aoeInstalled = true;
}
public static void UpdateShaders(Transform root)
{
Renderer[] componentsInChildren = ((Component)root).GetComponentsInChildren<Renderer>(true);
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
Material[] materials = val.materials;
foreach (Material val2 in materials)
{
if ((Object)(object)val2 != (Object)null && (Object)(object)val2.shader != (Object)null && ((Object)val2).name != "glass (Instance)")
{
val2.shader = Shader.Find(((Object)val2.shader).name);
}
}
}
}
}
internal class RudderPatch
{
[HarmonyPatch(typeof(GPButtonSteeringWheel))]
public static class GPButtonSteeringWheelPatches
{
[HarmonyPrefix]
[HarmonyPatch("RudderToWheelAngle")]
public static bool RudderToWheelAnglePatch(GPButtonSteeringWheel __instance, Rudder ___rudder, ref float __result)
{
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
if (((Object)__instance).name == "whipstaff" && ((Object)((Joint)__instance.attachedRudder).connectedBody).name == "BOAT ASTURIAS (227)(Clone)")
{
float num = Mathf.Abs(___rudder.currentAngle);
bool flag = ___rudder.currentAngle < 0f;
if (num > 30f)
{
num = 30f;
}
float num2 = 0f;
float num3 = 0f;
if (num <= 10f)
{
num2 = Mathf.Lerp(0f, 20f, num / 10f) * (float)((!flag) ? 1 : (-1));
num3 = Mathf.Lerp(4.03f, 4.01f, num / 10f);
}
else if (num <= 20f)
{
num2 = Mathf.Lerp(20f, 40f, (num - 10f) / 10f) * (float)((!flag) ? 1 : (-1));
num3 = Mathf.Lerp(4.01f, 3.56f, (num - 10f) / 10f);
}
else if (num <= 30f)
{
num2 = Mathf.Lerp(40f, 67.5f, (num - 20f) / 10f) * (float)((!flag) ? 1 : (-1));
num3 = Mathf.Lerp(3.56f, 3f, (num - 20f) / 10f);
}
((Component)__instance).transform.localPosition = new Vector3(-7.399f, 0f, num3);
__result = num2;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(ShipyardPartsInstaller))]
public static class ShipyardPartsInstallerPatches
{
[HarmonyPrefix]
[HarmonyPatch("ChangeOrderedOption")]
public static void Prefix(int partIndex, BoatPartsOrder ___currentOrder, BoatCustomParts ___currentParts)
{
int index = ___currentOrder.orderedOptions[partIndex];
GameObject gameObject = ((Component)___currentParts.availableParts[partIndex].partOptions[index]).gameObject;
GPButtonSteeringWheel componentInChildren = gameObject.GetComponentInChildren<GPButtonSteeringWheel>(true);
if (Object.op_Implicit((Object)(object)componentInChildren))
{
Transform rudderGraphicsFix = ((Component)componentInChildren.attachedRudder).gameObject.GetComponent<Rudder>().rudderGraphicsFix;
if (Object.op_Implicit((Object)(object)rudderGraphicsFix))
{
Debug.Log((object)("Disabing rudder connected to: " + ((Object)((Component)componentInChildren).gameObject).name));
((Component)rudderGraphicsFix).gameObject.SetActive(false);
}
}
RudderPatch.index = partIndex;
}
[HarmonyPostfix]
[HarmonyPatch("ChangeOrderedOption")]
public static void Postfix(int partIndex, BoatPartsOrder ___currentOrder, BoatCustomParts ___currentParts)
{
int index = ___currentOrder.orderedOptions[partIndex];
GameObject gameObject = ((Component)___currentParts.availableParts[partIndex].partOptions[index]).gameObject;
GPButtonSteeringWheel componentInChildren = gameObject.GetComponentInChildren<GPButtonSteeringWheel>(true);
if (Object.op_Implicit((Object)(object)componentInChildren))
{
Transform rudderGraphicsFix = ((Component)componentInChildren.attachedRudder).gameObject.GetComponent<Rudder>().rudderGraphicsFix;
if (Object.op_Implicit((Object)(object)rudderGraphicsFix))
{
Debug.Log((object)("Enabling rudder connected to: " + ((Object)((Component)componentInChildren).gameObject).name));
((Component)rudderGraphicsFix).gameObject.SetActive(true);
}
}
}
[HarmonyPostfix]
[HarmonyPatch("ResetOrder")]
public static void ResetOrderPostfix(BoatPartsOrder ___currentOrder, BoatCustomParts ___currentParts)
{
if (index <= -1)
{
return;
}
int num = ___currentOrder.orderedOptions[index];
List<BoatPartOption> partOptions = ___currentParts.availableParts[index].partOptions;
for (int i = 0; i < partOptions.Count; i++)
{
GameObject gameObject = ((Component)partOptions[i]).gameObject;
GPButtonSteeringWheel componentInChildren = gameObject.GetComponentInChildren<GPButtonSteeringWheel>(true);
if (Object.op_Implicit((Object)(object)componentInChildren))
{
Transform rudderGraphicsFix = ((Component)componentInChildren.attachedRudder).gameObject.GetComponent<Rudder>().rudderGraphicsFix;
if (Object.op_Implicit((Object)(object)rudderGraphicsFix))
{
((Component)rudderGraphicsFix).gameObject.SetActive(i == num);
}
}
}
index = -1;
}
}
[HarmonyPatch(typeof(Shipyard))]
public static class ShipyardPatches
{
[HarmonyPostfix]
[HarmonyPatch("AdmitShip")]
public static void Postfix(Shipyard __instance, GameObject ship)
{
GPButtonSteeringWheel[] componentsInChildren = ship.GetComponentsInChildren<GPButtonSteeringWheel>(true);
GPButtonSteeringWheel[] array = componentsInChildren;
foreach (GPButtonSteeringWheel val in array)
{
val.currentInput = 0f;
}
}
}
public static int index = -1;
}