Decompiled source of DrakeMayeGhostGirl v1.1.0

BepInEx/plugins/DrakeMayeGhostGirl/DrakeMayeGhostGirl.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace DrakeMayeGhostGirl;

[BepInPlugin("wes.drakemayeghostgirl", "DrakeMayeGhostGirl", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
	public const string Guid = "wes.drakemayeghostgirl";

	public const string Name = "DrakeMayeGhostGirl";

	public const string Version = "1.1.0";

	internal static ManualLogSource Log;

	internal static string PluginDir;

	internal static ConfigEntry<string> ImageFile;

	internal static ConfigEntry<float> Height;

	internal static ConfigEntry<float> FloatHeight;

	internal static ConfigEntry<bool> Glow;

	internal static ConfigEntry<bool> HideOriginalModel;

	internal static ConfigEntry<bool> ReplaceSounds;

	internal static ConfigEntry<bool> ShowUpMusic;

	internal static ConfigEntry<float> ShowUpVolume;

	internal static ConfigEntry<bool> StopMusicWhenHidden;

	internal static ConfigEntry<bool> MuteGhostGirlSounds;

	internal static ConfigEntry<string> ScanName;

	internal static Texture2D SkinTexture;

	internal static AudioClip ShowUpClip;

	internal static List<AudioClip> AppearClips = new List<AudioClip>();

	internal static AudioClip BreathingClip;

	internal static AudioClip SkipWalkClip;

	internal static AudioClip HeartbeatClip;

	private void Awake()
	{
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		PluginDir = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
		ImageFile = ((BaseUnityPlugin)this).Config.Bind<string>("Skin", "ImageFile", "drake.png", "PNG/JPG in the plugin folder to show instead of the Ghost Girl. A PNG with a transparent background looks best.");
		Height = ((BaseUnityPlugin)this).Config.Bind<float>("Skin", "Height", 0.95f, "How tall the picture is, in metres (width follows the image's shape). The default suits the head-and-shoulders photo. For a full-body picture use about 1.93 (Drake Maye is 6'4\") with FloatHeight 0.");
		FloatHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Skin", "FloatHeight", 0.8f, "How far above the floor the bottom of the picture floats, in metres. 0 = standing on the floor.");
		Glow = ((BaseUnityPlugin)this).Config.Bind<bool>("Skin", "Glow", false, "true = cutout ignores lighting and is always fully bright. false = lit like the real Ghost Girl (dark until your flashlight hits it).");
		HideOriginalModel = ((BaseUnityPlugin)this).Config.Bind<bool>("Skin", "HideOriginalModel", true, "Hide the vanilla Ghost Girl model so only the cutout is visible.");
		ShowUpMusic = ((BaseUnityPlugin)this).Config.Bind<bool>("Sounds", "ShowUpMusic", true, "Play sounds/showup.wav (or .ogg/.mp3) from the start every time he shows up.");
		ShowUpVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Sounds", "ShowUpVolume", 0.9f, "Volume of the show-up music, 0 to 1.");
		StopMusicWhenHidden = ((BaseUnityPlugin)this).Config.Bind<bool>("Sounds", "StopMusicWhenHidden", true, "true = the music fades out when he disappears. false = it always plays to the end.");
		MuteGhostGirlSounds = ((BaseUnityPlugin)this).Config.Bind<bool>("Sounds", "MuteGhostGirlSounds", true, "Silence all of the Ghost Girl's normal sounds (giggles, breathing, skipping, heartbeat).");
		ReplaceSounds = ((BaseUnityPlugin)this).Config.Bind<bool>("Sounds", "ReplaceSounds", true, "Only used when MuteGhostGirlSounds is false: swap her individual sounds for files in the 'sounds' folder (appear*.ogg/.wav, breathing, skipwalk, heartbeat).");
		ScanName = ((BaseUnityPlugin)this).Config.Bind<string>("Skin", "ScanName", "Drake Maye", "Name shown if the Ghost Girl is scanned. Leave empty to keep the vanilla name.");
		SkinTexture = LoadTexture(Path.Combine(PluginDir, ImageFile.Value));
		LoadSounds(Path.Combine(PluginDir, "sounds"));
		new Harmony("wes.drakemayeghostgirl").PatchAll(Assembly.GetExecutingAssembly());
		Log.LogInfo((object)("DrakeMayeGhostGirl 1.1.0 loaded. Image: " + (((Object)(object)SkinTexture != (Object)null) ? "OK" : "MISSING")));
	}

	private static Texture2D LoadTexture(string path)
	{
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Expected O, but got Unknown
		if (!File.Exists(path))
		{
			Log.LogWarning((object)("No image at " + path + " - the Ghost Girl will keep her normal look. Put a PNG there named " + Path.GetFileName(path) + "."));
			return null;
		}
		try
		{
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true);
			if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path)))
			{
				Log.LogError((object)("Could not decode image " + path + " (use PNG or JPG)."));
				return null;
			}
			((Object)val).name = "DrakeMayeSkin";
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)1;
			((Texture)val).anisoLevel = 4;
			val.Apply(true, false);
			return val;
		}
		catch (Exception ex)
		{
			Log.LogError((object)("Failed loading image: " + ex));
			return null;
		}
	}

	private static void LoadSounds(string dir)
	{
		if (!Directory.Exists(dir))
		{
			return;
		}
		string[] files = Directory.GetFiles(dir);
		foreach (string path in files)
		{
			string text = Path.GetFileNameWithoutExtension(path).ToLowerInvariant();
			AudioClip val = null;
			if (!(text == "showup") && !text.StartsWith("appear"))
			{
				switch (text)
				{
				case "breathing":
				case "skipwalk":
				case "heartbeat":
					break;
				default:
					goto IL_0073;
				}
			}
			val = LoadAudio(path);
			goto IL_0073;
			IL_0073:
			if (!((Object)(object)val == (Object)null))
			{
				if (text == "showup")
				{
					ShowUpClip = val;
				}
				else if (text.StartsWith("appear"))
				{
					AppearClips.Add(val);
				}
				else
				{
					switch (text)
					{
					case "breathing":
						BreathingClip = val;
						break;
					case "skipwalk":
						SkipWalkClip = val;
						break;
					case "heartbeat":
						HeartbeatClip = val;
						break;
					}
				}
				Log.LogInfo((object)("Loaded sound " + Path.GetFileName(path) + " (" + val.length.ToString("F1") + "s)"));
			}
		}
	}

	private static AudioClip LoadAudio(string path)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Invalid comparison between Unknown and I4
		AudioType val;
		switch (Path.GetExtension(path).ToLowerInvariant())
		{
		case ".ogg":
			val = (AudioType)14;
			break;
		case ".wav":
			val = (AudioType)20;
			break;
		case ".mp3":
			val = (AudioType)13;
			break;
		default:
			return null;
		}
		try
		{
			UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(new Uri(path).AbsoluteUri, val);
			try
			{
				UnityWebRequestAsyncOperation val2 = audioClip.SendWebRequest();
				DateTime dateTime = DateTime.UtcNow.AddSeconds(10.0);
				while (!((AsyncOperation)val2).isDone && DateTime.UtcNow < dateTime)
				{
				}
				if ((int)audioClip.result != 1)
				{
					Log.LogError((object)("Could not load sound " + path + ": " + audioClip.error));
					return null;
				}
				AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip);
				((Object)content).name = Path.GetFileNameWithoutExtension(path);
				return content;
			}
			finally
			{
				((IDisposable)audioClip)?.Dispose();
			}
		}
		catch (Exception ex)
		{
			Log.LogError((object)("Failed loading sound " + path + ": " + ex.Message));
			return null;
		}
	}
}
[HarmonyPatch(typeof(DressGirlAI), "Start")]
internal static class DressGirlStartPatch
{
	[HarmonyPostfix]
	private static void Postfix(DressGirlAI __instance)
	{
		try
		{
			if ((Object)(object)Plugin.SkinTexture != (Object)null && (Object)(object)((Component)__instance).GetComponent<DrakeCutout>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<DrakeCutout>().Init(__instance);
			}
			if (Plugin.ReplaceSounds.Value && !Plugin.MuteGhostGirlSounds.Value)
			{
				SwapSounds(__instance);
			}
			if (!string.IsNullOrEmpty(Plugin.ScanName.Value))
			{
				ScanNodeProperties componentInChildren = ((Component)__instance).GetComponentInChildren<ScanNodeProperties>(true);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.headerText = Plugin.ScanName.Value;
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogError((object)("Reskin failed: " + ex));
		}
	}

	private static void SwapSounds(DressGirlAI girl)
	{
		if (Plugin.AppearClips.Count > 0)
		{
			girl.appearStaringSFX = Plugin.AppearClips.ToArray();
		}
		if ((Object)(object)Plugin.BreathingClip != (Object)null)
		{
			girl.breathingSFX = Plugin.BreathingClip;
		}
		if ((Object)(object)Plugin.SkipWalkClip != (Object)null)
		{
			girl.skipWalkSFX = Plugin.SkipWalkClip;
		}
		if ((Object)(object)Plugin.HeartbeatClip != (Object)null && (Object)(object)girl.heartbeatMusic != (Object)null)
		{
			girl.heartbeatMusic.clip = Plugin.HeartbeatClip;
		}
	}
}
internal class DrakeCutout : MonoBehaviour
{
	private const float FadeSeconds = 0.75f;

	private Renderer[] originals = (Renderer[])(object)new Renderer[0];

	private Renderer reference;

	private GameObject quad;

	private MeshRenderer quadRenderer;

	private AudioSource music;

	private AudioSource[] girlSources = (AudioSource[])(object)new AudioSource[0];

	private bool wasShowing;

	private int appliedMute = -1;

	private float appliedHeight = -1f;

	private float appliedFloat = -1f;

	private int appliedGlow = -1;

	private int appliedHide = -1;

	public bool CutoutShowing
	{
		get
		{
			if ((Object)(object)quadRenderer != (Object)null && ((Renderer)quadRenderer).enabled)
			{
				return quad.layer != 23;
			}
			return false;
		}
	}

	public int CutoutLayer
	{
		get
		{
			if (!((Object)(object)quad != (Object)null))
			{
				return -1;
			}
			return quad.layer;
		}
	}

	public int OriginalLayer
	{
		get
		{
			if (!((Object)(object)reference != (Object)null))
			{
				return -1;
			}
			return ((Component)reference).gameObject.layer;
		}
	}

	public bool OriginalShowing
	{
		get
		{
			if ((Object)(object)reference != (Object)null && reference.enabled && ((Component)reference).gameObject.activeInHierarchy)
			{
				return ((Component)reference).gameObject.layer != 23;
			}
			return false;
		}
	}

	public string MusicState
	{
		get
		{
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			AudioSource[] array = girlSources;
			foreach (AudioSource val in array)
			{
				if ((Object)(object)val != (Object)null && val.mute)
				{
					num++;
				}
			}
			string text = (((Object)(object)music == (Object)null) ? "music=none" : ("musicPlaying=" + music.isPlaying + " musicTime=" + music.time.ToString("F1") + "s/" + music.clip.length.ToString("F1") + "s musicVolume=" + music.volume.ToString("F2") + " mixer=" + (((Object)(object)music.outputAudioMixerGroup != (Object)null) ? ((Object)music.outputAudioMixerGroup).name : "none") + " loadState=" + music.clip.loadState));
			return text + " herSoundsMuted=" + num + "/" + girlSources.Length;
		}
	}

	public void Init(DressGirlAI girl)
	{
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Expected O, but got Unknown
		List<Renderer> list = new List<Renderer>();
		if (((EnemyAI)girl).skinnedMeshRenderers != null)
		{
			SkinnedMeshRenderer[] skinnedMeshRenderers = ((EnemyAI)girl).skinnedMeshRenderers;
			foreach (SkinnedMeshRenderer val in skinnedMeshRenderers)
			{
				if ((Object)(object)val != (Object)null)
				{
					list.Add((Renderer)(object)val);
				}
			}
		}
		if (((EnemyAI)girl).meshRenderers != null)
		{
			MeshRenderer[] meshRenderers = ((EnemyAI)girl).meshRenderers;
			foreach (MeshRenderer val2 in meshRenderers)
			{
				if ((Object)(object)val2 != (Object)null)
				{
					list.Add((Renderer)(object)val2);
				}
			}
		}
		if (list.Count == 0)
		{
			list.AddRange((IEnumerable<Renderer>)(object)((Component)girl).GetComponentsInChildren<SkinnedMeshRenderer>(true));
		}
		originals = list.ToArray();
		Renderer[] array = originals;
		foreach (Renderer val3 in array)
		{
			if (!((Component)val3).CompareTag("DoNotSet"))
			{
				reference = val3;
				break;
			}
		}
		if ((Object)(object)reference == (Object)null && originals.Length > 0)
		{
			reference = originals[0];
		}
		quad = GameObject.CreatePrimitive((PrimitiveType)5);
		((Object)quad).name = "DrakeMayeCutout";
		Collider component = quad.GetComponent<Collider>();
		if ((Object)(object)component != (Object)null)
		{
			Object.Destroy((Object)(object)component);
		}
		quad.transform.SetParent(((Component)girl).transform, false);
		quadRenderer = quad.GetComponent<MeshRenderer>();
		((Renderer)quadRenderer).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)quadRenderer).receiveShadows = false;
		List<AudioSource> list2 = new List<AudioSource>(((Component)girl).GetComponentsInChildren<AudioSource>(true));
		AudioSource[] array2 = (AudioSource[])(object)new AudioSource[3]
		{
			((EnemyAI)girl).creatureVoice,
			((EnemyAI)girl).creatureSFX,
			girl.heartbeatMusic
		};
		foreach (AudioSource val4 in array2)
		{
			if ((Object)(object)val4 != (Object)null && !list2.Contains(val4))
			{
				list2.Add(val4);
			}
		}
		girlSources = list2.ToArray();
		if ((Object)(object)Plugin.ShowUpClip != (Object)null)
		{
			GameObject val5 = new GameObject("DrakeMayeShowUpMusic");
			val5.transform.SetParent(((Component)girl).transform, false);
			music = val5.AddComponent<AudioSource>();
			music.clip = Plugin.ShowUpClip;
			music.playOnAwake = false;
			music.loop = false;
			music.spatialBlend = 0f;
			music.volume = 0f;
			if ((Object)(object)((EnemyAI)girl).creatureVoice != (Object)null)
			{
				music.outputAudioMixerGroup = ((EnemyAI)girl).creatureVoice.outputAudioMixerGroup;
			}
		}
		ApplySettings();
		Sync();
		Plugin.Log.LogInfo((object)("Ghost Girl reskinned (" + originals.Length + " original renderers hidden). Shader: " + ((Object)((Renderer)quadRenderer).sharedMaterial.shader).name + ". Show-up music: " + (((Object)(object)music != (Object)null) ? ((Object)music.clip).name : "none") + ". Her sound sources: " + girlSources.Length));
	}

	private void UpdateAudio()
	{
		int num = (Plugin.MuteGhostGirlSounds.Value ? 1 : 0);
		if (num == 1)
		{
			AudioSource[] array = girlSources;
			foreach (AudioSource val in array)
			{
				if ((Object)(object)val != (Object)null && !val.mute)
				{
					val.mute = true;
				}
			}
		}
		else if (appliedMute == 1)
		{
			AudioSource[] array2 = girlSources;
			foreach (AudioSource val2 in array2)
			{
				if ((Object)(object)val2 != (Object)null)
				{
					val2.mute = false;
				}
			}
		}
		appliedMute = num;
		if ((Object)(object)music == (Object)null)
		{
			return;
		}
		bool cutoutShowing = CutoutShowing;
		float num2 = Mathf.Clamp01(Plugin.ShowUpVolume.Value);
		if (!Plugin.ShowUpMusic.Value)
		{
			if (music.isPlaying)
			{
				music.Stop();
			}
		}
		else if (cutoutShowing)
		{
			if (!wasShowing && !music.isPlaying)
			{
				music.time = 0f;
				music.Play();
			}
			music.volume = num2;
		}
		else if (music.isPlaying && Plugin.StopMusicWhenHidden.Value)
		{
			music.volume = Mathf.MoveTowards(music.volume, 0f, num2 * Time.deltaTime / 0.75f);
			if (music.volume <= 0.001f)
			{
				music.Stop();
			}
		}
		wasShowing = cutoutShowing;
	}

	private void ApplySettings()
	{
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Max(0.2f, Plugin.Height.Value);
		float value = Plugin.FloatHeight.Value;
		if (num != appliedHeight || value != appliedFloat)
		{
			Texture2D skinTexture = Plugin.SkinTexture;
			quad.transform.localPosition = new Vector3(0f, value + num * 0.5f, 0f);
			quad.transform.localScale = new Vector3(num * (float)((Texture)skinTexture).width / (float)((Texture)skinTexture).height, num, 1f);
			appliedHeight = num;
			appliedFloat = value;
		}
		int num2 = (Plugin.Glow.Value ? 1 : 0);
		if (num2 != appliedGlow)
		{
			((Renderer)quadRenderer).sharedMaterial = CutoutMaterial.Get(Plugin.SkinTexture, reference, num2 == 1);
			appliedGlow = num2;
		}
		int num3 = (Plugin.HideOriginalModel.Value ? 1 : 0);
		if (num3 == appliedHide)
		{
			return;
		}
		Renderer[] array = originals;
		foreach (Renderer val in array)
		{
			if ((Object)(object)val != (Object)null)
			{
				val.forceRenderingOff = num3 == 1;
			}
		}
		appliedHide = num3;
	}

	private void LateUpdate()
	{
		//IL_0076: 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_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)quad == (Object)null)
		{
			return;
		}
		ApplySettings();
		Sync();
		UpdateAudio();
		Camera val = null;
		if ((Object)(object)GameNetworkManager.Instance != (Object)null && (Object)(object)GameNetworkManager.Instance.localPlayerController != (Object)null)
		{
			val = GameNetworkManager.Instance.localPlayerController.gameplayCamera;
		}
		if ((Object)(object)val == (Object)null)
		{
			val = Camera.main;
		}
		if (!((Object)(object)val == (Object)null))
		{
			Vector3 val2 = quad.transform.position - ((Component)val).transform.position;
			val2.y = 0f;
			if (((Vector3)(ref val2)).sqrMagnitude > 0.0001f)
			{
				quad.transform.rotation = Quaternion.LookRotation(val2, Vector3.up);
			}
		}
	}

	private void Sync()
	{
		if ((Object)(object)reference == (Object)null)
		{
			((Renderer)quadRenderer).enabled = true;
			return;
		}
		quad.layer = ((Component)reference).gameObject.layer;
		((Renderer)quadRenderer).enabled = reference.enabled && ((Component)reference).gameObject.activeInHierarchy;
	}

	private void OnDestroy()
	{
		if ((Object)(object)quad != (Object)null)
		{
			Object.Destroy((Object)(object)quad);
		}
	}
}
internal static class CutoutMaterial
{
	private static Material cachedLit;

	private static Material cachedGlow;

	public static Material Get(Texture2D tex, Renderer reference, bool glow)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Expected O, but got Unknown
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Expected O, but got Unknown
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		Material val = (glow ? cachedGlow : cachedLit);
		if ((Object)(object)val != (Object)null)
		{
			return val;
		}
		bool flag = glow;
		Shader val2 = Shader.Find(glow ? "HDRP/Unlit" : "HDRP/Lit");
		Material val3;
		if ((Object)(object)val2 != (Object)null)
		{
			val3 = new Material(val2);
		}
		else if ((Object)(object)reference != (Object)null && (Object)(object)reference.sharedMaterial != (Object)null)
		{
			Plugin.Log.LogWarning((object)"HDRP shader not found; reusing the Ghost Girl's material.");
			val3 = new Material(reference.sharedMaterial);
			glow = false;
		}
		else
		{
			val3 = new Material(Shader.Find("Standard"));
		}
		((Object)val3).name = "DrakeMayeCutoutMat";
		if (glow)
		{
			SetTex(val3, "_UnlitColorMap", (Texture)(object)tex);
			SetColor(val3, "_UnlitColor", Color.white);
		}
		else
		{
			SetTex(val3, "_BaseColorMap", (Texture)(object)tex);
			SetColor(val3, "_BaseColor", Color.white);
			SetFloat(val3, "_Smoothness", 0.1f);
			SetFloat(val3, "_Metallic", 0f);
		}
		SetTex(val3, "_MainTex", (Texture)(object)tex);
		SetFloat(val3, "_AlphaCutoffEnable", 1f);
		SetFloat(val3, "_AlphaCutoff", 0.5f);
		SetFloat(val3, "_UseShadowThreshold", 0f);
		val3.EnableKeyword("_ALPHATEST_ON");
		SetFloat(val3, "_DoubleSidedEnable", 1f);
		SetFloat(val3, "_CullMode", 0f);
		SetFloat(val3, "_CullModeForward", 0f);
		val3.EnableKeyword("_DOUBLESIDED_ON");
		ValidateHdrp(val3);
		if (flag)
		{
			cachedGlow = val3;
		}
		else
		{
			cachedLit = val3;
		}
		return val3;
	}

	private static void ValidateHdrp(Material mat)
	{
		try
		{
			Type type = Type.GetType("UnityEngine.Rendering.HighDefinition.HDMaterial, Unity.RenderPipelines.HighDefinition.Runtime");
			if (!(type == null))
			{
				MethodInfo method = type.GetMethod("ValidateMaterial", BindingFlags.Static | BindingFlags.Public, null, new Type[1] { typeof(Material) }, null);
				if (method != null)
				{
					method.Invoke(null, new object[1] { mat });
				}
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("HDMaterial.ValidateMaterial failed: " + ex.Message));
		}
	}

	private static void SetTex(Material m, string p, Texture t)
	{
		if (m.HasProperty(p))
		{
			m.SetTexture(p, t);
		}
	}

	private static void SetColor(Material m, string p, Color c)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		if (m.HasProperty(p))
		{
			m.SetColor(p, c);
		}
	}

	private static void SetFloat(Material m, string p, float v)
	{
		if (m.HasProperty(p))
		{
			m.SetFloat(p, v);
		}
	}
}