using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using HarmonyLib;
using Newtonsoft.Json;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MassEditor")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MassEditor")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("209116BB-AF2B-4562-A63F-4BF48FB51C7E")]
[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 MassEditor;
[HarmonyPatch]
public static class MassCommandHandler
{
public static MassController massController = MassController.GetMassController();
public static void GetAllInstances(string[] arguments)
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: 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)
CommandConsole.Log("There are currently " + massController.massInstances.Count + " mass instances active");
foreach (MassInstance massInstance in massController.massInstances)
{
string text = "";
text = text + "ID: " + massInstance.ID;
string text2 = text;
Vector3 val = massInstance.UpDirection;
text = text2 + " Up direction: " + ((object)(Vector3)(ref val)).ToString();
string text3 = text;
val = massInstance.MoveDirection;
text = text3 + " Move Direction: " + ((object)(Vector3)(ref val)).ToString();
text = text + " Distance from player: " + massInstance.GetPlayerDistance();
CommandConsole.Log(text);
}
}
public static void GetField(string[] arguments)
{
if (arguments.Length != 2)
{
CommandConsole.LogError("Invalid amount of arguments");
return;
}
if (!int.TryParse(arguments[0], out var result))
{
CommandConsole.LogError("Invalid ID");
return;
}
FieldInfo fieldInfo = AccessTools.Field(typeof(MassInstance), arguments[1]);
if (fieldInfo == null)
{
CommandConsole.LogError("Field not found.");
return;
}
MassInstance instanceFromID = massController.GetInstanceFromID(result);
if (instanceFromID == null)
{
CommandConsole.LogError("Stated id does not match to an instance of deathgoo");
}
CommandConsole.Log("Field " + arguments[1] + " returned value " + fieldInfo.GetValue(instanceFromID));
}
public static void GetFieldNames(string[] arguments)
{
List<string> fieldNames = AccessTools.GetFieldNames(typeof(MassInstance));
string text = "All fields: ";
foreach (string item in fieldNames)
{
text = text + item + ", ";
}
text.Remove(text.Length - 1);
CommandConsole.Log(text);
}
public static void CanKill(string[] arguments)
{
if (arguments.Length < 1 || arguments.Length > 2)
{
CommandConsole.LogError("Invalid amount of arguments!");
return;
}
if (!int.TryParse(arguments[0], out var result))
{
CommandConsole.LogError("Invalid ID");
return;
}
MassInstance instanceFromID = massController.GetInstanceFromID(result);
if (instanceFromID == null)
{
CommandConsole.LogError("Stated id does not match to an instance of deathgoo");
return;
}
FieldInfo fieldInfo = AccessTools.Field(typeof(DEN_DeathFloor), "canKill");
bool result2;
if (arguments.Length == 1)
{
bool flag = (bool)fieldInfo.GetValue(instanceFromID.DeathFloorInstance);
fieldInfo.SetValue(instanceFromID.DeathFloorInstance, !flag);
CommandConsole.Log("Set the canKill value to be " + !flag);
}
else if (!bool.TryParse(arguments[1], out result2))
{
CommandConsole.LogError("Invalid boolean");
}
else
{
fieldInfo.SetValue(instanceFromID.DeathFloorInstance, result2);
CommandConsole.Log("Set the canKill value to be " + result2);
}
}
public static void SetSpeed(string[] arguments)
{
if (arguments.Length < 1 || arguments.Length > 2)
{
CommandConsole.LogError("Invalid amount of arguments!");
return;
}
if (!int.TryParse(arguments[0], out var result))
{
CommandConsole.LogError("Invalid ID");
return;
}
MassInstance instanceFromID = massController.GetInstanceFromID(result);
if (instanceFromID == null)
{
CommandConsole.LogError("Stated id does not match to an instance of deathgoo");
return;
}
float speed;
if (arguments.Length == 1)
{
speed = 0f;
}
else
{
if (!float.TryParse(arguments[1], out var result2))
{
CommandConsole.LogError("Stated speed cannot be read");
return;
}
speed = result2;
}
instanceFromID.DeathFloorInstance.speed = speed;
CommandConsole.Log("Set the speed value to be " + speed);
}
public static void SetHeight(string[] arguments)
{
if (arguments.Length < 1 || arguments.Length > 2)
{
CommandConsole.LogError("Invalid amount of arguments!");
return;
}
if (!int.TryParse(arguments[0], out var result))
{
CommandConsole.LogError("Invalid ID");
return;
}
MassInstance instanceFromID = massController.GetInstanceFromID(result);
if (instanceFromID == null)
{
CommandConsole.LogError("Stated id does not match to an instance of deathgoo");
return;
}
float num;
if (arguments.Length == 1)
{
num = -10f;
}
else
{
if (!float.TryParse(arguments[1], out var result2))
{
CommandConsole.LogError("Stated height cannot be read");
return;
}
num = result2;
}
instanceFromID.Height = instanceFromID.GetPlayerDistance() - num;
CommandConsole.Log("Set the height value to be " + num + " relative to player");
}
public static void DeleteMass(string[] arguments)
{
if (arguments.Length != 1)
{
CommandConsole.LogError("Invalid amount of arguments!");
return;
}
if (!int.TryParse(arguments[0], out var result))
{
CommandConsole.LogError("Invalid ID");
return;
}
MassInstance instanceFromID = massController.GetInstanceFromID(result);
if (instanceFromID == null)
{
CommandConsole.LogError("Stated id does not match to an instance of deathgoo");
return;
}
instanceFromID.Delete();
CommandConsole.Log("Deleted instance of deathgoo.");
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CommandConsole), "Awake")]
public static void CreateCommands()
{
CommandBuilder val = CommandConsole.BuildCommand("deathgoo-getinstances", (Action<string[]>)GetAllInstances);
val.Description("Returns all instances of deathgoo");
val.NotCheat();
CommandBuilder val2 = CommandConsole.BuildCommand("deathgoo-getfield", (Action<string[]>)GetField);
val2.Description("[id] [field] Returns the stated field of the deathgoo");
val2.NotCheat();
CommandBuilder val3 = CommandConsole.BuildCommand("deathgoo-getfieldnames", (Action<string[]>)GetFieldNames);
val3.Description("Returns all field names of the deathgoo");
val3.NotCheat();
CommandBuilder val4 = CommandConsole.BuildCommand("deathgoo-canKill", (Action<string[]>)CanKill);
val4.Description("[id] [enabled=toggle] toggles the death functionality of the selected deathgoo");
CommandBuilder val5 = CommandConsole.BuildCommand("deathgoo-setSpeed", (Action<string[]>)SetSpeed);
val5.Description("[id] [speed=0] sets the speed of the selected deathgoo");
CommandBuilder val6 = CommandConsole.BuildCommand("deathgoo-setHeight", (Action<string[]>)SetHeight);
val6.Description("[id] [height=-10] sets the height of the selected deathgoo, caution, this is RELATIVE TO THE PLAYER");
}
}
[HarmonyPatch]
public class MassController
{
private static MassController instance;
internal List<MassInstance> massInstances = new List<MassInstance>();
internal Dictionary<string, List<MassInstance.SaveData>> saveData = new Dictionary<string, List<MassInstance.SaveData>>();
private MassController()
{
}
internal int GetNextAvailableID()
{
if (massInstances.Count == 0)
{
return 0;
}
int iD = massInstances[0].ID;
foreach (MassInstance massInstance in massInstances)
{
if (massInstance.ID > iD)
{
iD = massInstance.ID;
}
}
return iD + 1;
}
public MassInstance GetInstanceFromID(int id)
{
foreach (MassInstance massInstance in massInstances)
{
if (massInstance.ID == id)
{
return massInstance;
}
}
return null;
}
public int[] GetAllIDs()
{
List<int> list = new List<int>();
foreach (MassInstance massInstance in massInstances)
{
list.Add(massInstance.ID);
}
return list.ToArray();
}
public void SaveMassInstances(SaveState saveState)
{
List<MassInstance.SaveData> list = new List<MassInstance.SaveData>();
foreach (MassInstance massInstance in massInstances)
{
list.Add(massInstance.CreateSaveData());
}
saveData[saveState.id] = list;
}
public void CreateMassInstancesOnLoad(string fileName)
{
LoadMassInstancesFromJson(LoadSessionFromFile(fileName));
}
public static string LoadSessionFromFile(string fileName)
{
string path = Path.Combine(Application.persistentDataPath, "Sessions/" + fileName + "-save.session");
if (!File.Exists(path))
{
return null;
}
using FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read);
using GZipStream stream2 = new GZipStream(stream, CompressionMode.Decompress);
using StreamReader streamReader = new StreamReader(stream2, Encoding.UTF8);
return streamReader.ReadToEnd();
}
public void LoadMassSaveStates(SaveState saveState)
{
while (massInstances.Count > 0)
{
massInstances[0].Delete();
}
if (!saveData.TryGetValue(saveState.id, out var value))
{
return;
}
foreach (MassInstance.SaveData item in value)
{
MassInstance massInstance = MassInstance.LoadSaveData(item);
}
}
public void LoadMassInstancesFromJson(string data)
{
Dictionary<string, object> dictionary = JsonConvert.DeserializeObject<Dictionary<string, object>>(data);
string text = dictionary["DeathGooData"].ToString();
Dictionary<string, object> dictionary2 = JsonConvert.DeserializeObject<Dictionary<string, object>>(text);
foreach (string key in dictionary2.Keys)
{
List<object> list = JsonConvert.DeserializeObject<List<object>>(dictionary2[key].ToString());
saveData[key] = new List<MassInstance.SaveData>();
foreach (object item2 in list)
{
MassInstance.SaveData item = JsonUtility.FromJson<MassInstance.SaveData>(item2.ToString());
saveData[key].Add(item);
}
}
}
public static string InjectDataIntoJson(string data)
{
string text = "{";
foreach (KeyValuePair<string, List<MassInstance.SaveData>> saveDatum in GetMassController().saveData)
{
text = text + "\"" + saveDatum.Key + "\": [";
foreach (MassInstance.SaveData item in saveDatum.Value)
{
text = text + JsonUtility.ToJson((object)item, true) + ", ";
}
text = text.TrimEnd(", ".ToCharArray());
text += "],";
}
text = text.TrimEnd(", ".ToCharArray());
text += "}";
Debug.Log((object)text);
data = data.Insert(1, "\"DeathGooData\": " + text + ",");
return data;
}
public List<MassInstance.SaveData> GetMassInstanceSaves()
{
List<MassInstance.SaveData> list = new List<MassInstance.SaveData>();
foreach (MassInstance massInstance in massInstances)
{
list.Add(massInstance.CreateSaveData());
}
return list;
}
public static MassController GetMassController()
{
if (instance == null)
{
instance = new MassController();
}
return instance;
}
public MassInstance GetInstanceFromFloorName(string name)
{
foreach (MassInstance massInstance in massInstances)
{
if (massInstance.floorName == name)
{
return massInstance;
}
}
return null;
}
public MassInstance GetInstanceFromDeathFloor(DEN_DeathFloor deathFloor)
{
foreach (MassInstance massInstance in massInstances)
{
if ((Object)(object)massInstance.DeathFloorInstance == (Object)(object)deathFloor)
{
return massInstance;
}
}
return null;
}
[HarmonyDebug]
[HarmonyTranspiler]
[HarmonyPatch(typeof(CL_SaveManager), "SaveSessionToFile")]
private static IEnumerable<CodeInstruction> AddToJson(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Expected O, but got Unknown
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, generator);
val.MatchEndForward((CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null)
}).ThrowIfInvalid("Cannot find proper string location");
val.Advance(5);
val.Insert((CodeInstruction[])(object)new CodeInstruction[3]
{
new CodeInstruction(OpCodes.Ldloc_0, (object)null),
CodeInstruction.Call(typeof(MassController), "InjectDataIntoJson", (Type[])null, (Type[])null),
new CodeInstruction(OpCodes.Stloc_0, (object)null)
});
return val.InstructionEnumeration();
}
[HarmonyPrefix]
[HarmonyPatch(typeof(SaveState), "Save")]
private static void SaveDeathFloors(SaveState __instance)
{
GetMassController().SaveMassInstances(__instance);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CL_SaveManager), "LoadSession")]
private static void LoadSaveInstances()
{
string text = "";
if (CL_GameManager.IsHardmode())
{
text += "-hardmode";
}
string fileName = CL_GameManager.GetGamemodeName(false, false).ToLower() + text;
Debug.Log((object)"yooohoo");
GetMassController().CreateMassInstancesOnLoad(fileName);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(SaveState), "LoadSave")]
private static void LoadSaves(SaveState __instance)
{
GetMassController().LoadMassSaveStates(__instance);
}
}
public class SpawnRequirementEventArgs
{
public bool? AllowSpawn = null;
}
[HarmonyPatch]
public class MassInstance
{
public class SpawnSettings
{
public List<string> SpawnLevels = new List<string>();
public List<string> SpawnRegions = new List<string>();
public List<string> SpawnSubregions = new List<string>();
public List<string> SpawnGamemodes = new List<string>();
public bool OverrideSpawnClauses = false;
public void AddToSaveData(ref SaveData saveData)
{
foreach (string spawnLevel in SpawnLevels)
{
ref string spawnLevels = ref saveData.SpawnLevels;
spawnLevels = spawnLevels + "\"" + spawnLevel + "\",";
}
foreach (string spawnRegion in SpawnRegions)
{
ref string spawnRegions = ref saveData.SpawnRegions;
spawnRegions = spawnRegions + "\"" + spawnRegion + "\",";
}
foreach (string spawnSubregion in SpawnSubregions)
{
ref string spawnSubregions = ref saveData.SpawnSubregions;
spawnSubregions = spawnSubregions + "\"" + spawnSubregion + "\",";
}
foreach (string spawnGamemode in SpawnGamemodes)
{
ref string spawnGamemodes = ref saveData.SpawnGamemodes;
spawnGamemodes = spawnGamemodes + "\"" + spawnGamemode + "\",";
}
saveData.OverrideSpawnClauses = OverrideSpawnClauses;
}
public static SpawnSettings CreateFromSaveData(SaveData saveData)
{
SpawnSettings spawnSettings = new SpawnSettings();
string[] array = saveData.SpawnLevels.Split(',');
foreach (string text in array)
{
spawnSettings.SpawnLevels.Add(text.TrimEnd("\"".ToCharArray()).TrimStart("\"".ToCharArray()));
}
string[] array2 = saveData.SpawnRegions.Split(',');
foreach (string text2 in array2)
{
spawnSettings.SpawnRegions.Add(text2.TrimEnd("\"".ToCharArray()).TrimStart("\"".ToCharArray()));
}
string[] array3 = saveData.SpawnSubregions.Split(',');
foreach (string text3 in array3)
{
spawnSettings.SpawnSubregions.Add(text3.TrimEnd("\"".ToCharArray()).TrimStart("\"".ToCharArray()));
}
string[] array4 = saveData.SpawnGamemodes.Split(',');
foreach (string text4 in array4)
{
spawnSettings.SpawnGamemodes.Add(text4.TrimEnd("\"".ToCharArray()).TrimStart("\"".ToCharArray()));
}
spawnSettings.OverrideSpawnClauses = saveData.OverrideSpawnClauses;
return spawnSettings;
}
}
public enum DeathFloorType
{
Normal,
Holiday,
Training
}
[Serializable]
public struct SaveData
{
public float distanceFromPlayer;
public string floorName;
public Vector3 upDirection;
public Vector3 moveDirection;
public string SpawnLevels;
public string SpawnRegions;
public string SpawnSubregions;
public string SpawnGamemodes;
public bool OverrideSpawnClauses;
public bool active;
public float speed;
public float speedMult;
public float _height;
public DeathFloorType _deathFloorType;
}
private float _height = 0f;
public Vector3 MoveDirection = Vector3.up;
private DeathFloorType _deathFloorType;
public bool CenterAccordingToPlane = true;
public string floorName;
public SpawnSettings spawnSettings;
public bool PreventMovement = false;
internal Vector3 ChosenTarget;
internal bool HasChosenTarget;
private AnimationCurve _customMovementCurve;
private float _currentTimeOnCurve;
private float _completetionTime;
public float Height
{
get
{
return _height;
}
set
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: 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_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: 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)
Transform transform = ((Component)DeathFloorInstance).transform;
transform.position += ((Vector3)(ref MoveDirection)).normalized * (value - _height);
if (CenterAccordingToPlane)
{
Transform transform2 = ((Component)DeathFloorInstance).transform;
Plane planeInstance = PlaneInstance;
transform2.position = ((Plane)(ref planeInstance)).ClosestPointOnPlane(((Component)ENT_Player.playerObject).transform.position);
}
_height = value;
}
}
public Vector3 UpDirection
{
get
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
return ((Component)DeathFloorInstance).gameObject.transform.up;
}
set
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
((Component)DeathFloorInstance).gameObject.transform.up = value;
}
}
public Plane PlaneInstance => new Plane(((Component)DeathFloorInstance).transform.up, ((Component)DeathFloorInstance).transform.position);
public Plane MovementPlane => new Plane(MoveDirection, ((Component)DeathFloorInstance).transform.position);
public DEN_DeathFloor DeathFloorInstance { get; }
public int ID { get; }
public event EventHandler<SpawnRequirementEventArgs> DeathFloorAttemptingSpawn;
private bool? OnDeathFloorAttemptingSpawn(SpawnRequirementEventArgs e)
{
this.DeathFloorAttemptingSpawn?.Invoke(this, e);
return e.AllowSpawn;
}
private void Update()
{
if ((Object)(object)DeathFloorInstance == (Object)null)
{
Delete();
}
}
public float GetPlayerDistance()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
Plane planeInstance = PlaneInstance;
return ((Plane)(ref planeInstance)).GetDistanceToPoint(((Component)ENT_Player.playerObject).transform.position);
}
public float GetDistanceFromMovementPlane(Transform t)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
Plane movementPlane = MovementPlane;
return ((Plane)(ref movementPlane)).GetDistanceToPoint(t.position);
}
public float GetHeight()
{
return Height;
}
public float GetRelativeHeight()
{
return 0f - GetPlayerDistance();
}
public void CheckIfCanSpawn()
{
try
{
bool flag = true;
if (!spawnSettings.OverrideSpawnClauses)
{
flag = false;
foreach (string spawnLevel in spawnSettings.SpawnLevels)
{
if (spawnLevel == ((Object)CL_EventManager.currentLevel).name || flag)
{
flag = true;
break;
}
}
foreach (string spawnRegion in spawnSettings.SpawnRegions)
{
if (spawnRegion == ((Object)CL_EventManager.currentRegion).name || flag)
{
flag = true;
break;
}
}
foreach (string spawnSubregion in spawnSettings.SpawnSubregions)
{
if (spawnSubregion == ((Object)CL_EventManager.currentSubregion).name || flag)
{
flag = true;
break;
}
}
bool flag2 = false;
foreach (string spawnGamemode in spawnSettings.SpawnGamemodes)
{
if (spawnGamemode == ((Object)CL_GameManager.GetCurrentGamemode()).name)
{
flag2 = true;
break;
}
}
if (!flag2 && spawnSettings.SpawnGamemodes.Count > 0 && flag)
{
flag = false;
}
else if (spawnSettings.SpawnLevels.Count + spawnSettings.SpawnRegions.Count + spawnSettings.SpawnSubregions.Count == 0 && flag2)
{
flag = true;
}
if (spawnSettings.SpawnGamemodes.Count > 0 && !flag2)
{
Delete();
return;
}
}
SpawnRequirementEventArgs e = new SpawnRequirementEventArgs();
bool? flag3 = OnDeathFloorAttemptingSpawn(e);
if (flag3.HasValue)
{
flag = flag3.Value;
}
((Component)DeathFloorInstance).gameObject.SetActive(flag);
Debug.Log((object)flag);
}
catch (Exception ex)
{
Debug.LogWarning((object)("Checking for spawn plausibility has failed. Exception: " + ex.GetType().Name + " Message: " + ex.Message));
}
}
public SaveData CreateSaveData()
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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)
SaveData saveData = default(SaveData);
saveData.distanceFromPlayer = GetPlayerDistance();
saveData.upDirection = UpDirection;
saveData.moveDirection = MoveDirection;
saveData.active = DeathFloorInstance.IsActive();
saveData.speed = DeathFloorInstance.speed;
saveData.speedMult = (float)AccessTools.Field(typeof(DEN_DeathFloor), "speedMult").GetValue(DeathFloorInstance);
saveData._height = _height;
saveData._deathFloorType = _deathFloorType;
saveData.floorName = floorName;
SaveData saveData2 = saveData;
spawnSettings.AddToSaveData(ref saveData2);
return saveData2;
}
public static MassInstance LoadSaveData(SaveData saveData)
{
//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)
MassInstance massInstance = Create(saveData.upDirection, saveData.moveDirection, saveData.distanceFromPlayer, saveData._deathFloorType);
massInstance.DeathFloorInstance.speed = saveData.speed;
massInstance._height = saveData._height;
massInstance.DeathFloorInstance.SetActive(saveData.active);
massInstance.floorName = saveData.floorName;
massInstance.spawnSettings = SpawnSettings.CreateFromSaveData(saveData);
AccessTools.Field(typeof(DEN_DeathFloor), "speedMult").SetValue(massInstance.DeathFloorInstance, saveData.speedMult);
if (massInstance.floorName == "MainGameGoo")
{
DEN_DeathFloor.instance = massInstance.DeathFloorInstance;
}
return massInstance;
}
public static MassInstance Create(Vector3 up, float distanceAtStart = 16f, DeathFloorType type = DeathFloorType.Normal)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
return Create(up, up, distanceAtStart, type);
}
public static MassInstance Create(Vector3 up, Vector3 moveDirection, float distanceAtStart = 16f, DeathFloorType type = DeathFloorType.Normal)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: 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_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
MassInstance massInstance = Create(type);
massInstance.UpDirection = up;
massInstance.MoveDirection = moveDirection;
((Component)massInstance.DeathFloorInstance).transform.position = ((Component)ENT_Player.playerObject).transform.position - ((Vector3)(ref moveDirection)).normalized * distanceAtStart;
massInstance._height = 0f - distanceAtStart;
return massInstance;
}
private static MassInstance Create(DeathFloorType type)
{
List<GameObject> entityPrefabs = CL_AssetManager.GetFullCombinedAssetDatabase().entityPrefabs;
string text = "Denizen_Death_Floor";
switch (type)
{
case DeathFloorType.Holiday:
text += "_Holiday";
break;
case DeathFloorType.Training:
text += "_Training";
break;
}
GameObject val = null;
foreach (GameObject item in entityPrefabs)
{
if (((Object)item).name.Equals(text))
{
val = Object.Instantiate<GameObject>(item);
}
}
if ((Object)(object)val == (Object)null)
{
throw new KeyNotFoundException("The stated type has not been found!");
}
val.SetActive(true);
MassController massController = MassController.GetMassController();
MassInstance massInstance = new MassInstance(val.GetComponent<DEN_DeathFloor>());
massInstance._deathFloorType = type;
massController.massInstances.Add(massInstance);
if (massController.massInstances.Count > 1)
{
massInstance.DeathFloorInstance.setCorruptionHeight = false;
}
return massInstance;
}
public void Delete()
{
MassController.GetMassController().massInstances.Remove(this);
if (!((Object)(object)DeathFloorInstance == (Object)null))
{
Object.Destroy((Object)(object)((Component)DeathFloorInstance).gameObject);
}
}
private MassInstance(DEN_DeathFloor deathFloor)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
DeathFloorInstance = deathFloor;
spawnSettings = new SpawnSettings();
ID = MassController.GetMassController().GetNextAvailableID();
}
public void MoveInDirection(Vector3 direction)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
MoveInDirection(((Vector3)(ref direction)).normalized, ((Vector3)(ref direction)).magnitude);
}
public void MoveInDirection(Vector3 direction, float magnitude)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: 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_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: 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_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = ((Component)DeathFloorInstance).transform.position + direction * magnitude;
Plane movementPlane = MovementPlane;
float distanceToPoint = ((Plane)(ref movementPlane)).GetDistanceToPoint(val);
Height += distanceToPoint;
if (!CenterAccordingToPlane)
{
movementPlane = MovementPlane;
Vector3 val2 = ((Plane)(ref movementPlane)).ClosestPointOnPlane(val);
Transform transform = ((Component)DeathFloorInstance).transform;
transform.position += val2 * magnitude;
}
}
public void SetPosition(GameObject g)
{
SetPosition(g.transform);
}
public void SetPosition(Transform t)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
SetPosition(t.position);
}
public void SetPosition(Vector3 position)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: 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)
float height = Height;
Plane movementPlane = MovementPlane;
Height = height + ((Plane)(ref movementPlane)).GetDistanceToPoint(position);
}
internal void MoveToHeightSequence(float amount)
{
//IL_003a: 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_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: 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_0021: Unknown result type (might be due to invalid IL or missing references)
if (!HasChosenTarget)
{
ChosenTarget = ((Vector3)(ref MoveDirection)).normalized * amount;
HasChosenTarget = true;
}
SetPosition(Vector3.Lerp(((Component)DeathFloorInstance).transform.position, ChosenTarget, Time.deltaTime));
}
internal bool IsWithinRange(float amount)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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_0016: 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_0021: Unknown result type (might be due to invalid IL or missing references)
if (!HasChosenTarget)
{
ChosenTarget = ((Vector3)(ref MoveDirection)).normalized * amount;
HasChosenTarget = true;
}
Plane movementPlane = MovementPlane;
bool flag = ((Plane)(ref movementPlane)).GetDistanceToPoint(ChosenTarget) <= 0.1f;
if (flag)
{
HasChosenTarget = false;
}
return flag;
}
public void RaiseOverTimeRoutine(float amount)
{
Height += amount * Time.deltaTime;
}
public void SetHeightRelativeToTransform(float h, Transform t)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: 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_0014: Unknown result type (might be due to invalid IL or missing references)
SetPosition(t.position + h * MoveDirection);
}
public void MoveFloor(float amount)
{
if (_customMovementCurve != null)
{
_currentTimeOnCurve = Math.Min(_currentTimeOnCurve + Time.deltaTime, _completetionTime);
Height = _customMovementCurve.Evaluate(_currentTimeOnCurve);
Debug.Log((object)"---------");
Debug.Log((object)_currentTimeOnCurve);
Debug.Log((object)_customMovementCurve.Evaluate(_currentTimeOnCurve));
Debug.Log((object)"---------");
if (_currentTimeOnCurve.Equals(_completetionTime))
{
_customMovementCurve = null;
_currentTimeOnCurve = 0f;
_completetionTime = 0f;
}
}
else if (PreventMovement)
{
Height += 0f;
}
else
{
Height += amount;
}
}
public void PushCustomMovement(AnimationCurve movementCurve)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
_customMovementCurve = movementCurve;
_currentTimeOnCurve = 0f;
Keyframe[] keys = movementCurve.keys;
for (int i = 0; i < keys.Length; i++)
{
Keyframe val = keys[i];
if (((Keyframe)(ref val)).time > _completetionTime)
{
_completetionTime = ((Keyframe)(ref val)).time;
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(DEN_DeathFloor), "Start")]
private static void Edit(DEN_DeathFloor __instance)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: 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)
MassInstance instanceFromDeathFloor = MassController.GetMassController().GetInstanceFromDeathFloor(__instance);
if (instanceFromDeathFloor == null)
{
if ((Object)(object)DEN_DeathFloor.instance != (Object)null)
{
Object.Destroy((Object)(object)__instance);
}
MassInstance massInstance = new MassInstance(__instance);
massInstance.MoveDirection = Vector3.up;
massInstance.UpDirection = Vector3.up;
massInstance.spawnSettings.OverrideSpawnClauses = true;
massInstance.floorName = "MainGameGoo";
MassController.GetMassController().massInstances.Add(massInstance);
DEN_DeathFloor.instance = __instance;
if (__instance.usePlayerStartHeight)
{
__instance.playerStartHeight += Math.Abs(((Component)__instance).transform.position.y);
}
}
else
{
instanceFromDeathFloor.CheckIfCanSpawn();
}
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(DEN_DeathFloor), "Update")]
private static IEnumerable<CodeInstruction> UpdateEditor(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Expected O, but got Unknown
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Expected O, but got Unknown
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Expected O, but got Unknown
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Expected O, but got Unknown
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Expected O, but got Unknown
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Expected O, but got Unknown
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Expected O, but got Unknown
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Expected O, but got Unknown
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Expected O, but got Unknown
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Expected O, but got Unknown
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Expected O, but got Unknown
//IL_028d: Unknown result type (might be due to invalid IL or missing references)
//IL_0293: Expected O, but got Unknown
//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
//IL_02a7: Expected O, but got Unknown
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02bb: Expected O, but got Unknown
//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
//IL_02cf: Expected O, but got Unknown
//IL_030f: Unknown result type (might be due to invalid IL or missing references)
//IL_0315: Expected O, but got Unknown
//IL_0375: Unknown result type (might be due to invalid IL or missing references)
//IL_037b: Expected O, but got Unknown
//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
//IL_03aa: Expected O, but got Unknown
//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
//IL_03be: Expected O, but got Unknown
//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
//IL_03d2: Expected O, but got Unknown
//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
//IL_03e6: Expected O, but got Unknown
//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
//IL_03fa: Expected O, but got Unknown
//IL_0408: Unknown result type (might be due to invalid IL or missing references)
//IL_040e: Expected O, but got Unknown
//IL_044e: Unknown result type (might be due to invalid IL or missing references)
//IL_0454: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, generator);
val.MatchEndForward((CodeMatch[])(object)new CodeMatch[6]
{
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null)
}).ThrowIfInvalid("WHYYYYYY");
val.Advance(-4);
val.RemoveInstructions(11);
val.Insert((CodeInstruction[])(object)new CodeInstruction[4]
{
CodeInstruction.Call(typeof(MassController), "GetMassController", (Type[])null, (Type[])null),
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
CodeInstruction.Call(typeof(MassController), "GetInstanceFromDeathFloor", (Type[])null, (Type[])null),
CodeInstruction.Call(typeof(MassInstance), "GetPlayerDistance", (Type[])null, (Type[])null)
});
val.MatchEndForward((CodeMatch[])(object)new CodeMatch[6]
{
new CodeMatch((OpCode?)OpCodes.Ldloca_S, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null)
}).ThrowIfInvalid("WHYYYYYY");
val.Advance(-5);
int pos = val.Pos;
val.RemoveInstructions(18);
val.Insert((CodeInstruction[])(object)new CodeInstruction[3]
{
CodeInstruction.Call(typeof(MassController), "GetMassController", (Type[])null, (Type[])null),
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
CodeInstruction.Call(typeof(MassController), "GetInstanceFromDeathFloor", (Type[])null, (Type[])null)
});
val.Advance(6);
val.RemoveInstructions(6);
val.Insert((CodeInstruction[])(object)new CodeInstruction[1] { CodeInstruction.Call(typeof(MassInstance), "MoveFloor", (Type[])null, (Type[])null) });
val.Advance(1);
Label label = default(Label);
val.CreateLabel(ref label);
val.Advance(pos - 1 - val.Pos);
val.Operand = label;
val.Advance(-val.Pos);
val.MatchEndForward((CodeMatch[])(object)new CodeMatch[4]
{
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Brfalse, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null)
}).ThrowIfInvalid("WHYYYYYY");
val.RemoveInstructions(5);
val.Insert((CodeInstruction[])(object)new CodeInstruction[4]
{
CodeInstruction.Call(typeof(MassController), "GetMassController", (Type[])null, (Type[])null),
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
CodeInstruction.Call(typeof(MassController), "GetInstanceFromDeathFloor", (Type[])null, (Type[])null),
CodeInstruction.Call(typeof(MassInstance), "GetPlayerDistance", (Type[])null, (Type[])null)
});
val.Advance(4);
val.RemoveInstructions(6);
val.Insert((CodeInstruction[])(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Ldc_R4, (object)(-1f))
});
val.Advance(-val.Pos);
val.MatchEndForward((CodeMatch[])(object)new CodeMatch[6]
{
new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Stloc_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Brtrue, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)null, (string)null)
}).ThrowIfInvalid("Cannot find CL_GameManager.gMan.GetPlayerCorrectedHeight()");
val.RemoveInstructions(2);
val.Insert((CodeInstruction[])(object)new CodeInstruction[4]
{
CodeInstruction.Call(typeof(MassController), "GetMassController", (Type[])null, (Type[])null),
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
CodeInstruction.Call(typeof(MassController), "GetInstanceFromDeathFloor", (Type[])null, (Type[])null),
CodeInstruction.Call(typeof(MassInstance), "GetPlayerDistance", (Type[])null, (Type[])null)
});
return val.InstructionEnumeration();
}
[HarmonyPostfix]
[HarmonyPatch(typeof(DEN_DeathFloor), "Update")]
private static void CancelFX(DEN_DeathFloor __instance)
{
FXManager.fxMan.corruptionHeight = -10000f;
MassController.GetMassController().GetInstanceFromDeathFloor(__instance).Update();
}
[HarmonyTranspiler]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private static IEnumerable<CodeInstruction> GoUpSequence(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Expected O, but got Unknown
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Expected O, but got Unknown
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Expected O, but got Unknown
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Expected O, but got Unknown
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Expected O, but got Unknown
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Expected O, but got Unknown
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Expected O, but got Unknown
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Expected O, but got Unknown
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Expected O, but got Unknown
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Expected O, but got Unknown
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Expected O, but got Unknown
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Expected O, but got Unknown
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Expected O, but got Unknown
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0227: Expected O, but got Unknown
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Expected O, but got Unknown
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Expected O, but got Unknown
//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
//IL_02cf: Expected O, but got Unknown
//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
//IL_02e3: Expected O, but got Unknown
//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
//IL_02f7: Expected O, but got Unknown
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_030b: Expected O, but got Unknown
//IL_0319: Unknown result type (might be due to invalid IL or missing references)
//IL_031f: Expected O, but got Unknown
//IL_032d: Unknown result type (might be due to invalid IL or missing references)
//IL_0333: Expected O, but got Unknown
//IL_0341: Unknown result type (might be due to invalid IL or missing references)
//IL_0347: Expected O, but got Unknown
//IL_0355: Unknown result type (might be due to invalid IL or missing references)
//IL_035b: Expected O, but got Unknown
//IL_0369: Unknown result type (might be due to invalid IL or missing references)
//IL_036f: Expected O, but got Unknown
//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
//IL_03b8: Expected O, but got Unknown
//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
//IL_03df: Expected O, but got Unknown
//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
//IL_03ed: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, generator);
val.Start();
val.MatchEndForward((CodeMatch[])(object)new CodeMatch[6]
{
new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null)
}).ThrowIfInvalid("WHYYYYYY0");
object operand = val.Operand;
val.Advance(-val.Pos);
val.MatchEndForward((CodeMatch[])(object)new CodeMatch[6]
{
new CodeMatch((OpCode?)OpCodes.Newobj, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Mul, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null)
}).ThrowIfInvalid("WHYYYYYY");
val.MatchEndBackwards((CodeMatch[])(object)new CodeMatch[5]
{
new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null)
}).ThrowIfInvalid("WHYYYYYY2");
val.Advance(-4);
val.RemoveInstructions(21);
val.Insert((CodeInstruction[])(object)new CodeInstruction[7]
{
CodeInstruction.Call(typeof(MassController), "GetMassController", (Type[])null, (Type[])null),
new CodeInstruction(OpCodes.Ldloc_1, (object)null),
CodeInstruction.Call(typeof(MassController), "GetInstanceFromDeathFloor", (Type[])null, (Type[])null),
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
new CodeInstruction(OpCodes.Ldfld, operand),
CodeInstruction.Call(typeof(MassInstance), "MoveToHeightSequence", (Type[])null, (Type[])null),
new CodeInstruction(OpCodes.Nop, (object)null)
});
Label label = default(Label);
val.CreateLabel(ref label);
do
{
val.Advance(1);
}
while (!(val.Opcode == OpCodes.Bgt));
val.Operand = label;
val.Advance(-val.Pos);
val.MatchEndForward((CodeMatch[])(object)new CodeMatch[9]
{
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Stfld, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldc_I4_1, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ret, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldc_I4_M1, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Stfld, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null)
});
val.SetAndAdvance(OpCodes.Nop, (object)null);
val.RemoveInstructions(8);
val.Insert((CodeInstruction[])(object)new CodeInstruction[6]
{
CodeInstruction.Call(typeof(MassController), "GetMassController", (Type[])null, (Type[])null),
new CodeInstruction(OpCodes.Ldloc_1, (object)null),
CodeInstruction.Call(typeof(MassController), "GetInstanceFromDeathFloor", (Type[])null, (Type[])null),
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
new CodeInstruction(OpCodes.Ldfld, operand),
CodeInstruction.Call(typeof(MassInstance), "IsWithinRange", (Type[])null, (Type[])null)
});
val.Advance(6);
val.Opcode = OpCodes.Brfalse;
return val.InstructionEnumeration();
}
[HarmonyTranspiler]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private static IEnumerable<CodeInstruction> RaiseOverTimeSequence(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Expected O, but got Unknown
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Expected O, but got Unknown
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Expected O, but got Unknown
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Expected O, but got Unknown
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, generator);
val.Start();
val.MatchEndForward((CodeMatch[])(object)new CodeMatch[7]
{
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldfld, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Sub, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Stfld, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldloc_1, (object)null, (string)null)
}).ThrowIfInvalid("Unable to find line \"denDeathFloor.transform.position += Vector3.up * Time.deltaTime * amount;\"");
val.RemoveInstructions(8);
object obj = ObjectExtensions.Copy(val.Operand);
val.RemoveInstructions(4);
val.Insert((CodeInstruction[])(object)new CodeInstruction[6]
{
CodeInstruction.Call(typeof(MassController), "GetMassController", (Type[])null, (Type[])null),
new CodeInstruction(OpCodes.Ldloc_1, (object)null),
CodeInstruction.Call(typeof(MassController), "GetInstanceFromDeathFloor", (Type[])null, (Type[])null),
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
new CodeInstruction(OpCodes.Ldfld, obj),
CodeInstruction.Call(typeof(MassInstance), "RaiseOverTimeRoutine", (Type[])null, (Type[])null)
});
return val.InstructionEnumeration();
}
[HarmonyPrefix]
[HarmonyPatch(typeof(DEN_DeathFloor), "SetHeightRelativeToTransform")]
private static bool SetHeightRelativeToTransformOverride(DEN_DeathFloor __instance, float h, Transform t)
{
MassController.GetMassController().GetInstanceFromDeathFloor(__instance).SetHeightRelativeToTransform(h, t);
return false;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(DEN_DeathFloor), "SetHeight", new Type[] { typeof(float) })]
private static bool SetHeight(DEN_DeathFloor __instance, float h)
{
MassController.GetMassController().GetInstanceFromDeathFloor(__instance).Height = h;
return false;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CL_EventManager), "EnterLevel")]
private static void CanSpawnInitializer()
{
MassController massController = MassController.GetMassController();
foreach (MassInstance massInstance in massController.massInstances)
{
massInstance.CheckIfCanSpawn();
}
Debug.Log((object)("Current Level: " + (object)CL_EventManager.currentLevel));
Debug.Log((object)("Current Region: " + (object)CL_EventManager.currentRegion));
Debug.Log((object)("Current Subregion: " + (object)CL_EventManager.currentSubregion));
Debug.Log((object)("Current Gamemode: " + (object)CL_GameManager.gamemode));
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(DEN_DeathFloor), "Start")]
private static IEnumerable<CodeInstruction> RemoveOriginalCommands(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Expected O, but got Unknown
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, generator);
val.Start().MatchEndForward((CodeMatch[])(object)new CodeMatch[2]
{
new CodeMatch((OpCode?)OpCodes.Stfld, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"deathgoo-stop", (string)null)
});
int pos = val.Pos;
val.MatchEndForward((CodeMatch[])(object)new CodeMatch[3]
{
new CodeMatch((OpCode?)OpCodes.Ldstr, (object)"BEGONE", (string)null),
new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Pop, (object)null, (string)null)
});
int pos2 = val.Pos;
val.RemoveInstructionsInRange(pos, pos2);
return val.InstructionEnumeration();
}
}
[BepInPlugin("mazknight.whiteknuckle.DeathFloorEditor", "DeathFloorEditor", "0.1.2")]
public class Plugin : BaseUnityPlugin
{
public const string pluginGuid = "mazknight.whiteknuckle.DeathFloorEditor";
public const string pluginName = "DeathFloorEditor";
public const string pluginVersion = "0.1.2";
private Harmony harmony = new Harmony("mazknight.whiteknuckle.DeathFloorEditor");
public void Awake()
{
harmony.PatchAll();
}
}
[HarmonyPatch]
public class Transpilation
{
[HarmonyPostfix]
[HarmonyPatch(typeof(CL_GameManager), "Awake")]
public static void CreateDeathGoo(CL_GameManager __instance)
{
if (CL_GameManager.IsInGame())
{
__instance.allowScores = false;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(CL_GameManager), "AreAchievementsAllowed")]
public static void DenyAchievements(ref bool __result)
{
__result = false;
}
[HarmonyTranspiler]
[HarmonyPatch(typeof(DEN_DeathFloor), "Start")]
public static IEnumerable<CodeInstruction> RemoveSingleton(IEnumerable<CodeInstruction> instructions)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Expected O, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Expected O, but got Unknown
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Expected O, but got Unknown
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Expected O, but got Unknown
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Expected O, but got Unknown
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Expected O, but got Unknown
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Expected O, but got Unknown
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Expected O, but got Unknown
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Expected O, but got Unknown
CodeMatcher val = new CodeMatcher(instructions, (ILGenerator)null);
val.Start().MatchEndForward((CodeMatch[])(object)new CodeMatch[8]
{
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ret, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Stfld, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null)
}).ThrowIfInvalid("Unable to find matching codes for \"DEN_DeathFloor.instance = this;\"");
val.RemoveInstructions(2);
val.MatchEndBackwards((CodeMatch[])(object)new CodeMatch[5]
{
new CodeMatch((OpCode?)OpCodes.Ldsfld, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldnull, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Brfalse, (object)null, (string)null),
new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null)
}).ThrowIfInvalid("Unable to find matching codes for \"UnityEngine.Object.Destroy((UnityEngine.Object) this.gameObject);\"");
val.RemoveInstructions(4);
return val.InstructionEnumeration();
}
public static void DebugChildren<T>(GameObject g) where T : Component
{
DebugChildrenInner<T>("", g.transform);
}
private static void DebugChildrenInner<T>(string start, Transform g)
{
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Expected O, but got Unknown
string text = "\n";
text = ((!(start == "")) ? (text + start + "-> " + ((Object)((Component)g).gameObject).name + "\n") : (text + start + ((Object)((Component)g).gameObject).name + "\n"));
for (int i = 0; i < ((Component)g).gameObject.GetComponentCount(); i++)
{
text = text + "\t" + ((object)((Component)g).gameObject.GetComponentAtIndex(i)).GetType().Name + "\n";
Component componentAtIndex = ((Component)g).gameObject.GetComponentAtIndex(i);
ObjectTagger val = (ObjectTagger)(object)((componentAtIndex is ObjectTagger) ? componentAtIndex : null);
if (val != null)
{
string text2 = "";
foreach (string tag in val.tags)
{
text2 = text2 + tag + ", ";
}
text = text + "\t\t" + text2 + "\n";
}
Component componentAtIndex2 = ((Component)g).gameObject.GetComponentAtIndex(i);
CL_Handhold val2 = (CL_Handhold)(object)((componentAtIndex2 is CL_Handhold) ? componentAtIndex2 : null);
if (val2 == null)
{
continue;
}
string text3 = "";
foreach (HandholdModule module in val2.modules)
{
text3 = text3 + ((object)module).GetType().Name + ", ";
}
text = text + "\t\t" + text3 + "\n";
}
text = text + ((Object)((Component)g).gameObject).GetInstanceID() + "\n";
if (((Component)g).gameObject.GetComponent<T>() != null)
{
Debug.Log((object)text);
}
foreach (Transform item in g)
{
Transform g2 = item;
if (start == "")
{
DebugChildrenInner<T>(start + ((Object)((Component)g).gameObject).name + " ", g2);
}
else
{
DebugChildrenInner<T>(start + "-> " + ((Object)((Component)g).gameObject).name + " ", g2);
}
}
}
public static void DebugChildren(GameObject g)
{
DebugChildrenInner(" ", g.transform);
}
private static void DebugChildrenInner(string start, Transform g)
{
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Expected O, but got Unknown
if (start == "")
{
Debug.Log((object)(start + ((Object)((Component)g).gameObject).name));
}
else
{
Debug.Log((object)(start + "-> " + ((Object)((Component)g).gameObject).name));
}
for (int i = 0; i < ((Component)g).gameObject.GetComponentCount(); i++)
{
Debug.Log((object)((object)((Component)g).gameObject.GetComponentAtIndex(i)).GetType().Name);
Component componentAtIndex = ((Component)g).gameObject.GetComponentAtIndex(i);
ObjectTagger val = (ObjectTagger)(object)((componentAtIndex is ObjectTagger) ? componentAtIndex : null);
if (val == null)
{
continue;
}
string text = "";
foreach (string tag in val.tags)
{
text = text + tag + ", ";
}
Debug.Log((object)("\t" + text));
}
foreach (Transform item in g)
{
Transform g2 = item;
if (start == "")
{
DebugChildrenInner(start + ((Object)((Component)g).gameObject).name + " ", g2);
}
else
{
DebugChildrenInner(start + "-> " + ((Object)((Component)g).gameObject).name + " ", g2);
}
}
}
}
public static class TranspilerTools
{
public static void DebugCurrentPosition(CodeMatcher matcher)
{
int pos = matcher.Pos;
int length = matcher.Length;
matcher.Advance(-pos);
for (int i = 0; i < length; i++)
{
int pos2 = matcher.Pos;
OpCode opcode = matcher.Opcode;
object operand = matcher.Operand;
string text = pos2.ToString();
text = ((pos2 != pos) ? (text + ": ") : (text + ":* "));
text = text + opcode.ToString() + " " + operand;
if (operand != null)
{
text = text + " Type: " + operand.GetType();
}
Debug.Log((object)text);
if (pos2 == length)
{
break;
}
matcher.Advance(1);
}
matcher.Advance(pos - length);
}
public static void DebugSurroundingPosition(CodeMatcher matcher, int distance)
{
int pos = matcher.Pos;
int length = matcher.Length;
if (pos < distance)
{
matcher.Advance(-pos);
}
else
{
matcher.Advance(-distance);
}
for (int i = 0; i < 2 * distance; i++)
{
int pos2 = matcher.Pos;
OpCode opcode = matcher.Opcode;
object operand = matcher.Operand;
string text = pos2.ToString();
text = ((pos2 != pos) ? (text + ": ") : (text + ":* "));
text = text + opcode.ToString() + " " + operand;
if (operand != null)
{
text = text + " Type: " + operand.GetType();
}
Debug.Log((object)text);
if (pos2 == length)
{
break;
}
matcher.Advance(1);
}
matcher.Advance(pos - matcher.Pos);
}
}