Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Wavekeeper v0.1.0
plugins/Wavekeeper/Wavekeeper.dll
Decompiled 7 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.UI; [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: CompilationRelaxations(8)] [assembly: AssemblyVersion("0.0.0.0")] namespace Wavekeeper; [HarmonyPatch] internal static class Board { internal const string PrefabName = "Wavekeeper_Board"; internal const float ModelY = 0.4f; internal const float FloatWidth = 2.2f; internal const float WeightY = -0.5f; private const float SailForce = 2.2f; private const float Steer = 1.6f; private const float RudderSpeed = 1.6f; private const float ForwardDamping = 0.6f; private const float WaveAccel = 3f; private const float RushToSpeed = 0.18181819f; private const float RollHold = 12f; private const float RollCalm = 4f; private const float AirLevel = 3f; private static GameObject _prefab; internal static Vector3 HullCentre; internal static readonly float[] WaveSpeed = new float[5] { 0f, 0f, 5f, 8f, 11f }; private static float _nextSpeedLog; internal static float BaseDampForward = 0.003f; [HarmonyPatch(typeof(ZNetScene), "Awake")] [HarmonyPostfix] private static void RegisterPrefab(ZNetScene __instance) { if ((Object)(object)_prefab == (Object)null) { try { _prefab = Build(__instance); } catch (Exception ex) { Plugin.Log.LogError((object)("[board] could not build the board: " + ex)); } } if ((Object)(object)_prefab == (Object)null) { return; } if ((Object)(object)Rush.Icon == (Object)null) { Rush.Icon = BoardIcon.Make(_prefab.transform.Find("wk_model")); Piece component = _prefab.GetComponent<Piece>(); if ((Object)(object)Rush.Icon != (Object)null && (Object)(object)component != (Object)null) { component.m_icon = Rush.Icon; } } if (!__instance.m_prefabs.Contains(_prefab)) { __instance.m_prefabs.Add(_prefab); } if (AccessTools.Field(typeof(ZNetScene), "m_namedPrefabs").GetValue(__instance) is Dictionary<int, GameObject> dictionary) { dictionary[StringExtensionMethods.GetStableHashCode("Wavekeeper_Board")] = _prefab; } if ((Object)(object)ObjectDB.instance != (Object)null) { AddToHammer(ObjectDB.instance); } } [HarmonyPostfix] [HarmonyPatch(typeof(ObjectDB), "Awake")] private static void DBAwake(ObjectDB __instance) { AddToHammer(__instance); } [HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")] [HarmonyPostfix] private static void DBCopy(ObjectDB __instance) { AddToHammer(__instance); } private static void AddToHammer(ObjectDB db) { if ((Object)(object)_prefab == (Object)null || (Object)(object)db == (Object)null || db.m_items == null || db.m_items.Count == 0) { return; } GameObject itemPrefab = db.GetItemPrefab("Hammer"); PieceTable val = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces : null); if (!((Object)(object)val == (Object)null)) { Piece component = _prefab.GetComponent<Piece>(); List<Requirement> list = new List<Requirement>(); AddReq(db, list, "FineWood", 10); AddReq(db, list, "WolfPelt", 4); AddReq(db, list, "Silver", 2); AddReq(db, list, "Needle", 5); component.m_resources = list.ToArray(); GameObject val2 = (((Object)(object)ZNetScene.instance != (Object)null) ? ZNetScene.instance.GetPrefab("piece_workbench") : null); component.m_craftingStation = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<CraftingStation>() : null); if (!val.m_pieces.Contains(_prefab)) { val.m_pieces.Add(_prefab); } } } private static void AddReq(ObjectDB db, List<Requirement> reqs, string item, int amount) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown GameObject itemPrefab = db.GetItemPrefab(item); if ((Object)(object)itemPrefab != (Object)null) { Requirement val = new Requirement(); val.m_resItem = itemPrefab.GetComponent<ItemDrop>(); val.m_amount = amount; val.m_recover = true; reqs.Add(val); } else { Plugin.Log.LogWarning((object)("[board] recipe item not found: " + item)); } } internal static bool IsBoard(Ship s) { if ((Object)(object)s != (Object)null) { return (Object)(object)((Component)s).GetComponent<BoardView>() != (Object)null; } return false; } private static GameObject Build(ZNetScene scene) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Expected O, but got Unknown //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_0360: 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_038f: Unknown result type (might be due to invalid IL or missing references) //IL_039f: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0713: Unknown result type (might be due to invalid IL or missing references) //IL_0718: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_0439: 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_05ef: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04d1: Unknown result type (might be due to invalid IL or missing references) //IL_04d8: Expected O, but got Unknown //IL_0501: Unknown result type (might be due to invalid IL or missing references) //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0522: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Unknown result type (might be due to invalid IL or missing references) //IL_0526: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_0565: Unknown result type (might be due to invalid IL or missing references) //IL_0592: Unknown result type (might be due to invalid IL or missing references) //IL_05ab: Unknown result type (might be due to invalid IL or missing references) if (!Data.Loaded) { Plugin.Log.LogWarning((object)"[board] no board data: the board is not added."); return null; } GameObject prefab = scene.GetPrefab("Raft"); if ((Object)(object)prefab == (Object)null) { Plugin.Log.LogWarning((object)"[board] the game's raft was not found: no board."); return null; } GameObject val = new GameObject("Wavekeeper_Holder"); val.SetActive(false); Object.DontDestroyOnLoad((Object)(object)val); GameObject val2 = Object.Instantiate<GameObject>(prefab, val.transform, false); ((Object)val2).name = "Wavekeeper_Board"; Ship component = val2.GetComponent<Ship>(); if (Plugin.DetailedLog.Value) { Dump(val2.transform, ""); } int num = -1; Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>(true); foreach (Renderer val3 in componentsInChildren) { if (!(val3 is ParticleSystemRenderer)) { if (num < 0 && val3 is MeshRenderer) { num = ((Component)val3).gameObject.layer; } val3.enabled = false; } } LODGroup[] componentsInChildren2 = val2.GetComponentsInChildren<LODGroup>(true); foreach (LODGroup val4 in componentsInChildren2) { val4.enabled = false; } Collider[] componentsInChildren3 = val2.GetComponentsInChildren<Collider>(true); foreach (Collider val5 in componentsInChildren3) { if ((Object)(object)val5 != (Object)(object)component.m_floatCollider && !val5.isTrigger) { val5.enabled = false; } } Transform[] componentsInChildren4 = val2.GetComponentsInChildren<Transform>(true); foreach (Transform val6 in componentsInChildren4) { if (((Object)val6).name.ToLowerInvariant().Contains("ladder")) { ((Component)val6).gameObject.SetActive(false); } } Transform transform = new GameObject("wk_model").transform; transform.SetParent(val2.transform, false); transform.localPosition = new Vector3(0f, 0.4f, 0f); BoardModel.Build(transform, (num < 0) ? val2.layer : num, out var hull); GameObject val7 = new GameObject("wk_hull"); val7.layer = val2.layer; val7.transform.SetParent(val2.transform, false); BoxCollider val8 = val7.AddComponent<BoxCollider>(); val8.center = ((Bounds)(ref hull)).center + new Vector3(0f, 0.4f, 0f); val8.size = ((Bounds)(ref hull)).size; HullCentre = val8.center; if ((Object)(object)component.m_floatCollider != (Object)null) { BoxCollider floatCollider = component.m_floatCollider; Vector3 val9 = ((Component)floatCollider).transform.InverseTransformPoint(val2.transform.TransformPoint(val8.center)); floatCollider.center = new Vector3(val9.x, floatCollider.center.y, val9.z); floatCollider.size = new Vector3(Mathf.Max(2.2f, ((Bounds)(ref hull)).size.x), floatCollider.size.y, ((Bounds)(ref hull)).size.z); } Collider[] components = val2.GetComponents<Collider>(); foreach (Collider val10 in components) { BoxCollider val11 = (BoxCollider)(object)((val10 is BoxCollider) ? val10 : null); if (!((Object)(object)val11 == (Object)null) && ((Collider)val11).isTrigger && !((Object)(object)val11 == (Object)(object)component.m_floatCollider)) { val11.center = new Vector3(((Bounds)(ref hull)).center.x, 1.6999999f, ((Bounds)(ref hull)).center.z); val11.size = new Vector3(Mathf.Max(1.6f, ((Bounds)(ref hull)).size.x + 0.8f), 3f, ((Bounds)(ref hull)).size.z + 0.6f); } } ShipControlls val12 = (((Object)(object)component.m_shipControlls != (Object)null) ? component.m_shipControlls : val2.GetComponentInChildren<ShipControlls>(true)); if ((Object)(object)val12 != (Object)null) { ((Component)val12).transform.position = val2.transform.TransformPoint(val8.center); Transform val13 = (((Object)(object)val12.m_attachPoint != (Object)null) ? val12.m_attachPoint : new GameObject("wk_attach").transform); val13.SetParent(transform, false); val13.localPosition = Data.Stand; val13.localRotation = Quaternion.Euler(0f, Data.Yaw, 0f); val12.m_attachPoint = val13; val12.m_hoverText = "Windsurf Board"; val12.m_maxUseRange = Mathf.Max(val12.m_maxUseRange, 4f); Transform val14 = transform.Find("wk_rig"); if ((Object)(object)val14 != (Object)null) { Vector3 val15 = Data.GripL - val14.localPosition; Vector3 val16 = Data.GripR - val14.localPosition; GameObject val17 = new GameObject("wk_use"); val17.layer = ((Component)val12).gameObject.layer; val17.transform.SetParent(val14, false); val17.transform.localPosition = (val15 + val16) * 0.5f; BoxCollider val18 = val17.AddComponent<BoxCollider>(); Vector3 val19 = val16 - val15; val18.size = new Vector3(Mathf.Abs(val19.x) + 0.35f, Mathf.Abs(val19.y) + 0.35f, Mathf.Abs(val19.z) + 0.6f); val17.AddComponent<BoardUse>(); Plugin.Debug(string.Concat("[board] use spot on the wishbone at ", val17.transform.localPosition, " size ", val18.size, ", layer ", LayerMask.LayerToName(val17.layer))); } Plugin.Debug(string.Concat("[board] rider spot ", Data.Stand, " facing ", Data.Yaw)); } else { Plugin.Log.LogWarning((object)"[board] the raft has no helm: nobody can ride the board."); } component.m_sailForceFactor *= 2.2f; component.m_stearForce *= 1.6f; component.m_rudderSpeed *= 1.6f; component.m_dampingForward *= 0.6f; BaseDampForward = component.m_dampingForward; object[] array = new object[12] { "[board] sail force ", component.m_sailForceFactor, ", steer ", component.m_stearForce, ", rudder speed ", component.m_rudderSpeed, ", damping fwd ", component.m_dampingForward, " side ", component.m_dampingSideway, ", hull ", null }; Vector3 size = ((Bounds)(ref hull)).size; array[11] = ((Vector3)(ref size)).ToString("0.00"); Plugin.Debug(string.Concat(array)); WearNTear component2 = val2.GetComponent<WearNTear>(); ImpactEffect[] componentsInChildren5 = val2.GetComponentsInChildren<ImpactEffect>(true); foreach (ImpactEffect val20 in componentsInChildren5) { val20.m_damageToSelf = false; } component.m_waterImpactDamage = 0f; if ((Object)(object)component2 != (Object)null) { component2.m_new = ((Component)transform).gameObject; component2.m_worn = ((Component)transform).gameObject; component2.m_broken = ((Component)transform).gameObject; component2.m_wet = null; component2.m_fragmentRoots = (GameObject[])(object)new GameObject[1] { ((Component)transform).gameObject }; } Piece component3 = val2.GetComponent<Piece>(); if ((Object)(object)component3 != (Object)null) { component3.m_canBeRemoved = true; component3.m_name = "Windsurf Board"; component3.m_description = "A board with a sail, for one. Faster than a raft, carries nothing. Stand on it and hold the wishbone."; } val2.AddComponent<BoardView>(); return val2; } private static void Dump(Transform t, string pad) { //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) List<string> list = new List<string>(); Component[] components = ((Component)t).GetComponents<Component>(); foreach (Component val in components) { if (!((Object)(object)val == (Object)null) && !(val is Transform)) { string text = ((object)val).GetType().Name; BoxCollider val2 = (BoxCollider)(object)((val is BoxCollider) ? val : null); if ((Object)(object)val2 != (Object)null) { string text2 = text; string[] array = new string[8] { text2, "(", ((Collider)val2).isTrigger ? "trigger " : "", "c", null, null, null, null }; Vector3 center = val2.center; array[4] = ((Vector3)(ref center)).ToString("0.00"); array[5] = " s"; Vector3 size = val2.size; array[6] = ((Vector3)(ref size)).ToString("0.00"); array[7] = ")"; text = string.Concat(array); } list.Add(text); } } ManualLogSource log = Plugin.Log; string[] array2 = new string[9] { "[raft] ", pad, ((Object)t).name, " [", LayerMask.LayerToName(((Component)t).gameObject.layer), "] p", null, null, null }; Vector3 localPosition = t.localPosition; array2[6] = ((Vector3)(ref localPosition)).ToString("0.00"); array2[7] = " "; array2[8] = string.Join(", ", list.ToArray()); log.LogInfo((object)string.Concat(array2)); foreach (Transform item in t) { Transform t2 = item; Dump(t2, pad + " "); } } [HarmonyPatch(typeof(ShipControlls), "Interact")] [HarmonyPrefix] private static bool Interact(ShipControlls __instance, Humanoid character, bool repeat, ref bool __result, Ship ___m_ship, ZNetView ___m_nview) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) if (!IsBoard(___m_ship)) { return true; } __result = false; if (repeat || (Object)(object)___m_nview == (Object)null || !___m_nview.IsValid()) { return false; } Player val = (Player)(object)((character is Player) ? character : null); if ((Object)(object)val == (Object)null || Vector3.Distance(((Component)val).transform.position, ((Component)___m_ship).transform.position) > 4.5f || ((Character)val).IsEncumbered()) { return false; } ___m_nview.InvokeRPC("RequestControl", new object[1] { val.GetPlayerID() }); Plugin.Debug("[ride] asked the board's owner to ride (" + Vector3.Distance(((Component)val).transform.position, ((Component)___m_ship).transform.position).ToString("0.0") + " m away)"); __result = true; return false; } [HarmonyPatch(typeof(Player), "StopDoodadControl")] [HarmonyPrefix] private static void LetGo(Player __instance) { Ship val = (((Object)(object)__instance == (Object)(object)Player.m_localPlayer) ? __instance.GetControlledShip() : null); if (!((Object)(object)val == (Object)null) && IsBoard(val)) { ZNetView component = ((Component)val).GetComponent<ZNetView>(); if ((Object)(object)component != (Object)null && component.IsValid()) { component.InvokeRPC("Stop", new object[0]); component.InvokeRPC("Rudder", new object[1] { 0f }); } Crest.Clear(); Plugin.Debug("[ride] let go of the board"); } } [HarmonyPrefix] [HarmonyPatch(typeof(Player), "SetControls")] private static void KeepOnJump(Player __instance, ref bool jump, ref bool dodge) { if (jump || dodge) { Ship controlledShip = __instance.GetControlledShip(); if ((Object)(object)controlledShip != (Object)null && IsBoard(controlledShip)) { jump = false; dodge = false; } } } [HarmonyPrefix] [HarmonyPatch(typeof(Ship), "CustomFixedUpdate")] private static void WaveDrag(Ship __instance, Rigidbody ___m_body, ZNetView ___m_nview) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_003e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)___m_body == (Object)null) && IsBoard(__instance)) { float num = WaveTarget(__instance); Vector3 forward = ((Component)__instance).transform.forward; forward.y = 0f; ((Vector3)(ref forward)).Normalize(); float num2 = Vector3.Dot(___m_body.linearVelocity, forward); __instance.m_dampingForward = ((num > 0f && num2 < num) ? 0f : BaseDampForward); } } internal static float WaveTarget(Ship ship) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected I4, but got Unknown int num = (int)ship.GetSpeedSetting(); if (num < 2 || num >= WaveSpeed.Length) { return 0f; } return WaveSpeed[num] * (1f + Surf.BonusFor(ship) * 0.18181819f); } [HarmonyPostfix] [HarmonyPatch(typeof(Ship), "CustomFixedUpdate")] private static void RideWaves(Ship __instance, float fixedDeltaTime, Rigidbody ___m_body, ZNetView ___m_nview) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected I4, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)___m_body == (Object)null || (Object)(object)___m_nview == (Object)null || !___m_nview.IsValid() || !___m_nview.IsOwner() || !IsBoard(__instance)) { return; } Steady(__instance, ___m_body); Surf.Fly(__instance, ___m_body, fixedDeltaTime); int num = (int)__instance.GetSpeedSetting(); if (num < 2 || num >= WaveSpeed.Length) { return; } float liquidLevel = Floating.GetLiquidLevel(((Component)__instance).transform.position, 1f, (LiquidType)0); if (!(((Component)__instance).transform.position.y > liquidLevel + 1f)) { Vector3 forward = ((Component)__instance).transform.forward; forward.y = 0f; ((Vector3)(ref forward)).Normalize(); float num2 = Vector3.Dot(___m_body.linearVelocity, forward); float num3 = WaveTarget(__instance); if (Plugin.DetailedLog.Value && Time.time >= _nextSpeedLog && Surf.BonusFor(__instance) >= 0f && (Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)Player.m_localPlayer.GetControlledShip() == (Object)(object)__instance) { _nextSpeedLog = Time.time + 2f; Vector3 linearVelocity = ___m_body.linearVelocity; linearVelocity.y = 0f; Plugin.Debug("[speed] " + ((Vector3)(ref linearVelocity)).magnitude.ToString("0.0") + " m/s (forward " + Vector3.Dot(___m_body.linearVelocity, ((Component)__instance).transform.forward).ToString("0.0") + "), wave target " + num3.ToString("0.0") + ", stage " + num + ", bonus +" + (Surf.BonusFor(__instance) * 100f).ToString("0") + "%, wind " + (((Object)(object)EnvMan.instance != (Object)null) ? EnvMan.instance.GetWindIntensity().ToString("0.00") : "?")); } if (!(num2 >= num3)) { float num4 = 3f * (1f + Surf.BonusFor(__instance)); float num5 = Mathf.Min(num3 - num2, num4 * fixedDeltaTime); ___m_body.AddForce(forward * num5, (ForceMode)2); } } } private static void Steady(Ship ship, Rigidbody body) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0019: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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) Transform transform = ((Component)ship).transform; Vector3 val = Vector3.Cross(transform.up, Vector3.up); Vector3 forward = transform.forward; Vector3 val2 = forward * Vector3.Dot(val, forward); Vector3 val3 = forward * Vector3.Dot(body.angularVelocity, forward); Vector3 val4 = val2 * 12f - val3 * 4f; if (Surf.InAir) { val4 += (val - val2) * 3f; } body.AddTorque(val4, (ForceMode)5); } [HarmonyPostfix] [HarmonyPatch(typeof(Ship), "ApplyControlls")] private static void DirectSteer(Ship __instance, Vector3 dir, ref float ___m_rudderValue, ref float ___m_sendRudderTime, ZNetView ___m_nview) { if (!IsBoard(__instance)) { return; } float num = Mathf.Clamp(dir.x, -1f, 1f); if (!Mathf.Approximately(num, ___m_rudderValue)) { ___m_rudderValue = num; if ((Object)(object)___m_nview != (Object)null && ___m_nview.IsValid()) { ___m_sendRudderTime = Time.time; ___m_nview.InvokeRPC("Rudder", new object[1] { num }); } } } [HarmonyPatch(typeof(Ship), "IsPlayerInBoat", new Type[] { typeof(long) })] [HarmonyPostfix] private static void InBoatId(Ship __instance, long playerID, ref bool __result) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (!__result && IsBoard(__instance)) { Player player = Player.GetPlayer(playerID); if ((Object)(object)player != (Object)null && Vector3.Distance(((Component)player).transform.position, ((Component)__instance).transform.position) < 6f) { __result = true; } } } [HarmonyPostfix] [HarmonyPatch(typeof(Ship), "IsPlayerInBoat", new Type[] { typeof(Player) })] private static void InBoatPlayer(Ship __instance, Player player, ref bool __result) { //IL_001c: 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) if (!__result && !((Object)(object)player == (Object)null) && IsBoard(__instance) && Vector3.Distance(((Component)player).transform.position, ((Component)__instance).transform.position) < 6f) { __result = true; } } } internal static class BoardIcon { private const int Size = 256; internal static Sprite Make(Transform model) { //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_040a: 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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Expected O, but got Unknown //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Expected O, but got Unknown //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)model == (Object)null) { return null; } int num = FreeLayer(); if (num < 0) { Plugin.Log.LogWarning((object)"[icon] no free layer: the board keeps the raft's icon"); return null; } GameObject val = null; GameObject val2 = null; GameObject val3 = null; RenderTexture val4 = null; Color ambientLight = RenderSettings.ambientLight; AmbientMode ambientMode = RenderSettings.ambientMode; bool fog = RenderSettings.fog; try { val = Object.Instantiate<GameObject>(((Component)model).gameObject); val.SetActive(true); val.transform.SetPositionAndRotation(new Vector3(0f, 6000f, 0f), Quaternion.identity); Transform[] componentsInChildren = val.GetComponentsInChildren<Transform>(true); foreach (Transform val5 in componentsInChildren) { ((Component)val5).gameObject.layer = num; } Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(val.transform.position, Vector3.zero); bool flag = false; Renderer[] componentsInChildren2 = val.GetComponentsInChildren<Renderer>(); foreach (Renderer val6 in componentsInChildren2) { if (!flag) { bounds = val6.bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val6.bounds); } } if (!flag) { return null; } val2 = new GameObject("wk_iconcam"); Camera val7 = val2.AddComponent<Camera>(); ((Behaviour)val7).enabled = false; val7.cullingMask = 1 << num; val7.clearFlags = (CameraClearFlags)2; val7.backgroundColor = new Color(0f, 0f, 0f, 0f); val7.fieldOfView = 30f; val7.allowHDR = false; val7.allowMSAA = false; Vector3 val8 = new Vector3(-1f, 0.55f, 0.8f); Vector3 normalized = ((Vector3)(ref val8)).normalized; Vector3 extents = ((Bounds)(ref bounds)).extents; float magnitude = ((Vector3)(ref extents)).magnitude; float num2 = magnitude / Mathf.Sin(val7.fieldOfView * 0.5f * ((float)Math.PI / 180f)) * 0.95f; ((Component)val7).transform.position = ((Bounds)(ref bounds)).center + normalized * num2; ((Component)val7).transform.LookAt(((Bounds)(ref bounds)).center); val7.nearClipPlane = 0.05f; val7.farClipPlane = num2 + magnitude * 2f; val3 = new GameObject("wk_iconlight"); Light val9 = val3.AddComponent<Light>(); val9.type = (LightType)1; val9.cullingMask = 1 << num; val9.intensity = 1.3f; val9.color = new Color(1f, 0.97f, 0.9f); Transform transform = ((Component)val9).transform; Vector3 val10 = normalized + new Vector3(0.6f, 0.8f, 0f); transform.rotation = Quaternion.LookRotation(-((Vector3)(ref val10)).normalized); RenderSettings.ambientMode = (AmbientMode)3; RenderSettings.ambientLight = new Color(0.55f, 0.55f, 0.6f); RenderSettings.fog = false; val4 = (val7.targetTexture = RenderTexture.GetTemporary(256, 256, 24, (RenderTextureFormat)0)); val7.Render(); RenderTexture active = RenderTexture.active; RenderTexture.active = val4; Texture2D val11 = new Texture2D(256, 256, (TextureFormat)5, false); ((Object)val11).name = "wk_board_icon"; Texture2D val12 = val11; val12.ReadPixels(new Rect(0f, 0f, 256f, 256f), 0, 0); val12.Apply(); RenderTexture.active = active; val7.targetTexture = null; object[] array = new object[4] { "[icon] board photographed on layer ", num, ", size ", null }; Vector3 size = ((Bounds)(ref bounds)).size; array[3] = ((Vector3)(ref size)).ToString("0.0"); Plugin.Debug(string.Concat(array)); return Sprite.Create(val12, new Rect(0f, 0f, 256f, 256f), new Vector2(0.5f, 0.5f), 100f); } catch (Exception ex) { Plugin.Log.LogWarning((object)("[icon] could not photograph the board: " + ex.Message)); return null; } finally { RenderSettings.ambientLight = ambientLight; RenderSettings.ambientMode = ambientMode; RenderSettings.fog = fog; if ((Object)(object)val4 != (Object)null) { RenderTexture.ReleaseTemporary(val4); } if ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)val); } if ((Object)(object)val2 != (Object)null) { Object.DestroyImmediate((Object)(object)val2); } if ((Object)(object)val3 != (Object)null) { Object.DestroyImmediate((Object)(object)val3); } } } private static int FreeLayer() { for (int num = 31; num >= 20; num--) { if (string.IsNullOrEmpty(LayerMask.LayerToName(num))) { return num; } } return -1; } } internal static class BoardModel { internal static void Build(Transform model, int layer, out Bounds hull) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Expected O, but got Unknown //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: 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_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) hull = default(Bounds); bool flag = false; Transform val = null; Dictionary<string, Material> made = new Dictionary<string, Material>(); int num = 0; foreach (PieceDef piece in Data.Pieces) { GamePart gamePart = GameParts.Find(piece.Key); if (gamePart == null) { Plugin.Log.LogWarning((object)("[model] piece not found in the game: " + piece.Key)); continue; } Mesh val2 = MakeMesh(gamePart, piece); Transform val3 = model; Vector3 localPosition = piece.Pos; if (piece.Unit != "" && piece.HasPivot) { if ((Object)(object)val == (Object)null) { val = new GameObject("wk_rig").transform; val.SetParent(model, false); val.localPosition = piece.Pivot; } val3 = val; localPosition = piece.Pos - val.localPosition; } GameObject val4 = new GameObject("wk_" + gamePart.Prefab + "_" + num); val4.layer = layer; val4.transform.SetParent(val3, false); val4.transform.localPosition = localPosition; val4.transform.localRotation = piece.Rot; val4.transform.localScale = piece.Scale; val4.AddComponent<MeshFilter>().sharedMesh = val2; MeshRenderer val5 = val4.AddComponent<MeshRenderer>(); ((Renderer)val5).sharedMaterial = MaterialFor(piece, gamePart, made); if (piece.Key.IndexOf("Sail", StringComparison.OrdinalIgnoreCase) >= 0) { ((Object)val4).name = "wk_sail"; } num++; if (!((Object)(object)val3 == (Object)(object)model) || !(piece.Pos.y < 0.5f) || piece.Key.IndexOf("pole", StringComparison.OrdinalIgnoreCase) >= 0 || piece.Key.IndexOf("Rudder", StringComparison.OrdinalIgnoreCase) >= 0) { continue; } Matrix4x4 val6 = Matrix4x4.TRS(piece.Pos, piece.Rot, piece.Scale); Vector3[] vertices = val2.vertices; foreach (Vector3 val7 in vertices) { Vector3 val8 = ((Matrix4x4)(ref val6)).MultiplyPoint3x4(val7); if (!flag) { hull = new Bounds(val8, Vector3.zero); flag = true; } else { ((Bounds)(ref hull)).Encapsulate(val8); } } } if (!flag) { hull = new Bounds(new Vector3(0f, 0.09f, 0f), new Vector3(0.8f, 0.2f, 3f)); } ((Bounds)(ref hull)).size = new Vector3(((Bounds)(ref hull)).size.x, Mathf.Max(0.25f, ((Bounds)(ref hull)).size.y), ((Bounds)(ref hull)).size.z); if ((Object)(object)val == (Object)null) { val = new GameObject("wk_rig").transform; val.SetParent(model, false); val.localPosition = new Vector3(0f, 1.3f, 0.35f); } Spot("wk_gripL", val, Data.GripL - val.localPosition); Spot("wk_gripR", val, Data.GripR - val.localPosition); Spot("wk_footL", model, Data.FootL); Spot("wk_footR", model, Data.FootR); object[] array = new object[10] { "[model] built ", num, " of ", Data.Pieces.Count, " pieces, rig joint ", val.localPosition, ", hull ", null, null, null }; Vector3 center = ((Bounds)(ref hull)).center; array[7] = ((Vector3)(ref center)).ToString("0.00"); array[8] = " size "; Vector3 size = ((Bounds)(ref hull)).size; array[9] = ((Vector3)(ref size)).ToString("0.00"); Plugin.Debug(string.Concat(array)); } private static void Spot(string name, Transform parent, Vector3 local) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) Transform transform = new GameObject(name).transform; transform.SetParent(parent, false); transform.localPosition = local; } private static Mesh MakeMesh(GamePart part, PieceDef pd) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown Vector3[] array = (Vector3[])(object)new Vector3[part.V.Length]; for (int i = 0; i < array.Length; i++) { ref Vector3 reference = ref array[i]; reference = (pd.Edits.TryGetValue(i, out var value) ? value : part.V[i]) - pd.Centre; } List<int> list = new List<int>(); for (int j = 0; j + 2 < part.T.Length; j += 3) { int item = part.T[j]; int item2 = part.T[j + 1]; int item3 = part.T[j + 2]; if (!pd.Cut.Contains(item) && !pd.Cut.Contains(item2) && !pd.Cut.Contains(item3)) { list.Add(item); list.Add(item2); list.Add(item3); } } Mesh val = new Mesh(); ((Object)val).name = "wk_" + part.Key; Mesh val2 = val; val2.vertices = array; if (part.Uv != null) { val2.uv = part.Uv; } val2.triangles = list.ToArray(); val2.RecalculateNormals(); val2.RecalculateBounds(); return val2; } private static Material MaterialFor(PieceDef pd, GamePart part, Dictionary<string, Material> made) { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) string text = (string.IsNullOrEmpty(pd.Tex) ? part.Tex : pd.Tex); if (!GameParts.ByTexture.TryGetValue(text, out var value)) { string[] candidates = Exporter.Candidates; foreach (string prefabName in candidates) { GameParts.Of(prefabName); } if (!GameParts.ByTexture.TryGetValue(text, out value)) { value = part.Mat; Plugin.Log.LogWarning((object)("[model] texture " + text + " not found, " + pd.Key + " keeps its own")); } } if ((Object)(object)value == (Object)null) { return null; } string key = ((Object)value).GetInstanceID() + "|" + ColorUtility.ToHtmlStringRGB(pd.Tint) + "|" + pd.Rep.x + "|" + pd.Rep.y; if (made.TryGetValue(key, out var value2)) { return value2; } Material val = new Material(value); ((Object)val).name = "wk_" + ((Object)value).name; value2 = val; if (value2.HasProperty("_Color")) { value2.color = value.color * pd.Tint; } if (value2.HasProperty("_MainTex")) { value2.mainTextureScale = pd.Rep; } made[key] = value2; return value2; } } internal class BoardUse : MonoBehaviour, Hoverable, Interactable { private ShipControlls Helm; private float _lastLog; private void Awake() { Ship componentInParent = ((Component)this).GetComponentInParent<Ship>(); Helm = (((Object)(object)componentInParent != (Object)null) ? componentInParent.m_shipControlls : null); if ((Object)(object)Helm == (Object)null) { Helm = ((Component)((Component)this).transform.root).GetComponentInChildren<ShipControlls>(true); } } public string GetHoverText() { if (Plugin.DetailedLog.Value && Time.time - _lastLog > 2f) { _lastLog = Time.time; Plugin.Debug("[use] pointing at the wishbone"); } return Localization.instance.Localize("[<color=yellow><b>$KEY_Use</b></color>] Let's surf!"); } public string GetHoverName() { return "Windsurf Board"; } public float GetHoverOffset() { return 0f; } public bool UseItem(Humanoid user, ItemData item) { return false; } public bool Interact(Humanoid user, bool hold, bool alt) { bool flag = (Object)(object)Helm != (Object)null && Helm.Interact(user, hold, alt); Plugin.Debug("[use] E on the wishbone (hold " + hold + "): " + (flag ? "asked to ride" : "refused")); return flag; } } internal class BoardView : MonoBehaviour { private class RiderBones { internal Transform Hips; internal Dictionary<string, Transform> ByName = new Dictionary<string, Transform>(); } private const float MaxTilt = 5f; private const string KeyC = "Wavekeeper_poseCrouch"; private const string KeyA = "Wavekeeper_poseAir"; private const string KeyW = "Wavekeeper_poseWhip"; private const float CrouchRate = 5f; private const float AirRate = 6.5f; private const float AirOutRate = 3.3f; private const float WhipRate = 12f; private Ship _ship; private Rigidbody _body; private Transform _rig; private Transform _attach; private Transform _gripL; private Transform _gripR; private Transform _footL; private Transform _footR; private Transform _sail; private float _tilt; private float _wind; private Mesh _sailMesh; private Vector3[] _base; private Vector3[] _work; private float[] _w; private float[] _chord; private float[] _s; private int _thin = -1; private Vector3 _scale; private readonly Dictionary<Player, RiderBones> _riders = new Dictionary<Player, RiderBones>(); private static readonly List<Player> Near = new List<Player>(); private readonly Dictionary<Player, Vector3> _moments = new Dictionary<Player, Vector3>(); private static Vector3 _sent = new Vector3(-1f, -1f, -1f); private Vector3 MomentsOf(Player p, float dt) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) Vector3 val; if ((Object)(object)p == (Object)(object)Player.m_localPlayer) { val = Surf.Moments(); } else { ZNetView component = ((Component)p).GetComponent<ZNetView>(); ZDO val2 = (((Object)(object)component != (Object)null && component.IsValid()) ? component.GetZDO() : null); val = (Vector3)((val2 != null) ? new Vector3(val2.GetFloat("Wavekeeper_poseCrouch", 0f), val2.GetFloat("Wavekeeper_poseAir", 0f), val2.GetFloat("Wavekeeper_poseWhip", 0f)) : Vector3.zero); } _moments.TryGetValue(p, out var value); value.x = Mathf.MoveTowards(value.x, val.x, 5f * dt); value.y = Mathf.MoveTowards(value.y, val.y, ((val.y > value.y) ? 6.5f : 3.3f) * dt); value.z = Mathf.MoveTowards(value.z, val.z, 12f * dt); _moments[p] = value; return value; } private static Quaternion E(PoseKey k, string bone) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) if (!k.Turns.TryGetValue(bone, out var value)) { return Quaternion.identity; } return Quaternion.Euler(value); } private void Awake() { //IL_0138: Unknown result type (might be due to invalid IL or missing references) _ship = ((Component)this).GetComponent<Ship>(); _body = ((Component)this).GetComponent<Rigidbody>(); Transform val = ((Component)this).transform.Find("wk_model"); if ((Object)(object)val == (Object)null) { ((Behaviour)this).enabled = false; return; } _rig = val.Find("wk_rig"); _footL = val.Find("wk_footL"); _footR = val.Find("wk_footR"); if ((Object)(object)_rig != (Object)null) { _gripL = _rig.Find("wk_gripL"); _gripR = _rig.Find("wk_gripR"); _sail = _rig.Find("wk_sail"); } _attach = (((Object)(object)_ship != (Object)null && (Object)(object)_ship.m_shipControlls != (Object)null) ? _ship.m_shipControlls.m_attachPoint : null); if ((Object)(object)_sail != (Object)null) { PrepBelly(); } if ((Object)(object)_body != (Object)null) { _body.centerOfMass = new Vector3(Board.HullCentre.x, -0.5f, Board.HullCentre.z); } } private void Update() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)_ship != (Object)null) || !((Object)(object)localPlayer != (Object)null) || !((Object)(object)localPlayer.GetControlledShip() == (Object)(object)_ship)) { return; } Surf.Tick(_ship, _body, ((Component)_ship).GetComponent<ZNetView>()); Vector3 val = Surf.Moments(); Vector3 val2 = val - _sent; if (((Vector3)(ref val2)).sqrMagnitude > 0.0004f || (val == Vector3.zero && _sent != Vector3.zero)) { ZNetView component = ((Component)localPlayer).GetComponent<ZNetView>(); ZDO val3 = (((Object)(object)component != (Object)null && component.IsValid()) ? component.GetZDO() : null); if (val3 != null) { val3.Set("Wavekeeper_poseCrouch", val.x); val3.Set("Wavekeeper_poseAir", val.y); val3.Set("Wavekeeper_poseWhip", val.z); _sent = val; } } } private void LateUpdate() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Expected I4, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_rig == (Object)null || (Object)(object)_ship == (Object)null) { return; } float deltaTime = Time.deltaTime; _tilt = Mathf.MoveTowards(_tilt, (0f - _ship.GetRudderValue()) * 5f, 25f * deltaTime); _rig.localRotation = Quaternion.AngleAxis(_tilt, Vector3.right); Speed speedSetting = _ship.GetSpeedSetting(); float num = (speedSetting - 2) switch { 2 => 1f, 1 => 0.65f, 0 => 0.3f, _ => 0f, }; float num2 = (((Object)(object)EnvMan.instance != (Object)null) ? EnvMan.instance.GetWindIntensity() : 0.5f); _wind = Mathf.MoveTowards(_wind, num * Mathf.Lerp(0.5f, 1f, num2), deltaTime * 0.8f); Belly(Time.time, _wind); if ((Object)(object)_attach == (Object)null) { return; } float num3; if (!((Object)(object)_body != (Object)null)) { num3 = 0f; } else { Vector3 linearVelocity = _body.linearVelocity; num3 = ((Vector3)(ref linearVelocity)).magnitude; } float speed = num3; Near.Clear(); foreach (Player allPlayer in Player.GetAllPlayers()) { if ((Object)(object)allPlayer != (Object)null && ((Character)allPlayer).IsAttached() && (Object)(object)allPlayer.GetAttachPoint() == (Object)(object)_attach) { Near.Add(allPlayer); } } foreach (Player item in Near) { Pose(item, speed, MomentsOf(item, deltaTime)); } } private RiderBones BonesOf(Player p) { if (_riders.TryGetValue(p, out var value) && (Object)(object)value.Hips != (Object)null) { return value; } RiderBones riderBones = new RiderBones(); riderBones.Hips = Utils.FindChild(((Component)p).transform, "Hips", (IterativeSearchType)0); value = riderBones; if ((Object)(object)value.Hips != (Object)null) { Transform[] componentsInChildren = ((Component)value.Hips).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (!value.ByName.ContainsKey(((Object)val).name)) { value.ByName[((Object)val).name] = val; } } } _riders[p] = value; if ((Object)(object)value.Hips == (Object)null) { Plugin.Log.LogWarning((object)("[ride] no Hips bone on " + p.GetPlayerName())); } return value; } private static PoseKey Key(string k) { if (!Data.Keys.TryGetValue(k, out var value)) { return new PoseKey(); } return value; } private static Quaternion Turn(PoseKey a, PoseKey b, float w, string bone) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Vector3 value; bool flag = a.Turns.TryGetValue(bone, out value); Vector3 value2; bool flag2 = b.Turns.TryGetValue(bone, out value2); if (!flag && !flag2) { return Quaternion.identity; } return Quaternion.Slerp(Quaternion.Euler(flag ? value : Vector3.zero), Quaternion.Euler(flag2 ? value2 : Vector3.zero), w); } private static Quaternion Mix(PoseKey a, PoseKey b, float w, PoseKey kc, float wc, PoseKey ka, float wa, PoseKey kw, float ww, string bone) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) Quaternion val = Turn(a, b, w, bone); if (wc > 0f) { val = Quaternion.Slerp(val, E(kc, bone), wc); } if (wa > 0f) { val = Quaternion.Slerp(val, E(ka, bone), wa); } if (ww > 0f) { val = Quaternion.Slerp(val, E(kw, bone), ww); } return val; } private void Pose(Player p, float speed, Vector3 m) { //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: 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_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: 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_0220: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_034e: 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_038a: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0398: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_04f4: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_03f4: Unknown result type (might be due to invalid IL or missing references) //IL_0409: 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_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) RiderBones riderBones = BonesOf(p); if ((Object)(object)riderBones.Hips == (Object)null) { return; } Transform transform = ((Component)p).transform; Transform hips = riderBones.Hips; PoseKey poseKey = Key("ride"); PoseKey poseKey2 = Key("hang"); float num = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(3f, 9f, speed)); float num2 = Mathf.Lerp(poseKey.Lean, poseKey2.Lean, num); float num3 = Mathf.Lerp(poseKey.Drop, poseKey2.Drop, num); float num4 = Mathf.Lerp(poseKey.Side, poseKey2.Side, num); PoseKey poseKey3 = Key("crouch"); PoseKey poseKey4 = Key("air"); PoseKey poseKey5 = Key("whip"); float num5 = Mathf.SmoothStep(0f, 1f, m.x); float num6 = Mathf.SmoothStep(0f, 1f, m.y); float num7 = Mathf.SmoothStep(0f, 1f, m.z); num2 = Mathf.Lerp(Mathf.Lerp(Mathf.Lerp(num2, poseKey3.Lean, num5), poseKey4.Lean, num6), poseKey5.Lean, num7); num3 = Mathf.Lerp(Mathf.Lerp(Mathf.Lerp(num3, poseKey3.Drop, num5), poseKey4.Drop, num6), poseKey5.Drop, num7); num4 = Mathf.Lerp(Mathf.Lerp(Mathf.Lerp(num4, poseKey3.Side, num5), poseKey4.Side, num6), poseKey5.Side, num7); hips.position = transform.TransformPoint(Data.HipsPos); hips.rotation = transform.rotation * Data.HipsRot * Mix(poseKey, poseKey2, num, poseKey3, num5, poseKey4, num6, poseKey5, num7, "Hips"); foreach (KeyValuePair<string, Quaternion> item in Data.RestLocal) { if (!(item.Key == "Hips") && riderBones.ByName.TryGetValue(item.Key, out var value)) { value.localRotation = item.Value * Mix(poseKey, poseKey2, num, poseKey3, num5, poseKey4, num6, poseKey5, num7, item.Key); } } Quaternion val = Quaternion.AngleAxis(0f - num2, Vector3.right) * Quaternion.AngleAxis(0f - num4, Vector3.forward); Vector3 val2 = transform.InverseTransformPoint(hips.position); val2.y -= num3; hips.position = transform.TransformPoint(val * val2); hips.rotation = transform.rotation * val * Quaternion.Inverse(transform.rotation) * hips.rotation; if (!Get(riderBones, "LeftArm", out var t) || !Get(riderBones, "LeftForeArm", out var t2) || !Get(riderBones, "LeftHand", out var t3) || !Get(riderBones, "RightArm", out var t4) || !Get(riderBones, "RightForeArm", out var t5) || !Get(riderBones, "RightHand", out var t6)) { return; } for (int i = 0; i < 3; i++) { float worst = 0f; Vector3 pull = Vector3.zero; Check(t, t2, t3, _gripL, ref worst, ref pull); Check(t4, t5, t6, _gripR, ref worst, ref pull); if (worst <= 0.002f) { break; } hips.position += pull * worst; } if ((Object)(object)_footL != (Object)null && Get(riderBones, "LeftUpLeg", out var t7) && Get(riderBones, "LeftLeg", out var t8) && Get(riderBones, "LeftFoot", out var t9)) { Reach(t7, t8, t9, _footL.position, transform.TransformDirection(new Vector3(0f, 0.3f, 1f))); } if ((Object)(object)_footR != (Object)null && Get(riderBones, "RightUpLeg", out t7) && Get(riderBones, "RightLeg", out t8) && Get(riderBones, "RightFoot", out t9)) { Reach(t7, t8, t9, _footR.position, transform.TransformDirection(new Vector3(0f, 0.3f, 1f))); } if ((Object)(object)_gripL != (Object)null) { Reach(t, t2, t3, Wrist(t, _gripL), transform.TransformDirection(new Vector3(-0.6f, -1f, -0.4f))); } if ((Object)(object)_gripR != (Object)null) { Reach(t4, t5, t6, Wrist(t4, _gripR), transform.TransformDirection(new Vector3(0.6f, -1f, -0.4f))); } } private static bool Get(RiderBones rb, string n, out Transform t) { if (rb.ByName.TryGetValue(n, out t)) { return (Object)(object)t != (Object)null; } return false; } private static Vector3 Wrist(Transform shoulder, Transform grip) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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) Vector3 position = grip.position; Vector3 val = shoulder.position - position; return position + ((Vector3)(ref val)).normalized * 0.07f; } private static void Check(Transform a, Transform b, Transform c, Transform grip, ref float worst, ref Vector3 pull) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)grip == (Object)null)) { Vector3 val = Wrist(a, grip); float num = Vector3.Distance(a.position, val) - (Vector3.Distance(a.position, b.position) + Vector3.Distance(b.position, c.position)) * 0.97f; if (num > worst) { worst = num; Vector3 val2 = val - a.position; pull = ((Vector3)(ref val2)).normalized; } } } private static void Reach(Transform a, Transform b, Transform c, Vector3 t, Vector3 pole) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_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_002d: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) Vector3 position = a.position; Vector3 position2 = b.position; Vector3 position3 = c.position; float num = Vector3.Distance(position, position2); float num2 = Vector3.Distance(position2, position3); Vector3 val = t - position; float num3 = Mathf.Clamp(((Vector3)(ref val)).magnitude, 0.001f, num + num2 - 0.0001f); Vector3 normalized = ((Vector3)(ref val)).normalized; float num4 = Mathf.Clamp((num * num + num3 * num3 - num2 * num2) / (2f * num * num3), -1f, 1f); float num5 = Mathf.Sqrt(1f - num4 * num4); Vector3 val2 = pole - normalized * Vector3.Dot(pole, normalized); if (((Vector3)(ref val2)).sqrMagnitude < 1E-08f) { val2 = Vector3.down; } ((Vector3)(ref val2)).Normalize(); Vector3 val3 = position + normalized * (num * num4) + val2 * (num * num5); a.rotation = Quaternion.FromToRotation(position2 - position, val3 - position) * a.rotation; Vector3 position4 = b.position; Vector3 position5 = c.position; Vector3 val4 = position + normalized * num3; b.rotation = Quaternion.FromToRotation(position5 - position4, val4 - position4) * b.rotation; } private static Vector3 Axis(int k) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return (Vector3)(k switch { 1 => Vector3.up, 0 => Vector3.right, _ => Vector3.forward, }); } private void PrepBelly() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) MeshFilter component = ((Component)_sail).GetComponent<MeshFilter>(); if ((Object)(object)component == (Object)null || (Object)(object)component.sharedMesh == (Object)null) { return; } _sailMesh = Object.Instantiate<Mesh>(component.sharedMesh); component.sharedMesh = _sailMesh; _base = _sailMesh.vertices; _work = (Vector3[])_base.Clone(); int[] triangles = _sailMesh.triangles; HashSet<int> hashSet = new HashSet<int>(triangles); Vector3 val = Vector3.one * 1E+09f; Vector3 val2 = Vector3.one * -1E+09f; foreach (int item in hashSet) { val = Vector3.Min(val, _base[item]); val2 = Vector3.Max(val2, _base[item]); } _scale = new Vector3(Mathf.Abs(_sail.localScale.x), Mathf.Abs(_sail.localScale.y), Mathf.Abs(_sail.localScale.z)); float[] array = new float[3] { (val2.x - val.x) * _scale.x, (val2.y - val.y) * _scale.y, (val2.z - val.z) * _scale.z }; _thin = ((!(array[0] <= array[1]) || !(array[0] <= array[2])) ? ((array[1] <= array[2]) ? 1 : 2) : 0); int num = ((_thin == 0) ? 1 : 0); int num2 = ((_thin == 2) ? 1 : 2); int num3 = ((Mathf.Abs((_sail.localRotation * Axis(num)).y) > Mathf.Abs((_sail.localRotation * Axis(num2)).y)) ? num : num2); int num4 = ((num3 == num) ? num2 : num); _w = new float[_base.Length]; _chord = new float[_base.Length]; _s = new float[_base.Length]; foreach (int item2 in hashSet) { float num5 = ((Vector3)(ref _base[item2]))[num3]; float num6 = 1E+09f; float num7 = -1E+09f; for (int i = 0; i + 2 < triangles.Length; i += 3) { for (int j = 0; j < 3; j++) { int num8 = triangles[i + j]; int num9 = triangles[i + (j + 1) % 3]; float num10 = ((Vector3)(ref _base[num8]))[num3]; float num11 = ((Vector3)(ref _base[num9]))[num3]; if (!((num10 - num5) * (num11 - num5) > 0f) && num10 != num11) { float num12 = ((Vector3)(ref _base[num8]))[num4] + (((Vector3)(ref _base[num9]))[num4] - ((Vector3)(ref _base[num8]))[num4]) * (num5 - num10) / (num11 - num10); num6 = Mathf.Min(num6, num12); num7 = Mathf.Max(num7, num12); } } } if (!(num7 <= num6)) { float num13 = Mathf.Clamp01((((Vector3)(ref _base[item2]))[num4] - num6) / (num7 - num6)); float num14 = Mathf.Clamp01((num5 - ((Vector3)(ref val))[num3]) / Mathf.Max(1E-06f, ((Vector3)(ref val2))[num3] - ((Vector3)(ref val))[num3])); _w[item2] = Mathf.Sin((float)Math.PI * num13) * Mathf.Pow(Mathf.Sin((float)Math.PI * num14), 0.5f); _chord[item2] = (num7 - num6) * ((Vector3)(ref _scale))[num4]; _s[item2] = num13; } } } private void Belly(float time, float wind) { //IL_0024: 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_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0066: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0189: 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) if ((Object)(object)_sailMesh == (Object)null || _thin < 0) { return; } Vector3 val = _sail.TransformDirection(Axis(_thin)); Vector3 val2 = (((Object)(object)_attach != (Object)null) ? (_attach.position - _sail.position) : ((Component)this).transform.right); float num = ((Vector3.Dot(val, val2) > 0f) ? (-1f) : 1f); float num2 = Mathf.Max(1E-06f, ((Vector3)(ref _scale))[_thin]); for (int i = 0; i < _base.Length; i++) { Vector3 val3 = _base[i]; if (_w[i] > 0f) { float num3 = 1f + 0.08f * Mathf.Sin(time * 2.3f + _s[i] * 2f); float num4 = wind * 0.09f * _chord[i] * _w[i] * num3; float num5 = (1f - wind) * 0.05f * Mathf.Sin(time * 9f + _s[i] * 7f) * _s[i] * _s[i]; int thin; ((Vector3)(ref val3))[thin = _thin] = ((Vector3)(ref val3))[thin] + num * (num4 + num5) / num2; } _work[i] = val3; } _sailMesh.vertices = _work; _sailMesh.RecalculateNormals(); _sailMesh.RecalculateBounds(); } } internal static class Crest { private const float Every = 6f; private const float StormEvery = 3f; private const float Retry = 1f; private const float Ahead = 24f; private const float Speed = 5f; private const float HalfWidth = 6f; private const float HalfDepth = 1.6f; private const float MinSpeed = 3f; private const float MaxAge = 12f; private const float ArrowSpeed = 1.2f; private const int Across = 13; private const int Along = 5; private static bool _on; private static bool _used; private static Vector3 _p; private static Vector3 _axis; private static Vector3 _side; private static float _born; private static float _next; private static float _usedAt; private static GameObject _go; private static Mesh _mesh; private static Material _mat; private static Vector3[] _v; internal static void Tick(Ship ship) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Invalid comparison between Unknown and I4 //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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) float time = Time.time; Rigidbody component = ((Component)ship).GetComponent<Rigidbody>(); float num; if (!((Object)(object)component != (Object)null)) { num = 0f; } else { Vector3 linearVelocity = component.linearVelocity; num = ((Vector3)(ref linearVelocity)).magnitude; } float num2 = num; bool flag = (int)ship.GetSpeedSetting() >= 2 && num2 >= 3f; Vector3 position = ((Component)ship).transform.position; if (_on) { _p -= _axis * 5f * Time.deltaTime; if (!(time - _born > 12f)) { Vector3 val = position - _p; if (!(((Vector3)(ref val)).sqrMagnitude > 4900f) && (!_used || !(time - _usedAt > 0.6f))) { goto IL_00c5; } } Clear(); } goto IL_00c5; IL_00c5: if (!_on && flag && time >= _next) { if (Spawn(ship)) { _born = time; _next = time + (Surf.Stormy() ? 3f : 6f); } else { _next = time + 1f; } } Draw(time); } internal static bool Over(Vector3 pos) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (!_on || _used) { return false; } Vector3 val = pos - _p; if (Mathf.Abs(Vector3.Dot(val, _axis)) > 2.1f || Mathf.Abs(Vector3.Dot(val, _side)) > 6f) { return false; } _used = true; _usedAt = Time.time; return true; } internal static void Clear() { _on = false; _used = false; if ((Object)(object)_go != (Object)null) { _go.SetActive(false); } } private static float Level(Vector3 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Floating.GetLiquidLevel(p, 1f, (LiquidType)0); } private static bool Spawn(Ship ship) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) Vector3 forward = ((Component)ship).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.01f) { return false; } ((Vector3)(ref forward)).Normalize(); _axis = forward; Vector3 val = Vector3.Cross(Vector3.up, forward); _side = ((Vector3)(ref val)).normalized; _p = ((Component)ship).transform.position + forward * 24f; _on = true; _used = false; Plugin.Debug("[crest] band " + 24f + " m ahead" + (Surf.Stormy() ? " (storm)" : "")); return true; } private static void Make() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Expected O, but got Unknown //IL_0096: 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) _go = new GameObject("wk_crest"); Object.DontDestroyOnLoad((Object)(object)_go); Mesh val = new Mesh(); ((Object)val).name = "wk_crest"; _mesh = val; _mesh.MarkDynamic(); _v = (Vector3[])(object)new Vector3[65]; Vector2[] array = (Vector2[])(object)new Vector2[_v.Length]; int[] array2 = new int[288]; int num = 0; for (int i = 0; i < 5; i++) { for (int j = 0; j < 13; j++) { ref Vector2 reference = ref array[i * 13 + j]; reference = new Vector2((float)j / 12f * 4f, (float)i / 4f); if (j < 12 && i < 4) { int num2 = i * 13 + j; int num3 = num2 + 1; int num4 = num2 + 13; int num5 = num4 + 1; array2[num++] = num2; array2[num++] = num4; array2[num++] = num3; array2[num++] = num3; array2[num++] = num4; array2[num++] = num5; } } } _mesh.vertices = _v; _mesh.uv = array; _mesh.triangles = array2; _go.AddComponent<MeshFilter>().sharedMesh = _mesh; MeshRenderer val2 = _go.AddComponent<MeshRenderer>(); ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = false; Shader val3 = Shader.Find("Sprites/Default"); Material val4 = new Material(val3); val4.mainTexture = (Texture)(object)Arrows(); ((Object)val4).name = "wk_crest"; _mat = val4; ((Renderer)val2).sharedMaterial = _mat; } private static Texture2D Arrows() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false); ((Texture)val).wrapMode = (TextureWrapMode)0; ((Object)val).name = "wk_arrows"; Texture2D val2 = val; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { float num = ((float)j + 0.5f) / 64f - 0.5f; float num2 = ((float)i + 0.5f) / 64f; float num3 = 0.78f - Mathf.Abs(num) * 1.1f; float num4 = Mathf.Abs(num2 - num3); float num5 = ((Mathf.Abs(num) < 0.36f) ? Mathf.Clamp01(1f - (num4 - 0.06f) / 0.04f) : 0f); float num6 = Mathf.Max(0.18f, num5 * 0.85f); val2.SetPixel(j, i, new Color(1f, 1f, 1f, num6)); } } val2.Apply(); Object.DontDestroyOnLoad((Object)(object)val2); return val2; } private static void Draw(float now) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) if (!_on) { if ((Object)(object)_go != (Object)null && _go.activeSelf) { _go.SetActive(false); } return; } if ((Object)(object)_go == (Object)null) { Make(); } if (!_go.activeSelf) { _go.SetActive(true); } _go.transform.SetPositionAndRotation(Vector3.zero, Quaternion.identity); for (int i = 0; i < 5; i++) { float num = Mathf.Lerp(-1.6f, 1.6f, (float)i / 4f); for (int j = 0; j < 13; j++) { float num2 = Mathf.Lerp(-6f, 6f, (float)j / 12f); Vector3 val = _p + _axis * num + _side * num2; val.y = Level(val) + 0.06f; _v[i * 13 + j] = val; } } _mesh.vertices = _v; _mesh.RecalculateBounds(); float num3 = 0.45f + 0.12f * Mathf.Sin(now * 4f); if (_used) { num3 *= Mathf.Clamp01(1f - (now - _usedAt) / 0.6f); } _mat.color = new Color(1f, 0.85f, 0.2f, num3); _mat.mainTextureOffset = new Vector2(0f, (0f - now) * 1.2f); } } internal class PieceDef { internal string Key; internal string Tex; internal string Unit; internal Vector3 Centre; internal Vector3 Pos; internal Vector3 Scale; internal Vector3 Pivot; internal Quaternion Rot; internal Vector2 Rep; internal Color Tint; internal Dictionary<int, Vector3> Edits = new Dictionary<int, Vector3>(); internal HashSet<int> Cut = new HashSet<int>(); internal bool HasPivot; } internal class PoseKey { internal float Lean; internal float Drop; internal float Side; internal Dictionary<string, Vector3> Turns = new Dictionary<string, Vector3>(); } internal static class Data { internal static readonly List<PieceDef> Pieces = new List<PieceDef>(); internal static Vector3 Stand; internal static Vector3 FootL; internal static Vector3 FootR; internal static Vector3 GripL; internal static Vector3 GripR; internal static float Yaw = -90f; internal static readonly Dictionary<string, PoseKey> Keys = new Dictionary<string, PoseKey>(); internal static Vector3 HipsPos; internal static Quaternion HipsRot = Quaternion.identity; internal static readonly Dictionary<string, Quaternion> RestLocal = new Dictionary<string, Quaternion>(); internal static bool Loaded; internal static void Load(string dir) { try { ReadBoard(File.ReadAllText(Path.Combine(dir, "board.json"))); ReadRider(File.ReadAllText(Path.Combine(dir, "rider.json"))); ReadRest(File.ReadAllText(Path.Combine(dir, "rest.json"))); Loaded = Pieces.Count > 0; Plugin.Log.LogInfo((object)("[data] board " + Pieces.Count + " pieces, rider poses " + Keys.Count + ", rest bones " + RestLocal.Count)); } catch (Exception ex) { Plugin.Log.LogError((object)("[data] could not read the board files next to the dll: " + ex.Message)); } } private static Vector3 V(object o, Vector3 fallback) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) float[] array = MiniJson.Floats(o); if (array == null || array.Length < 3) { return fallback; } return new Vector3(array[0], array[1], array[2]); } private static void ReadBoard(string json) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, object> d = MiniJson.Obj(MiniJson.Parse(json)); Color val = default(Color); foreach (object item in MiniJson.Arr(MiniJson.Get(d, "pieces"))) { Dictionary<string, object> d2 = MiniJson.Obj(item); PieceDef pieceDef = new PieceDef(); pieceDef.Key = MiniJson.Str(MiniJson.Get(d2, "key")); pieceDef.Centre = V(MiniJson.Get(d2, "centre"), Vector3.zero); pieceDef.Pos = V(MiniJson.Get(d2, "pos"), Vector3.zero); float[] array = MiniJson.Floats(MiniJson.Get(d2, "rot")); pieceDef.Rot = (Quaternion)((array != null && array.Length == 4) ? new Quaternion(array[0], array[1], array[2], array[3]) : Quatern