Decompiled source of TexturePainterAPI v1.0.2

plugins/TexturePainterAPI.dll

Decompiled 8 months ago
using System;
using System.CodeDom.Compiler;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using GTFO.API;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("TexturePainterAPI")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+gitedbf070-dirty-master")]
[assembly: AssemblyProduct("TexturePainterAPI")]
[assembly: AssemblyTitle("TexturePainterAPI")]
[assembly: TargetPlatform("Windows7.0")]
[assembly: SupportedOSPlatform("Windows7.0")]
[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 TexturePainterAPI
{
	internal static class Assets
	{
		public static Material Tint3MaskMat;

		public static Material Tint3MaskCompMat;

		public static void Init()
		{
			Tint3MaskMat = AssetAPI.GetLoadedAsset<Material>("Assets/Modding/TexturePainter/3MaskTintMat.mat");
			Tint3MaskCompMat = AssetAPI.GetLoadedAsset<Material>("Assets/Modding/TexturePainter/3MaskTintCompressedMat.mat");
		}
	}
	[BepInPlugin("TexturePainterAPI", "TexturePainterAPI", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class EntryPoint : BasePlugin
	{
		public override void Load()
		{
			AssetAPI.OnAssetBundlesLoaded += AssetAPI_OnAssetBundlesLoaded;
		}

		private void AssetAPI_OnAssetBundlesLoaded()
		{
			Assets.Init();
		}
	}
	internal static class Logger
	{
		private static readonly ManualLogSource _Logger;

		static Logger()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			_Logger = new ManualLogSource("TexturePainterAPI");
			Logger.Sources.Add((ILogSource)(object)_Logger);
		}

		private static string Format(object msg)
		{
			return msg.ToString();
		}

		public static void Info(BepInExInfoLogInterpolatedStringHandler handler)
		{
			_Logger.LogInfo(handler);
		}

		public static void Info(string str)
		{
			_Logger.LogMessage((object)str);
		}

		public static void Info(object data)
		{
			_Logger.LogMessage((object)Format(data));
		}

		public static void Debug(BepInExDebugLogInterpolatedStringHandler handler)
		{
			_Logger.LogDebug(handler);
		}

		public static void Debug(string str)
		{
			_Logger.LogDebug((object)str);
		}

		public static void Debug(object data)
		{
			_Logger.LogDebug((object)Format(data));
		}

		public static void Error(BepInExErrorLogInterpolatedStringHandler handler)
		{
			_Logger.LogError(handler);
		}

		public static void Error(string str)
		{
			_Logger.LogError((object)str);
		}

		public static void Error(object data)
		{
			_Logger.LogError((object)Format(data));
		}

		public static void Fatal(BepInExFatalLogInterpolatedStringHandler handler)
		{
			_Logger.LogFatal(handler);
		}

		public static void Fatal(string str)
		{
			_Logger.LogFatal((object)str);
		}

		public static void Fatal(object data)
		{
			_Logger.LogFatal((object)Format(data));
		}

		public static void Warn(BepInExWarningLogInterpolatedStringHandler handler)
		{
			_Logger.LogWarning(handler);
		}

		public static void Warn(string str)
		{
			_Logger.LogWarning((object)str);
		}

		public static void Warn(object data)
		{
			_Logger.LogWarning((object)Format(data));
		}

		[Conditional("DEBUG")]
		public static void DebugOnly(object data)
		{
		}
	}
	internal static class P
	{
		public static readonly int MaskTex = Shader.PropertyToID("_MaskTex");

		public static readonly int MaskTexA = Shader.PropertyToID("_MaskTexA");

		public static readonly int MaskTexB = Shader.PropertyToID("_MaskTexB");

		public static readonly int MaskTexC = Shader.PropertyToID("_MaskTexC");

		public static readonly int MaskColA = Shader.PropertyToID("_MaskColA");

		public static readonly int MaskColB = Shader.PropertyToID("_MaskColB");

		public static readonly int MaskColC = Shader.PropertyToID("_MaskColC");
	}
	[GeneratedCode("VersionInfoGenerator", "2.1.3+git35c0c2a-master")]
	[CompilerGenerated]
	internal static class VersionInfo
	{
		public const string RootNamespace = "TexturePainterAPI";

		public const string Version = "1.0.0";

		public const string VersionPrerelease = null;

		public const string VersionMetadata = "gitedbf070-dirty-master";

		public const string SemVer = "1.0.0+gitedbf070-dirty-master";

		public const string GitRevShort = "edbf070-dirty";

		public const string GitRevLong = "edbf0705248fe3298108bf95510cfcaf1244fb48-dirty";

		public const string GitBranch = "master";

		public const string GitTag = null;

		public const int GitCommitsSinceTag = 0;

		public const bool GitIsDirty = true;
	}
}
namespace TexturePainterAPI.PaintableTextures
{
	public class PaintableChannelMaskedTexture : PaintableTexture
	{
		private Texture2D _MainTexture;

		private Texture2D _MaskTexture;

		private Color _TintA;

		private Color _TintB;

		private Color _TintC;

		private RenderTexture _ResultTexture;

		private bool _IsReady;

		public override Texture CurrentTexture => (Texture)(object)_ResultTexture;

		public PaintableChannelMaskedTexture(Texture2D mainTexture)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			SetMainTexture(mainTexture);
			SetMaskTexture(Texture2D.whiteTexture);
			SetTintColor(Color.clear);
			_IsReady = true;
			UpdateTexture();
		}

		public void SetMainTexture(Texture2D mainTexture)
		{
			//IL_003a: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			_MainTexture = mainTexture;
			if ((Object)(object)_ResultTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_ResultTexture);
			}
			_ResultTexture = new RenderTexture(((Texture)_MainTexture).width, ((Texture)_MainTexture).height, 1, (RenderTextureFormat)0, (RenderTextureReadWrite)2)
			{
				name = "PaintableMaskedTexture",
				enableRandomWrite = true,
				hideFlags = (HideFlags)61
			};
			_ResultTexture.Create();
		}

		public void SetMaskTexture(Texture2D mask)
		{
			_MaskTexture = mask;
			UpdateTexture();
		}

		public void SetTintColor(Color color1)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			SetTintColor(color1, Color.clear, Color.clear);
		}

		public void SetTintColor(Color color1, Color color2)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			SetTintColor(color1, color2, Color.clear);
		}

		public void SetTintColor(Color color1, Color color2, Color color3)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			_TintA = color1;
			_TintB = color2;
			_TintC = color3;
			UpdateTexture();
		}

		private void UpdateTexture()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (_IsReady)
			{
				Material tint3MaskCompMat = Assets.Tint3MaskCompMat;
				tint3MaskCompMat.SetTexture(P.MaskTex, (Texture)(object)_MaskTexture);
				tint3MaskCompMat.SetColor(P.MaskColA, _TintA);
				tint3MaskCompMat.SetColor(P.MaskColB, _TintB);
				tint3MaskCompMat.SetColor(P.MaskColC, _TintC);
				Graphics.Blit((Texture)(object)_MainTexture, _ResultTexture, tint3MaskCompMat);
			}
		}

		public override Texture CreateCopy()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			Texture2D val = new Texture2D(((Texture)_MainTexture).width, ((Texture)_MainTexture).height, (TextureFormat)5, true, false);
			Graphics.CopyTexture((Texture)(object)_ResultTexture, (Texture)(object)val);
			val.Apply();
			((Object)val).hideFlags = (HideFlags)61;
			return (Texture)(object)val;
		}

		public override void Destroy()
		{
			if ((Object)(object)_ResultTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_ResultTexture);
			}
		}
	}
	public class PaintableMaskedTexture : PaintableTexture
	{
		private Texture2D _MainTexture;

		private Texture2D _MaskA;

		private Texture2D _MaskB;

		private Texture2D _MaskC;

		private Color _TintA;

		private Color _TintB;

		private Color _TintC;

		private RenderTexture _ResultTexture;

		private bool _IsReady;

		public override Texture CurrentTexture => (Texture)(object)_ResultTexture;

		public PaintableMaskedTexture(Texture2D mainTexture)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			SetMainTexture(mainTexture);
			SetMaskTexture(Texture2D.whiteTexture);
			SetTintColor(Color.clear);
			_IsReady = true;
			UpdateTexture();
		}

		public void SetMainTexture(Texture2D mainTexture)
		{
			//IL_003a: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			_MainTexture = mainTexture;
			if ((Object)(object)_ResultTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_ResultTexture);
			}
			_ResultTexture = new RenderTexture(((Texture)_MainTexture).width, ((Texture)_MainTexture).height, 1, (RenderTextureFormat)0, (RenderTextureReadWrite)2)
			{
				name = "PaintableMaskedTexture",
				enableRandomWrite = true,
				hideFlags = (HideFlags)61
			};
			_ResultTexture.Create();
		}

		public void SetMaskTexture(Texture2D mask1)
		{
			SetMaskTexture(mask1, Texture2D.whiteTexture, Texture2D.whiteTexture);
		}

		public void SetMaskTexture(Texture2D mask1, Texture2D mask2)
		{
			SetMaskTexture(mask1, mask2, Texture2D.whiteTexture);
		}

		public void SetMaskTexture(Texture2D mask1, Texture2D mask2, Texture2D mask3)
		{
			_MaskA = mask1;
			_MaskB = mask2;
			_MaskC = mask3;
			UpdateTexture();
		}

		public void SetTintColor(Color color1)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			SetTintColor(color1, Color.clear, Color.clear);
		}

		public void SetTintColor(Color color1, Color color2)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			SetTintColor(color1, color2, Color.clear);
		}

		public void SetTintColor(Color color1, Color color2, Color color3)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			_TintA = color1;
			_TintB = color2;
			_TintC = color3;
			UpdateTexture();
		}

		private void UpdateTexture()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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)
			if (_IsReady)
			{
				Material tint3MaskMat = Assets.Tint3MaskMat;
				tint3MaskMat.SetTexture(P.MaskTexA, (Texture)(object)_MaskA);
				tint3MaskMat.SetTexture(P.MaskTexB, (Texture)(object)_MaskB);
				tint3MaskMat.SetTexture(P.MaskTexC, (Texture)(object)_MaskC);
				tint3MaskMat.SetColor(P.MaskColA, _TintA);
				tint3MaskMat.SetColor(P.MaskColB, _TintB);
				tint3MaskMat.SetColor(P.MaskColC, _TintC);
				Graphics.Blit((Texture)(object)_MainTexture, _ResultTexture, tint3MaskMat);
			}
		}

		public override Texture CreateCopy()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			Texture2D val = new Texture2D(((Texture)_MainTexture).width, ((Texture)_MainTexture).height, (TextureFormat)5, true, false);
			Graphics.CopyTexture((Texture)(object)_ResultTexture, (Texture)(object)val);
			val.Apply();
			((Object)val).hideFlags = (HideFlags)61;
			return (Texture)(object)val;
		}

		public override void Destroy()
		{
			if ((Object)(object)_ResultTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_ResultTexture);
			}
		}
	}
	public abstract class PaintableTexture
	{
		public abstract Texture CurrentTexture { get; }

		public abstract Texture CreateCopy();

		public abstract void Destroy();
	}
}