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 HanestadShip v1.0.0
BepInEx/plugins/HanestadShip/HanestadShip.dll
Decompiled 13 hours agousing System.Collections; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("HanestadShip")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("HanestadShip")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("a82884c3-8c02-459a-92f9-04b1189b5db7")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace HanestadShip; [BepInPlugin("no.hanestad.hanestadship", "Hanestad Ship", "0.7.3")] public class Plugin : BaseUnityPlugin { private bool shipPainted = false; private bool logosCreated = false; private readonly Color pink = new Color(0.95f, 0.12f, 0.45f, 1f); private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"HANESTAD SHIP 0.7.3 LASTET"); ((MonoBehaviour)this).StartCoroutine(SetupShip()); } private IEnumerator SetupShip() { while (!shipPainted) { yield return (object)new WaitForSeconds(2f); PaintShipPink(); } yield return (object)new WaitForSeconds(1f); if (!logosCreated) { CreateExteriorLogos(); } } private void PaintShipPink() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) Renderer[] array = Resources.FindObjectsOfTypeAll<Renderer>(); int num = 0; Renderer[] array2 = array; foreach (Renderer val in array2) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null) { continue; } Scene scene = ((Component)val).gameObject.scene; if (!((Scene)(ref scene)).IsValid()) { continue; } string fullPath = GetFullPath(((Component)val).transform); string text = fullPath.ToLower(); string text2 = ((Object)((Component)val).gameObject).name.ToLower(); if (!text.Contains("ship") && !text.Contains("elevator") && !text2.Contains("ship") && !text2.Contains("elevator")) { continue; } Material[] materials = val.materials; foreach (Material val2 in materials) { if ((Object)(object)val2 == (Object)null) { continue; } string text3 = ((Object)val2).name.ToLower(); if (!text3.Contains("screen") && !text3.Contains("terminal") && !text3.Contains("button") && !text3.Contains("glass") && !text3.Contains("monitor") && !text3.Contains("light") && !text3.Contains("emiss") && !text3.Contains("door") && !text3.Contains("floor") && !text2.Contains("terminal") && !text2.Contains("monitor") && !text2.Contains("button") && !text2.Contains("screen") && (text3.Contains("ship") || text3.Contains("wall") || text3.Contains("metal") || text3.Contains("panel") || text3.Contains("inside") || text3.Contains("interior") || text2.Contains("wall") || text2.Contains("panel"))) { bool flag = false; if (val2.HasProperty("_BaseColor")) { val2.SetColor("_BaseColor", pink); flag = true; } if (val2.HasProperty("_Color")) { val2.SetColor("_Color", pink); flag = true; } if (flag) { num++; } } } } if (num > 0) { shipPainted = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Rosa skip aktivert."); } } private void CreateExteriorLogos() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Expected O, but got Unknown //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020a: 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_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0231: 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_0259: 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_0281: 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_02c7: 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_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) Renderer val = FindShipHull(); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Fant ikke ShipHull."); return; } Bounds bounds = val.bounds; string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); string text = Path.Combine(directoryName, "hanestadship"); if (!File.Exists(text)) { ((BaseUnityPlugin)this).Logger.LogError((object)"Fant ikke hanestadship AssetBundle."); return; } AssetBundle val2 = AssetBundle.LoadFromFile(text); if ((Object)(object)val2 == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Kunne ikke laste hanestadship AssetBundle."); return; } GameObject val3 = FindLogoPrefab(val2); if ((Object)(object)val3 == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Fant ikke hanestad_logo."); val2.Unload(false); return; } SpriteRenderer componentInChildren = val3.GetComponentInChildren<SpriteRenderer>(); if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren.sprite == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Logo-prefaben mangler SpriteRenderer."); val2.Unload(false); return; } Sprite sprite = componentInChildren.sprite; Texture2D texture = sprite.texture; if ((Object)(object)texture == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Logoen mangler texture."); val2.Unload(false); return; } Shader val4 = Shader.Find("Unlit/Transparent"); if ((Object)(object)val4 == (Object)null) { val4 = Shader.Find("Unlit/Texture"); } if ((Object)(object)val4 == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"Fant ikke passende shader."); val2.Unload(false); return; } Material val5 = new Material(val4); ((Object)val5).name = "HANESTAD_ExteriorLogoMaterial"; val5.mainTexture = (Texture)(object)texture; if (val5.HasProperty("_Cull")) { val5.SetInt("_Cull", 2); } float num = 4.8f; Rect rect = sprite.rect; float num2 = ((Rect)(ref rect)).width; rect = sprite.rect; float num3 = num2 / ((Rect)(ref rect)).height; float height = num / num3; float num4 = ((Bounds)(ref bounds)).center.x - 4f; float num5 = ((Bounds)(ref bounds)).center.x - 3.8f; float num6 = ((Bounds)(ref bounds)).center.y + 0.5f; float num7 = ((Bounds)(ref bounds)).center.y + 0.5f; float num8 = ((Bounds)(ref bounds)).max.z + 0.08f; float num9 = ((Bounds)(ref bounds)).min.z - 0.08f; GameObject val6 = CreateLogoQuad("HANESTAD_ExteriorLogo_Side1", val5, num, height); val6.transform.position = new Vector3(num4, num6, num8); val6.transform.rotation = Quaternion.Euler(0f, 180f, 0f); GameObject val7 = CreateLogoQuad("HANESTAD_ExteriorLogo_Side2", val5, num, height); val7.transform.position = new Vector3(num5, num7, num9); val7.transform.rotation = Quaternion.Euler(0f, 0f, 0f); val6.transform.SetParent(((Component)val).transform, true); val7.transform.SetParent(((Component)val).transform, true); logosCreated = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"HANESTAD 0.7.3: Begge utvendige logoer aktivert."); val2.Unload(false); } private GameObject CreateLogoQuad(string objectName, Material material, float width, float height) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val).name = objectName; Collider component = val.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } MeshRenderer component2 = val.GetComponent<MeshRenderer>(); ((Renderer)component2).material = material; val.transform.localScale = new Vector3(width, height, 1f); return val; } private Renderer FindShipHull() { //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) Renderer[] array = Resources.FindObjectsOfTypeAll<Renderer>(); Renderer[] array2 = array; foreach (Renderer val in array2) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null)) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid() && ((Object)((Component)val).gameObject).name == "ShipHull") { return val; } } } return null; } private GameObject FindLogoPrefab(AssetBundle bundle) { string[] allAssetNames = bundle.GetAllAssetNames(); string[] array = allAssetNames; foreach (string text in array) { if (text.ToLower().Contains("hanestad_logo")) { GameObject val = bundle.LoadAsset<GameObject>(text); if ((Object)(object)val != (Object)null) { return val; } } } return null; } private string GetFullPath(Transform transform) { string text = ((Object)transform).name; while ((Object)(object)transform.parent != (Object)null) { transform = transform.parent; text = ((Object)transform).name + "/" + text; } return text; } }