using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using CustomMapCreatorTool;
using Il2Cpp;
using Il2CppRUMBLE.MoveSystem;
using Il2CppRUMBLE.Utilities;
using MelonLoader;
using RumbleModdingAPI;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(main), "CustomMapCreatorTool", "1.2.2", "UlvakSkillz", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 195, 0, 255)]
[assembly: MelonAuthorColor(255, 195, 0, 255)]
[assembly: VerifyLoaderVersion(0, 6, 2, true)]
[assembly: AssemblyTitle("CustomMapCreatorTool")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CustomMapCreatorTool")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3fc6e151-242c-443a-b26e-98530f5ccbfe")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CustomMapCreatorTool;
public static class ModBuildInfo
{
public const string Version = "1.2.2";
}
public class main : MelonMod
{
private GameObject parentGO;
private GameObject primitiveStorage;
private bool PKeyPressed = false;
private bool PKeyReleased = true;
private bool EqualKeyPressed = false;
private bool EqualKeyReleased = true;
public override void OnLateInitializeMelon()
{
Calls.onMapInitialized += Init;
if (!File.Exists("UserData\\MapCreator\\CustomMap.txt"))
{
File.Create("UserData\\MapCreator\\CustomMap.txt");
}
if (!File.Exists("UserData\\MapCreator\\Map.txt"))
{
File.Create("UserData\\MapCreator\\Map.txt");
}
}
private void Init()
{
SpawnPrimitives();
}
public override void OnUpdate()
{
if (Input.GetKeyDown((KeyCode)112) && PKeyReleased)
{
PKeyPressed = true;
PKeyReleased = false;
}
if (Input.GetKeyUp((KeyCode)112) && !PKeyReleased)
{
PKeyReleased = true;
}
if (Input.GetKeyDown((KeyCode)61) && EqualKeyReleased)
{
EqualKeyPressed = true;
EqualKeyReleased = false;
}
if (Input.GetKeyUp((KeyCode)61) && !EqualKeyReleased)
{
EqualKeyReleased = true;
}
}
public override void OnFixedUpdate()
{
if (PKeyPressed)
{
PKeyPressed = false;
parentGO = GameObject.Find("StoreHere");
SaveText();
SaveCustomMap();
}
if (EqualKeyPressed)
{
EqualKeyPressed = false;
parentGO = GameObject.Find("StoreHere");
LoadCustomMap();
}
}
private void LoadCustomMap()
{
try
{
string[] array = File.ReadAllLines("UserData\\MapCreator\\CustomMap.txt");
string text = "1";
string[] array2 = array;
foreach (string text2 in array2)
{
text = text + "|" + text2;
}
string text3 = text;
string[] recievedText = text3.Split(new char[1] { '|' });
LoadCustomMap(recievedText);
}
catch
{
MelonLogger.Error("Failed to Read Custom Map: UserData\\MapCreator\\CustomMap.txt");
}
}
private void LoadCustomMap(string[] recievedText)
{
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Invalid comparison between Unknown and I4
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Invalid comparison between Unknown and I4
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Invalid comparison between Unknown and I4
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_0204: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Invalid comparison between Unknown and I4
//IL_028d: Unknown result type (might be due to invalid IL or missing references)
//IL_037d: Unknown result type (might be due to invalid IL or missing references)
//IL_0395: Unknown result type (might be due to invalid IL or missing references)
//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
//IL_031e: Invalid comparison between Unknown and I4
//IL_0320: Unknown result type (might be due to invalid IL or missing references)
//IL_0323: Invalid comparison between Unknown and I4
GameObject val = parentGO;
Shader shader = Shader.Find("Universal Render Pipeline/Lit");
int num = int.Parse(recievedText[1]);
for (int i = 0; i < num; i++)
{
string text = recievedText[13 * i + 2];
float num2 = float.Parse(recievedText[13 * i + 3], CultureInfo.InvariantCulture);
float num3 = float.Parse(recievedText[13 * i + 4], CultureInfo.InvariantCulture);
float num4 = float.Parse(recievedText[13 * i + 5], CultureInfo.InvariantCulture);
float num5 = float.Parse(recievedText[13 * i + 6], CultureInfo.InvariantCulture);
float num6 = float.Parse(recievedText[13 * i + 7], CultureInfo.InvariantCulture);
float num7 = float.Parse(recievedText[13 * i + 8], CultureInfo.InvariantCulture);
float num8 = float.Parse(recievedText[13 * i + 9], CultureInfo.InvariantCulture);
float num9 = float.Parse(recievedText[13 * i + 10], CultureInfo.InvariantCulture);
float num10 = float.Parse(recievedText[13 * i + 11], CultureInfo.InvariantCulture);
float num11 = float.Parse(recievedText[13 * i + 12], CultureInfo.InvariantCulture);
float num12 = float.Parse(recievedText[13 * i + 13], CultureInfo.InvariantCulture);
float num13 = float.Parse(recievedText[13 * i + 14], CultureInfo.InvariantCulture);
PrimitiveType val2 = (PrimitiveType)3;
if (text.Contains("Capsule"))
{
val2 = (PrimitiveType)1;
}
else if (text.Contains("Cylinder"))
{
val2 = (PrimitiveType)2;
}
else if (text.Contains("Plane"))
{
val2 = (PrimitiveType)4;
}
else if (text.Contains("Quad"))
{
val2 = (PrimitiveType)5;
}
else if (text.Contains("Sphere"))
{
val2 = (PrimitiveType)0;
}
GameObject val3 = GameObject.CreatePrimitive(val2);
((Object)val3).name = text;
if ((int)val2 == 3)
{
Object.Destroy((Object)(object)val3.GetComponent<BoxCollider>());
}
else if ((int)val2 == 1 || (int)val2 == 2)
{
Object.Destroy((Object)(object)val3.GetComponent<CapsuleCollider>());
}
else if ((int)val2 == 0)
{
Object.Destroy((Object)(object)val3.GetComponent<SphereCollider>());
}
if (text.ToLower().Contains("wall"))
{
val3.AddComponent<BoxCollider>();
}
if (text.ToLower().Contains("invisible"))
{
Object.Destroy((Object)(object)val3.GetComponent<MeshRenderer>());
}
else
{
val3.GetComponent<Renderer>().material.shader = shader;
val3.GetComponent<Renderer>().material.color = new Color(num2, num3, num4);
}
if (text.ToLower().Contains("visual"))
{
val3.layer = 0;
}
else
{
if (text.ToLower().Contains("death"))
{
val3.AddComponent<KillPlayerOnCollision>();
}
if (text.ToLower().Contains("environment"))
{
val3.layer = 10;
val3.AddComponent<KillStructureOnImpact>();
}
else
{
val3.layer = 9;
}
MeshCollider collider = (((int)val2 != 4 && (int)val2 != 5) ? val3.AddComponent<MeshCollider>() : val3.GetComponent<MeshCollider>());
GroundCollider val4 = val3.AddComponent<GroundCollider>();
val4.isMainGroundCollider = true;
val4.collider = (Collider)(object)collider;
}
val3.transform.parent = val.transform;
val3.transform.position = new Vector3(num5, num6, num7);
val3.transform.rotation = Quaternion.Euler(num8, num9, num10);
val3.transform.localScale = new Vector3(num11, num12, num13);
}
}
private void SpawnPrimitives()
{
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
GameObject val = GameObject.CreatePrimitive((PrimitiveType)1);
val.GetComponent<Renderer>().material.shader = Shader.Find("Universal Render Pipeline/Lit");
val.layer = 9;
val.transform.parent = primitiveStorage.transform;
GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3);
val2.GetComponent<Renderer>().material.shader = Shader.Find("Universal Render Pipeline/Lit");
val2.layer = 9;
val2.transform.parent = primitiveStorage.transform;
GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)2);
val3.GetComponent<Renderer>().material.shader = Shader.Find("Universal Render Pipeline/Lit");
val3.layer = 9;
val3.transform.parent = primitiveStorage.transform;
GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)4);
val4.GetComponent<Renderer>().material.shader = Shader.Find("Universal Render Pipeline/Lit");
val4.layer = 9;
val4.transform.parent = primitiveStorage.transform;
GameObject val5 = GameObject.CreatePrimitive((PrimitiveType)5);
val5.GetComponent<Renderer>().material.shader = Shader.Find("Universal Render Pipeline/Lit");
val5.layer = 9;
val5.transform.parent = primitiveStorage.transform;
GameObject val6 = GameObject.CreatePrimitive((PrimitiveType)0);
val6.GetComponent<Renderer>().material.shader = Shader.Find("Universal Render Pipeline/Lit");
val6.layer = 9;
val6.transform.parent = primitiveStorage.transform;
primitiveStorage.transform.position = new Vector3(0f, -10f, 0f);
primitiveStorage.SetActive(false);
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
parentGO = new GameObject();
((Object)parentGO).name = "StoreHere";
primitiveStorage = new GameObject();
((Object)primitiveStorage).name = "PrimitiveStorage";
}
public void SaveCustomMap()
{
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_022b: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0290: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
//IL_02be: Unknown result type (might be due to invalid IL or missing references)
List<string> list = new List<string>();
list.Add($"{parentGO.transform.childCount}");
for (int i = 0; i < parentGO.transform.childCount; i++)
{
GameObject gameObject = ((Component)parentGO.transform.GetChild(i)).gameObject;
list.Add(ShortenName(((Object)gameObject).name) ?? "");
float num;
float num2;
float num3;
if (!((Object)gameObject).name.ToLower().Contains("invisible"))
{
num = gameObject.GetComponent<Renderer>().material.color.r;
num2 = gameObject.GetComponent<Renderer>().material.color.g;
num3 = gameObject.GetComponent<Renderer>().material.color.b;
}
else
{
num = 0f;
num2 = 0f;
num3 = 0f;
}
list.Add(num.ToString(CultureInfo.InvariantCulture) + "|" + num2.ToString(CultureInfo.InvariantCulture) + "|" + num3.ToString(CultureInfo.InvariantCulture));
list.Add(gameObject.transform.position.x.ToString(CultureInfo.InvariantCulture) + "|" + gameObject.transform.position.y.ToString(CultureInfo.InvariantCulture) + "|" + gameObject.transform.position.z.ToString(CultureInfo.InvariantCulture));
string[] array = new string[5];
Quaternion rotation = gameObject.transform.rotation;
array[0] = ((Quaternion)(ref rotation)).eulerAngles.x.ToString(CultureInfo.InvariantCulture);
array[1] = "|";
rotation = gameObject.transform.rotation;
array[2] = ((Quaternion)(ref rotation)).eulerAngles.y.ToString(CultureInfo.InvariantCulture);
array[3] = "|";
rotation = gameObject.transform.rotation;
array[4] = ((Quaternion)(ref rotation)).eulerAngles.z.ToString(CultureInfo.InvariantCulture);
list.Add(string.Concat(array));
list.Add(gameObject.transform.localScale.x.ToString(CultureInfo.InvariantCulture) + "|" + gameObject.transform.localScale.y.ToString(CultureInfo.InvariantCulture) + "|" + gameObject.transform.localScale.z.ToString(CultureInfo.InvariantCulture));
}
File.WriteAllLines("UserData\\MapCreator\\CustomMap.txt", list);
MelonLogger.Msg("CustomMap File Saved");
}
public void SaveText()
{
//IL_0291: Unknown result type (might be due to invalid IL or missing references)
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_0450: Unknown result type (might be due to invalid IL or missing references)
//IL_0455: Unknown result type (might be due to invalid IL or missing references)
//IL_0479: Unknown result type (might be due to invalid IL or missing references)
//IL_047e: Unknown result type (might be due to invalid IL or missing references)
//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0517: Unknown result type (might be due to invalid IL or missing references)
//IL_051c: Unknown result type (might be due to invalid IL or missing references)
//IL_0520: Unknown result type (might be due to invalid IL or missing references)
//IL_0525: Unknown result type (might be due to invalid IL or missing references)
//IL_0549: Unknown result type (might be due to invalid IL or missing references)
//IL_054e: Unknown result type (might be due to invalid IL or missing references)
//IL_0552: Unknown result type (might be due to invalid IL or missing references)
//IL_0557: Unknown result type (might be due to invalid IL or missing references)
//IL_0595: Unknown result type (might be due to invalid IL or missing references)
//IL_059a: Unknown result type (might be due to invalid IL or missing references)
//IL_05be: Unknown result type (might be due to invalid IL or missing references)
//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
//IL_05e7: Unknown result type (might be due to invalid IL or missing references)
//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
List<string> list = new List<string>();
list.Add("private void LoadMap()");
list.Add("{");
list.Add("GameObject mapParent = new GameObject();");
list.Add("mapParent.name = \"mapParent\";");
list.Add("mapParent.transform.parent = mapsParent.transform;");
list.Add("MeshCollider meshCollider;");
list.Add("GroundCollider groundCollider;");
list.Add("Shader urp = Shader.Find(\"Universal Render Pipeline/Lit\");");
list.Add("GameObject shape;");
for (int i = 0; i < parentGO.transform.childCount; i++)
{
GameObject gameObject = ((Component)parentGO.transform.GetChild(i)).gameObject;
string text;
if (((Object)gameObject).name.Contains("Capsule"))
{
text = "PrimitiveType.Capsule";
}
else if (((Object)gameObject).name.Contains("Cube"))
{
text = "PrimitiveType.Cube";
}
else if (((Object)gameObject).name.Contains("Cylinder"))
{
text = "PrimitiveType.Cylinder";
}
else if (((Object)gameObject).name.Contains("Plane"))
{
text = "PrimitiveType.Plane";
}
else if (((Object)gameObject).name.Contains("Quad"))
{
text = "PrimitiveType.Quad";
}
else
{
if (!((Object)gameObject).name.Contains("Sphere"))
{
continue;
}
text = "PrimitiveType.Sphere";
}
list.Add("shape = GameObject.CreatePrimitive(" + text + ");");
list.Add("shape.name = \"" + ShortenName(((Object)gameObject).name) + "\";");
if (text == "PrimitiveType.Cube")
{
list.Add("Component.Destroy(shape.GetComponent<BoxCollider>());");
}
else if (text == "PrimitiveType.Capsule" || text == "PrimitiveType.Cylinder")
{
list.Add("Component.Destroy(shape.GetComponent<CapsuleCollider>());");
}
else if (text == "PrimitiveType.Sphere")
{
list.Add("Component.Destroy(shape.GetComponent<SphereCollider>());");
}
if (((Object)gameObject).name.ToLower().Contains("wall"))
{
list.Add("shape.AddComponent<BoxCollider>();");
}
if (((Object)gameObject).name.ToLower().Contains("invisible"))
{
list.Add("Component.Destroy(shape.GetComponent<MeshRenderer>());");
}
else
{
list.Add("shape.GetComponent<Renderer>().material.shader = urp;");
Renderer component = gameObject.GetComponent<Renderer>();
if ((Object)(object)component != (Object)null)
{
float r = gameObject.GetComponent<Renderer>().material.color.r;
float g = gameObject.GetComponent<Renderer>().material.color.g;
float b = gameObject.GetComponent<Renderer>().material.color.b;
list.Add("shape.GetComponent<Renderer>().material.color = new Color(" + r.ToString(CultureInfo.InvariantCulture) + "f, " + g.ToString(CultureInfo.InvariantCulture) + "f, " + b.ToString(CultureInfo.InvariantCulture) + "f); ");
}
}
if (((Object)gameObject).name.ToLower().Contains("visual"))
{
list.Add("shape.layer = 0;");
}
else
{
if (((Object)gameObject).name.ToLower().Contains("death"))
{
list.Add("shape.AddComponent<KillPlayerOnCollision>();");
}
if (((Object)gameObject).name.ToLower().Contains("environment"))
{
list.Add("shape.layer = 10;");
list.Add("shape.AddComponent<KillStructureOnImpact>();");
}
else
{
list.Add("shape.layer = 9;");
}
if (text == "PrimitiveType.Plane" || text == "PrimitiveType.Quad")
{
list.Add("meshCollider = shape.GetComponent<MeshCollider>();");
}
else
{
list.Add("meshCollider = shape.AddComponent<MeshCollider>();");
}
list.Add("groundCollider = shape.AddComponent<GroundCollider>();");
list.Add("groundCollider.isMainGroundCollider = true;");
list.Add("groundCollider.collider = meshCollider;");
}
list.Add("shape.transform.parent = mapParent.transform;");
list.Add("shape.transform.position = new Vector3(" + gameObject.transform.position.x.ToString(CultureInfo.InvariantCulture) + "f, " + gameObject.transform.position.y.ToString(CultureInfo.InvariantCulture) + "f, " + gameObject.transform.position.z.ToString(CultureInfo.InvariantCulture) + "f);");
string[] obj = new string[7] { "shape.transform.rotation = Quaternion.Euler(", null, null, null, null, null, null };
Quaternion rotation = gameObject.transform.rotation;
obj[1] = ((Quaternion)(ref rotation)).eulerAngles.x.ToString(CultureInfo.InvariantCulture);
obj[2] = "f, ";
rotation = gameObject.transform.rotation;
obj[3] = ((Quaternion)(ref rotation)).eulerAngles.y.ToString(CultureInfo.InvariantCulture);
obj[4] = "f, ";
rotation = gameObject.transform.rotation;
obj[5] = ((Quaternion)(ref rotation)).eulerAngles.z.ToString(CultureInfo.InvariantCulture);
obj[6] = "f);";
list.Add(string.Concat(obj));
list.Add("shape.transform.localScale = new Vector3(" + gameObject.transform.localScale.x.ToString(CultureInfo.InvariantCulture) + "f, " + gameObject.transform.localScale.y.ToString(CultureInfo.InvariantCulture) + "f, " + gameObject.transform.localScale.z.ToString(CultureInfo.InvariantCulture) + "f);");
}
list.Add("mapParent.SetActive(false);");
list.Add("}");
File.WriteAllLines("UserData\\MapCreator\\Map.txt", list);
MelonLogger.Msg("Map File Saved");
}
private string ShortenName(string name)
{
while (name.Contains("(Clone)"))
{
for (int i = 0; i < name.Length - 6; i++)
{
if (name.Substring(i, 7) == "(Clone)")
{
name = name.Remove(i, 7);
break;
}
}
}
return name;
}
}