using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("universal multiplayer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("universal multiplayer")]
[assembly: AssemblyTitle("universal multiplayer")]
[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.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]
[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;
}
}
[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;
}
}
}
[BepInPlugin("com.robotboy.linguiniskulls", "linguiniskulls", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
private static Mesh? LinguiniMesh;
private static Material[]? baseMaterials;
private static Material[]? redMaterials;
private static Material[]? blueMaterials;
private static bool LinguiniReady = false;
public static Color RedTint = new Color(1f, 0.55f, 0.55f);
public static Color BlueTint = new Color(0.55f, 0.75f, 1f);
public static float RedTintIntensity = 1f;
public static float BlueTintIntensity = 1f;
private static readonly Vector3 RED_POS = new Vector3(-0.19f, 0.03f, -0.2f);
private static readonly Vector3 BLUE_POS = new Vector3(-0.07f, 0.02f, -0.22f);
public static Vector3 Rot = new Vector3(1f, 16f, 87f);
public static float Scale = 2.8f;
public static Vector3 HeldPos = new Vector3(-0.23f, -0.05f, 0.03f);
public static Vector3 HeldRot = new Vector3(14f, 58f, 120f);
public static float HeldScale = 2.7f;
private void Awake()
{
((MonoBehaviour)this).StartCoroutine(DownloadLinguini());
}
private void Update()
{
if (!LinguiniReady)
{
return;
}
Skull[] array = Object.FindObjectsOfType<Skull>();
Skull[] array2 = array;
foreach (Skull val in array2)
{
if (Object.op_Implicit((Object)(object)val))
{
ApplyLinguini(val);
}
}
}
private void ApplyLinguini(Skull skull)
{
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
Transform[] componentsInChildren = ((Component)skull).GetComponentsInChildren<Transform>(true);
Transform val = null;
Transform[] array = componentsInChildren;
foreach (Transform val2 in array)
{
if (((Object)val2).name == "NewSkull")
{
val = val2;
break;
}
}
if ((Object)(object)val == (Object)null)
{
return;
}
MeshFilter component = ((Component)val).GetComponent<MeshFilter>();
MeshRenderer component2 = ((Component)val).GetComponent<MeshRenderer>();
if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
{
return;
}
if ((Object)(object)component.sharedMesh != (Object)(object)LinguiniMesh && (Object)(object)LinguiniMesh != (Object)null)
{
component.sharedMesh = LinguiniMesh;
Material[] array2 = (((Object)skull).name.ToLower().Contains("red") ? redMaterials : blueMaterials);
if (array2 != null)
{
((Renderer)component2).sharedMaterials = array2;
}
}
if (Object.op_Implicit((Object)(object)((Component)skull).transform.root) && ((Object)((Component)skull).transform.root).name == "Player")
{
val.localPosition = HeldPos;
val.localRotation = Quaternion.Euler(HeldRot);
val.localScale = Vector3.one * HeldScale;
}
else
{
Vector3 localPosition = (((Object)skull).name.ToLower().Contains("red") ? RED_POS : BLUE_POS);
val.localPosition = localPosition;
val.localRotation = Quaternion.Euler(Rot);
val.localScale = Vector3.one * Scale;
}
}
private static Material Tint(Material src, Color tint, float intensity)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: 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_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)
Material val = new Material(src);
Color val2 = Color.Lerp(Color.white, tint, Mathf.Clamp01(intensity));
if (val.HasProperty("_BaseColor"))
{
val.SetColor("_BaseColor", Color.Lerp(val.GetColor("_BaseColor"), val2, 0.95f));
}
else if (val.HasProperty("_Color"))
{
val.SetColor("_Color", Color.Lerp(val.GetColor("_Color"), val2, 0.95f));
}
return val;
}
private IEnumerator DownloadLinguini()
{
string objUrl = "https://raw.githubusercontent.com/robotboy89/FileHoster/refs/heads/main/cubes.obj";
string texUrl = "https://raw.githubusercontent.com/robotboy89/FileHoster/refs/heads/main/texture.png";
UnityWebRequest objReq = UnityWebRequest.Get(objUrl);
yield return objReq.SendWebRequest();
if ((int)objReq.result != 1)
{
Debug.LogError((object)("[linguiniskulls] Failed to download OBJ: " + objReq.error));
yield break;
}
UnityWebRequest texReq = UnityWebRequestTexture.GetTexture(texUrl);
yield return texReq.SendWebRequest();
if ((int)texReq.result != 1)
{
Debug.LogError((object)("[linguiniskulls] Failed to download texture: " + texReq.error));
yield break;
}
LinguiniMesh = OBJParser.Parse(objReq.downloadHandler.text);
Texture2D texture = DownloadHandlerTexture.GetContent(texReq);
Shader shader = Shader.Find("Universal Render Pipeline/Lit");
if (!Object.op_Implicit((Object)(object)shader))
{
shader = Shader.Find("Standard");
}
Material baseMat = new Material(shader);
baseMat.SetTexture("_MainTex", (Texture)(object)texture);
baseMat.SetTexture("_BaseMap", (Texture)(object)texture);
baseMaterials = (Material[]?)(object)new Material[1] { baseMat };
redMaterials = (Material[]?)(object)new Material[1] { Tint(baseMat, RedTint, RedTintIntensity) };
blueMaterials = (Material[]?)(object)new Material[1] { Tint(baseMat, BlueTint, BlueTintIntensity) };
LinguiniReady = true;
Debug.Log((object)"[linguiniskulls] Linguini loaded successfully!");
}
}
public static class OBJParser
{
public static Mesh Parse(string objText)
{
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Expected O, but got Unknown
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
List<Vector3> list = new List<Vector3>();
List<Vector2> list2 = new List<Vector2>();
List<Vector3> list3 = new List<Vector3>();
List<Vector3> list4 = new List<Vector3>();
List<Vector2> list5 = new List<Vector2>();
List<Vector3> list6 = new List<Vector3>();
List<int> list7 = new List<int>();
string[] array = objText.Split(new char[1] { '\n' }, StringSplitOptions.None);
for (int i = 0; i < array.Length; i++)
{
string text = array[i].Trim();
if (text.Length == 0 || text[0] == '#')
{
continue;
}
string[] array2 = text.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
if (array2.Length == 0)
{
continue;
}
string text2 = array2[0];
if (text2 == "v" && array2.Length >= 4)
{
list.Add(new Vector3(ParseFloat(array2[1]), ParseFloat(array2[2]), ParseFloat(array2[3])));
}
else if (text2 == "vt" && array2.Length >= 3)
{
list2.Add(new Vector2(ParseFloat(array2[1]), ParseFloat(array2[2])));
}
else if (text2 == "vn" && array2.Length >= 4)
{
list3.Add(new Vector3(ParseFloat(array2[1]), ParseFloat(array2[2]), ParseFloat(array2[3])));
}
else if (text2 == "f" && array2.Length >= 4)
{
int num = array2.Length - 1;
for (int j = 1; j < num - 1; j++)
{
AddFaceVert(array2[1], list, list2, list3, list4, list5, list6, list7);
AddFaceVert(array2[j + 1], list, list2, list3, list4, list5, list6, list7);
AddFaceVert(array2[j + 2], list, list2, list3, list4, list5, list6, list7);
}
}
}
Mesh val = new Mesh();
val.vertices = list4.ToArray();
val.triangles = list7.ToArray();
if (list5.Count == list4.Count)
{
val.uv = list5.ToArray();
}
if (list6.Count == list4.Count)
{
val.normals = list6.ToArray();
}
else
{
NormalSolver.RecalculateNormals(val, 60f);
}
val.RecalculateBounds();
return val;
}
private static float ParseFloat(string s)
{
return float.Parse(s, CultureInfo.InvariantCulture);
}
private static int ParseInt(string s)
{
int num = 0;
foreach (char c in s)
{
if (c < '0' || c > '9')
{
break;
}
num = num * 10 + (c - 48);
}
return num;
}
private static void AddFaceVert(string token, List<Vector3> verts, List<Vector2> uvs, List<Vector3> normals, List<Vector3> finalVerts, List<Vector2> finalUVs, List<Vector3> finalNormals, List<int> tris)
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: 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)
string[] array = token.Split(new char[1] { '/' }, StringSplitOptions.None);
int num = ParseInt(array[0]) - 1;
if (num >= 0 && num < verts.Count)
{
finalVerts.Add(verts[num]);
}
else
{
finalVerts.Add(Vector3.zero);
}
if (array.Length > 1 && array[1].Length > 0)
{
int num2 = ParseInt(array[1]) - 1;
if (num2 >= 0 && num2 < uvs.Count)
{
finalUVs.Add(uvs[num2]);
}
}
if (array.Length > 2 && array[2].Length > 0)
{
int num3 = ParseInt(array[2]) - 1;
if (num3 >= 0 && num3 < normals.Count)
{
finalNormals.Add(normals[num3]);
}
}
tris.Add(finalVerts.Count - 1);
}
}