Decompiled source of Crystallum v0.8.7

LavaEmissionMove.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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;
		}
	}
}
namespace TextureMove
{
	[BepInPlugin("com.tolian.lavaemissionmove", "LavaEmissionMove", "1.0.0")]
	public class LavaEmissionMove : BaseUnityPlugin
	{
	}
	[DisallowMultipleComponent]
	public class LavaEmissionScroller : MonoBehaviour
	{
		private sealed class LavaMaterial
		{
			public Material material;

			public int propertyId;
		}

		[Tooltip("Horizontal speed of the emission texture scroll (UV units per second).")]
		[SerializeField]
		private float speedX = 0.02f;

		[Tooltip("Vertical speed of the emission texture scroll (UV units per second).")]
		[SerializeField]
		private float speedY = 0.008f;

		private readonly List<LavaMaterial> materials = new List<LavaMaterial>();

		private bool initialized;

		private static readonly string[] EmissionTextureNames = new string[2] { "_EmissionMap", "_EmissiveColorMap" };

		private void Awake()
		{
			CollectMaterials();
			initialized = true;
		}

		private void CollectMaterials()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			materials.Clear();
			Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				Material[] array = val.materials;
				bool flag = false;
				for (int j = 0; j < array.Length; j++)
				{
					Material val2 = array[j];
					if (!((Object)(object)val2 == (Object)null))
					{
						int num = FindEmissionTextureId(val2);
						if (num != 0)
						{
							Material material = (array[j] = new Material(val2));
							flag = true;
							materials.Add(new LavaMaterial
							{
								material = material,
								propertyId = num
							});
						}
					}
				}
				if (flag)
				{
					val.materials = array;
				}
			}
			if (materials.Count == 0)
			{
				Debug.LogWarning((object)"LavaEmissionScroller: no emission texture found on this object. Assign an emission map to the material.");
			}
		}

		private static int FindEmissionTextureId(Material material)
		{
			string[] emissionTextureNames = EmissionTextureNames;
			for (int i = 0; i < emissionTextureNames.Length; i++)
			{
				int num = Shader.PropertyToID(emissionTextureNames[i]);
				if ((Object)(object)material.GetTexture(num) != (Object)null)
				{
					return num;
				}
			}
			return 0;
		}

		private void Update()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if (initialized && materials.Count != 0)
			{
				float deltaTime = Time.deltaTime;
				float num = speedX * deltaTime;
				float num2 = speedY * deltaTime;
				for (int i = 0; i < materials.Count; i++)
				{
					Material material = materials[i].material;
					int propertyId = materials[i].propertyId;
					Vector2 textureOffset = material.GetTextureOffset(propertyId);
					textureOffset.x = Mathf.Repeat(textureOffset.x + num, 1f);
					textureOffset.y = Mathf.Repeat(textureOffset.y + num2, 1f);
					material.SetTextureOffset(propertyId, textureOffset);
				}
			}
		}

		private void OnDestroy()
		{
			foreach (LavaMaterial material in materials)
			{
				if ((Object)(object)material.material != (Object)null)
				{
					Object.Destroy((Object)(object)material.material);
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "com.tolian.lavaemissionmove";

		public const string PLUGIN_NAME = "LavaEmissionMove";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}