Please disclose if your mod was created primarily 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 Shawesomes Awesome Boats v2.1.0
Shawesomes_Awesome_Boats.dll
Decompiled 4 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("Shawesomes_Infinte_Multiverse")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Shawesomes_Infinte_Multiverse")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e0e26f8d-a8f0-41a7-a502-951624fa6f31")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace Shawesomes_Awesome_Boats { public class flamethrower : MonoBehaviour, Hoverable, Interactable { private string firename = "Dragon's Fire"; private Vector3 projectileForce = new Vector3(-10f, 1f, 0f); private Vector3 projOffset = new Vector3(-36f, 9f, 0f); public string GetHoverName() { return firename; } public string GetHoverText() { return firename; } public bool Interact(Humanoid user, bool hold, bool alt) { ((Character)user).Message((MessageType)2, "Flamethrower Engaged ∞", 0, (Sprite)null); float time = Time.time; Shoot(); return true; } public bool UseItem(Humanoid user, ItemData item) { ((Character)user).Message((MessageType)2, "Used " + ((Object)item.m_dropPrefab).name + " with Flamethrower", 0, (Sprite)null); return true; } public void Shoot() { //IL_002e: 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_0055: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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) Container component = ((Component)((Component)this).transform.GetChild(0)).GetComponent<Container>(); if ((Object)(object)component != (Object)null) { GameObject item = component.m_defaultItems.m_drops[0].m_item; GameObject val = Object.Instantiate<GameObject>(item, ((Component)this).gameObject.transform.position + ((Component)this).gameObject.transform.rotation * projOffset, Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f)); Projectile component2 = val.GetComponent<Projectile>(); if (Object.op_Implicit((Object)(object)component2)) { component2.m_vel = ((Component)this).gameObject.transform.rotation * projectileForce; } } } } public class Cannon : MonoBehaviour, Hoverable, Interactable { private string firename = "Molten Cannon"; private float lastProjectile = 0f; private float projectileCooldown = 5f; private Vector3 projectileForce = new Vector3(0f, 1f, -20f); private Vector3 projOffset = new Vector3(0f, 1f, -4f); public string GetHoverName() { return firename; } public string GetHoverText() { return firename; } public bool Interact(Humanoid user, bool hold, bool alt) { ((Character)user).Message((MessageType)2, "Cannon Engaged - 5 sec. Cooldown", 0, (Sprite)null); float time = Time.time; if (time > lastProjectile + projectileCooldown) { Shoot(); lastProjectile = time; } return true; } public bool UseItem(Humanoid user, ItemData item) { ((Character)user).Message((MessageType)2, "Used " + ((Object)item.m_dropPrefab).name + " with Cannon", 0, (Sprite)null); return true; } public void Shoot() { //IL_002e: 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_0055: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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) Container component = ((Component)((Component)this).transform.GetChild(0)).GetComponent<Container>(); if ((Object)(object)component != (Object)null) { GameObject item = component.m_defaultItems.m_drops[0].m_item; GameObject val = Object.Instantiate<GameObject>(item, ((Component)this).gameObject.transform.position + ((Component)this).gameObject.transform.rotation * projOffset, Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f)); Projectile component2 = val.GetComponent<Projectile>(); if (Object.op_Implicit((Object)(object)component2)) { component2.m_vel = ((Component)this).gameObject.transform.rotation * projectileForce; } } } } public class Harpoon : MonoBehaviour, Hoverable, Interactable { public string firename = "Harpoon"; private float lastProjectile = 0f; public float projectileCooldown = 5f; private Vector3 projectileForce = new Vector3(0f, 1f, -10f); public Vector3 projOffset = new Vector3(0f, 2f, -3f); public string GetHoverName() { return firename; } public string GetHoverText() { return firename; } public bool Interact(Humanoid user, bool hold, bool alt) { ((Character)user).Message((MessageType)2, "Harpoon Engaged - 5 sec. Cooldown", 0, (Sprite)null); float time = Time.time; if (time > lastProjectile + projectileCooldown) { Shoot(); lastProjectile = time; } return true; } public bool UseItem(Humanoid user, ItemData item) { ((Character)user).Message((MessageType)2, "Used " + ((Object)item.m_dropPrefab).name + " with Harpoon", 0, (Sprite)null); return true; } public void Shoot() { //IL_002e: 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_0055: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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) Container component = ((Component)((Component)this).transform.GetChild(0)).GetComponent<Container>(); if ((Object)(object)component != (Object)null) { GameObject item = component.m_defaultItems.m_drops[0].m_item; GameObject val = Object.Instantiate<GameObject>(item, ((Component)this).gameObject.transform.position + ((Component)this).gameObject.transform.rotation * projOffset, Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f)); Projectile component2 = val.GetComponent<Projectile>(); if (Object.op_Implicit((Object)(object)component2)) { component2.m_vel = ((Component)this).gameObject.transform.rotation * projectileForce; } } } } public class BattleDrums : MonoBehaviour, Hoverable, Interactable { private string firename = "Battle Drums"; private int enabledSong = 0; public string GetHoverName() { return firename; } public string GetHoverText() { return "[<color=orange><b>E</b></color>] Cycle Song\n[<color=orange><b>Shift+E</b></color>] Play/Pause Song"; } public bool Interact(Humanoid user, bool hold, bool alt) { if (alt) { ((Component)((Component)this).transform.GetChild(enabledSong)).gameObject.SetActive(!((Component)((Component)this).transform.GetChild(enabledSong)).gameObject.activeInHierarchy); ((Character)user).Message((MessageType)2, "Sound Off/On", 0, (Sprite)null); } else { ((Character)user).Message((MessageType)2, "Next Song", 0, (Sprite)null); enabledSong = (enabledSong + 1) % ((Component)this).transform.childCount; for (int i = 0; i < ((Component)this).transform.childCount; i++) { if (i != enabledSong) { ((Component)((Component)this).transform.GetChild(i)).gameObject.SetActive(false); } else { ((Component)((Component)this).transform.GetChild(i)).gameObject.SetActive(true); } } } return true; } public bool UseItem(Humanoid user, ItemData item) { ((Character)user).Message((MessageType)2, "Used " + ((Object)item.m_dropPrefab).name + " with Drums", 0, (Sprite)null); return true; } } public class Patches : MonoBehaviour { [HarmonyPatch(typeof(Player), "SetControls")] [HarmonyPrefix] private static void PrefixSetControlsforShip(Player __instance, ref bool jump, ref bool crouch) { Ship controlledShip = __instance.GetControlledShip(); ShipFly shipFly = default(ShipFly); if (!((Object)(object)controlledShip == (Object)null) && ((Component)controlledShip).gameObject.TryGetComponent<ShipFly>(ref shipFly)) { shipFly.flyship(ref jump, ref crouch); } } } public class ShipFly : MonoBehaviour { private Ship ship; private Rigidbody rb; public float drop_reduction = 10f; public Vector3 forcepos = new Vector3(0f, 0f, 0f); public float forwardReduction = 0.5f; public float hoverlift_modifier = 0.1f; public float hoverheight_modifier = 0.15f; public float hovertilt_modifier = 2f; public float jump_lift_mod = 0.1f; public float maxspeed = 30f; private float lift = 110f; public float LR_StabilityForce = 100f; public Vector3 LRpos = new Vector3(0f, 4f, -5f); public float maxangle = 0.35f; public float R_multi = 10f; public float rightingForce = -45f; public float rollForce = -25000f; public float rotationForce = 50f; public float slowDown_multi = 3f; public float thrust = 15f; public float turningForce = 0.05f; public float yawForce = 30000f; private float waterlvl = 30f; public void Awake() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) ship = ((Component)this).gameObject.GetComponent<Ship>(); if (Object.op_Implicit((Object)(object)ship)) { rb = ship.m_body; waterlvl = (Object.op_Implicit((Object)(object)ship.m_previousCenter) ? ((Component)ship.m_previousCenter).transform.position.y : 30f); } } private bool hasShip() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)ship) && Object.op_Implicit((Object)(object)rb)) { return true; } ship = ((Component)this).gameObject.GetComponent<Ship>(); if (Object.op_Implicit((Object)(object)ship)) { rb = ship.m_body; waterlvl = (Object.op_Implicit((Object)(object)ship.m_previousCenter) ? ((Component)ship.m_previousCenter).transform.position.y : 30f); if (Object.op_Implicit((Object)(object)rb)) { return true; } return false; } return false; } public void flyship(ref bool jump, ref bool crouch) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0263: 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_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_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_030d: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0351: 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_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_0376: 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_0393: 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_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Invalid comparison between Unknown and I4 //IL_053b: Unknown result type (might be due to invalid IL or missing references) //IL_0546: Unknown result type (might be due to invalid IL or missing references) //IL_054b: Unknown result type (might be due to invalid IL or missing references) //IL_0550: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_0572: Unknown result type (might be due to invalid IL or missing references) //IL_0577: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_046e: 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_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0427: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_05ee: Unknown result type (might be due to invalid IL or missing references) //IL_061c: Unknown result type (might be due to invalid IL or missing references) //IL_0621: Unknown result type (might be due to invalid IL or missing references) //IL_05b2: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04cd: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_0508: Unknown result type (might be due to invalid IL or missing references) if (!hasShip()) { Shawesomes_Awesome_Boats.logger.LogWarning((object)"Does not have ship"); return; } if (jump) { jump = false; } float num = 1f + 0.25f * Math.Min(Math.Max(rb.position.y - waterlvl, 0f), 6f); float num2 = Math.Max(Math.Min(1.25f - 0.25f * Math.Min(rb.position.y - waterlvl, 4f), 1f), 0f) * rotationForce; Vector3 val = rb.position + forcepos; Vector3 val2 = rb.rotation * Vector3.forward; float num3 = Vector3.Dot(val2, Vector3.up); if (num3 > maxangle) { num2 *= -1f; } float num4 = (maxangle - num3) * (maxangle - num3) * 100f; float num5 = Vector3.Dot(rb.velocity, val2); if (ZInput.GetButton("Jump") || ZInput.GetButtonDown("JoyJump")) { rb.AddForceAtPosition(new Vector3(0f, num2 * num4, 0f), rb.position, (ForceMode)1); if (num5 < 30f) { rb.AddForce(val2 * thrust * num, (ForceMode)1); } rb.AddForce(rb.rotation * new Vector3(0f, 1f, 0.1f) * Math.Min(lift * jump_lift_mod * num3 * num5, 2400f), (ForceMode)1); } int num6 = 1; if (ZInput.GetButton("Crouch") || ZInput.GetButtonDown("JoyCrouch")) { num6 = 5; } rb.AddForceAtPosition(new Vector3(0f, rightingForce * (float)num6, 0f), val, (ForceMode)1); float num7 = 1f; if (rb.position.y > waterlvl + 20f) { num7 = 1f - Math.Min(0.01f * (rb.position.y - waterlvl - 20f), 0.3f); } rb.AddForce(rb.rotation * new Vector3(0f, 1f, 0.1f) * Math.Min(lift * num7 * num3 * num5, 2400f), (ForceMode)1); float num8 = Vector3.Dot(rb.rotation * Vector3.left, Vector3.up); Vector3 val3 = rb.position + R_multi * num8 * (rb.rotation * Vector3.right) + rb.rotation * LRpos; rb.AddForceAtPosition(new Vector3(0f, LR_StabilityForce, 0f), val3, (ForceMode)1); if (num < 2f) { return; } float num9 = Math.Max(num - 1.5f, 0f); if ((int)ship.m_speed >= 1) { float num10 = Math.Max(Math.Min(10f / num5 - 27f, 2f), 0.1f); if (num5 < maxspeed) { rb.AddForce(val2 * thrust * num10 * num * hoverheight_modifier, (ForceMode)1); } else { rb.AddForce(val2 * thrust * slowDown_multi * (maxspeed - num5) * num * hoverheight_modifier, (ForceMode)1); } rb.AddForceAtPosition(new Vector3(0f, num2 * hovertilt_modifier * num10 * num4, 0f), rb.position, (ForceMode)1); rb.AddForce(rb.rotation * new Vector3(0f, 1f, 0.1f) * Math.Min(lift * num3 * num5 * hoverlift_modifier, 2400f), (ForceMode)1); } if (num9 > 0f) { float rudderValue = ship.m_rudderValue; float num11 = Vector3.Dot(rb.velocity, rb.rotation * Vector3.left); float num12 = Vector3.Dot(rb.velocity, rb.rotation * Vector3.up); if (num12 < 0f && num5 > 15f) { rb.AddForce(new Vector3(0f, 1f, 0f) * Math.Min(lift * (0f - num12) * drop_reduction * num9, 2400f), (ForceMode)1); } rb.AddForce(rb.rotation * new Vector3(num11 * turningForce * num9, 0f, forwardReduction * Math.Abs(num11) * turningForce * num9), (ForceMode)2); rb.AddRelativeTorque(0f, rudderValue * yawForce * num9, rudderValue * rollForce * num9); ship.m_rudderValue += 0.02f * (num9 * (float)((!(ship.m_rudderValue > 0f)) ? 1 : (-1))); } } } [BepInPlugin("Shawesome.Shawesomes_Awesome_Boats", "Shawesomes_Awesome_Boats", "2.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Shawesomes_Awesome_Boats : BaseUnityPlugin { public Harmony harmony; public static GameObject Root; public string version = "1.0.0"; public static ManualLogSource logger; public static ManualLogSource harmonyLog; private static AssetBundle Shawcassets; public static Sprite FreezingIcon; public static List<GameObject> EffectList = new List<GameObject>(); public void Awake() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown logger = ((BaseUnityPlugin)this).Logger; VanillaShaders.InitLogFilter(); VanillaShaders.RegisterAssetBundle("shaw_fwc"); harmony = new Harmony("IDshawesome4u2"); Root = new GameObject("Shaw Root"); Object.DontDestroyOnLoad((Object)(object)Root); harmony.PatchAll(typeof(Patches)); harmonyLog = ((BaseUnityPlugin)this).Logger; Shawcassets = AssetUtils.LoadAssetBundleFromResources("shaw_fwc", Assembly.GetExecutingAssembly()); LoadAssets(); PrefabManager.OnVanillaPrefabsAvailable += additems; PrefabManager.OnPrefabsRegistered += delegate { harmonyLog.LogMessage((object)"Registering VFX via PrefabManager (safe, ZNetScene ready)..."); AddEffectsToZNet(); }; } public static void LoadAssets() { EffectList.Add(Shawcassets.LoadAsset<GameObject>("Assets/PrefabInstance/DvergerStaffFire_fireball_projectile1.prefab")); EffectList.Add(Shawcassets.LoadAsset<GameObject>("Assets/PrefabInstance/DragonsFire.prefab")); EffectList.Add(Shawcassets.LoadAsset<GameObject>("Assets/ShawesomeBoats1not working/sfx_FireAddFuel.prefab")); EffectList.Add(Shawcassets.LoadAsset<GameObject>("Assets/ShawesomeBoats1not working/DvergerStaffFire_fire_aoe1.prefab")); EffectList.Add(Shawcassets.LoadAsset<GameObject>("Assets/PrefabInstance/projectile_chitinharpoon1.prefab")); } public static void AddEffectsToZNet() { harmonyLog.LogMessage((object)"Adding effects to ZNet"); foreach (GameObject effect in EffectList) { int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)effect).name); harmonyLog.LogMessage((object)("Attempting to add to Znet " + stableHashCode + ":" + ((Object)effect).name)); if ((Object)(object)ZNetScene.instance != (Object)null && !ZNetScene.instance.m_namedPrefabs.ContainsKey(stableHashCode)) { harmonyLog.LogMessage((object)("Adding to ZNet" + ((Object)effect).name)); PrefabManager.Instance.RegisterToZNetScene(effect); } harmonyLog.LogMessage((object)((Object)(object)ZNetScene.instance.GetPrefab(stableHashCode) != (Object)null)); } } public static void additems() { Addmistboat(); Adddreddboat(); Addshawesomeboat(); PrefabManager.OnVanillaPrefabsAvailable -= additems; } public static void Addplainsboat() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown PieceConfig val = new PieceConfig(); val.PieceTable = PieceTables.Hammer; val.CraftingStation = CraftingStations.Workbench; val.Category = PieceCategories.Misc; val.AddRequirement(new RequirementConfig("IronNails", 200, 0, false)); val.AddRequirement(new RequirementConfig("ElderBark", 100, 0, false)); val.AddRequirement(new RequirementConfig("BlackMetal", 100, 0, false)); val.AddRequirement(new RequirementConfig("Eitr", 100, 0, false)); GameObject val2 = Shawcassets.LoadAsset<GameObject>("Assets/ShawesomeBoats/shwsm_plainsboat.prefab"); CustomPiece val3 = new CustomPiece(val2, true, val); PieceManager.Instance.AddPiece(val3); } public static void Addmistboat() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown PieceConfig val = new PieceConfig(); val.PieceTable = PieceTables.Hammer; val.CraftingStation = CraftingStations.Workbench; val.Category = PieceCategories.Misc; val.AddRequirement(new RequirementConfig("IronNails", 200, 0, false)); val.AddRequirement(new RequirementConfig("ElderBark", 100, 0, false)); val.AddRequirement(new RequirementConfig("BlackMetal", 100, 0, false)); val.AddRequirement(new RequirementConfig("Eitr", 100, 0, false)); GameObject val2 = Shawcassets.LoadAsset<GameObject>("Assets/ShawesomeBoats/shwsm_mistboat.prefab"); CustomPiece val3 = new CustomPiece(val2, true, val); PieceManager.Instance.AddPiece(val3); } public static void Adddreddboat() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Expected O, but got Unknown PieceConfig val = new PieceConfig(); val.PieceTable = PieceTables.Hammer; val.CraftingStation = CraftingStations.Workbench; val.Category = PieceCategories.Misc; val.AddRequirement(new RequirementConfig("IronNails", 200, 0, false)); val.AddRequirement(new RequirementConfig("ElderBark", 100, 0, false)); val.AddRequirement(new RequirementConfig("BlackMetal", 100, 0, false)); val.AddRequirement(new RequirementConfig("FlametalNew", 100, 0, false)); GameObject val2 = Shawcassets.LoadAsset<GameObject>("Assets/ShawesomeBoats/dreddShip.prefab"); ((Component)val2.transform.Find("ship").Find("visual").Find("hull_new") .Find("skull_head")).gameObject.AddComponent<flamethrower>(); ((Component)val2.transform.Find("ship").Find("Battle Drums")).gameObject.AddComponent<BattleDrums>(); ((Component)val2.transform.Find("ship").Find("visual").Find("hull_new") .Find("CannonGap")).gameObject.AddComponent<Cannon>(); ((Component)val2.transform.Find("ship").Find("visual").Find("hull_new") .Find("CannonGap (1)")).gameObject.AddComponent<Cannon>(); ((Component)val2.transform.Find("ship").Find("visual").Find("hull_new") .Find("CannonGap (2)")).gameObject.AddComponent<Cannon>(); ((Component)val2.transform.Find("ship").Find("visual").Find("hull_new") .Find("CannonGap (3)")).gameObject.AddComponent<Cannon>(); ((Component)val2.transform.Find("ship").Find("visual").Find("hull_new") .Find("CannonGap (4)")).gameObject.AddComponent<Cannon>(); ((Component)val2.transform.Find("ship").Find("visual").Find("hull_new") .Find("CannonGap (5)")).gameObject.AddComponent<Cannon>(); ((Component)val2.transform.Find("ship").Find("visual").Find("hull_new") .Find("Rear_Harpoon")).gameObject.AddComponent<Harpoon>(); ((Component)val2.transform.Find("ship").Find("visual").Find("hull_new") .Find("Rear_Harpoon (1)")).gameObject.AddComponent<Harpoon>(); CustomPiece val3 = new CustomPiece(val2, true, val); PieceManager.Instance.AddPiece(val3); } public static void Addshawesomeboat() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown PieceConfig val = new PieceConfig(); val.PieceTable = PieceTables.Hammer; val.CraftingStation = CraftingStations.Workbench; val.Category = PieceCategories.Misc; val.AddRequirement(new RequirementConfig("IronNails", 200, 0, false)); val.AddRequirement(new RequirementConfig("ElderBark", 100, 0, false)); val.AddRequirement(new RequirementConfig("BlackMetal", 100, 0, false)); val.AddRequirement(new RequirementConfig("FlametalNew", 100, 0, false)); GameObject val2 = Shawcassets.LoadAsset<GameObject>("Assets/ShawesomeBoats/Shawesomeship.prefab"); ShipFly shipFly = val2.AddComponent<ShipFly>(); shipFly.maxspeed = 15f; shipFly.turningForce = 2f; shipFly.yawForce = 60000f; CustomPiece val3 = new CustomPiece(val2, true, val); PieceManager.Instance.AddPiece(val3); } } public static class Utils2 { private const BindingFlags bindingFlags = BindingFlags.Public; public static T GetCopyOf<T>(this Component comp, T other) where T : Component { Type type = ((object)comp).GetType(); if (type != ((object)other).GetType()) { return default(T); } List<Type> list = new List<Type>(); Type baseType = type.BaseType; while (baseType != null && !(baseType == typeof(MonoBehaviour))) { list.Add(baseType); baseType = baseType.BaseType; } IEnumerable<PropertyInfo> enumerable = type.GetProperties(BindingFlags.Public); foreach (Type item in list) { enumerable = enumerable.Concat(item.GetProperties(BindingFlags.Public)); } enumerable = from property in enumerable where !(type == typeof(Rigidbody)) || !(property.Name == "inertiaTensor") where !property.CustomAttributes.Any((CustomAttributeData attribute) => attribute.AttributeType == typeof(ObsoleteAttribute)) select property; foreach (PropertyInfo pinfo in enumerable) { if (pinfo.CanWrite && !enumerable.Any((PropertyInfo e) => e.Name == $"shared{char.ToUpper(pinfo.Name[0])}{pinfo.Name.Substring(1)}")) { try { pinfo.SetValue(comp, pinfo.GetValue(other, null), null); } catch { } } } IEnumerable<FieldInfo> enumerable2 = type.GetFields(BindingFlags.Public); foreach (FieldInfo finfo in enumerable2) { foreach (Type item2 in list) { if (!enumerable2.Any((FieldInfo e) => e.Name == $"shared{char.ToUpper(finfo.Name[0])}{finfo.Name.Substring(1)}")) { enumerable2 = enumerable2.Concat(item2.GetFields(BindingFlags.Public)); } } } foreach (FieldInfo item3 in enumerable2) { item3.SetValue(comp, item3.GetValue(other)); } enumerable2 = enumerable2.Where((FieldInfo field) => field.CustomAttributes.Any((CustomAttributeData attribute) => attribute.AttributeType == typeof(ObsoleteAttribute))); foreach (FieldInfo item4 in enumerable2) { item4.SetValue(comp, item4.GetValue(other)); } return (T)(object)((comp is T) ? comp : null); } public static T AddComponent<T>(this GameObject go, T toAdd) where T : Component { return go.AddComponent(((object)toAdd).GetType()).GetCopyOf(toAdd); } public static void updateSKMesh(Transform parent, SkinnedMeshRenderer skmesh) { //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) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) List<ParticleSystem> list = ((Component)parent).GetComponentsInChildren<ParticleSystem>().ToList(); foreach (ParticleSystem item in list) { ShapeModule shape = item.shape; if (!Object.op_Implicit((Object)(object)((ShapeModule)(ref shape)).skinnedMeshRenderer)) { ShapeModule shape2 = item.shape; ((ShapeModule)(ref shape2)).skinnedMeshRenderer = skmesh; } } } public static SkinnedMeshRenderer createSkMeshRen(Transform objectTrans, Transform attach_skin) { SkinnedMeshRenderer val = default(SkinnedMeshRenderer); if (!((Component)objectTrans).gameObject.TryGetComponent<SkinnedMeshRenderer>(ref val)) { val = ((Component)objectTrans).gameObject.AddComponent<SkinnedMeshRenderer>(); } val.rootBone = attach_skin.Find("Armature").Find("Hips"); return val; } public static Mesh createBonedMesh(Mesh newmesh, Mesh copymesh, Vector3 pos, Vector3 rot, Vector3 scale, bool stretch = true) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) Mesh newmesh2 = AlignedSkinMesh(newmesh, pos, rot, scale); return copyBoneWeights(newmesh2, copymesh, stretch); } public static Mesh AlignedSkinMesh(Mesh meshtomodify, Vector3 pos, Vector3 rot, Vector3 scale) { //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_002d: 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_005d: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_007d: 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_008a: 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_0097: Unknown result type (might be due to invalid IL or missing references) Mesh val = Object.Instantiate<Mesh>(meshtomodify); List<Vector3> list = new List<Vector3>(); for (int i = 0; i < meshtomodify.vertices.Count(); i++) { Vector3 val2 = Quaternion.Euler(rot) * new Vector3(meshtomodify.vertices[i].x * scale.x, meshtomodify.vertices[i].y * scale.y, meshtomodify.vertices[i].z * scale.z); list.Add(new Vector3(val2.x + pos.x, val2.y + pos.y, val2.z + pos.z)); } val.SetVertices(list); ((Object)val).name = "copymesh"; return val; } public static Mesh copyBoneWeights(Mesh newmesh, Mesh copymesh, bool stretch = true) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0082: 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_00a5: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) BoneWeight[] array = (BoneWeight[])(object)new BoneWeight[newmesh.vertexCount]; newmesh.bindposes = copymesh.bindposes; if (stretch) { for (int i = 0; i < newmesh.vertexCount; i++) { int closestVert = getClosestVert(newmesh.vertices[i], copymesh.vertices); array[i] = copymesh.boneWeights[closestVert]; } } else { Vector3 val = Vector3.zero; for (int j = 0; j < newmesh.vertexCount; j++) { val += newmesh.vertices[j]; } int closestVert2 = getClosestVert(val / (float)newmesh.vertexCount, copymesh.vertices); for (int k = 0; k < newmesh.vertexCount; k++) { array[k] = copymesh.boneWeights[closestVert2]; } } newmesh.boneWeights = array; return newmesh; } public static int getClosestVert(Vector3 vert, Vector3[] basemesh) { //IL_000e: 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) float num = 99999f; int result = -1; for (int i = 0; i < basemesh.Length; i++) { float num2 = Vector3.Distance(vert, basemesh[i]); if (num2 < num) { num = num2; result = i; } } return result; } public static void alignMeshAllChidren(Transform objectTrans, Transform basetransform) { //IL_001a: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_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_006a: 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_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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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) MeshFilter[] componentsInChildren = ((Component)objectTrans).GetComponentsInChildren<MeshFilter>(); for (int i = 0; i < componentsInChildren.Length; i++) { Transform val = ((Component)componentsInChildren[i]).transform; Vector3 val2 = val.localPosition; Vector3 val3 = ((Component)val).transform.localEulerAngles; Vector3 val4 = ((Component)val).transform.localScale; for (int j = 0; j < 20; j++) { if (!((Object)(object)val.parent != (Object)(object)objectTrans)) { break; } val = val.parent; val4 = Vector3.Scale(val4, val.localScale); val2 = Vector3.Scale(val4, val2) + val.localPosition; val3 += val.localEulerAngles; } SkinnedMeshRenderer val5 = createSkMeshRen(((Component)componentsInChildren[i]).transform, basetransform); val5.sharedMesh = AlignedSkinMesh(val5.sharedMesh, val2, val3, val4); } } public static void boneMeshAllChidren(Transform objectTrans, Transform basetransform, Mesh baseMesh, bool stretch = true) { //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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_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_006b: 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_006f: 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_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_0081: 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_0086: 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_0090: 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_00bc: 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_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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) Transform val = basetransform.Find("Armature").Find("Hips"); MeshFilter[] componentsInChildren = ((Component)objectTrans).GetComponentsInChildren<MeshFilter>(); for (int i = 0; i < componentsInChildren.Length; i++) { Transform val2 = ((Component)componentsInChildren[i]).transform; Vector3 val3 = val2.localPosition; Vector3 val4 = ((Component)val2).transform.localEulerAngles; Vector3 val5 = ((Component)val2).transform.localScale; for (int j = 0; j < 20; j++) { if (!((Object)(object)val2.parent != (Object)(object)objectTrans)) { break; } val2 = val2.parent; val5 = Vector3.Scale(val5, val2.localScale); val3 = Vector3.Scale(val5, val3) + val2.localPosition; val4 += val2.localEulerAngles; } val3 += new Vector3(0f, 0f - val.localPosition.y, 0f - val.localPosition.z); SkinnedMeshRenderer val6 = createSkMeshRen(((Component)componentsInChildren[i]).transform, basetransform); val6.sharedMesh = createBonedMesh(val6.sharedMesh, baseMesh, val3, val4, val5, stretch); } } public static void setStyleTex(Material mat, Texture2D styles) { mat.EnableKeyword("_USESTYLES_ON"); mat.SetFloat("_Style", 0f); mat.SetFloat("_UseStyles", 1f); mat.SetTexture("_StyleTex", (Texture)(object)styles); } public static Mesh createScaledCape(Mesh originalMesh, Vector3 scaleTop, Vector3 scaleBot, Vector3 offset = default(Vector3)) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0046: 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_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_0071: 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_0089: 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_009b: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0112: 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_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; Vector3 one = Vector3.one; Mesh val = Object.Instantiate<Mesh>(originalMesh); List<Vector3> list = new List<Vector3>(); for (int i = 0; i < originalMesh.vertices.Count(); i++) { Vector3 val2 = originalMesh.vertices[i]; ((Vector3)(ref zero))..ctor(Mathf.Max(zero.x, val2.x), Mathf.Max(zero.y, val2.y), Mathf.Max(zero.z, val2.z)); ((Vector3)(ref one))..ctor(Mathf.Min(one.x, val2.x), Mathf.Min(one.y, val2.y), Mathf.Min(one.z, val2.z)); } Vector3 val4 = default(Vector3); for (int j = 0; j < originalMesh.vertices.Count(); j++) { Vector3 val3 = originalMesh.vertices[j]; float num = val3.x * (scaleBot.x + (scaleTop.x - scaleBot.x) * (val3.z - one.z) / (zero.z - one.z)); float num2 = val3.y * (scaleBot.y + (scaleTop.y - scaleBot.y) * (val3.z - one.z) / (zero.z - one.z)); ((Vector3)(ref val4))..ctor(num, num2, val3.z); list.Add(new Vector3(val4.x + offset.x, val4.y + offset.y, val4.z + offset.z)); } val.SetVertices(list); ((Object)val).name = "scaled_" + ((Object)val).name; return val; } public static GameObject getmockGo(string mockname, Transform newParent) { string[] array = mockname.Split(new char[1] { '.' }); if (!array[0].StartsWith("ATmock_")) { return null; } Transform transform; try { transform = PrefabManager.Instance.GetPrefab(array[0].Replace("ATmock_", "")).transform; } catch { return null; } for (int i = 1; i < array.Length; i++) { try { transform = ((Component)transform.Find(array[i])).transform; } catch { } } return ((Component)transform).gameObject; } } public static class VanillaShaders { private static bool s_logFilterInitialized; private static bool s_patchInitialized; private static readonly HashSet<string> s_registeredPrefabs = new HashSet<string>(); private static readonly HashSet<string> s_registeredBundles = new HashSet<string>(); private static readonly Dictionary<string, Shader> s_shaderCache = new Dictionary<string, Shader>(); private static bool s_cacheBuilt; private static HashSet<int> s_processedObjects = new HashSet<int>(); private static int s_totalFixed; public static void RegisterAssetBundle(string bundleName) { s_registeredBundles.Add(bundleName); } public static void RegisterPrefab(string prefabName) { s_registeredPrefabs.Add(prefabName); } public static bool IsRegistered(string prefabName) { return s_registeredPrefabs.Contains(prefabName); } public static void InitLogFilter() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown if (s_logFilterInitialized) { return; } s_logFilterInitialized = true; ManualLogSource logger = Shawesomes_Awesome_Boats.logger; if (logger != null) { logger.LogInfo((object)"[VanillaShaders] Initializing shader fixer..."); } Harmony val = new Harmony("Shawesomes.Boats.VanillaShaders"); Type type = Type.GetType("BepInEx.Logging.UnityLogSource, BepInEx"); if (type != null) { MethodInfo method = type.GetMethod("OnUnityLogMessageReceived", BindingFlags.Static | BindingFlags.NonPublic); if (method != null) { val.Patch((MethodBase)method, new HarmonyMethod(typeof(VanillaShaders), "FilterUnityLogMessage", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } if (!s_patchInitialized) { s_patchInitialized = true; MethodInfo method2 = typeof(ZNetView).GetMethod("Awake", BindingFlags.Instance | BindingFlags.NonPublic); if (method2 != null) { val.Patch((MethodBase)method2, (HarmonyMethod)null, new HarmonyMethod(typeof(VanillaShaders), "OnZNetViewAwake", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } } } private static void OnZNetViewAwake(ZNetView __instance) { if ((Object)(object)__instance == (Object)null) { return; } string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject); if (s_registeredPrefabs.Contains(prefabName) || IsPrefabFromRegisteredBundle(prefabName)) { ManualLogSource logger = Shawesomes_Awesome_Boats.logger; if (logger != null) { logger.LogDebug((object)("[VanillaShaders] Auto-fixing shaders on: " + prefabName)); } FixShaders(((Component)__instance).gameObject); } } private static bool IsPrefabFromRegisteredBundle(string prefabName) { foreach (string bundleName in s_registeredBundles) { AssetBundle val = AssetBundle.GetAllLoadedAssetBundles().FirstOrDefault((Func<AssetBundle, bool>)((AssetBundle b) => string.Equals(((Object)b).name, bundleName, StringComparison.OrdinalIgnoreCase))); if (!((Object)(object)val != (Object)null)) { continue; } string[] allAssetNames = val.GetAllAssetNames(); string[] array = allAssetNames; foreach (string path in array) { string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path); if (string.Equals(fileNameWithoutExtension, prefabName, StringComparison.OrdinalIgnoreCase)) { s_registeredPrefabs.Add(prefabName); return true; } } } return false; } private static bool FilterUnityLogMessage(string message) { if (message != null && message.Contains("Failed to find expected binary shader data")) { return false; } return true; } private static void BuildShaderCache() { if (s_cacheBuilt) { return; } Shader[] array = Resources.FindObjectsOfTypeAll<Shader>(); Dictionary<string, Shader> dictionary = new Dictionary<string, Shader>(); Shader[] array2 = array; foreach (Shader val in array2) { if (!((Object)(object)val == (Object)null) && !string.IsNullOrEmpty(((Object)val).name)) { if (val.isSupported && val.passCount > 0) { s_shaderCache[((Object)val).name] = val; } else if (!s_shaderCache.ContainsKey(((Object)val).name)) { dictionary[((Object)val).name] = val; } } } foreach (KeyValuePair<string, Shader> item in dictionary) { if (!s_shaderCache.ContainsKey(item.Key)) { s_shaderCache[item.Key] = item.Value; } } s_cacheBuilt = true; ManualLogSource logger = Shawesomes_Awesome_Boats.logger; if (logger != null) { logger.LogInfo((object)$"[VanillaShaders] Cached {s_shaderCache.Count} shaders ({dictionary.Count} were stubs)"); } } public static void FixShaders(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return; } BuildShaderCache(); s_processedObjects.Clear(); s_totalFixed = 0; FixShadersRecursive(gameObject, 0); if (s_totalFixed > 0) { ManualLogSource logger = Shawesomes_Awesome_Boats.logger; if (logger != null) { logger.LogInfo((object)$"[VanillaShaders] Fixed {s_totalFixed} shaders on {((Object)gameObject).name} and its references"); } } } private static void FixShadersRecursive(GameObject gameObject, int depth) { if ((Object)(object)gameObject == (Object)null || depth > 10) { return; } int instanceID = ((Object)gameObject).GetInstanceID(); if (s_processedObjects.Contains(instanceID)) { return; } s_processedObjects.Add(instanceID); FixRenderersOnObject(gameObject); Component[] componentsInChildren = gameObject.GetComponentsInChildren<Component>(true); foreach (Component val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { FindAndFixReferences(val, depth); } } } private static void FindAndFixReferences(Component component, int depth) { if ((Object)(object)component == (Object)null) { return; } Type type = ((object)component).GetType(); FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { try { object value = fieldInfo.GetValue(component); if (value == null) { continue; } GameObject val = (GameObject)((value is GameObject) ? value : null); if (val != null) { FixShadersRecursive(val, depth + 1); continue; } Material val2 = (Material)((value is Material) ? value : null); if (val2 != null) { FixMaterial(val2); continue; } if (value is GameObject[] array2) { GameObject[] array3 = array2; foreach (GameObject gameObject in array3) { FixShadersRecursive(gameObject, depth + 1); } continue; } if (value is Material[] array4) { Material[] array5 = array4; foreach (Material material in array5) { FixMaterial(material); } continue; } EffectList val3 = (EffectList)((value is EffectList) ? value : null); if (val3 != null) { FixEffectList(val3, depth); } else { if (!(value is IList list) || list.Count <= 0) { continue; } foreach (object item in list) { if (item == null) { continue; } Type type2 = item.GetType(); FieldInfo field = type2.GetField("m_prefab"); if (field != null) { object? value2 = field.GetValue(item); GameObject val4 = (GameObject)((value2 is GameObject) ? value2 : null); if ((Object)(object)val4 != (Object)null) { FixShadersRecursive(val4, depth + 1); } } } continue; } } catch { } } } private static void FixEffectList(EffectList effectList, int depth) { if (effectList?.m_effectPrefabs == null) { return; } EffectData[] effectPrefabs = effectList.m_effectPrefabs; foreach (EffectData val in effectPrefabs) { if ((Object)(object)val?.m_prefab != (Object)null) { FixShadersRecursive(val.m_prefab, depth + 1); } } } private static void FixRenderersOnObject(GameObject gameObject) { Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>(true); Renderer[] array = componentsInChildren; foreach (Renderer val in array) { if ((Object)(object)val == (Object)null) { continue; } Material[] sharedMaterials = val.sharedMaterials; bool flag = false; for (int j = 0; j < sharedMaterials.Length; j++) { if (FixMaterial(sharedMaterials[j])) { flag = true; } } if (flag) { val.sharedMaterials = sharedMaterials; } } } private static bool FixMaterial(Material material) { if ((Object)(object)material == (Object)null || (Object)(object)material.shader == (Object)null) { return false; } Shader shader = material.shader; string name = ((Object)shader).name; if (shader.isSupported && shader.passCount > 0) { return false; } if (!s_shaderCache.TryGetValue(name, out Shader value)) { return false; } if (!value.isSupported || value.passCount == 0) { return false; } material.shader = value; s_totalFixed++; return true; } public static void RebuildCache() { s_shaderCache.Clear(); s_cacheBuilt = false; BuildShaderCache(); } } }