using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.IL2CPP;
using BepInEx.IL2CPP.Utils;
using CrabDevKit.Intermediary;
using CrabDevKit.Utilities;
using Il2CppSystem;
using Microsoft.CodeAnalysis;
using SteamworksNative;
using UnhollowerBaseLib;
using UnhollowerRuntimeLib;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
[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("Antro.Graffiti")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Antro.Graffiti")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0")]
[assembly: AssemblyProduct("Antro.Graffiti")]
[assembly: AssemblyTitle("Antro.Graffiti")]
[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 Antro.Graffiti
{
[BepInPlugin("Antro.Graffiti", "Antro Graffiti Net", "1.0.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class GraffitiPlugin : BasePlugin
{
public struct GraffitiRequest
{
public Vector3 p;
public Vector3 n;
public Vector3 u;
public float s;
}
private class IncomingFile
{
public int totalSize;
public List<byte> data = new List<byte>();
}
[CompilerGenerated]
private static class <>O
{
public static MessageHandler <0>__HandleSpray;
public static MessageHandler <1>__HandleRequest;
public static MessageHandler <2>__HandleData;
}
[CompilerGenerated]
private sealed class <SendDataRoutine>d__33 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public ulong targetId;
public string hash;
public byte[] data;
private int <chunkSize>5__1;
private int <totalSent>5__2;
private int <currentChunkSize>5__3;
private ObjectPublicIDisposableLi1ByInByBoUnique <p>5__4;
private int <i>5__5;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SendDataRoutine>d__33(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<p>5__4 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<chunkSize>5__1 = 4096;
<totalSent>5__2 = 0;
break;
case 1:
<>1__state = -1;
<p>5__4 = null;
break;
}
if (<totalSent>5__2 < data.Length)
{
<currentChunkSize>5__3 = Math.Min(<chunkSize>5__1, data.Length - <totalSent>5__2);
<p>5__4 = new ObjectPublicIDisposableLi1ByInByBoUnique();
PacketExtensions.Write(<p>5__4, hash);
PacketExtensions.Write(<p>5__4, data.Length);
PacketExtensions.Write(<p>5__4, <currentChunkSize>5__3);
<i>5__5 = 0;
while (<i>5__5 < <currentChunkSize>5__3)
{
PacketExtensions.Write(<p>5__4, data[<totalSent>5__2 + <i>5__5]);
<i>5__5++;
}
CrabNet.SendMessage("Antro:G_Data", <p>5__4, (IEnumerable<ulong>)new List<ulong> { targetId });
<totalSent>5__2 += <currentChunkSize>5__3;
<>2__current = null;
<>1__state = 1;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static float _cooldownTimer = 0f;
public const float COOLDOWN_DURATION = 30f;
private static int _sortingOrderCounter = 0;
public static GraffitiPlugin Instance;
public static string GraffitiPath;
public static List<Texture2D> LocalTextures = new List<Texture2D>();
public static List<string> LocalHashes = new List<string>();
public static Dictionary<string, byte[]> LocalDataMap = new Dictionary<string, byte[]>();
public static Dictionary<string, Texture2D> RemoteTextureCache = new Dictionary<string, Texture2D>();
public static List<GameObject> SpawnedDecals = new List<GameObject>();
public static Dictionary<string, List<GraffitiRequest>> PendingSpawns = new Dictionary<string, List<GraffitiRequest>>();
public const string MSG_SPRAY = "Antro:G_Spray";
public const string MSG_REQ = "Antro:G_Req";
public const string MSG_DATA = "Antro:G_Data";
private static Dictionary<string, IncomingFile> _downloads = new Dictionary<string, IncomingFile>();
public static bool _isHoldingKey = false;
public static int _selectedIndex = 0;
public static float _currentScale = 1.5f;
public const float MIN_SCALE = 1.5f;
public const float MAX_SCALE = 7.5f;
public const float SCALE_SPEED = 1.5f;
public static GameObject _previewObj;
public static bool _hasCrabNet = false;
public override void Load()
{
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Expected O, but got Unknown
Instance = this;
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
Debug.Log(Object.op_Implicit("[AntroLog] Loading Plugin v1.0.0.0 (Fix Loader + Net)..."));
try
{
ClassInjector.RegisterTypeInIl2Cpp<GraffitiController>();
}
catch
{
}
GraffitiPath = Path.Combine(Paths.PluginPath, "AntroGraffiti");
if (!Directory.Exists(GraffitiPath))
{
Directory.CreateDirectory(GraffitiPath);
}
DeepReflector.Init();
ReloadLocalFiles();
if (((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.ContainsKey("lammas123.CrabDevKit"))
{
_hasCrabNet = true;
RegisterNetwork();
}
SceneManager.sceneLoaded += UnityAction<Scene, LoadSceneMode>.op_Implicit((Action<Scene, LoadSceneMode>)OnSceneLoaded);
GameObject val = new GameObject("AntroGraffiti_Controller");
Object.DontDestroyOnLoad((Object)(object)val);
((Object)val).hideFlags = (HideFlags)61;
val.AddComponent<GraffitiController>();
}
public static void ReloadLocalFiles()
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Expected O, but got Unknown
Debug.Log(Object.op_Implicit("[AntroLog] Reloading local files..."));
LocalTextures.Clear();
LocalHashes.Clear();
LocalDataMap.Clear();
Texture2D val = new Texture2D(64, 64);
for (int i = 0; i < 64; i++)
{
for (int j = 0; j < 64; j++)
{
val.SetPixel(j, i, ((j / 16 + i / 16) % 2 == 0) ? Color.black : Color.green);
}
}
val.Apply();
((Object)val).name = "System_Checkerboard";
((Object)val).hideFlags = (HideFlags)61;
LocalTextures.Add(val);
LocalHashes.Add("SYS_CHECKER");
if (!Directory.Exists(GraffitiPath))
{
return;
}
string[] files = Directory.GetFiles(GraffitiPath);
string[] array = files;
foreach (string path in array)
{
string text = Path.GetExtension(path).ToLowerInvariant();
if (!(text == ".png") && !(text == ".jpg") && !(text == ".jpeg"))
{
continue;
}
try
{
byte[] array2 = File.ReadAllBytes(path);
string mD = GetMD5(array2);
Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, false);
if (DeepReflector.LoadImage(val2, array2))
{
((Object)val2).name = Path.GetFileNameWithoutExtension(path);
((Object)val2).hideFlags = (HideFlags)61;
((Texture)val2).filterMode = (FilterMode)1;
((Texture)val2).wrapMode = (TextureWrapMode)1;
Object.DontDestroyOnLoad((Object)(object)val2);
LocalTextures.Add(val2);
LocalHashes.Add(mD);
LocalDataMap[mD] = array2;
Debug.Log(Object.op_Implicit($"[AntroLog] LOADED: {((Object)val2).name} ({((Texture)val2).width}x{((Texture)val2).height})"));
}
else
{
Debug.LogError(Object.op_Implicit("[AntroLog] LoadImage failed for " + Path.GetFileName(path)));
}
}
catch (Exception ex)
{
Debug.LogError(Object.op_Implicit("[AntroLog] Error " + Path.GetFileName(path) + ": " + ex.Message));
}
}
}
private static string GetMD5(byte[] data)
{
using MD5 mD = MD5.Create();
byte[] array = mD.ComputeHash(data);
return BitConverter.ToString(array).Replace("-", "").ToLowerInvariant();
}
private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
foreach (GameObject spawnedDecal in SpawnedDecals)
{
if ((Object)(object)spawnedDecal != (Object)null)
{
Object.Destroy((Object)(object)spawnedDecal);
}
}
SpawnedDecals.Clear();
PendingSpawns.Clear();
_downloads.Clear();
}
private void RegisterNetwork()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected O, but got Unknown
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
try
{
object obj = <>O.<0>__HandleSpray;
if (obj == null)
{
MessageHandler val = HandleSpray;
<>O.<0>__HandleSpray = val;
obj = (object)val;
}
CrabNet.RegisterMessageHandler("Antro:G_Spray", (MessageHandler)obj);
object obj2 = <>O.<1>__HandleRequest;
if (obj2 == null)
{
MessageHandler val2 = HandleRequest;
<>O.<1>__HandleRequest = val2;
obj2 = (object)val2;
}
CrabNet.RegisterMessageHandler("Antro:G_Req", (MessageHandler)obj2);
object obj3 = <>O.<2>__HandleData;
if (obj3 == null)
{
MessageHandler val3 = HandleData;
<>O.<2>__HandleData = val3;
obj3 = (object)val3;
}
CrabNet.RegisterMessageHandler("Antro:G_Data", (MessageHandler)obj3);
}
catch
{
}
}
public static void SendGraffiti(Vector3 pos, Vector3 normal, Vector3 upDir, float scale, int index)
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: 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_0056: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
if (index >= 0 && index < LocalTextures.Count)
{
string text = LocalHashes[index];
Texture2D tex = LocalTextures[index];
SpawnDecal(pos, normal, upDir, scale, tex);
if (_hasCrabNet)
{
ObjectPublicIDisposableLi1ByInByBoUnique val = new ObjectPublicIDisposableLi1ByInByBoUnique();
PacketExtensions.Write(val, pos);
PacketExtensions.Write(val, normal);
PacketExtensions.Write(val, upDir);
PacketExtensions.Write(val, scale);
PacketExtensions.Write(val, text);
SendToLobby("Antro:G_Spray", val);
}
}
}
private static void HandleSpray(ulong senderId, ObjectPublicIDisposableLi1ByInByBoUnique p)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Expected O, but got Unknown
if ((Object)(object)MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance != (Object)null && senderId == SteamUser.GetSteamID().m_SteamID)
{
return;
}
Vector3 val = PacketExtensions.ReadVector3(p, true);
Vector3 val2 = PacketExtensions.ReadVector3(p, true);
Vector3 val3 = PacketExtensions.ReadVector3(p, true);
float num = PacketExtensions.ReadFloat(p, true);
string text = PacketExtensions.ReadString(p, true);
Texture2D val4 = null;
int num2 = LocalHashes.IndexOf(text);
if (num2 >= 0)
{
val4 = LocalTextures[num2];
}
if ((Object)(object)val4 == (Object)null && RemoteTextureCache.ContainsKey(text))
{
val4 = RemoteTextureCache[text];
}
if ((Object)(object)val4 != (Object)null)
{
SpawnDecal(val, val2, val3, num, val4);
return;
}
if (!PendingSpawns.ContainsKey(text))
{
PendingSpawns[text] = new List<GraffitiRequest>();
}
PendingSpawns[text].Add(new GraffitiRequest
{
p = val,
n = val2,
u = val3,
s = num
});
if (!_downloads.ContainsKey(text))
{
_downloads[text] = new IncomingFile();
ObjectPublicIDisposableLi1ByInByBoUnique val5 = new ObjectPublicIDisposableLi1ByInByBoUnique();
PacketExtensions.Write(val5, text);
CrabNet.SendMessage("Antro:G_Req", val5, (IEnumerable<ulong>)new List<ulong> { senderId });
}
}
private static void HandleRequest(ulong senderId, ObjectPublicIDisposableLi1ByInByBoUnique p)
{
string text = PacketExtensions.ReadString(p, true);
if (LocalDataMap.ContainsKey(text))
{
MonoBehaviourExtensions.StartCoroutine((MonoBehaviour)(object)GraffitiController.Instance, SendDataRoutine(senderId, text, LocalDataMap[text]));
}
}
[IteratorStateMachine(typeof(<SendDataRoutine>d__33))]
public static IEnumerator SendDataRoutine(ulong targetId, string hash, byte[] data)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SendDataRoutine>d__33(0)
{
targetId = targetId,
hash = hash,
data = data
};
}
private static void HandleData(ulong senderId, ObjectPublicIDisposableLi1ByInByBoUnique p)
{
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
string text = PacketExtensions.ReadString(p, true);
int num = PacketExtensions.ReadInt(p, true);
int num2 = PacketExtensions.ReadInt(p, true);
if (!_downloads.ContainsKey(text))
{
_downloads[text] = new IncomingFile
{
totalSize = num
};
}
IncomingFile incomingFile = _downloads[text];
incomingFile.totalSize = num;
for (int i = 0; i < num2; i++)
{
incomingFile.data.Add(PacketExtensions.ReadByte(p, true));
}
if (incomingFile.data.Count < num)
{
return;
}
Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
if (DeepReflector.LoadImage(val, incomingFile.data.ToArray()))
{
((Object)val).name = "Remote_" + text.Substring(0, 6);
((Object)val).hideFlags = (HideFlags)61;
((Texture)val).filterMode = (FilterMode)1;
((Texture)val).wrapMode = (TextureWrapMode)1;
Object.DontDestroyOnLoad((Object)(object)val);
RemoteTextureCache[text] = val;
if (PendingSpawns.ContainsKey(text))
{
foreach (GraffitiRequest item in PendingSpawns[text])
{
SpawnDecal(item.p, item.n, item.u, item.s, val);
}
PendingSpawns.Remove(text);
}
}
_downloads.Remove(text);
}
public static void SpawnDecal(Vector3 pos, Vector3 normal, Vector3 upDir, float scale, Texture2D tex)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: 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_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
try
{
_sortingOrderCounter++;
float num = 0.02f + (float)_sortingOrderCounter * 0.0005f;
GameObject val = new GameObject("Graffiti_Container");
val.transform.position = pos + normal * num;
val.transform.rotation = Quaternion.LookRotation(-normal, upDir);
GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)5);
if (Object.op_Implicit((Object)(object)val2.GetComponent<Collider>()))
{
Object.Destroy((Object)(object)val2.GetComponent<Collider>());
}
val2.transform.SetParent(val.transform);
val2.transform.localPosition = Vector3.zero;
val2.transform.localRotation = Quaternion.identity;
SetupMaterial(val2.GetComponent<Renderer>(), tex, isBlackBack: false);
GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)5);
if (Object.op_Implicit((Object)(object)val3.GetComponent<Collider>()))
{
Object.Destroy((Object)(object)val3.GetComponent<Collider>());
}
val3.transform.SetParent(val.transform);
val3.transform.localPosition = new Vector3(0f, 0f, 0.0005f);
val3.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
SetupMaterial(val3.GetComponent<Renderer>(), Texture2D.blackTexture, isBlackBack: true);
val.transform.localScale = new Vector3(scale, scale, 1f);
SpawnedDecals.Add(val);
}
catch
{
}
}
private static void SetupMaterial(Renderer rend, Texture2D tex, bool isBlackBack)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
Shader val = Shader.Find("Standard");
if ((Object)(object)val == (Object)null)
{
val = Shader.Find("Unlit/Texture");
}
rend.material = new Material(val);
rend.material.mainTexture = (Texture)(object)tex;
if (((Object)val).name == "Standard")
{
if (isBlackBack)
{
rend.material.SetColor("_Color", Color.black);
rend.material.SetFloat("_Mode", 0f);
}
else
{
rend.material.SetFloat("_Mode", 2f);
rend.material.SetInt("_SrcBlend", 5);
rend.material.SetInt("_DstBlend", 10);
rend.material.SetInt("_ZWrite", 0);
rend.material.EnableKeyword("_ALPHABLEND_ON");
rend.material.renderQueue = 3000;
}
rend.material.SetFloat("_Cull", 2f);
}
}
private static void SendToLobby(string msgId, ObjectPublicIDisposableLi1ByInByBoUnique p)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: 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)
if (!((Object)(object)MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance == (Object)null))
{
List<CSteamID> list = new List<CSteamID>();
int numLobbyMembers = SteamMatchmaking.GetNumLobbyMembers(MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.currentLobby);
for (int i = 0; i < numLobbyMembers; i++)
{
list.Add(SteamMatchmaking.GetLobbyMemberByIndex(MonoBehaviourPublicObInUIgaStCSBoStcuCSUnique.Instance.currentLobby, i));
}
CrabNet.SendMessage(msgId, p, (IEnumerable<CSteamID>)list);
}
}
}
public static class DeepReflector
{
private static MethodInfo _method;
private static bool _isStatic;
public static void Init()
{
try
{
Type type = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule");
if (type == null)
{
type = typeof(ImageConversion);
}
if (type != null)
{
MethodInfo[] methods = type.GetMethods();
foreach (MethodInfo methodInfo in methods)
{
if (methodInfo.Name.Contains("LoadImage") && methodInfo.GetParameters().Length == 2)
{
_method = methodInfo;
_isStatic = true;
Debug.Log(Object.op_Implicit("[AntroLog] FOUND METHOD: ImageConversion.LoadImage (2 args)"));
return;
}
}
}
}
catch
{
}
try
{
Type typeFromHandle = typeof(Texture2D);
MethodInfo[] methods2 = typeFromHandle.GetMethods();
foreach (MethodInfo methodInfo2 in methods2)
{
if (methodInfo2.Name.Contains("LoadImage") && methodInfo2.GetParameters().Length == 1)
{
_method = methodInfo2;
_isStatic = false;
Debug.Log(Object.op_Implicit("[AntroLog] FOUND METHOD: Texture2D.LoadImage (1 arg)"));
return;
}
}
}
catch
{
}
Debug.LogError(Object.op_Implicit("[AntroLog] FATAL: Reflector found nothing!"));
}
public static bool LoadImage(Texture2D tex, byte[] data)
{
if (_method == null)
{
return false;
}
try
{
Il2CppStructArray<byte> val = Il2CppStructArray<byte>.op_Implicit(data);
if (_isStatic)
{
return (bool)_method.Invoke(null, new object[2] { tex, val });
}
return (bool)_method.Invoke(tex, new object[1] { val });
}
catch
{
return false;
}
}
}
public class GraffitiController : MonoBehaviour
{
public static GraffitiController Instance;
public GraffitiController(IntPtr ptr)
: base(ptr)
{
}
private void Awake()
{
Instance = this;
}
private void Update()
{
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_0316: Unknown result type (might be due to invalid IL or missing references)
//IL_0333: Unknown result type (might be due to invalid IL or missing references)
//IL_0338: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Expected O, but got Unknown
//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
//IL_0421: Unknown result type (might be due to invalid IL or missing references)
//IL_0426: Unknown result type (might be due to invalid IL or missing references)
//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0400: Unknown result type (might be due to invalid IL or missing references)
//IL_0435: Unknown result type (might be due to invalid IL or missing references)
//IL_043a: Unknown result type (might be due to invalid IL or missing references)
//IL_043f: Unknown result type (might be due to invalid IL or missing references)
//IL_0441: Unknown result type (might be due to invalid IL or missing references)
//IL_0466: Unknown result type (might be due to invalid IL or missing references)
//IL_0416: Unknown result type (might be due to invalid IL or missing references)
//IL_041b: Unknown result type (might be due to invalid IL or missing references)
//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
if (GraffitiPlugin._cooldownTimer > 0f)
{
GraffitiPlugin._cooldownTimer -= Time.deltaTime;
if (GraffitiPlugin._cooldownTimer < 0f)
{
GraffitiPlugin._cooldownTimer = 0f;
}
}
if (Input.GetKeyDown((KeyCode)286))
{
GraffitiPlugin.ReloadLocalFiles();
}
GraffitiPlugin._isHoldingKey = Input.GetKey((KeyCode)103);
RaycastHit val = default(RaycastHit);
if (GraffitiPlugin._isHoldingKey && Input.GetKeyDown((KeyCode)325) && (Object)(object)Camera.main != (Object)null && Physics.Raycast(((Component)Camera.main).transform.position, ((Component)Camera.main).transform.forward, ref val, 10f))
{
Renderer val2 = ((Component)((RaycastHit)(ref val)).collider).GetComponent<Renderer>();
if ((Object)(object)val2 == (Object)null && (Object)(object)((Component)((RaycastHit)(ref val)).collider).transform.parent != (Object)null)
{
val2 = ((Component)((Component)((RaycastHit)(ref val)).collider).transform.parent).GetComponentInChildren<Renderer>();
}
if ((Object)(object)val2 != (Object)null && (Object)(object)val2.material.mainTexture != (Object)null)
{
Texture2D val3 = (Texture2D)val2.material.mainTexture;
if (((Object)val3).name != "System_Checkerboard" && ((Object)val3).name != "UnityWhite" && ((Object)val3).name != "UnityBlack")
{
Debug.Log(Object.op_Implicit("[AntroLog] COPY REQUEST: Found graffiti '" + ((Object)val3).name + "'. (Saving logic pending)"));
}
}
}
if (GraffitiPlugin._isHoldingKey && GraffitiPlugin.LocalTextures.Count > 0)
{
float axis = Input.GetAxis("Mouse ScrollWheel");
if (axis != 0f)
{
if (axis > 0f)
{
GraffitiPlugin._selectedIndex--;
}
else
{
GraffitiPlugin._selectedIndex++;
}
if (GraffitiPlugin._selectedIndex < 0)
{
GraffitiPlugin._selectedIndex = GraffitiPlugin.LocalTextures.Count - 1;
}
else if (GraffitiPlugin._selectedIndex >= GraffitiPlugin.LocalTextures.Count)
{
GraffitiPlugin._selectedIndex = 0;
}
}
if (Input.GetKey((KeyCode)273))
{
GraffitiPlugin._currentScale += 1.5f * Time.deltaTime;
if (GraffitiPlugin._currentScale > 7.5f)
{
GraffitiPlugin._currentScale = 7.5f;
}
}
if (Input.GetKey((KeyCode)274))
{
GraffitiPlugin._currentScale -= 1.5f * Time.deltaTime;
if (GraffitiPlugin._currentScale < 1.5f)
{
GraffitiPlugin._currentScale = 1.5f;
}
}
if ((Object)(object)Camera.main == (Object)null)
{
return;
}
RaycastHit val4 = default(RaycastHit);
if (Physics.Raycast(((Component)Camera.main).transform.position, ((Component)Camera.main).transform.forward, ref val4, 7.5f))
{
float num = Mathf.Abs(Vector3.Dot(((RaycastHit)(ref val4)).normal, Vector3.up));
bool flag = num > 0.7f;
float num2 = (flag ? 7.5f : 6f);
if (((RaycastHit)(ref val4)).distance <= num2)
{
if ((Object)(object)GraffitiPlugin._previewObj == (Object)null)
{
CreatePreview();
}
GraffitiPlugin._previewObj.SetActive(true);
GraffitiPlugin._previewObj.transform.position = ((RaycastHit)(ref val4)).point + ((RaycastHit)(ref val4)).normal * 0.05f;
Vector3 val6;
if (flag)
{
Vector3 up = ((Component)Camera.main).transform.up;
Vector3 val5 = Vector3.ProjectOnPlane(up, ((RaycastHit)(ref val4)).normal);
val6 = ((Vector3)(ref val5)).normalized;
if (((Vector3)(ref val6)).sqrMagnitude < 0.001f)
{
val6 = Vector3.up;
}
}
else
{
val6 = Vector3.up;
}
GraffitiPlugin._previewObj.transform.rotation = Quaternion.LookRotation(-((RaycastHit)(ref val4)).normal, val6);
float currentScale = GraffitiPlugin._currentScale;
GraffitiPlugin._previewObj.transform.localScale = new Vector3(currentScale, currentScale, 1f);
Renderer component = GraffitiPlugin._previewObj.GetComponent<Renderer>();
if ((Object)(object)component != (Object)null)
{
int selectedIndex = GraffitiPlugin._selectedIndex;
if (selectedIndex >= 0 && selectedIndex < GraffitiPlugin.LocalTextures.Count)
{
component.material.mainTexture = (Texture)(object)GraffitiPlugin.LocalTextures[selectedIndex];
}
}
if (Input.GetKeyDown((KeyCode)323))
{
if (GraffitiPlugin._cooldownTimer <= 0f)
{
GraffitiPlugin.SendGraffiti(((RaycastHit)(ref val4)).point, ((RaycastHit)(ref val4)).normal, val6, GraffitiPlugin._currentScale, GraffitiPlugin._selectedIndex);
GraffitiPlugin._cooldownTimer = 30f;
}
else
{
Debug.Log(Object.op_Implicit($"[AntroLog] Cooldown active! Wait {GraffitiPlugin._cooldownTimer:F1}s"));
}
}
}
else if ((Object)(object)GraffitiPlugin._previewObj != (Object)null)
{
GraffitiPlugin._previewObj.SetActive(false);
}
}
else if ((Object)(object)GraffitiPlugin._previewObj != (Object)null)
{
GraffitiPlugin._previewObj.SetActive(false);
}
}
else if ((Object)(object)GraffitiPlugin._previewObj != (Object)null)
{
GraffitiPlugin._previewObj.SetActive(false);
}
}
private void CreatePreview()
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
GraffitiPlugin._previewObj = GameObject.CreatePrimitive((PrimitiveType)5);
((Object)GraffitiPlugin._previewObj).name = "Graffiti_Preview";
if (Object.op_Implicit((Object)(object)GraffitiPlugin._previewObj.GetComponent<Collider>()))
{
Object.Destroy((Object)(object)GraffitiPlugin._previewObj.GetComponent<Collider>());
}
Renderer component = GraffitiPlugin._previewObj.GetComponent<Renderer>();
Shader val = Shader.Find("Unlit/Transparent");
if ((Object)(object)val == (Object)null)
{
val = Shader.Find("Standard");
}
component.material = new Material(val);
component.material.color = new Color(1f, 1f, 1f, 0.5f);
}
private void OnGUI()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Expected O, but got Unknown
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: Expected O, but got Unknown
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Unknown result type (might be due to invalid IL or missing references)
//IL_0341: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
GUIStyle val = new GUIStyle(GUI.skin.label);
val.fontSize = 20;
val.fontStyle = (FontStyle)1;
val.normal.textColor = new Color(0.85f, 0.6f, 1f);
string text = $"Graffiti: {GraffitiPlugin.LocalTextures.Count} local | {GraffitiPlugin.RemoteTextureCache.Count} remote";
if (!GraffitiPlugin._isHoldingKey || GraffitiPlugin.LocalTextures.Count == 0)
{
return;
}
float num = (float)Screen.width / 2f;
float num2 = (float)Screen.height - 150f;
int selectedIndex = GraffitiPlugin._selectedIndex;
if (selectedIndex >= 0 && selectedIndex < GraffitiPlugin.LocalTextures.Count)
{
Texture2D val2 = GraffitiPlugin.LocalTextures[selectedIndex];
if (GraffitiPlugin._cooldownTimer > 0f)
{
string text2 = $"CD: {GraffitiPlugin._cooldownTimer:F2}";
GUIStyle val3 = new GUIStyle(GUI.skin.label);
val3.fontSize = 26;
val3.fontStyle = (FontStyle)1;
val3.alignment = (TextAnchor)4;
val3.normal.textColor = new Color(1f, 0.2f, 0.2f);
GUI.Label(new Rect(num - 150f, num2 - 210f, 300f, 50f), text2, val3);
}
GUI.color = new Color(0f, 0f, 0f, 0.7f);
GUI.DrawTexture(new Rect(num - 220f, num2 - 90f, 440f, 110f), (Texture)(object)Texture2D.whiteTexture);
GUI.color = new Color(0f, 0f, 0f, 0.5f);
GUI.DrawTexture(new Rect(num - 40f, num2 - 160f, 80f, 80f), (Texture)(object)Texture2D.whiteTexture);
GUI.color = Color.white;
if ((Object)(object)val2 != (Object)null)
{
GUI.DrawTexture(new Rect(num - 35f, num2 - 155f, 70f, 70f), (Texture)(object)val2, (ScaleMode)2);
}
GUIStyle val4 = new GUIStyle(GUI.skin.label);
val4.alignment = (TextAnchor)4;
val4.fontSize = 20;
val4.fontStyle = (FontStyle)1;
GUI.color = Color.white;
GUI.Label(new Rect(num - 250f, num2 - 80f, 500f, 30f), ((Object)val2).name, val4);
val4.fontSize = 14;
val4.normal.textColor = Color.yellow;
GUI.Label(new Rect(num - 250f, num2 - 50f, 500f, 25f), "Scroll: Select | LMB: Spray", val4);
string text3 = $"Size: {GraffitiPlugin._currentScale:F1}x (Arrows)";
val4.fontSize = 16;
val4.normal.textColor = Color.green;
GUI.Label(new Rect(num - 250f, num2 - 25f, 500f, 25f), text3, val4);
}
}
}
}