using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
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("ValheimBaseExporter")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Scan Computers")]
[assembly: AssemblyProduct("ValheimBaseExporter")]
[assembly: AssemblyCopyright("Copyright © Scan Computers 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c7a10d7e-45c8-41c6-b4c4-7480922d6548")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.yourname.baseexporter", "Base Exporter", "1.0.1")]
public class BaseExporter : BaseUnityPlugin
{
private void Update()
{
if (Input.GetKeyDown((KeyCode)290))
{
ExportBase(50f);
}
}
private void ExportBase(float radius)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0352: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: 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_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: 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_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: 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_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: 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_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: 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_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)"Starting Export...");
StringBuilder stringBuilder = new StringBuilder();
int num = 1;
Collider[] array = Physics.OverlapSphere(((Component)Player.m_localPlayer).transform.position, radius);
HashSet<int> hashSet = new HashSet<int>();
Collider[] array2 = array;
foreach (Collider val in array2)
{
Piece componentInParent = ((Component)val).GetComponentInParent<Piece>();
if ((Object)(object)componentInParent == (Object)null)
{
continue;
}
int instanceID = ((Object)((Component)componentInParent).gameObject).GetInstanceID();
if (hashSet.Contains(instanceID))
{
continue;
}
hashSet.Add(instanceID);
MeshFilter componentInChildren = ((Component)componentInParent).GetComponentInChildren<MeshFilter>();
if ((Object)(object)componentInChildren == (Object)null)
{
continue;
}
Mesh sharedMesh = componentInChildren.sharedMesh;
if ((Object)(object)sharedMesh == (Object)null || !sharedMesh.isReadable)
{
continue;
}
Vector3[] vertices = sharedMesh.vertices;
foreach (Vector3 val2 in vertices)
{
Vector3 val3 = ((Component)componentInParent).transform.TransformPoint(val2);
stringBuilder.AppendLine(string.Format(CultureInfo.InvariantCulture, "v {0} {1} {2}", 0f - val3.x, val3.y, val3.z));
}
Vector2[] uv = sharedMesh.uv;
foreach (Vector2 val4 in uv)
{
stringBuilder.AppendLine(string.Format(CultureInfo.InvariantCulture, "vt {0} {1}", val4.x, val4.y));
}
Vector3[] normals = sharedMesh.normals;
foreach (Vector3 val5 in normals)
{
Vector3 val6 = ((Component)componentInParent).transform.TransformDirection(val5);
stringBuilder.AppendLine(string.Format(CultureInfo.InvariantCulture, "vn {0} {1} {2}", 0f - val6.x, val6.y, val6.z));
}
for (int m = 0; m < sharedMesh.subMeshCount; m++)
{
int[] triangles = sharedMesh.GetTriangles(m);
for (int n = 0; n < triangles.Length; n += 3)
{
int num2 = triangles[n] + num;
int num3 = triangles[n + 1] + num;
int num4 = triangles[n + 2] + num;
stringBuilder.AppendLine($"f {num4}/{num4}/{num4} {num3}/{num3}/{num3} {num2}/{num2}/{num2}");
}
}
num += sharedMesh.vertices.Length;
}
string text = Path.Combine(Paths.GameRootPath, "ValheimBaseExport.obj");
File.WriteAllText(text, stringBuilder.ToString());
Debug.Log((object)("Base exported to: " + text));
Chat.instance.SetNpcText(((Component)Player.m_localPlayer).gameObject, Vector3.up, 5f, 5f, "", "Saved to " + text, false);
}
}