using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
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 = "")]
[assembly: AssemblyCompany("EasyCustomPlayerSkin")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("custom textures for your player")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+58b4bee8ae273aeeaa0c859f3a09fc10a6e6075b")]
[assembly: AssemblyProduct("EasyCustomPlayerSkin")]
[assembly: AssemblyTitle("EasyCustomPlayerSkin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 EasyPackageVariety
{
[BepInPlugin("EasyCustomPlayerSkin", "EasyCustomPlayerSkin", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch]
public class sCosmeticAppearancePatch : HarmonyPatch
{
private static MethodInfo TargetMethod()
{
return typeof(sCosmeticAppearance).GetMethod("SetAppearance", BindingFlags.Instance | BindingFlags.Public);
}
private static void Postfix(sCosmeticAppearance __instance)
{
if (!hasTexture)
{
return;
}
((Texture)playerTexture).filterMode = (FilterMode)0;
Transform val = ((Component)__instance).transform.Find("head");
if ((Object)(object)val == (Object)null)
{
return;
}
Transform val2 = ((Component)val).transform.Find("head");
if ((Object)(object)val2 == (Object)null)
{
return;
}
MeshRenderer component = ((Component)val2).GetComponent<MeshRenderer>();
if ((Object)(object)component == (Object)null)
{
return;
}
Material[] sharedMaterials = ((Renderer)component).sharedMaterials;
foreach (Material val3 in sharedMaterials)
{
val3.SetTexture("_BaseMap", (Texture)(object)playerTexture);
val3.SetTexture("_MainTex", (Texture)(object)playerTexture);
}
Transform val4 = ((Component)__instance).transform.Find("cylinder");
if ((Object)(object)val4 == (Object)null)
{
return;
}
MeshRenderer component2 = ((Component)val4).GetComponent<MeshRenderer>();
if (!((Object)(object)component2 == (Object)null))
{
Material[] sharedMaterials2 = ((Renderer)component2).sharedMaterials;
foreach (Material val5 in sharedMaterials2)
{
val5.SetTexture("_BaseMap", (Texture)(object)playerTexture);
val5.SetTexture("_MainTex", (Texture)(object)playerTexture);
}
}
}
}
internal static ManualLogSource Log;
private static string texturePath = Application.streamingAssetsPath + "/CustomPlayer/player.png";
private static Texture2D playerTexture;
private static bool hasTexture = false;
private void Awake()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin EasyCustomPlayerSkin is loaded!");
Harmony val = new Harmony("EasyCustomPlayerSkin");
val.PatchAll();
((MonoBehaviour)this).StartCoroutine(GetTexture());
}
private static IEnumerator GetTexture()
{
if (File.Exists(texturePath))
{
UnityWebRequest uwr = UnityWebRequestTexture.GetTexture("file://" + texturePath);
try
{
yield return uwr.SendWebRequest();
if ((int)uwr.result != 1)
{
Log.LogError((object)uwr.error);
yield break;
}
Texture2D texture = DownloadHandlerTexture.GetContent(uwr);
playerTexture = texture;
Log.LogInfo((object)"custom player texture loaded from file :3");
hasTexture = true;
}
finally
{
((IDisposable)uwr)?.Dispose();
}
}
else
{
Log.LogError((object)"no custom player texture at expected path");
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "EasyCustomPlayerSkin";
public const string PLUGIN_NAME = "EasyCustomPlayerSkin";
public const string PLUGIN_VERSION = "1.0.0";
}
}