using System;
using System.Collections;
using System.Diagnostics;
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? RedMesh;
private static Material[]? RedMaterials;
private static Mesh? BlueMesh;
private static Material[]? BlueMaterials;
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.12f);
public static Vector3 Rot = new Vector3(1f, 16f, 87f);
public static float Scale = 350.8f;
public static float BlueScale = 17.9f;
public static Vector3 BlueHeldPos = new Vector3(0.23f, -0.05f, 0.03f);
public static Vector3 RedHeldPos = new Vector3(-0.23f, -0.05f, 0.03f);
public static Vector3 HeldRot = new Vector3(14f, 58f, 120f);
public static float HeldScale = 250.7f;
public static float BlueHeldScale = 12.85f;
private void Awake()
{
((MonoBehaviour)this).StartCoroutine(LoadBundle("https://raw.githubusercontent.com/robotboy89/FileHoster/refs/heads/main/linguini.unity3d", "Linguini", isRed: true));
((MonoBehaviour)this).StartCoroutine(LoadBundle("https://github.com/robotboy89/FileHoster/raw/refs/heads/main/mikulasgunini.unity3d", "mikulasguini", isRed: false));
}
private void Update()
{
if ((Object)(object)RedMesh == (Object)null && (Object)(object)BlueMesh == (Object)null)
{
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_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: 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_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: 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_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
bool flag = ((Object)skull).name.ToLower().Contains("red");
Mesh val = (flag ? RedMesh : BlueMesh);
Material[] array = (flag ? RedMaterials : BlueMaterials);
if ((Object)(object)val == (Object)null)
{
return;
}
Transform[] componentsInChildren = ((Component)skull).GetComponentsInChildren<Transform>(true);
Transform val2 = null;
Transform[] array2 = componentsInChildren;
foreach (Transform val3 in array2)
{
if (((Object)val3).name == "NewSkull")
{
val2 = val3;
break;
}
}
if ((Object)(object)val2 == (Object)null)
{
return;
}
MeshFilter component = ((Component)val2).GetComponent<MeshFilter>();
MeshRenderer component2 = ((Component)val2).GetComponent<MeshRenderer>();
if ((Object)(object)component == (Object)null || (Object)(object)component2 == (Object)null)
{
return;
}
if ((Object)(object)component.sharedMesh != (Object)(object)val)
{
component.sharedMesh = val;
if (array != null)
{
((Renderer)component2).sharedMaterials = array;
}
}
if (Object.op_Implicit((Object)(object)((Component)skull).transform.root) && ((Object)((Component)skull).transform.root).name == "Player")
{
val2.localPosition = (flag ? RedHeldPos : BlueHeldPos);
val2.localRotation = Quaternion.Euler(HeldRot);
if (flag)
{
val2.localScale = Vector3.one * HeldScale;
}
else
{
val2.localScale = Vector3.one * BlueHeldScale;
}
return;
}
Vector3 localPosition = (flag ? RED_POS : BLUE_POS);
val2.localPosition = localPosition;
val2.localRotation = Quaternion.Euler(Rot);
if (flag)
{
val2.localScale = Vector3.one * Scale;
}
else
{
val2.localScale = Vector3.one * BlueScale;
}
}
private IEnumerator LoadBundle(string bundleUrl, string prefabName, bool isRed)
{
UnityWebRequest req = UnityWebRequestAssetBundle.GetAssetBundle(bundleUrl);
yield return req.SendWebRequest();
if ((int)req.result != 1)
{
Debug.LogError((object)("[linguiniskulls] failed to download bundle: " + req.error + ", github is either down or your offline sorry cant do anything about that"));
yield break;
}
AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(req);
if ((Object)(object)bundle == (Object)null)
{
Debug.LogError((object)"[linguiniskulls] bundle was invalid (idk man my bad ill fix it soon)");
yield break;
}
AssetBundleRequest loadReq = bundle.LoadAssetAsync<GameObject>(prefabName);
yield return loadReq;
Object asset = loadReq.asset;
GameObject prefab = (GameObject)(object)((asset is GameObject) ? asset : null);
if ((Object)(object)prefab == (Object)null)
{
Debug.LogError((object)("[linguiniskulls] the prefab '" + prefabName + "'s contents were not found: " + string.Join(", ", bundle.GetAllAssetNames())));
bundle.Unload(true);
yield break;
}
MeshFilter mf = prefab.GetComponentInChildren<MeshFilter>();
MeshRenderer mr = prefab.GetComponentInChildren<MeshRenderer>();
Material[] mats = (Material[])(object)new Material[1] { ((Renderer)mr).sharedMaterial };
if (isRed)
{
RedMesh = mf.sharedMesh;
RedMaterials = mats;
}
else
{
BlueMesh = mf.sharedMesh;
BlueMaterials = mats;
}
bundle.Unload(false);
}
}