using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using ImGuiNET;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using On.RoR2.Navigation;
using OverlayDearImGui;
using RoR2;
using RoR2.Navigation;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("InteractableSpawnFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("InteractableSpawnFix")]
[assembly: AssemblyTitle("InteractableSpawnFix")]
[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 InteractableSpawnFixNS
{
public static class DictionaryExtensions
{
public static TValue GetValueOrAddDefault<TKey, TValue>(this Dictionary<TKey, TValue> dict, TKey key) where TValue : new()
{
if (!dict.TryGetValue(key, out var value))
{
value = (dict[key] = new TValue());
}
return value;
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("iDeathHD.InteractableSpawnFix", "InteractableSpawnFix", "1.0.0")]
public class InteractableSpawnFix : BaseUnityPlugin
{
private class BlockedInteractableSpawnPoint
{
public string name;
[JsonConverter(typeof(Vector3Converter))]
public Vector3 boundsMin;
[JsonConverter(typeof(Vector3Converter))]
public Vector3 boundsMax;
}
public class Vector3Converter : JsonConverter<Vector3>
{
public override void WriteJson(JsonWriter writer, Vector3 value, JsonSerializer serializer)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: 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)
writer.WriteStartObject();
writer.WritePropertyName("x");
writer.WriteValue(value.x);
writer.WritePropertyName("y");
writer.WriteValue(value.y);
writer.WritePropertyName("z");
writer.WriteValue(value.z);
writer.WriteEndObject();
}
public override Vector3 ReadJson(JsonReader reader, Type objectType, Vector3 existingValue, bool hasExistingValue, JsonSerializer serializer)
{
//IL_0009: 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)
JObject val = JObject.Load(reader);
Vector3 result = default(Vector3);
JToken obj = val["x"];
result.x = ((obj != null) ? Extensions.Value<float>((IEnumerable<JToken>)obj) : 0f);
JToken obj2 = val["y"];
result.y = ((obj2 != null) ? Extensions.Value<float>((IEnumerable<JToken>)obj2) : 0f);
JToken obj3 = val["z"];
result.z = ((obj3 != null) ? Extensions.Value<float>((IEnumerable<JToken>)obj3) : 0f);
return result;
}
}
private class FileInfo
{
public string FilePath;
public string FileName;
}
public const string PluginGUID = "iDeathHD.InteractableSpawnFix";
public const string PluginAuthor = "iDeathHD";
public const string PluginName = "InteractableSpawnFix";
public const string PluginVersion = "1.0.0";
private static int CustomMultiplierInteractableCredit = 1;
private static bool _isMyUIOpen = false;
private static Dictionary<string, List<BlockedInteractableSpawnPoint>> _sceneNameToBlockedInteractableSpawnPoints = new Dictionary<string, List<BlockedInteractableSpawnPoint>>();
private static Dictionary<string, List<BlockedInteractableSpawnPoint>> _sceneNameToInteractablesThatGotDenied = new Dictionary<string, List<BlockedInteractableSpawnPoint>>();
private static string spawnPointNameFilter = "";
private static readonly string SaveFolder = Path.Combine(Application.persistentDataPath, "InteractableSpawnFix");
private static FileInfo[] cachedFiles = new FileInfo[0];
private static FileInfo selectedFile = null;
private static bool IsValidFloat(float value)
{
if (!float.IsNaN(value))
{
return !float.IsInfinity(value);
}
return false;
}
private static bool IsValidVector2(Vector2 vec)
{
//IL_0000: 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)
if (IsValidFloat(vec.x))
{
return IsValidFloat(vec.y);
}
return false;
}
private static void DrawDottedLine(ImDrawListPtr draw, Vector2 a, Vector2 b, uint color)
{
//IL_000c: 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_000e: 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_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: 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_004f: 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_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
float num = 6f;
float num2 = 4f;
Vector2 val = b - a;
float magnitude = ((Vector2)(ref val)).magnitude;
if (magnitude <= 0.001f || float.IsNaN(magnitude) || float.IsInfinity(magnitude))
{
return;
}
val /= magnitude;
for (float num3 = 0f; num3 < magnitude; num3 += num + num2)
{
Vector2 val2 = a + val * num3;
Vector2 val3 = a + val * MathF.Min(num3 + num, magnitude);
if (IsValidVector2(val2) && IsValidVector2(val3))
{
((ImDrawListPtr)(ref draw)).AddLine(val2, val3, color, 1f);
continue;
}
break;
}
}
private static bool IsOccluded(Camera cam, Vector3 a, Vector3 b)
{
//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)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//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_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = (a + b) * 0.5f - ((Component)cam).transform.position;
RaycastHit val2 = default(RaycastHit);
if (Physics.Raycast(((Component)cam).transform.position, ((Vector3)(ref val)).normalized, ref val2, ((Vector3)(ref val)).magnitude))
{
return true;
}
return false;
}
private static void DrawWireBox(Vector3 topLeft, Vector3 bottomRight, Vector4 color)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: 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_001e: 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_0025: 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_0027: 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_0036: 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_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: 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_005b: 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_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: 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_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: 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_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_024c: Unknown result type (might be due to invalid IL or missing references)
//IL_025e: 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)
Camera main = Camera.main;
if ((Object)(object)main == (Object)null)
{
return;
}
ImDrawListPtr backgroundDrawList = ImGui.GetBackgroundDrawList();
float num = Screen.height;
Vector3 val = Vector3.Min(topLeft, bottomRight);
Vector3 val2 = Vector3.Max(topLeft, bottomRight);
Vector3[] array = (Vector3[])(object)new Vector3[8]
{
new Vector3(val.x, val.y, val.z),
new Vector3(val2.x, val.y, val.z),
new Vector3(val.x, val2.y, val.z),
new Vector3(val2.x, val2.y, val.z),
new Vector3(val.x, val.y, val2.z),
new Vector3(val2.x, val.y, val2.z),
new Vector3(val.x, val2.y, val2.z),
new Vector3(val2.x, val2.y, val2.z)
};
Vector2[] array2 = (Vector2[])(object)new Vector2[8];
bool[] array3 = new bool[8];
for (int i = 0; i < 8; i++)
{
Vector3 val3 = main.WorldToScreenPoint(array[i]);
array3[i] = val3.z > 0f;
array2[i] = new Vector2(val3.x, num - val3.y);
}
int[,] array4 = new int[12, 2]
{
{ 0, 1 },
{ 1, 3 },
{ 3, 2 },
{ 2, 0 },
{ 4, 5 },
{ 5, 7 },
{ 7, 6 },
{ 6, 4 },
{ 0, 4 },
{ 1, 5 },
{ 2, 6 },
{ 3, 7 }
};
uint colorU = ImGui.GetColorU32(color);
uint colorU2 = ImGui.GetColorU32(new Vector4(color.x, color.y, color.z, 0.4f));
for (int j = 0; j < array4.GetLength(0); j++)
{
int num2 = array4[j, 0];
int num3 = array4[j, 1];
if (!array3[num2] || !array3[num3])
{
continue;
}
if (IsOccluded(main, array[num2], array[num3]))
{
DrawDottedLine(backgroundDrawList, array2[num2], array2[num3], colorU2);
continue;
}
if (IsValidVector2(array2[num2]) && IsValidVector2(array2[num3]))
{
((ImDrawListPtr)(ref backgroundDrawList)).AddLine(array2[num2], array2[num3], colorU, 2f);
continue;
}
break;
}
}
public void Awake()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
Log.Init(((BaseUnityPlugin)this).Logger);
NodeGraph.GetNodePosition += new hook_GetNodePosition(BlockInvalidSpawnPositions);
SceneManager.activeSceneChanged += delegate(Scene oldScene, Scene newScene)
{
Log.Info("Scene changed to '" + ((Scene)(ref newScene)).name + "'");
};
if (Directory.Exists(SaveFolder))
{
cachedFiles = (from s in Directory.GetFiles(SaveFolder, "*.json")
select new FileInfo
{
FilePath = s,
FileName = Path.GetFileName(s)
}).ToArray();
selectedFile = cachedFiles.FirstOrDefault((FileInfo f) => f.FileName == "Default.json");
if (selectedFile != null)
{
LoadSpawnPoints(selectedFile.FilePath);
}
}
else
{
Directory.CreateDirectory(SaveFolder);
}
}
private bool BlockInvalidSpawnPositions(orig_GetNodePosition orig, NodeGraph self, NodeIndex nodeIndex, out Vector3 position)
{
//IL_0005: 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_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: 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_01d2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: 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_01e5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
Dictionary<string, List<BlockedInteractableSpawnPoint>> sceneNameToBlockedInteractableSpawnPoints = _sceneNameToBlockedInteractableSpawnPoints;
Scene activeScene = SceneManager.GetActiveScene();
List<BlockedInteractableSpawnPoint> valueOrAddDefault = sceneNameToBlockedInteractableSpawnPoints.GetValueOrAddDefault(((Scene)(ref activeScene)).name);
bool result = orig.Invoke(self, nodeIndex, ref position);
Vector3 val = default(Vector3);
Vector3 val2 = default(Vector3);
foreach (BlockedInteractableSpawnPoint item in valueOrAddDefault)
{
if (position.x >= Mathf.Min(item.boundsMin.x, item.boundsMax.x) && position.x <= Mathf.Max(item.boundsMin.x, item.boundsMax.x) && position.y >= Mathf.Min(item.boundsMin.y, item.boundsMax.y) && position.y <= Mathf.Max(item.boundsMin.y, item.boundsMax.y) && position.z >= Mathf.Min(item.boundsMin.z, item.boundsMax.z) && position.z <= Mathf.Max(item.boundsMin.z, item.boundsMax.z))
{
Log.Info($"Prevented interactable spawn at node {nodeIndex} (position {position}) due to it being inside disallowed area '{item.name}'");
((Vector3)(ref val))..ctor(1f, 1f, 1f);
((Vector3)(ref val2))..ctor(position.x, position.y, position.z);
Dictionary<string, List<BlockedInteractableSpawnPoint>> sceneNameToInteractablesThatGotDenied = _sceneNameToInteractablesThatGotDenied;
activeScene = SceneManager.GetActiveScene();
sceneNameToInteractablesThatGotDenied.GetValueOrAddDefault(((Scene)(ref activeScene)).name).Add(new BlockedInteractableSpawnPoint
{
name = $"Denied Spawn Point {valueOrAddDefault.Count + 1}",
boundsMin = val2 - val,
boundsMax = val2 + val
});
position = Vector3.zero;
return false;
}
}
return result;
}
public void OnEnable()
{
Overlay.OnRender += MyUI;
}
private static void DrawDisallowedInteractableSpawnBoxes()
{
//IL_0005: 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_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
Dictionary<string, List<BlockedInteractableSpawnPoint>> sceneNameToBlockedInteractableSpawnPoints = _sceneNameToBlockedInteractableSpawnPoints;
Scene activeScene = SceneManager.GetActiveScene();
foreach (BlockedInteractableSpawnPoint item in sceneNameToBlockedInteractableSpawnPoints.GetValueOrAddDefault(((Scene)(ref activeScene)).name))
{
DrawWireBox(new Vector3(item.boundsMin.x, item.boundsMin.y, item.boundsMin.z), new Vector3(item.boundsMax.x, item.boundsMax.y, item.boundsMax.z), new Vector4(1f, 1f, 0f, 1f));
}
Dictionary<string, List<BlockedInteractableSpawnPoint>> sceneNameToInteractablesThatGotDenied = _sceneNameToInteractablesThatGotDenied;
activeScene = SceneManager.GetActiveScene();
foreach (BlockedInteractableSpawnPoint item2 in sceneNameToInteractablesThatGotDenied.GetValueOrAddDefault(((Scene)(ref activeScene)).name))
{
DrawWireBox(new Vector3(item2.boundsMin.x, item2.boundsMin.y, item2.boundsMin.z), new Vector3(item2.boundsMax.x, item2.boundsMax.y, item2.boundsMax.z), new Vector4(1f, 0f, 0f, 1f));
}
}
private static void Try(Action action)
{
try
{
action();
}
catch (Exception data)
{
Log.Error(data);
}
}
private static void MyUI()
{
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
if (ImGui.BeginMainMenuBar())
{
if (ImGui.BeginMenu("Debug", true))
{
if (ImGui.MenuItem("Open Debug Window", (string)null, _isMyUIOpen))
{
_isMyUIOpen = !_isMyUIOpen;
}
ImGui.EndMenu();
}
ImGui.EndMainMenuBar();
}
if (ImGui.Begin("Interactable Node Fixes", (ImGuiWindowFlags)64))
{
Try(delegate
{
//IL_0005: 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)
Scene activeScene3 = SceneManager.GetActiveScene();
ImGui.Text("Current Scene: " + ((Scene)(ref activeScene3)).name);
});
ImGui.DragInt("Custom Interactable Credit Multiplier", ref CustomMultiplierInteractableCredit, 1f, 1, 1000);
Dictionary<string, List<BlockedInteractableSpawnPoint>> sceneNameToBlockedInteractableSpawnPoints = _sceneNameToBlockedInteractableSpawnPoints;
Scene activeScene = SceneManager.GetActiveScene();
List<BlockedInteractableSpawnPoint> spawnPoints = sceneNameToBlockedInteractableSpawnPoints.GetValueOrAddDefault(((Scene)(ref activeScene)).name);
Try(DrawSerializationUI);
ImGui.Separator();
if (ImGui.Button("Add Interactable Spawn Point"))
{
Try(delegate
{
//IL_0014: 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_002a: 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_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
CharacterBody body3 = PlayerCharacterMasterController.instances[0].body;
Vector3 val3 = default(Vector3);
((Vector3)(ref val3))..ctor(body3.corePosition.x, body3.corePosition.y, body3.corePosition.z);
Vector3 val4 = default(Vector3);
((Vector3)(ref val4))..ctor(1f, 1f, 1f);
Dictionary<string, List<BlockedInteractableSpawnPoint>> sceneNameToBlockedInteractableSpawnPoints2 = _sceneNameToBlockedInteractableSpawnPoints;
Scene activeScene2 = SceneManager.GetActiveScene();
sceneNameToBlockedInteractableSpawnPoints2.GetValueOrAddDefault(((Scene)(ref activeScene2)).name).Add(new BlockedInteractableSpawnPoint
{
name = $"Spawn Point {spawnPoints.Count + 1}",
boundsMin = val3 - val4,
boundsMax = val3 + val4
});
});
}
ImGui.InputText("Filter by Name", ref spawnPointNameFilter, 256u);
for (int i = 0; i < spawnPoints.Count; i++)
{
BlockedInteractableSpawnPoint item = spawnPoints[i];
if (!string.IsNullOrEmpty(spawnPointNameFilter) && !item.name.Contains(spawnPointNameFilter, StringComparison.OrdinalIgnoreCase))
{
continue;
}
Try(delegate
{
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
ImGui.Text($"[{i}] Name: {item.name}");
if (ImGui.DragFloat3($"Min##{i}", ref item.boundsMin) | ImGui.DragFloat3($"Max##{i}", ref item.boundsMax))
{
UpdateBounds();
}
if (ImGui.Button($"Set Min To Current Player Pos##{i}"))
{
CharacterBody body = PlayerCharacterMasterController.instances[0].body;
Vector3 boundsMin = default(Vector3);
((Vector3)(ref boundsMin))..ctor(body.corePosition.x, body.corePosition.y, body.corePosition.z);
item.boundsMin = boundsMin;
UpdateBounds();
}
if (ImGui.Button($"Set Max To Current Player Pos##{i}"))
{
CharacterBody body2 = PlayerCharacterMasterController.instances[0].body;
Vector3 boundsMax = default(Vector3);
((Vector3)(ref boundsMax))..ctor(body2.corePosition.x, body2.corePosition.y, body2.corePosition.z);
item.boundsMax = boundsMax;
UpdateBounds();
}
if (ImGui.Button($"Remove##{i}"))
{
spawnPoints.RemoveAt(i);
int num = i;
i = num - 1;
}
if (i < spawnPoints.Count - 1)
{
ImGui.Separator();
}
});
void UpdateBounds()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: 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_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: 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)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = new Vector3(item.boundsMin.x, item.boundsMin.y, item.boundsMin.z);
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(item.boundsMax.x, item.boundsMax.y, item.boundsMax.z);
Vector3.Min(val, val2);
Vector3.Max(val, val2);
item.boundsMin = new Vector3(item.boundsMin.x, item.boundsMin.y, item.boundsMin.z);
item.boundsMax = new Vector3(item.boundsMax.x, item.boundsMax.y, item.boundsMax.z);
}
}
ImGui.End();
}
Try(DrawDisallowedInteractableSpawnBoxes);
_ = _isMyUIOpen;
}
private void Update()
{
}
private static void SaveSpawnPoints(string fileName)
{
Directory.CreateDirectory(SaveFolder);
string text = Path.Combine(SaveFolder, fileName);
try
{
string contents = JsonConvert.SerializeObject((object)_sceneNameToBlockedInteractableSpawnPoints, (Formatting)1);
File.WriteAllText(text, contents);
Log.Info("Saved blocked spawn points to " + text);
}
catch (Exception data)
{
Log.Error(data);
}
}
private static void LoadSpawnPoints(string filePath, bool merge = false)
{
if (!File.Exists(filePath))
{
Log.Error("File not found: " + filePath);
return;
}
try
{
Dictionary<string, List<BlockedInteractableSpawnPoint>> dictionary = JsonConvert.DeserializeObject<Dictionary<string, List<BlockedInteractableSpawnPoint>>>(File.ReadAllText(filePath));
if (dictionary == null)
{
Log.Info("No data found in file.");
return;
}
if (merge)
{
foreach (KeyValuePair<string, List<BlockedInteractableSpawnPoint>> item in dictionary)
{
_sceneNameToBlockedInteractableSpawnPoints.GetValueOrAddDefault(item.Key).AddRange(item.Value);
}
}
else
{
_sceneNameToBlockedInteractableSpawnPoints = dictionary;
}
Log.Info($"Loaded blocked spawn points from {filePath} (merge={merge})");
}
catch (Exception data)
{
Log.Error(data);
}
}
private static void DrawSerializationUI()
{
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
if (!ImGui.CollapsingHeader("Spawn Points Serialization"))
{
return;
}
ImGui.Text("Folder: " + SaveFolder);
if (ImGui.Button("Copy Folder Path To Clipboard"))
{
ImGui.SetClipboardText(SaveFolder);
}
if (ImGui.Button("Save To Default.json"))
{
string text = "Default.json";
SaveSpawnPoints(text);
selectedFile = new FileInfo
{
FilePath = Path.Combine(SaveFolder, text),
FileName = text
};
}
ImGui.SameLine();
if (ImGui.Button("Refresh File List"))
{
if (Directory.Exists(SaveFolder))
{
cachedFiles = (from s in Directory.GetFiles(SaveFolder, "*.json")
select new FileInfo
{
FilePath = s,
FileName = Path.GetFileName(s)
}).ToArray();
}
else
{
cachedFiles = new FileInfo[0];
}
}
ImGui.Separator();
ImGui.Text("Available Files:");
if (cachedFiles.Length == 0)
{
ImGui.TextColored(new Vector4(1f, 0f, 0f, 1f), "No files found or folder missing. Refresh List if needed.");
return;
}
FileInfo[] array = cachedFiles;
foreach (FileInfo fileInfo in array)
{
int num;
if (selectedFile != null)
{
num = ((selectedFile == fileInfo) ? 1 : 0);
if (num != 0)
{
ImGui.PushStyleColor((ImGuiCol)0, new Vector4(0f, 1f, 0f, 1f));
}
}
else
{
num = 0;
}
ImGui.Text(fileInfo.FileName);
ImGui.SameLine();
if (ImGui.Button("Load##" + fileInfo.FileName))
{
LoadSpawnPoints(fileInfo.FilePath);
selectedFile = fileInfo;
}
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip("Override existing blocked spawn points with the ones from " + fileInfo.FileName);
}
ImGui.SameLine();
if (ImGui.Button("Merge##" + fileInfo.FileName))
{
LoadSpawnPoints(fileInfo.FilePath, merge: true);
selectedFile = fileInfo;
}
if (ImGui.IsItemHovered())
{
ImGui.SetTooltip("Load or merge blocked spawn points from " + fileInfo.FileName);
}
if (num != 0)
{
ImGui.PopStyleColor();
}
}
}
}
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}
}