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 DiscoBall v1.0.0
DiscoBall.dll
Decompiled 2 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("DiscoBall")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+0feec4eef9f2caeffc061073664faf81cd151881")] [assembly: AssemblyProduct("DiscoBall")] [assembly: AssemblyTitle("DiscoBall")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace DiscoBall { [BepInPlugin("mishka.valheim.discoball", "DiscoBall", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class DiscoBallPlugin : BaseUnityPlugin { private class DiscoSpin : MonoBehaviour { private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.Rotate(Vector3.up, 90f * Time.deltaTime, (Space)0); } } private class DiscoLightCycle : MonoBehaviour { private Light light; private float timer; private int colorIndex; private void Awake() { light = ((Component)this).GetComponent<Light>(); } private void Update() { //IL_0060: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)light == (Object)null)) { timer += Time.deltaTime; if (timer >= 0.5f) { timer = 0f; colorIndex = (colorIndex + 1) % LightColors.Length; light.color = LightColors[colorIndex]; } } } } public const string PluginGUID = "mishka.valheim.discoball"; public const string PluginName = "DiscoBall"; public const string PluginVersion = "1.0.0"; private const float ChainScale = 0.5f; private const float BallRadius = 0.35f; private const int ChainSegmentCount = 4; private static readonly Color[] LightColors = (Color[])(object)new Color[6] { Color.red, Color.green, Color.blue, Color.yellow, Color.magenta, Color.cyan }; private void Awake() { PrefabManager.OnVanillaPrefabsAvailable += AddDiscoBall; } private void AddDiscoBall() { //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_0136: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: 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_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Expected O, but got Unknown //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029d: 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_02b0: Expected O, but got Unknown //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: 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_02ca: Expected O, but got Unknown //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: 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_02e4: Expected O, but got Unknown //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable -= AddDiscoBall; GameObject val = PrefabManager.Instance.CreateClonedPrefab("piece_discoball", "piece_brazierceiling01"); val.GetComponent<Piece>().m_comfort = 0; Fireplace component = val.GetComponent<Fireplace>(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } string[] array = new string[5] { "ashlayer", "_enabled", "_enabled_high", "_enabled_low", "New" }; foreach (string text in array) { Transform val2 = val.transform.Find(text); if ((Object)(object)val2 != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val2).gameObject); } } EffectArea[] componentsInChildren = val.GetComponentsInChildren<EffectArea>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } Vector3 val3 = Vector3.up * 0.175f; float baseHeight = val3.y + 0.35f; float chainSegmentHeight = GetChainSegmentHeight(); AddChainSegment(val.transform, 0, baseHeight, chainSegmentHeight); GameObject val4 = new GameObject("DiscoBallMesh"); val4.transform.SetParent(val.transform, false); val4.transform.localPosition = val3; val4.transform.localScale = Vector3.one * 0.35f; Mesh mesh = CreateLowPolySphere(6, 9, 1f); MakeFlatShaded(mesh); val4.AddComponent<MeshFilter>().mesh = mesh; ((Renderer)val4.AddComponent<MeshRenderer>()).sharedMaterial = CreateMirrorMaterial(); val4.AddComponent<SphereCollider>().radius = 1f; val4.AddComponent<DiscoSpin>(); GameObject val5 = new GameObject("DiscoLight"); val5.transform.SetParent(val4.transform, false); Light obj = val5.AddComponent<Light>(); obj.type = (LightType)2; obj.range = 8f; obj.intensity = 1.5f; obj.color = Color.white; val5.AddComponent<DiscoLightCycle>(); LODGroup component2 = val.GetComponent<LODGroup>(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } Sprite icon = RenderManager.Instance.Render(val); for (int j = 1; j < 4; j++) { AddChainSegment(val.transform, j, baseHeight, chainSegmentHeight); } PieceManager instance = PieceManager.Instance; PieceConfig val6 = new PieceConfig(); val6.Name = "Disco Ball"; val6.Description = "Reflects the light of a thousand lost dreams. Purely decorative."; val6.PieceTable = "Hammer"; val6.Category = "Furniture"; val6.CraftingStation = "piece_workbench"; val6.Icon = icon; val6.Requirements = (RequirementConfig[])(object)new RequirementConfig[3] { new RequirementConfig { Item = "Bronze", Amount = 5 }, new RequirementConfig { Item = "FineWood", Amount = 4 }, new RequirementConfig { Item = "Chain", Amount = 1 } }; instance.AddPiece(new CustomPiece(val, true, val6)); } private static Mesh CreateLowPolySphere(int rings, int segments, float radius) { //IL_007b: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0130: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Expected O, but got Unknown List<Vector3> list = new List<Vector3>(); List<Vector2> list2 = new List<Vector2>(); List<int> list3 = new List<int>(); for (int i = 0; i <= rings; i++) { float num = (float)i / (float)rings; float num2 = num * (float)Math.PI; for (int j = 0; j <= segments; j++) { float num3 = (float)j / (float)segments; float num4 = num3 * (float)Math.PI * 2f; float num5 = Mathf.Sin(num2) * Mathf.Cos(num4); float num6 = Mathf.Cos(num2); float num7 = Mathf.Sin(num2) * Mathf.Sin(num4); list.Add(new Vector3(num5, num6, num7) * radius); list2.Add(new Vector2(num3, num)); } } int num8 = segments + 1; for (int k = 0; k < rings; k++) { for (int l = 0; l < segments; l++) { int num9 = k * num8 + l; int num10 = num9 + num8; list3.Add(num9); list3.Add(num10); list3.Add(num9 + 1); list3.Add(num9 + 1); list3.Add(num10); list3.Add(num10 + 1); } } Mesh val = new Mesh(); val.SetVertices(list); val.SetUVs(0, list2); val.SetTriangles(list3, 0); val.RecalculateNormals(); val.RecalculateBounds(); return val; } private static void MakeFlatShaded(Mesh mesh) { //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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) Vector3[] vertices = mesh.vertices; Vector2[] uv = mesh.uv; int[] triangles = mesh.triangles; Vector3[] array = (Vector3[])(object)new Vector3[triangles.Length]; Vector2[] array2 = (Vector2[])(object)new Vector2[triangles.Length]; for (int i = 0; i < triangles.Length; i++) { array[i] = vertices[triangles[i]]; array2[i] = uv[triangles[i]]; triangles[i] = i; } mesh.vertices = array; mesh.uv = array2; mesh.triangles = triangles; mesh.RecalculateNormals(); } private static float GetChainSegmentHeight() { //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_005d: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = PrefabManager.Instance.GetPrefab("Chain"); Transform val = (((Object)(object)prefab != (Object)null) ? prefab.transform.Find("model") : null); MeshFilter val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<MeshFilter>() : null); if (!((Object)(object)val2 != (Object)null)) { return 0f; } Bounds bounds = val2.sharedMesh.bounds; return ((Bounds)(ref bounds)).size.y * 0.5f; } private static void AddChainSegment(Transform parent, int index, float baseHeight, float segmentHeight) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: 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_00bd: 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) GameObject prefab = PrefabManager.Instance.GetPrefab("Chain"); Transform val = (((Object)(object)prefab != (Object)null) ? prefab.transform.Find("model") : null); if (!((Object)(object)val == (Object)null)) { GameObject obj = Object.Instantiate<GameObject>(((Component)val).gameObject, parent, false); ((Object)obj).name = "DiscoBallChain" + index; Collider component = obj.GetComponent<Collider>(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } LODGroup component2 = obj.GetComponent<LODGroup>(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } obj.transform.localPosition = Vector3.up * (baseHeight + segmentHeight * ((float)index + 0.5f)); obj.transform.localRotation = Quaternion.identity; obj.transform.localScale = Vector3.one * 0.5f; } } private static Material CreateMirrorMaterial() { //IL_0043: 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_0048: 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_0062: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown GameObject prefab = PrefabManager.Instance.GetPrefab("Silver"); MeshRenderer val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponentInChildren<MeshRenderer>() : null); Material val2 = (((Object)(object)val != (Object)null) ? new Material(((Renderer)val).sharedMaterial) : new Material(Shader.Find("Sprites/Default"))); val2.color = new Color(0.85f, 0.87f, 0.9f); val2.mainTexture = (Texture)(object)CreateFacetTexture(); val2.mainTextureScale = new Vector2(6f, 3f); return val2; } private static Texture2D CreateFacetTexture() { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown //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_003c: 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_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_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) Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ((Texture)val).wrapMode = (TextureWrapMode)0; ((Texture)val).filterMode = (FilterMode)0; val.SetPixels((Color[])(object)new Color[4] { Color.white, new Color(0.75f, 0.8f, 0.85f), new Color(0.75f, 0.8f, 0.85f), Color.white }); val.Apply(); return val; } } }