using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.Json; using System.Text.Json.Nodes; using System.Text.RegularExpressions; using Agents; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using ExtraObjectiveSetup; using ExtraObjectiveSetup.BaseClasses; using ExtraObjectiveSetup.ExtendedWardenEvents; using ExtraObjectiveSetup.JSON; using FloLib.Networks.Replications; using GTFO.API; using GTFO.API.Utilities; using GameData; using HarmonyLib; using Il2CppInterop.Runtime.Injection; using Il2CppInterop.Runtime.InteropTypes; using Il2CppSystem.Collections.Generic; using MTFO.API; using Microsoft.CodeAnalysis; using Player; using SNetwork; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("AddEvents")] [assembly: AssemblyProduct("AddEvents")] [assembly: AssemblyFileVersion("1.1.3.0")] [assembly: AssemblyInformationalVersion("1.1.3")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.3.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace AddEvents { internal static class LaserRoomConfigResolver { internal static bool TryResolveMainLevelLayoutForExternalConfig(JsonElement element, out uint mainLevelLayout, out string resolvedBy) { mainLevelLayout = 0u; resolvedBy = string.Empty; try { if (element.ValueKind == JsonValueKind.Number && element.TryGetUInt32(out var value)) { mainLevelLayout = value; resolvedBy = "numeric"; return value != 0; } if (element.ValueKind != JsonValueKind.String) { return false; } string text = element.GetString()?.Trim() ?? string.Empty; if (string.IsNullOrWhiteSpace(text)) { return false; } if (uint.TryParse(text, out var result)) { mainLevelLayout = result; resolvedBy = "numeric string"; return result != 0; } if (MTFOPartialDataIdResolver.TryResolve(text, out var id) && id != 0) { mainLevelLayout = id; resolvedBy = "MTFO PartialData:" + text; return true; } if (GameDataBlockBase.HasBlock(text)) { uint blockID = GameDataBlockBase.GetBlockID(text); if (blockID != 0) { mainLevelLayout = blockID; resolvedBy = "LevelLayoutDataBlock:" + text; return true; } } } catch (Exception ex) { AddEventsRuntime.LogThrottled("LaserRoom MainLevelLayout resolver failed: " + ex.Message); } return false; } } internal static class MTFOPartialDataIdResolver { private const string PartialDataPluginGuid = "MTFO.Extension.PartialBlocks"; private const string IdFileName = "_persistentID.json"; private static readonly object Sync = new object(); private static Dictionary? _guidToId; private static bool _loadAttempted; internal static bool TryResolve(string guid, out uint id) { id = 0u; if (string.IsNullOrWhiteSpace(guid)) { return false; } EnsureLoaded(); lock (Sync) { return _guidToId != null && _guidToId.TryGetValue(guid.Trim(), out id); } } private static void EnsureLoaded() { lock (Sync) { if (_loadAttempted) { return; } _loadAttempted = true; try { string text = TryGetPartialDataPathFromPlugin(); if (string.IsNullOrWhiteSpace(text)) { return; } string text2 = Path.Combine(text, "_persistentID.json"); if (File.Exists(text2)) { Dictionary dictionary = ReadPersistentIdFile(text2); if (dictionary.Count > 0) { _guidToId = dictionary; } } } catch (Exception ex) { AddEventsRuntime.LogThrottled("MTFO PartialData persistentID resolver failed: " + ex.Message); } } } private static string TryGetPartialDataPathFromPlugin() { try { if (((BaseChainloader)(object)IL2CPPChainloader.Instance).Plugins.TryGetValue("MTFO.Extension.PartialBlocks", out var value)) { Assembly assembly = ((value == null) ? null : value.Instance?.GetType()?.Assembly); if (assembly != null && (assembly.GetTypes().FirstOrDefault((Type t) => string.Equals(t.Name, "PartialDataManager", StringComparison.Ordinal))?.GetProperty("PartialDataPath", BindingFlags.Static | BindingFlags.Public))?.GetValue(null) is string text && !string.IsNullOrWhiteSpace(text)) { return text; } } } catch { } return DiscoverPartialDataPathFromFileSystem(); } private static string DiscoverPartialDataPathFromFileSystem() { try { foreach (string item in Directory.EnumerateFiles(Paths.PluginPath, "_persistentID.json", SearchOption.AllDirectories)) { string directoryName = Path.GetDirectoryName(item); if (!string.IsNullOrWhiteSpace(directoryName)) { return directoryName; } } } catch { } return string.Empty; } private static Dictionary ReadPersistentIdFile(string idFilePath) { Dictionary dictionary = new Dictionary(StringComparer.OrdinalIgnoreCase); string text = File.ReadAllText(idFilePath); try { using JsonDocument jsonDocument = JsonDocument.Parse(text, new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip, AllowTrailingCommas = true }); if (jsonDocument.RootElement.ValueKind == JsonValueKind.Array) { foreach (JsonElement item in jsonDocument.RootElement.EnumerateArray()) { if (TryReadGuidEntry(item, out string guid, out uint id)) { dictionary[guid] = id; } } } else if (jsonDocument.RootElement.ValueKind == JsonValueKind.Object) { foreach (JsonProperty item2 in jsonDocument.RootElement.EnumerateObject()) { if (TryReadUIntElement(item2.Value, out var id2) && !string.IsNullOrWhiteSpace(item2.Name)) { dictionary[item2.Name.Trim()] = id2; } } } } catch { foreach (Match item3 in Regex.Matches(text, "\\{[^{}]*\\\"GUID\\\"\\s*:\\s*\\\"(?(?:\\\\.|[^\\\"])*)\\\"[^{}]*\\\"ID\\\"\\s*:\\s*(?\\d+)[^{}]*\\}", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.CultureInvariant)) { string text2 = Regex.Unescape(item3.Groups["guid"].Value).Trim(); if (!string.IsNullOrWhiteSpace(text2) && uint.TryParse(item3.Groups["id"].Value, out var result)) { dictionary[text2] = result; } } } return dictionary; } private static bool TryReadGuidEntry(JsonElement entry, out string guid, out uint id) { guid = string.Empty; id = 0u; if (entry.ValueKind != JsonValueKind.Object) { return false; } foreach (JsonProperty item in entry.EnumerateObject()) { if (string.Equals(item.Name, "GUID", StringComparison.OrdinalIgnoreCase) || string.Equals(item.Name, "Guid", StringComparison.OrdinalIgnoreCase) || string.Equals(item.Name, "persistentID", StringComparison.OrdinalIgnoreCase)) { guid = ((item.Value.ValueKind == JsonValueKind.String) ? (item.Value.GetString() ?? string.Empty).Trim() : item.Value.ToString().Trim()); } else if (string.Equals(item.Name, "ID", StringComparison.OrdinalIgnoreCase) || string.Equals(item.Name, "Id", StringComparison.OrdinalIgnoreCase)) { TryReadUIntElement(item.Value, out id); } } if (!string.IsNullOrWhiteSpace(guid)) { return id != 0; } return false; } private static bool TryReadUIntElement(JsonElement element, out uint id) { id = 0u; if (element.ValueKind == JsonValueKind.Number && element.TryGetUInt32(out var value)) { id = value; return true; } if (element.ValueKind == JsonValueKind.String && uint.TryParse(element.GetString(), out var result)) { id = result; return true; } return false; } } internal sealed class AddEventsType2004EventData { internal int Count { get; set; } internal bool Enabled { get; set; } = true; internal bool HasEnabled { get; set; } internal Vector3 Position { get; set; } internal bool HasPosition { get; set; } internal float FogTransitionDuration { get; set; } internal bool HasFogTransitionDuration { get; set; } internal List Events { get; set; } = new List(); } internal readonly struct AddEventsType2004Signature : IEquatable { private readonly int _count; private readonly bool _enabled; private readonly int _radius1000; private readonly int _x1000; private readonly int _y1000; private readonly int _z1000; internal AddEventsType2004Signature(int count, bool enabled, float radius, Vector3 position) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) _count = count; _enabled = enabled; _radius1000 = Quantize(radius); _x1000 = Quantize(position.x); _y1000 = Quantize(position.y); _z1000 = Quantize(position.z); } internal static AddEventsType2004Signature FromEvent(WardenObjectiveEventData e) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) return new AddEventsType2004Signature(e.Count, e.Enabled, e.FogTransitionDuration, e.Position); } public bool Equals(AddEventsType2004Signature other) { if (_count == other._count && _enabled == other._enabled && _radius1000 == other._radius1000 && _x1000 == other._x1000 && _y1000 == other._y1000) { return _z1000 == other._z1000; } return false; } public override bool Equals(object? obj) { if (obj is AddEventsType2004Signature other) { return Equals(other); } return false; } public override int GetHashCode() { return HashCode.Combine(_count, _enabled, _radius1000, _x1000, _y1000, _z1000); } private static int Quantize(float value) { if (float.IsNaN(value) || float.IsInfinity(value)) { return 0; } return (int)Math.Round(value * 1000f); } } internal static class AddEventsType2004SidecarStore { private static readonly Dictionary ByEventPointer = new Dictionary(); private static readonly Dictionary> ByLooseSignature = new Dictionary>(); private static readonly List LooseFallback = new List(); private static readonly HashSet RegisteredLooseFingerprints = new HashSet(StringComparer.Ordinal); private static readonly HashSet AmbiguousWarningPrinted = new HashSet(); private static bool _isDeserializingSidecarEvents; private static bool _diskScanned; internal static bool TryGet(WardenObjectiveEventData eventData, out AddEventsType2004EventData data) { if (eventData != null && ByEventPointer.TryGetValue(((Il2CppObjectBase)eventData).Pointer, out data)) { return true; } if (eventData != null) { AddEventsType2004Signature addEventsType2004Signature = AddEventsType2004Signature.FromEvent(eventData); if (ByLooseSignature.TryGetValue(addEventsType2004Signature, out List value) && value.Count > 0) { data = value[0]; if (value.Count > 1 && AmbiguousWarningPrinted.Add(addEventsType2004Signature)) { ManualLogSource? log = AddEventsRuntime.Log; if (log != null) { log.LogWarning((object)"AddEvents Type 2004 sidecar fallback matched multiple definitions with the same vanilla signature. Using the first match. Make Count/Position/FogTransitionDuration/Enabled unique if this is not intended."); } } ByEventPointer[((Il2CppObjectBase)eventData).Pointer] = data; return true; } } if (LooseFallback.Count == 1) { data = LooseFallback[0]; if (eventData != null) { ByEventPointer[((Il2CppObjectBase)eventData).Pointer] = data; } return true; } data = null; return false; } internal static void ScanDiskForDefinitions() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown if (_diskScanned) { return; } _diskScanned = true; int num = 0; int num2 = 0; int num3 = 0; bool flag = default(bool); ManualLogSource log; try { foreach (string item in EnumerateCandidateJsonFiles()) { num++; string text; try { text = File.ReadAllText(item); } catch { continue; } if (text.IndexOf("2004", StringComparison.OrdinalIgnoreCase) >= 0) { List list = ParseType2004Nodes(text); if (list.Count != 0) { num2++; num3 += list.Count; RegisterLoose(list); } } } } catch (Exception ex) { log = AddEventsRuntime.Log; if (log != null) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(48, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2004 disk sidecar scan failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } if (num3 > 0) { log = AddEventsRuntime.Log; if (log != null) { BepInExMessageLogInterpolatedStringHandler val2 = new BepInExMessageLogInterpolatedStringHandler(96, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("AddEvents Type 2004 disk sidecar scan complete. FilesScanned="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", FilesWithType2004="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", Definitions="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num3); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log.LogMessage(val2); } return; } log = AddEventsRuntime.Log; if (log != null) { BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(77, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("AddEvents Type 2004 disk sidecar scan complete. FilesScanned="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", Definitions=0."); } log.LogDebug(val3); } } internal static void Capture(string json, object? result) { //IL_008c: 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_00fb: Invalid comparison between Unknown and I4 if (_isDeserializingSidecarEvents || string.IsNullOrWhiteSpace(json) || json.IndexOf("2004", StringComparison.OrdinalIgnoreCase) < 0) { return; } List list = ParseType2004Nodes(json); if (list.Count == 0) { return; } RegisterLoose(list); if (result == null) { return; } List list2 = new List(); CollectEvents(result, list2, new HashSet(ReferenceEqualityComparer.Instance), 0); if (list2.Count == 0) { return; } Dictionary> dictionary = new Dictionary>(); foreach (AddEventsType2004EventData item in list) { AddEventsType2004Signature key = new AddEventsType2004Signature(item.Count, item.Enabled, item.FogTransitionDuration, item.Position); if (!dictionary.TryGetValue(key, out var value)) { value = (dictionary[key] = new Queue()); } value.Enqueue(item); } Queue queue2 = new Queue(list); foreach (WardenObjectiveEventData item2 in list2) { if ((int)item2.Type == 2004) { AddEventsType2004EventData addEventsType2004EventData = null; AddEventsType2004Signature key2 = AddEventsType2004Signature.FromEvent(item2); if (dictionary.TryGetValue(key2, out var value2) && value2.Count > 0) { addEventsType2004EventData = value2.Dequeue(); } else if (queue2.Count > 0) { addEventsType2004EventData = queue2.Dequeue(); } if (addEventsType2004EventData != null) { ByEventPointer[((Il2CppObjectBase)item2).Pointer] = addEventsType2004EventData; } } } } private static void RegisterLoose(IEnumerable parsed) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) foreach (AddEventsType2004EventData item in parsed) { string looseFingerprint = GetLooseFingerprint(item); if (RegisteredLooseFingerprints.Add(looseFingerprint)) { AddEventsType2004Signature key = new AddEventsType2004Signature(item.Count, item.Enabled, item.FogTransitionDuration, item.Position); if (!ByLooseSignature.TryGetValue(key, out List value)) { value = new List(1); ByLooseSignature[key] = value; } value.Add(item); LooseFallback.Add(item); } } } private static string GetLooseFingerprint(AddEventsType2004EventData data) { //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) //IL_0028: Expected I4, but got Unknown //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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) int num = 17; foreach (WardenObjectiveEventData @event in data.Events) { num = num * 31 + @event.Type; num = num * 31 + @event.Count; num = num * 31 + ((object)@event.LocalIndex/*cast due to .constrained prefix*/).GetHashCode(); num = num * 31 + ((object)@event.Layer/*cast due to .constrained prefix*/).GetHashCode(); num = num * 31 + ((object)@event.DimensionIndex/*cast due to .constrained prefix*/).GetHashCode(); num = num * 31 + ((object)@event.Position/*cast due to .constrained prefix*/).GetHashCode(); num = num * 31 + @event.FogTransitionDuration.GetHashCode(); } return string.Join("|", data.Count, data.Enabled, data.FogTransitionDuration, data.Position.x, data.Position.y, data.Position.z, data.Events.Count, num); } private static IEnumerable EnumerateCandidateJsonFiles() { HashSet roots = new HashSet(StringComparer.OrdinalIgnoreCase); AddRoot(Paths.PluginPath); AddRoot(Path.Combine(Paths.BepInExRootPath, "GameData")); AddRoot(Path.Combine(Paths.BepInExRootPath, "Custom")); foreach (string item in roots) { IEnumerable enumerable; try { enumerable = Directory.EnumerateFiles(item, "*.json", SearchOption.AllDirectories).ToArray(); } catch { continue; } foreach (string item2 in enumerable) { yield return item2; } } void AddRoot(string? root) { if (!string.IsNullOrWhiteSpace(root) && Directory.Exists(root)) { roots.Add(Path.GetFullPath(root)); } } } private static List ParseType2004Nodes(string json) { List list = new List(); try { JsonNode jsonNode = JsonNode.Parse(json, new JsonNodeOptions { PropertyNameCaseInsensitive = true }, new JsonDocumentOptions { AllowTrailingCommas = true, CommentHandling = JsonCommentHandling.Skip }); if (jsonNode != null) { TraverseJson(jsonNode, list); } } catch { } return list; } private static void TraverseJson(JsonNode node, List output) { if (node is JsonObject jsonObject) { if (IsType2004Object(jsonObject)) { output.Add(ParseEventData(jsonObject)); } { foreach (KeyValuePair item in jsonObject) { if (item.Value != null) { TraverseJson(item.Value, output); } } return; } } if (!(node is JsonArray jsonArray)) { return; } foreach (JsonNode item2 in jsonArray) { if (item2 != null) { TraverseJson(item2, output); } } } private static bool IsType2004Object(JsonObject obj) { if (!obj.TryGetPropertyValue("Type", out JsonNode jsonNode)) { return false; } if (jsonNode is JsonValue jsonValue) { if (jsonValue.TryGetValue(out var value)) { return value == 2004; } if (jsonValue.TryGetValue(out string value2)) { if (!string.Equals(value2, "2004", StringComparison.OrdinalIgnoreCase)) { return string.Equals(value2, "AddPlayersToDeathEventGroup", StringComparison.OrdinalIgnoreCase); } return true; } } return false; } private static AddEventsType2004EventData ParseEventData(JsonObject obj) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) JsonNode jsonNode; AddEventsType2004EventData addEventsType2004EventData = new AddEventsType2004EventData { Count = ReadInt(obj, "Count", 0), HasEnabled = obj.ContainsKey("Enabled"), Enabled = ReadBool(obj, "Enabled", fallback: true), HasPosition = obj.ContainsKey("Position"), Position = ReadVector3(obj.TryGetPropertyValue("Position", out jsonNode) ? jsonNode : null), HasFogTransitionDuration = obj.ContainsKey("FogTransitionDuration"), FogTransitionDuration = ReadFloat(obj, "FogTransitionDuration", 0f) }; if (obj.TryGetPropertyValue("Events", out JsonNode jsonNode2) && jsonNode2 != null) { addEventsType2004EventData.Events = DeserializeEvents(jsonNode2.ToJsonString()); } return addEventsType2004EventData; } private static List DeserializeEvents(string json) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown try { _isDeserializingSidecarEvents = true; return EOSJson.Deserialize>(json) ?? new List(); } catch (Exception ex) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(59, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2004 could not deserialize nested Events: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } return new List(); } finally { _isDeserializingSidecarEvents = false; } } private static void CollectEvents(object obj, List output, HashSet visited, int depth) { if (obj == null || depth > 12 || !visited.Add(obj)) { return; } WardenObjectiveEventData val = (WardenObjectiveEventData)((obj is WardenObjectiveEventData) ? obj : null); if (val != null) { output.Add(val); return; } if (obj is IEnumerable enumerable && !(obj is string)) { foreach (object item in enumerable) { if (item != null) { CollectEvents(item, output, visited, depth + 1); } } return; } Type type = obj.GetType(); if (type.IsPrimitive || type.IsEnum || type == typeof(string)) { return; } PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (PropertyInfo propertyInfo in properties) { if (propertyInfo.GetIndexParameters().Length != 0) { continue; } try { object value = propertyInfo.GetValue(obj); if (value != null) { CollectEvents(value, output, visited, depth + 1); } } catch { } } FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { try { object value2 = fieldInfo.GetValue(obj); if (value2 != null) { CollectEvents(value2, output, visited, depth + 1); } } catch { } } } private static int ReadInt(JsonObject node, string name, int fallback) { try { if (node.TryGetPropertyValue(name, out JsonNode jsonNode) && jsonNode is JsonValue jsonValue) { if (jsonValue.TryGetValue(out var value)) { return value; } if (jsonValue.TryGetValue(out string value2) && int.TryParse(value2, out value)) { return value; } } } catch { } return fallback; } private static float ReadFloat(JsonObject node, string name, float fallback) { try { if (node.TryGetPropertyValue(name, out JsonNode jsonNode) && jsonNode is JsonValue jsonValue) { if (jsonValue.TryGetValue(out var value)) { return value; } if (jsonValue.TryGetValue(out var value2)) { return (float)value2; } if (jsonValue.TryGetValue(out string value3) && float.TryParse(value3, NumberStyles.Float, CultureInfo.InvariantCulture, out value)) { return value; } } } catch { } return fallback; } private static bool ReadBool(JsonObject node, string name, bool fallback) { try { if (node.TryGetPropertyValue(name, out JsonNode jsonNode) && jsonNode is JsonValue jsonValue) { if (jsonValue.TryGetValue(out var value)) { return value; } if (jsonValue.TryGetValue(out string value2) && bool.TryParse(value2, out value)) { return value; } } } catch { } return fallback; } private static Vector3 ReadVector3(JsonNode? node) { //IL_0040: 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) if (!(node is JsonObject node2)) { return Vector3.zero; } return new Vector3(ReadFloat(node2, "x", 0f), ReadFloat(node2, "y", 0f), ReadFloat(node2, "z", 0f)); } } internal static class AddEventsDeathEventGroupEvents { internal static void AddPlayersToDeathEventGroup(WardenObjectiveEventData eventData) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown if (!AddEventsNetworkEventProxy.EnsureHostExecution(AddEventsCustomEventType.AddPlayersToDeathEventGroup, eventData)) { return; } if (!AddEventsType2004SidecarStore.TryGet(eventData, out AddEventsType2004EventData data)) { data = new AddEventsType2004EventData { Count = eventData.Count, Enabled = eventData.Enabled, Position = eventData.Position, HasPosition = true, FogTransitionDuration = eventData.FogTransitionDuration, HasFogTransitionDuration = (eventData.FogTransitionDuration > 0f), Events = new List() }; } bool flag = default(bool); ManualLogSource log; if (!data.Enabled) { AddEventsDeathEventGroupManager.Current.SetGroupEnabled(data.Count, enabled: false); log = AddEventsRuntime.Log; if (log != null) { BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(60, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2004 death event group "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(data.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" disabled and cleared."); } log.LogDebug(val); } return; } List list = ResolvePlayers(eventData, data); int num = AddEventsDeathEventGroupManager.Current.AddPlayersToGroup(data.Count, list, data.Events); log = AddEventsRuntime.Log; if (log != null) { BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(67, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2004 death event group "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(data.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": added "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(list.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" player(s), Events="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(data.Events.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogDebug(val); } } private static List ResolvePlayers(WardenObjectiveEventData eventData, AddEventsType2004EventData data) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) float num = (data.HasFogTransitionDuration ? data.FogTransitionDuration : eventData.FogTransitionDuration); Vector3 origin = (data.HasPosition ? data.Position : eventData.Position); if (num > 0f) { return GetPlayersInRadius(origin, num); } return GetAllPlayers(); } private static List GetPlayersInRadius(Vector3 origin, float radius) { //IL_0030: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) float num = radius * radius; List list = new List(); Enumerator enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator(); while (enumerator.MoveNext()) { PlayerAgent current = enumerator.Current; if (!((Object)(object)current == (Object)null) && ((Agent)current).Alive) { Vector3 val = ((Agent)current).Position - origin; if (((Vector3)(ref val)).sqrMagnitude <= num) { list.Add(current); } } } return list; } private static List GetAllPlayers() { List list = new List(); Enumerator enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator(); while (enumerator.MoveNext()) { PlayerAgent current = enumerator.Current; if ((Object)(object)current != (Object)null && ((Agent)current).Alive) { list.Add(current); } } return list; } } public struct AddEventsDeathEventGroupReplicationState { public bool enabled; public bool checkP1; public bool checkP2; public bool checkP3; public bool checkP4; } internal sealed class AddEventsDeathEventGroup { internal const int MaxPlayers = 4; private readonly bool[] _slots = new bool[4]; private readonly Dictionary _lastDeathFrameBySlot = new Dictionary(); private StateReplicator? _stateReplicator; internal bool Enabled { get; private set; } internal List Events { get; set; } = new List(); internal int Count { get { int num = 0; for (int i = 0; i < _slots.Length; i++) { if (_slots[i]) { num++; } } return num; } } internal bool SetPlayerInGroup(int slot, bool inGroup) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if (!IsValidPlayerSlot(slot)) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(63, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2004 invalid player slot index "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(slot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; expected [0, "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(4); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } log.LogError(val); } return false; } if (_slots[slot] == inGroup) { return false; } int count = Count; _slots[slot] = inGroup; if (inGroup) { _lastDeathFrameBySlot.Remove(slot); } int count2 = Count; if (count == 0 && count2 > 0) { Enabled = true; } else if (count > 0 && count2 == 0) { Enabled = false; } Sync(); return true; } internal void Toggle(bool enabled) { if (!enabled) { ClearAndDisable(); } else if (!Enabled) { Enabled = true; Sync(); } } internal void ClearAndDisable() { bool flag = Enabled || Count > 0 || Events.Count > 0 || _lastDeathFrameBySlot.Count > 0; Enabled = false; for (int i = 0; i < _slots.Length; i++) { _slots[i] = false; } _lastDeathFrameBySlot.Clear(); Events = new List(); if (flag) { Sync(); } } internal bool ContainsSlot(int slot) { if (IsValidPlayerSlot(slot)) { return _slots[slot]; } return false; } internal bool TryMarkDeathFrame(int slot, int frame) { if (_lastDeathFrameBySlot.TryGetValue(slot, out var value) && value == frame) { return false; } _lastDeathFrameBySlot[slot] = frame; return true; } internal void ResetSynced() { Reset(); Sync(); } internal void ResetUnsynced() { Reset(); _stateReplicator?.SetStateUnsynced(GetSyncState()); } private void Reset() { Enabled = false; for (int i = 0; i < _slots.Length; i++) { _slots[i] = false; } _lastDeathFrameBySlot.Clear(); Events = new List(); } private void Sync() { if (!SNet.IsMaster) { ManualLogSource? log = AddEventsRuntime.Log; if (log != null) { log.LogWarning((object)"AddEvents Type 2004 death event group sync blocked on client; state changes must be executed by host."); } } else { _stateReplicator?.SetState(GetSyncState()); } } private void OnStateChanged(AddEventsDeathEventGroupReplicationState oldState, AddEventsDeathEventGroupReplicationState newState, bool isRecall) { if (isRecall) { Enabled = newState.enabled; _slots[0] = newState.checkP1; _slots[1] = newState.checkP2; _slots[2] = newState.checkP3; _slots[3] = newState.checkP4; } } private AddEventsDeathEventGroupReplicationState GetSyncState() { return new AddEventsDeathEventGroupReplicationState { enabled = Enabled, checkP1 = _slots[0], checkP2 = _slots[1], checkP3 = _slots[2], checkP4 = _slots[3] }; } internal static AddEventsDeathEventGroup? Instantiate() { uint num = EOSNetworking.AllotForeverReplicatorID(); if (num == 0) { ManualLogSource? log = AddEventsRuntime.Log; if (log != null) { log.LogError((object)"AddEvents Type 2004 could not allocate a network replicator id."); } return null; } AddEventsDeathEventGroup addEventsDeathEventGroup = new AddEventsDeathEventGroup(); addEventsDeathEventGroup._stateReplicator = AddEventsStateReplicatorCompat.Create(num, default(AddEventsDeathEventGroupReplicationState), (LifeTimeType)0, "AddEvents Type 2004"); if (addEventsDeathEventGroup._stateReplicator == null) { return null; } addEventsDeathEventGroup._stateReplicator.OnStateChanged += addEventsDeathEventGroup.OnStateChanged; addEventsDeathEventGroup.ResetUnsynced(); return addEventsDeathEventGroup; } private static bool IsValidPlayerSlot(int slot) { if (slot >= 0) { return slot < 4; } return false; } private AddEventsDeathEventGroup() { } } internal sealed class AddEventsDeathEventGroupManager { internal const int MaxGroups = 4; private readonly List _groups = new List(); private bool _initialized; internal static AddEventsDeathEventGroupManager Current { get; } = new AddEventsDeathEventGroupManager(); internal void Init() { if (!_initialized) { _initialized = true; EventAPI.OnManagersSetup += SetupGroups; LevelAPI.OnBuildStart += ResetUnsynced; LevelAPI.OnLevelCleanup += ResetUnsynced; } } internal int AddPlayersToGroup(int groupIndex, IEnumerable players, List events) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown EnsureGroupsReady(); if (!TryGetGroup(groupIndex, out AddEventsDeathEventGroup group)) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(61, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2004 group index must be between 0 and "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_groups.Count - 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; got "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(groupIndex); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogError(val); } return 0; } if (events.Count > 0) { group.Events = events; } int num = 0; foreach (PlayerAgent player in players) { try { if (group.SetPlayerInGroup(player.PlayerSlotIndex, inGroup: true)) { num++; } } catch { } } return num; } internal void SetGroupEnabled(int groupIndex, bool enabled) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown EnsureGroupsReady(); if (!TryGetGroup(groupIndex, out AddEventsDeathEventGroup group)) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(61, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2004 group index must be between 0 and "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_groups.Count - 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; got "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(groupIndex); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogError(val); } } else { group.Toggle(enabled); } } internal void ResetSynced() { foreach (AddEventsDeathEventGroup group in _groups) { group.ResetSynced(); } } internal void ResetUnsynced() { foreach (AddEventsDeathEventGroup group in _groups) { group.ResetUnsynced(); } } internal void OnPlayerDied(PlayerAgent? player) { //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown if ((Object)(object)player == (Object)null || !SNet.IsMaster) { return; } int playerSlotIndex; try { playerSlotIndex = player.PlayerSlotIndex; } catch { return; } int frameCount = Time.frameCount; bool flag = default(bool); for (int i = 0; i < _groups.Count; i++) { AddEventsDeathEventGroup addEventsDeathEventGroup = _groups[i]; if (!addEventsDeathEventGroup.Enabled || !addEventsDeathEventGroup.ContainsSlot(playerSlotIndex) || !addEventsDeathEventGroup.TryMarkDeathFrame(playerSlotIndex, frameCount)) { continue; } ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(79, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2004 death event group "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": player slot "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(playerSlotIndex); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" died; executing "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(addEventsDeathEventGroup.Events.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" event(s)."); } log.LogDebug(val); } foreach (WardenObjectiveEventData @event in addEventsDeathEventGroup.Events) { try { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(@event, (eWardenObjectiveEventTrigger)0, true, 0f); } catch (Exception ex) { log = AddEventsRuntime.Log; if (log != null) { BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(43, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("AddEvents Type 2004 nested event failed: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log.LogWarning(val2); } } } } } private void SetupGroups() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (_groups.Count > 0) { return; } bool flag = default(bool); for (int i = 0; i < 4; i++) { AddEventsDeathEventGroup addEventsDeathEventGroup = AddEventsDeathEventGroup.Instantiate(); if (addEventsDeathEventGroup == null) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(58, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2004 instantiated death event group count: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_groups.Count); } log.LogError(val); } break; } _groups.Add(addEventsDeathEventGroup); } } private void EnsureGroupsReady() { if (_groups.Count == 0) { SetupGroups(); } } private bool TryGetGroup(int groupIndex, out AddEventsDeathEventGroup? group) { if (groupIndex < 0 || groupIndex >= _groups.Count) { group = null; return false; } group = _groups[groupIndex]; return true; } private AddEventsDeathEventGroupManager() { } } [HarmonyPatch(typeof(Dam_PlayerDamageBase), "ReceiveSetDead")] internal static class AddEventsDeathEvent_DamPlayerDamageBaseReceiveSetDeadPatch { private static void Postfix(Dam_PlayerDamageBase __instance) { AddEventsDeathEventGroupManager.Current.OnPlayerDied(TryGetOwner(__instance)); } internal static PlayerAgent? TryGetOwner(Dam_PlayerDamageBase? damageBase) { if ((Object)(object)damageBase == (Object)null) { return null; } try { return damageBase.Owner; } catch { return null; } } } [HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveSetDead")] internal static class AddEventsDeathEvent_DamPlayerDamageLocalReceiveSetDeadPatch { private static void Postfix(Dam_PlayerDamageLocal __instance) { AddEventsDeathEventGroupManager.Current.OnPlayerDied(AddEventsDeathEvent_DamPlayerDamageBaseReceiveSetDeadPatch.TryGetOwner((Dam_PlayerDamageBase?)(object)__instance)); } } internal sealed class AddEventsType2005EventData { internal int Count { get; set; } internal bool Enabled { get; set; } = true; internal bool HasEnabled { get; set; } internal Vector3 Position { get; set; } internal bool HasPosition { get; set; } internal float FogTransitionDuration { get; set; } internal bool HasFogTransitionDuration { get; set; } internal List Events { get; set; } = new List(); } internal readonly struct AddEventsType2005Signature : IEquatable { private readonly int _count; private readonly bool _enabled; private readonly int _radius1000; private readonly int _x1000; private readonly int _y1000; private readonly int _z1000; internal AddEventsType2005Signature(int count, bool enabled, float radius, Vector3 position) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) _count = count; _enabled = enabled; _radius1000 = Quantize(radius); _x1000 = Quantize(position.x); _y1000 = Quantize(position.y); _z1000 = Quantize(position.z); } internal static AddEventsType2005Signature FromEvent(WardenObjectiveEventData e) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) return new AddEventsType2005Signature(e.Count, e.Enabled, e.FogTransitionDuration, e.Position); } public bool Equals(AddEventsType2005Signature other) { if (_count == other._count && _enabled == other._enabled && _radius1000 == other._radius1000 && _x1000 == other._x1000 && _y1000 == other._y1000) { return _z1000 == other._z1000; } return false; } public override bool Equals(object? obj) { if (obj is AddEventsType2005Signature other) { return Equals(other); } return false; } public override int GetHashCode() { return HashCode.Combine(_count, _enabled, _radius1000, _x1000, _y1000, _z1000); } private static int Quantize(float value) { if (float.IsNaN(value) || float.IsInfinity(value)) { return 0; } return (int)Math.Round(value * 1000f); } } internal static class AddEventsType2005SidecarStore { private static readonly Dictionary ByEventPointer = new Dictionary(); private static readonly Dictionary> ByLooseSignature = new Dictionary>(); private static readonly List LooseFallback = new List(); private static readonly HashSet RegisteredLooseFingerprints = new HashSet(StringComparer.Ordinal); private static readonly HashSet AmbiguousWarningPrinted = new HashSet(); private static bool _isDeserializingSidecarEvents; private static bool _diskScanned; internal static bool TryGet(WardenObjectiveEventData eventData, out AddEventsType2005EventData data) { if (eventData != null && ByEventPointer.TryGetValue(((Il2CppObjectBase)eventData).Pointer, out data)) { return true; } if (eventData != null) { AddEventsType2005Signature addEventsType2005Signature = AddEventsType2005Signature.FromEvent(eventData); if (ByLooseSignature.TryGetValue(addEventsType2005Signature, out List value) && value.Count > 0) { data = value[0]; if (value.Count > 1 && AmbiguousWarningPrinted.Add(addEventsType2005Signature)) { ManualLogSource? log = AddEventsRuntime.Log; if (log != null) { log.LogWarning((object)"AddEvents Type 2005 sidecar fallback matched multiple definitions with the same vanilla signature. Using the first match. Make Count/Position/FogTransitionDuration/Enabled unique if this is not intended."); } } ByEventPointer[((Il2CppObjectBase)eventData).Pointer] = data; return true; } } if (LooseFallback.Count == 1) { data = LooseFallback[0]; if (eventData != null) { ByEventPointer[((Il2CppObjectBase)eventData).Pointer] = data; } return true; } data = null; return false; } internal static void ScanDiskForDefinitions() { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown if (_diskScanned) { return; } _diskScanned = true; int num = 0; int num2 = 0; int num3 = 0; bool flag = default(bool); ManualLogSource log; try { foreach (string item in EnumerateCandidateJsonFiles()) { num++; string text; try { text = File.ReadAllText(item); } catch { continue; } if (text.IndexOf("2005", StringComparison.OrdinalIgnoreCase) >= 0) { List list = ParseType2005Nodes(text); if (list.Count != 0) { num2++; num3 += list.Count; RegisterLoose(list); } } } } catch (Exception ex) { log = AddEventsRuntime.Log; if (log != null) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(48, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2005 disk sidecar scan failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } if (num3 > 0) { log = AddEventsRuntime.Log; if (log != null) { BepInExMessageLogInterpolatedStringHandler val2 = new BepInExMessageLogInterpolatedStringHandler(96, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("AddEvents Type 2005 disk sidecar scan complete. FilesScanned="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", FilesWithType2005="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", Definitions="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num3); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log.LogMessage(val2); } return; } log = AddEventsRuntime.Log; if (log != null) { BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(77, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("AddEvents Type 2005 disk sidecar scan complete. FilesScanned="); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", Definitions=0."); } log.LogDebug(val3); } } internal static void Capture(string json, object? result) { //IL_008c: 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_00fb: Invalid comparison between Unknown and I4 if (_isDeserializingSidecarEvents || string.IsNullOrWhiteSpace(json) || json.IndexOf("2005", StringComparison.OrdinalIgnoreCase) < 0) { return; } List list = ParseType2005Nodes(json); if (list.Count == 0) { return; } RegisterLoose(list); if (result == null) { return; } List list2 = new List(); CollectEvents(result, list2, new HashSet(ReferenceEqualityComparer.Instance), 0); if (list2.Count == 0) { return; } Dictionary> dictionary = new Dictionary>(); foreach (AddEventsType2005EventData item in list) { AddEventsType2005Signature key = new AddEventsType2005Signature(item.Count, item.Enabled, item.FogTransitionDuration, item.Position); if (!dictionary.TryGetValue(key, out var value)) { value = (dictionary[key] = new Queue()); } value.Enqueue(item); } Queue queue2 = new Queue(list); foreach (WardenObjectiveEventData item2 in list2) { if ((int)item2.Type == 2005) { AddEventsType2005EventData addEventsType2005EventData = null; AddEventsType2005Signature key2 = AddEventsType2005Signature.FromEvent(item2); if (dictionary.TryGetValue(key2, out var value2) && value2.Count > 0) { addEventsType2005EventData = value2.Dequeue(); } else if (queue2.Count > 0) { addEventsType2005EventData = queue2.Dequeue(); } if (addEventsType2005EventData != null) { ByEventPointer[((Il2CppObjectBase)item2).Pointer] = addEventsType2005EventData; } } } } private static void RegisterLoose(IEnumerable parsed) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) foreach (AddEventsType2005EventData item in parsed) { string looseFingerprint = GetLooseFingerprint(item); if (RegisteredLooseFingerprints.Add(looseFingerprint)) { AddEventsType2005Signature key = new AddEventsType2005Signature(item.Count, item.Enabled, item.FogTransitionDuration, item.Position); if (!ByLooseSignature.TryGetValue(key, out List value)) { value = new List(1); ByLooseSignature[key] = value; } value.Add(item); LooseFallback.Add(item); } } } private static string GetLooseFingerprint(AddEventsType2005EventData data) { //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) //IL_0028: Expected I4, but got Unknown //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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_0108: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) int num = 17; foreach (WardenObjectiveEventData @event in data.Events) { num = num * 31 + @event.Type; num = num * 31 + @event.Count; num = num * 31 + ((object)@event.LocalIndex/*cast due to .constrained prefix*/).GetHashCode(); num = num * 31 + ((object)@event.Layer/*cast due to .constrained prefix*/).GetHashCode(); num = num * 31 + ((object)@event.DimensionIndex/*cast due to .constrained prefix*/).GetHashCode(); num = num * 31 + ((object)@event.Position/*cast due to .constrained prefix*/).GetHashCode(); num = num * 31 + @event.FogTransitionDuration.GetHashCode(); } return string.Join("|", data.Count, data.Enabled, data.FogTransitionDuration, data.Position.x, data.Position.y, data.Position.z, data.Events.Count, num); } private static IEnumerable EnumerateCandidateJsonFiles() { HashSet roots = new HashSet(StringComparer.OrdinalIgnoreCase); AddRoot(Paths.PluginPath); AddRoot(Path.Combine(Paths.BepInExRootPath, "GameData")); AddRoot(Path.Combine(Paths.BepInExRootPath, "Custom")); foreach (string item in roots) { IEnumerable enumerable; try { enumerable = Directory.EnumerateFiles(item, "*.json", SearchOption.AllDirectories).ToArray(); } catch { continue; } foreach (string item2 in enumerable) { yield return item2; } } void AddRoot(string? root) { if (!string.IsNullOrWhiteSpace(root) && Directory.Exists(root)) { roots.Add(Path.GetFullPath(root)); } } } private static List ParseType2005Nodes(string json) { List list = new List(); try { JsonNode jsonNode = JsonNode.Parse(json, new JsonNodeOptions { PropertyNameCaseInsensitive = true }, new JsonDocumentOptions { AllowTrailingCommas = true, CommentHandling = JsonCommentHandling.Skip }); if (jsonNode != null) { TraverseJson(jsonNode, list); } } catch { } return list; } private static void TraverseJson(JsonNode node, List output) { if (node is JsonObject jsonObject) { if (IsType2005Object(jsonObject)) { output.Add(ParseEventData(jsonObject)); } { foreach (KeyValuePair item in jsonObject) { if (item.Value != null) { TraverseJson(item.Value, output); } } return; } } if (!(node is JsonArray jsonArray)) { return; } foreach (JsonNode item2 in jsonArray) { if (item2 != null) { TraverseJson(item2, output); } } } private static bool IsType2005Object(JsonObject obj) { if (!obj.TryGetPropertyValue("Type", out JsonNode jsonNode)) { return false; } if (jsonNode is JsonValue jsonValue) { if (jsonValue.TryGetValue(out var value)) { return value == 2005; } if (jsonValue.TryGetValue(out string value2)) { if (!string.Equals(value2, "2005", StringComparison.OrdinalIgnoreCase)) { return string.Equals(value2, "AddPlayersToAllDownEventGroup", StringComparison.OrdinalIgnoreCase); } return true; } } return false; } private static AddEventsType2005EventData ParseEventData(JsonObject obj) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) JsonNode jsonNode; AddEventsType2005EventData addEventsType2005EventData = new AddEventsType2005EventData { Count = ReadInt(obj, "Count", 0), HasEnabled = obj.ContainsKey("Enabled"), Enabled = ReadBool(obj, "Enabled", fallback: true), HasPosition = obj.ContainsKey("Position"), Position = ReadVector3(obj.TryGetPropertyValue("Position", out jsonNode) ? jsonNode : null), HasFogTransitionDuration = obj.ContainsKey("FogTransitionDuration"), FogTransitionDuration = ReadFloat(obj, "FogTransitionDuration", 0f) }; if (obj.TryGetPropertyValue("Events", out JsonNode jsonNode2) && jsonNode2 != null) { addEventsType2005EventData.Events = DeserializeEvents(jsonNode2.ToJsonString()); } return addEventsType2005EventData; } private static List DeserializeEvents(string json) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown try { _isDeserializingSidecarEvents = true; return EOSJson.Deserialize>(json) ?? new List(); } catch (Exception ex) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(59, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2005 could not deserialize nested Events: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } return new List(); } finally { _isDeserializingSidecarEvents = false; } } private static void CollectEvents(object obj, List output, HashSet visited, int depth) { if (obj == null || depth > 12 || !visited.Add(obj)) { return; } WardenObjectiveEventData val = (WardenObjectiveEventData)((obj is WardenObjectiveEventData) ? obj : null); if (val != null) { output.Add(val); return; } if (obj is IEnumerable enumerable && !(obj is string)) { foreach (object item in enumerable) { if (item != null) { CollectEvents(item, output, visited, depth + 1); } } return; } Type type = obj.GetType(); if (type.IsPrimitive || type.IsEnum || type == typeof(string)) { return; } PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (PropertyInfo propertyInfo in properties) { if (propertyInfo.GetIndexParameters().Length != 0) { continue; } try { object value = propertyInfo.GetValue(obj); if (value != null) { CollectEvents(value, output, visited, depth + 1); } } catch { } } FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (FieldInfo fieldInfo in fields) { try { object value2 = fieldInfo.GetValue(obj); if (value2 != null) { CollectEvents(value2, output, visited, depth + 1); } } catch { } } } private static int ReadInt(JsonObject node, string name, int fallback) { try { if (node.TryGetPropertyValue(name, out JsonNode jsonNode) && jsonNode is JsonValue jsonValue) { if (jsonValue.TryGetValue(out var value)) { return value; } if (jsonValue.TryGetValue(out string value2) && int.TryParse(value2, out value)) { return value; } } } catch { } return fallback; } private static float ReadFloat(JsonObject node, string name, float fallback) { try { if (node.TryGetPropertyValue(name, out JsonNode jsonNode) && jsonNode is JsonValue jsonValue) { if (jsonValue.TryGetValue(out var value)) { return value; } if (jsonValue.TryGetValue(out var value2)) { return (float)value2; } if (jsonValue.TryGetValue(out string value3) && float.TryParse(value3, NumberStyles.Float, CultureInfo.InvariantCulture, out value)) { return value; } } } catch { } return fallback; } private static bool ReadBool(JsonObject node, string name, bool fallback) { try { if (node.TryGetPropertyValue(name, out JsonNode jsonNode) && jsonNode is JsonValue jsonValue) { if (jsonValue.TryGetValue(out var value)) { return value; } if (jsonValue.TryGetValue(out string value2) && bool.TryParse(value2, out value)) { return value; } } } catch { } return fallback; } private static Vector3 ReadVector3(JsonNode? node) { //IL_0040: 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) if (!(node is JsonObject node2)) { return Vector3.zero; } return new Vector3(ReadFloat(node2, "x", 0f), ReadFloat(node2, "y", 0f), ReadFloat(node2, "z", 0f)); } } internal static class AddEventsAllDownEventGroupEvents { internal static void AddPlayersToAllDownEventGroup(WardenObjectiveEventData eventData) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown if (!AddEventsNetworkEventProxy.EnsureHostExecution(AddEventsCustomEventType.AddPlayersToAllDownEventGroup, eventData)) { return; } if (!AddEventsType2005SidecarStore.TryGet(eventData, out AddEventsType2005EventData data)) { data = new AddEventsType2005EventData { Count = eventData.Count, Enabled = eventData.Enabled, Position = eventData.Position, HasPosition = true, FogTransitionDuration = eventData.FogTransitionDuration, HasFogTransitionDuration = (eventData.FogTransitionDuration > 0f), Events = new List() }; } bool flag = default(bool); ManualLogSource log; if (!data.Enabled) { AddEventsAllDownEventGroupManager.Current.SetGroupEnabled(data.Count, enabled: false); log = AddEventsRuntime.Log; if (log != null) { BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(63, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2005 all-down event group "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(data.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" disabled and cleared."); } log.LogDebug(val); } return; } List list = ResolvePlayers(eventData, data); int num = AddEventsAllDownEventGroupManager.Current.AddPlayersToGroup(data.Count, list, data.Events); log = AddEventsRuntime.Log; if (log != null) { BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(70, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2005 all-down event group "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(data.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": added "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(list.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" player(s), Events="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(data.Events.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogDebug(val); } } private static List ResolvePlayers(WardenObjectiveEventData eventData, AddEventsType2005EventData data) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) float num = (data.HasFogTransitionDuration ? data.FogTransitionDuration : eventData.FogTransitionDuration); Vector3 origin = (data.HasPosition ? data.Position : eventData.Position); if (num > 0f) { return GetPlayersInRadius(origin, num); } return GetAllPlayers(); } private static List GetPlayersInRadius(Vector3 origin, float radius) { //IL_0030: 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) float num = radius * radius; List list = new List(); Enumerator enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator(); while (enumerator.MoveNext()) { PlayerAgent current = enumerator.Current; if (!((Object)(object)current == (Object)null) && ((Agent)current).Alive) { Vector3 val = ((Agent)current).Position - origin; if (((Vector3)(ref val)).sqrMagnitude <= num) { list.Add(current); } } } return list; } private static List GetAllPlayers() { List list = new List(); Enumerator enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator(); while (enumerator.MoveNext()) { PlayerAgent current = enumerator.Current; if ((Object)(object)current != (Object)null && ((Agent)current).Alive) { list.Add(current); } } return list; } } public struct AddEventsAllDownEventGroupReplicationState { public bool enabled; public bool checkP1; public bool checkP2; public bool checkP3; public bool checkP4; } internal sealed class AddEventsAllDownEventGroup { internal const int MaxPlayers = 4; private readonly bool[] _slots = new bool[4]; private readonly bool[] _downSlots = new bool[4]; private readonly Dictionary _lastDeathFrameBySlot = new Dictionary(); private bool _hasTriggered; private StateReplicator? _stateReplicator; internal bool Enabled { get; private set; } internal List Events { get; set; } = new List(); internal int Count { get { int num = 0; for (int i = 0; i < _slots.Length; i++) { if (_slots[i]) { num++; } } return num; } } internal bool SetPlayerInGroup(int slot, bool inGroup) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if (!IsValidPlayerSlot(slot)) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(63, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2005 invalid player slot index "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(slot); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; expected [0, "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(4); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } log.LogError(val); } return false; } if (_slots[slot] == inGroup) { return false; } int count = Count; _slots[slot] = inGroup; _downSlots[slot] = false; _lastDeathFrameBySlot.Remove(slot); if (inGroup) { _hasTriggered = false; } int count2 = Count; if (count == 0 && count2 > 0) { Enabled = true; } else if (count > 0 && count2 == 0) { Enabled = false; } Sync(); return true; } internal void Toggle(bool enabled) { if (!enabled) { ClearAndDisable(); } else if (!Enabled) { Enabled = true; Sync(); } } internal void ClearAndDisable() { bool flag = Enabled || Count > 0 || Events.Count > 0 || _lastDeathFrameBySlot.Count > 0 || _hasTriggered; Enabled = false; for (int i = 0; i < _slots.Length; i++) { _slots[i] = false; _downSlots[i] = false; } _lastDeathFrameBySlot.Clear(); _hasTriggered = false; Events = new List(); if (flag) { Sync(); } } internal bool ContainsSlot(int slot) { if (IsValidPlayerSlot(slot)) { return _slots[slot]; } return false; } internal bool TryMarkPlayerDownAndCheckAll(int slot, int frame, out int markedCount, out int downCount) { markedCount = Count; downCount = GetDownCount(); if (!IsValidPlayerSlot(slot) || !_slots[slot] || _hasTriggered) { return false; } if (_lastDeathFrameBySlot.TryGetValue(slot, out var value) && value == frame) { return false; } _lastDeathFrameBySlot[slot] = frame; _downSlots[slot] = true; downCount = GetDownCount(); markedCount = Count; if (markedCount <= 0 || downCount < markedCount) { return false; } _hasTriggered = true; return true; } internal void Rearm(List events) { _hasTriggered = false; _lastDeathFrameBySlot.Clear(); for (int i = 0; i < _downSlots.Length; i++) { _downSlots[i] = false; } if (events.Count > 0) { Events = events; } } private int GetDownCount() { int num = 0; for (int i = 0; i < _slots.Length; i++) { if (_slots[i] && _downSlots[i]) { num++; } } return num; } internal void ResetSynced() { Reset(); Sync(); } internal void ResetUnsynced() { Reset(); _stateReplicator?.SetStateUnsynced(GetSyncState()); } private void Reset() { Enabled = false; for (int i = 0; i < _slots.Length; i++) { _slots[i] = false; _downSlots[i] = false; } _lastDeathFrameBySlot.Clear(); _hasTriggered = false; Events = new List(); } private void Sync() { if (!SNet.IsMaster) { ManualLogSource? log = AddEventsRuntime.Log; if (log != null) { log.LogWarning((object)"AddEvents Type 2005 all-down event group sync blocked on client; state changes must be executed by host."); } } else { _stateReplicator?.SetState(GetSyncState()); } } private void OnStateChanged(AddEventsAllDownEventGroupReplicationState oldState, AddEventsAllDownEventGroupReplicationState newState, bool isRecall) { if (isRecall) { Enabled = newState.enabled; _slots[0] = newState.checkP1; _slots[1] = newState.checkP2; _slots[2] = newState.checkP3; _slots[3] = newState.checkP4; } } private AddEventsAllDownEventGroupReplicationState GetSyncState() { return new AddEventsAllDownEventGroupReplicationState { enabled = Enabled, checkP1 = _slots[0], checkP2 = _slots[1], checkP3 = _slots[2], checkP4 = _slots[3] }; } internal static AddEventsAllDownEventGroup? Instantiate() { uint num = EOSNetworking.AllotForeverReplicatorID(); if (num == 0) { ManualLogSource? log = AddEventsRuntime.Log; if (log != null) { log.LogError((object)"AddEvents Type 2005 could not allocate a network replicator id."); } return null; } AddEventsAllDownEventGroup addEventsAllDownEventGroup = new AddEventsAllDownEventGroup(); addEventsAllDownEventGroup._stateReplicator = AddEventsStateReplicatorCompat.Create(num, default(AddEventsAllDownEventGroupReplicationState), (LifeTimeType)0, "AddEvents Type 2005"); if (addEventsAllDownEventGroup._stateReplicator == null) { return null; } addEventsAllDownEventGroup._stateReplicator.OnStateChanged += addEventsAllDownEventGroup.OnStateChanged; addEventsAllDownEventGroup.ResetUnsynced(); return addEventsAllDownEventGroup; } private static bool IsValidPlayerSlot(int slot) { if (slot >= 0) { return slot < 4; } return false; } private AddEventsAllDownEventGroup() { } } internal sealed class AddEventsAllDownEventGroupManager { internal const int MaxGroups = 4; private readonly List _groups = new List(); private bool _initialized; internal static AddEventsAllDownEventGroupManager Current { get; } = new AddEventsAllDownEventGroupManager(); internal void Init() { if (!_initialized) { _initialized = true; EventAPI.OnManagersSetup += SetupGroups; LevelAPI.OnBuildStart += ResetUnsynced; LevelAPI.OnLevelCleanup += ResetUnsynced; } } internal int AddPlayersToGroup(int groupIndex, IEnumerable players, List events) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown EnsureGroupsReady(); if (!TryGetGroup(groupIndex, out AddEventsAllDownEventGroup group)) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(61, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2005 group index must be between 0 and "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_groups.Count - 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; got "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(groupIndex); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogError(val); } return 0; } group.Rearm(events); int num = 0; foreach (PlayerAgent player in players) { try { if (group.SetPlayerInGroup(player.PlayerSlotIndex, inGroup: true)) { num++; } } catch { } } return num; } internal void SetGroupEnabled(int groupIndex, bool enabled) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown EnsureGroupsReady(); if (!TryGetGroup(groupIndex, out AddEventsAllDownEventGroup group)) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(61, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2005 group index must be between 0 and "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_groups.Count - 1); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("; got "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(groupIndex); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogError(val); } } else { group.Toggle(enabled); } } internal void ResetSynced() { foreach (AddEventsAllDownEventGroup group in _groups) { group.ResetSynced(); } } internal void ResetUnsynced() { foreach (AddEventsAllDownEventGroup group in _groups) { group.ResetUnsynced(); } } internal void OnPlayerDied(PlayerAgent? player) { //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Expected O, but got Unknown //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown if ((Object)(object)player == (Object)null || !SNet.IsMaster) { return; } int playerSlotIndex; try { playerSlotIndex = player.PlayerSlotIndex; } catch { return; } int frameCount = Time.frameCount; bool flag = default(bool); for (int i = 0; i < _groups.Count; i++) { AddEventsAllDownEventGroup addEventsAllDownEventGroup = _groups[i]; if (!addEventsAllDownEventGroup.Enabled || !addEventsAllDownEventGroup.ContainsSlot(playerSlotIndex)) { continue; } ManualLogSource log; if (!addEventsAllDownEventGroup.TryMarkPlayerDownAndCheckAll(playerSlotIndex, frameCount, out var markedCount, out var downCount)) { log = AddEventsRuntime.Log; if (log != null) { BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(99, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2005 all-down event group "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": player slot "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(playerSlotIndex); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" downed ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(downCount); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(markedCount); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("); waiting for all marked players."); } log.LogDebug(val); } continue; } log = AddEventsRuntime.Log; if (log != null) { BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(94, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2005 all-down event group "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(i); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": all marked players downed ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(downCount); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(markedCount); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("); executing "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(addEventsAllDownEventGroup.Events.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" event(s)."); } log.LogDebug(val); } foreach (WardenObjectiveEventData @event in addEventsAllDownEventGroup.Events) { try { WardenObjectiveManager.CheckAndExecuteEventsOnTrigger(@event, (eWardenObjectiveEventTrigger)0, true, 0f); } catch (Exception ex) { log = AddEventsRuntime.Log; if (log != null) { BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(43, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("AddEvents Type 2005 nested event failed: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log.LogWarning(val2); } } } } } private void SetupGroups() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if (_groups.Count > 0) { return; } bool flag = default(bool); for (int i = 0; i < 4; i++) { AddEventsAllDownEventGroup addEventsAllDownEventGroup = AddEventsAllDownEventGroup.Instantiate(); if (addEventsAllDownEventGroup == null) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(61, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents Type 2005 instantiated all-down event group count: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_groups.Count); } log.LogError(val); } break; } _groups.Add(addEventsAllDownEventGroup); } } private void EnsureGroupsReady() { if (_groups.Count == 0) { SetupGroups(); } } private bool TryGetGroup(int groupIndex, out AddEventsAllDownEventGroup? group) { if (groupIndex < 0 || groupIndex >= _groups.Count) { group = null; return false; } group = _groups[groupIndex]; return true; } private AddEventsAllDownEventGroupManager() { } } [HarmonyPatch(typeof(Dam_PlayerDamageBase), "ReceiveSetDead")] internal static class AddEventsAllDownEvent_DamPlayerDamageBaseReceiveSetDeadPatch { private static void Postfix(Dam_PlayerDamageBase __instance) { AddEventsAllDownEventGroupManager.Current.OnPlayerDied(TryGetOwner(__instance)); } internal static PlayerAgent? TryGetOwner(Dam_PlayerDamageBase? damageBase) { if ((Object)(object)damageBase == (Object)null) { return null; } try { return damageBase.Owner; } catch { return null; } } } [HarmonyPatch(typeof(Dam_PlayerDamageLocal), "ReceiveSetDead")] internal static class AddEventsAllDownEvent_DamPlayerDamageLocalReceiveSetDeadPatch { private static void Postfix(Dam_PlayerDamageLocal __instance) { AddEventsAllDownEventGroupManager.Current.OnPlayerDied(AddEventsAllDownEvent_DamPlayerDamageBaseReceiveSetDeadPatch.TryGetOwner((Dam_PlayerDamageBase?)(object)__instance)); } } internal delegate void AddEventsCustomEventHandler(WardenObjectiveEventData eventData); internal enum AddEventsCustomEventType { AddPlayersToDeathEventGroup = 2004, AddPlayersToAllDownEventGroup = 2005, ToggleLaserRoom = 2010 } internal static class AddEventsCustomEventRegistry { private static bool _registered; private static readonly Dictionary Handlers = new Dictionary(); internal static void RegisterDefaults() { if (!_registered) { Register(AddEventsCustomEventType.AddPlayersToDeathEventGroup, AddEventsDeathEventGroupEvents.AddPlayersToDeathEventGroup); Register(AddEventsCustomEventType.AddPlayersToAllDownEventGroup, AddEventsAllDownEventGroupEvents.AddPlayersToAllDownEventGroup); Register(AddEventsCustomEventType.ToggleLaserRoom, LaserRoomEvents.ToggleLaserRoom); _registered = true; ManualLogSource? log = AddEventsRuntime.Log; if (log != null) { log.LogMessage((object)"AddEvents custom event registry initialized with numeric Type 2004, 2005 and 2010."); } } } private static void Register(AddEventsCustomEventType eventType, AddEventsCustomEventHandler handler) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown Handlers[eventType] = handler; string text = eventType.ToString(); uint num = (uint)eventType; if (EOSWardenEventManager.Current.AddEventDefinition(text, num, (Action)delegate(WardenObjectiveEventData e) { handler(e); })) { return; } ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(113, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents custom event Type="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" Name="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" could not be registered. Another plugin may already own this event name or id."); } log.LogWarning(val); } } internal static void Execute(AddEventsCustomEventType eventType, WardenObjectiveEventData eventData) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown if (Handlers.TryGetValue(eventType, out AddEventsCustomEventHandler value)) { value(eventData); return; } ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(52, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents custom event '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(eventType); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' has no registered handler."); } log.LogWarning(val); } } internal static bool IsAddEventsEvent(eWardenObjectiveEventType type, out AddEventsCustomEventType eventType) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Expected I4, but got Unknown int num = (int)type; if (Enum.IsDefined(typeof(AddEventsCustomEventType), num)) { eventType = (AddEventsCustomEventType)num; return true; } eventType = (AddEventsCustomEventType)0; return false; } } [StructLayout(LayoutKind.Sequential, Pack = 1)] internal struct AddEventsEventRequestPacket { public int EventType; public byte Enabled; public int Count; public float PosX; public float PosY; public float PosZ; } internal static class AddEventsNetworkEventProxy { private const string EventName = "AddEvents.EventRequest.v1"; private static bool _registered; private static bool _executingHostRequest; private static bool _registrationFailed; internal static void Init() { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown if (_registered) { return; } bool flag = default(bool); try { if (!NetworkAPI.IsEventRegistered("AddEvents.EventRequest.v1")) { NetworkAPI.RegisterEvent("AddEvents.EventRequest.v1", (Action)OnReceiveEventRequest); ManualLogSource? log = AddEventsRuntime.Log; if (log != null) { log.LogMessage((object)"AddEvents network event proxy registered."); } } else { ManualLogSource log2 = AddEventsRuntime.Log; if (log2 != null) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(61, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents network event proxy event '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted("AddEvents.EventRequest.v1"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' is already registered."); } log2.LogWarning(val); } } _registered = true; _registrationFailed = false; } catch (Exception ex) { _registered = false; _registrationFailed = true; ManualLogSource log2 = AddEventsRuntime.Log; if (log2 != null) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(98, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents network event proxy disabled because GTFO-API NetworkAPI is not ready or unavailable: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log2.LogWarning(val); } } } internal static bool EnsureHostExecution(AddEventsCustomEventType eventType, WardenObjectiveEventData eventData) { //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown if (_executingHostRequest || SNet.IsMaster) { return true; } bool flag = default(bool); if (!SNet.HasMaster || (Object)(object)SNet.Master == (Object)null) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(73, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents event '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(eventType); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' ignored on client because no SNet master is available."); } log.LogWarning(val); } return false; } if (!_registered) { Init(); if (!_registered) { string text = (_registrationFailed ? "network proxy registration is unavailable" : "network proxy is not registered"); ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(54, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents event '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(eventType); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' was not forwarded to host because "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogWarning(val); } return false; } } try { AddEventsEventRequestPacket addEventsEventRequestPacket = BuildPacket(eventType, eventData); NetworkAPI.InvokeEvent("AddEvents.EventRequest.v1", addEventsEventRequestPacket, SNet.Master, (SNet_ChannelType)4); ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExMessageLogInterpolatedStringHandler val2 = new BepInExMessageLogInterpolatedStringHandler(65, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("AddEvents event '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(eventType); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' forwarded to host for authoritative execution."); } log.LogMessage(val2); } } catch (Exception ex) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(42, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("AddEvents event '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(eventType); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("' host-forward failed: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } log.LogError(val3); } } return false; } private static AddEventsEventRequestPacket BuildPacket(AddEventsCustomEventType eventType, WardenObjectiveEventData eventData) { //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_0039: 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_0053: Unknown result type (might be due to invalid IL or missing references) Vector3 position = eventData.Position; return new AddEventsEventRequestPacket { EventType = (int)eventType, Enabled = (byte)(eventData.Enabled ? 1 : 0), Count = eventData.Count, PosX = position.x, PosY = position.y, PosZ = position.z }; } private static void OnReceiveEventRequest(ulong sender, AddEventsEventRequestPacket packet) { //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown if (!SNet.IsMaster) { return; } bool flag = default(bool); if (!Enum.IsDefined(typeof(AddEventsCustomEventType), packet.EventType)) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(71, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("AddEvents network event proxy ignored unknown event type "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(packet.EventType); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" from sender "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(sender); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogWarning(val); } return; } AddEventsCustomEventType eventType = (AddEventsCustomEventType)packet.EventType; try { _executingHostRequest = true; WardenObjectiveEventData eventData = new WardenObjectiveEventData { Type = (eWardenObjectiveEventType)packet.EventType, Enabled = (packet.Enabled != 0), Count = packet.Count, Position = new Vector3(packet.PosX, packet.PosY, packet.PosZ) }; ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExMessageLogInterpolatedStringHandler val2 = new BepInExMessageLogInterpolatedStringHandler(60, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("AddEvents network event proxy executing '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(eventType); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' on host. Sender="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(sender); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log.LogMessage(val2); } AddEventsCustomEventRegistry.Execute(eventType, eventData); } catch (Exception ex) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(54, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("AddEvents network event proxy failed to execute '"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(eventType); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("': "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(ex.Message); } log.LogError(val3); } } finally { _executingHostRequest = false; } } } internal struct LaserRoomSyncState { public byte Enabled; } internal enum LaserMovementAnchor { Start, End } internal sealed class LaserRoomComponent : MonoBehaviour { private const string ShaderName = "Unlit/Color"; private GameObject? _visual; private CapsuleCollider? _trigger; private Light? _light; private readonly List _lines = new List(); private readonly List _materials = new List(); private Vector3 _basePosition; private readonly List _movingPositions = new List(); private bool _isMovable; private int _moveSegmentIndex; private float _moveSegmentLerp; private float _movementSpeed; private bool _enabled; private Vector3 _centerOffsetFromStart; private LaserMovementAnchor _movementAnchor; private StateReplicator? _stateReplicator; internal LaserRoomDefinition? Definition; internal LaserRoomSensorDefinition? Sensor; internal void Setup() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0037: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00b9: 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_00c2: 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_00cc: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_028b: 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_007a: Expected O, but got Unknown //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Expected O, but got Unknown //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) LaserRoomDefinition definition = Definition; if (definition == null) { ManualLogSource? log = AddEventsRuntime.Log; if (log != null) { log.LogError((object)"LaserRoom Setup failed: definition is null."); } return; } LaserRoomSensorDefinition sensor = Sensor; Vector3 startPosition = GetStartPosition(definition, sensor); Vector3 endPosition = GetEndPosition(definition, sensor); Vector3 val = endPosition - startPosition; float magnitude = ((Vector3)(ref val)).magnitude; float num = Mathf.Max(0.01f, definition.Radius); bool flag = default(bool); ManualLogSource log2; if (magnitude < 0.1f) { log2 = AddEventsRuntime.Log; if (log2 != null) { BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(63, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LaserRoom Count="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(definition.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" endpoint distance is too short. Laser skipped."); } log2.LogWarning(val2); } return; } Vector3 val3 = (startPosition + endPosition) * 0.5f; Quaternion rotation = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up); _centerOffsetFromStart = val3 - startPosition; ((Component)this).transform.position = val3; ((Component)this).transform.rotation = rotation; _basePosition = val3; SetupMovement(); _visual = new GameObject("Visual"); _visual.transform.SetParent(((Component)this).transform, false); Color color = ToColor(definition.Color); BuildLaserVisual(magnitude, num, color, definition.VisualLayers, definition.CoreWidthScale, definition.GlowWidthScale); _trigger = ((Component)this).gameObject.AddComponent(); ((Collider)_trigger).isTrigger = true; _trigger.direction = 2; _trigger.radius = num; _trigger.height = magnitude; _trigger.center = Vector3.zero; Rigidbody obj = ((Component)this).gameObject.AddComponent(); obj.isKinematic = true; obj.useGravity = false; if (definition.LightIntensity > 0f && definition.LightRange > 0f) { _light = _visual.AddComponent(); _light.type = (LightType)2; _light.color = color; _light.intensity = definition.LightIntensity; _light.range = definition.LightRange; } SetupNetworkState(definition.StartEnabled); ApplyEnabled(definition.StartEnabled); Vector3 value = ((Component)this).transform.TransformPoint(new Vector3(0f, 0f, (0f - magnitude) * 0.5f)); Vector3 value2 = ((Component)this).transform.TransformPoint(new Vector3(0f, 0f, magnitude * 0.5f)); log2 = AddEventsRuntime.Log; if (log2 != null) { BepInExMessageLogInterpolatedStringHandler val4 = new BepInExMessageLogInterpolatedStringHandler(59, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("LaserRoom built Count="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(definition.Count); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" Center="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(FormatVector(val3)); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" Start="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(FormatVector(value)); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" End="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(FormatVector(value2)); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" Length="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(magnitude, "0.###"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(" Radius="); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted(num, "0.###"); ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("."); } log2.LogMessage(val4); } } internal void SetEnabled(bool enabled) { ApplyEnabled(enabled); LaserRoomDefinition definition = Definition; if (_stateReplicator != null && definition != null && AddEventsNetworkStateAudit.Current.CanMasterWrite($"LaserRoom:{definition.Count}", $"SetEnabled:{enabled}")) { _stateReplicator.SetState(new LaserRoomSyncState { Enabled = (byte)(enabled ? 1 : 0) }); } } private void ApplyEnabled(bool enabled) { _enabled = enabled; if ((Object)(object)_visual != (Object)null) { _visual.SetActive(enabled); } if ((Object)(object)_trigger != (Object)null) { ((Collider)_trigger).enabled = enabled; } } private void SetupNetworkState(bool startEnabled) { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown LaserRoomDefinition definition = Definition; if (definition == null) { return; } uint num = EOSNetworking.AllotReplicatorID(); bool flag = default(bool); if (num == 0) { AddEventsNetworkStateAudit.Current.ReplicatorFailed($"LaserRoom:{definition.Count}", "Replicator ID depleted"); ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(62, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom Count="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(definition.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": Replicator ID depleted, state sync disabled."); } log.LogError(val); } return; } _stateReplicator = AddEventsStateReplicatorCompat.Create(num, new LaserRoomSyncState { Enabled = (byte)(startEnabled ? 1 : 0) }, (LifeTimeType)1, $"LaserRoom:{definition.Count}"); if (_stateReplicator == null) { AddEventsNetworkStateAudit.Current.ReplicatorFailed($"LaserRoom:{definition.Count}", "StateReplicator creation failed"); ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(71, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom Count="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(definition.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": StateReplicator creation failed, state sync disabled."); } log.LogError(val); } } else { _stateReplicator.OnStateChanged += OnStateChanged; AddEventsNetworkStateAudit.Current.ReplicatorCreated($"LaserRoom:{definition.Count}", num, "Level"); } } private void OnStateChanged(LaserRoomSyncState oldState, LaserRoomSyncState newState, bool isRecall) { LaserRoomDefinition definition = Definition; bool enabled = newState.Enabled != 0; ApplyEnabled(enabled); if (definition != null && isRecall) { AddEventsNetworkStateAudit.Current.StateRecall($"LaserRoom:{definition.Count}", (oldState.Enabled != 0).ToString(), enabled.ToString()); } } private void OnTriggerStay(Collider other) { LaserRoomDefinition definition = Definition; if (_enabled && definition != null && definition.DamagePlayers) { PlayerAgent val = ResolvePlayer(other); if ((Object)(object)val != (Object)null && val.Owner.IsLocal && definition.DamagePerSecond > 0f) { ApplySmoothDamage(val, definition.DamagePerSecond * Time.deltaTime); } } } private void Update() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_004a: 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_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) if (!_enabled || !_isMovable || _movingPositions.Count < 2) { return; } Vector3 val = _movingPositions[_moveSegmentIndex]; Vector3 val2 = _movingPositions[_moveSegmentIndex + 1]; float num = Mathf.Max(0.001f, Vector3.Distance(val, val2)); _moveSegmentLerp += Time.deltaTime * _movementSpeed / num; while (_moveSegmentLerp >= 1f) { _moveSegmentLerp -= 1f; _moveSegmentIndex++; if (_moveSegmentIndex >= _movingPositions.Count - 1) { _moveSegmentIndex = 0; } val = _movingPositions[_moveSegmentIndex]; val2 = _movingPositions[_moveSegmentIndex + 1]; num = Mathf.Max(0.001f, Vector3.Distance(val, val2)); } float num2 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(_moveSegmentLerp)); ((Component)this).transform.position = Vector3.Lerp(val, val2, num2); } private void BuildLaserVisual(float length, float radius, Color color, int visualLayers, float coreWidthScale, float glowWidthScale) { //IL_0047: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Clamp(visualLayers, 1, 2); float num2 = radius * 2f; Color color2 = default(Color); for (int i = 0; i < num; i++) { GameObject val = new GameObject((i == 0) ? "Core" : $"Glow_{i}"); val.transform.SetParent(_visual.transform, false); LineRenderer val2 = val.AddComponent(); val2.useWorldSpace = false; val2.positionCount = 2; val2.SetPosition(0, new Vector3(0f, 0f, (0f - length) * 0.5f)); val2.SetPosition(1, new Vector3(0f, 0f, length * 0.5f)); val2.numCapVertices = 4; val2.numCornerVertices = 0; val2.alignment = (LineAlignment)0; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = false; float num3 = ((num == 1) ? 0f : ((float)i / (float)(num - 1))); float num4 = ((i == 0) ? coreWidthScale : Mathf.Lerp(1f, glowWidthScale, num3)); float num5 = ((i == 0) ? 1f : Mathf.Lerp(0.45f, 0.12f, num3)); ((Color)(ref color2))..ctor(color.r, color.g, color.b, color.a * num5); val2.startWidth = Mathf.Max(0.005f, num2 * num4); val2.endWidth = val2.startWidth; ((Renderer)val2).material = CreateMaterial(color2); _lines.Add(val2); } } private static PlayerAgent? ResolvePlayer(Collider collider) { try { PlayerAgent component = ((Component)collider).GetComponent(); if ((Object)(object)component != (Object)null) { return component; } return ((Component)collider).GetComponentInParent(); } catch { return null; } } private void SetupMovement() { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_009e: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00c8: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) LaserRoomDefinition definition = Definition; _movingPositions.Clear(); _moveSegmentIndex = 0; _moveSegmentLerp = 0f; if (definition == null) { _isMovable = false; return; } _movementSpeed = ((definition.MovingSpeedMulti > 0f) ? definition.MovingSpeedMulti : 1f); _isMovable = string.Equals(definition.SensorType, "MOVABLE", StringComparison.OrdinalIgnoreCase); List movingPosition = GetMovingPosition(definition, Sensor); if (!_isMovable || movingPosition.Count < 1) { return; } Vector3 startPosition = GetStartPosition(definition, Sensor); Vector3 endPosition = GetEndPosition(definition, Sensor); Vector3 val = movingPosition[0].ToVector3(); _movementAnchor = GetMovementAnchor(val, startPosition, endPosition); if (!Approximately((_movementAnchor == LaserMovementAnchor.End) ? endPosition : startPosition, val)) { _movingPositions.Add(_basePosition); } for (int i = 0; i < movingPosition.Count; i++) { Vector3 anchorPoint = movingPosition[i].ToVector3(); Vector3 val2 = AnchorPointToCenter(anchorPoint); if (_movingPositions.Count == 0 || !Approximately(_movingPositions[_movingPositions.Count - 1], val2)) { _movingPositions.Add(val2); } } if (_movingPositions.Count > 0 && !Approximately(_basePosition, _movingPositions[_movingPositions.Count - 1])) { _movingPositions.Add(_basePosition); } _isMovable = _movingPositions.Count >= 2; } private static bool Approximately(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_0007: Unknown result type (might be due to invalid IL or missing references) Vector3 val = a - b; return ((Vector3)(ref val)).sqrMagnitude < 0.0001f; } private Vector3 AnchorPointToCenter(Vector3 anchorPoint) { //IL_0016: 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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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) if (_movementAnchor != LaserMovementAnchor.End) { return anchorPoint + _centerOffsetFromStart; } return anchorPoint - _centerOffsetFromStart; } private static LaserMovementAnchor GetMovementAnchor(Vector3 firstPoint, Vector3 start, Vector3 end) { //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_0007: 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) //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_0017: Unknown result type (might be due to invalid IL or missing references) Vector3 val = firstPoint - start; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; val = firstPoint - end; if (!(((Vector3)(ref val)).sqrMagnitude < sqrMagnitude)) { return LaserMovementAnchor.Start; } return LaserMovementAnchor.End; } private static Vector3 GetStartPosition(LaserRoomDefinition definition, LaserRoomSensorDefinition? sensor) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) return (sensor?.StartPosition ?? definition.StartPosition).ToVector3(); } private static Vector3 GetEndPosition(LaserRoomDefinition definition, LaserRoomSensorDefinition? sensor) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) return (sensor?.EndPosition ?? definition.EndPosition).ToVector3(); } private static List GetMovingPosition(LaserRoomDefinition definition, LaserRoomSensorDefinition? sensor) { if (sensor?.MovingPosition != null && sensor.MovingPosition.Count > 0) { return sensor.MovingPosition; } return definition.MovingPosition ?? new List(); } private static void ApplySmoothDamage(PlayerAgent player, float damage) { if (damage <= 0f || (Object)(object)player.Damage == (Object)null) { return; } try { ((Dam_SyncedDamageBase)player.Damage).NoAirDamage(damage); if (((Dam_SyncedDamageBase)player.Damage).Health <= 1.01f) { player.Damage.OnIncomingDamage(damage, 0f, (Agent)null); } } catch (Exception ex) { AddEventsRuntime.LogThrottled("LaserRoom player damage failed: " + ex.GetType().Name + ": " + ex.Message); } } private Material CreateMaterial(Color color) { //IL_0026: 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_002c: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) Shader val = Shader.Find("Unlit/Color"); Material val2 = (((Object)(object)val != (Object)null) ? new Material(val) : new Material(Shader.Find("Sprites/Default"))); val2.color = color; _materials.Add(val2); return val2; } private static Color ToColor(LaserRoomVec4 color) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new Color(color.r, color.g, color.b, color.a); } private static string FormatVector(Vector3 value) { //IL_0017: 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_0053: Unknown result type (might be due to invalid IL or missing references) return $"({value.x:0.###}, {value.y:0.###}, {value.z:0.###})"; } private void OnDestroy() { for (int i = 0; i < _materials.Count; i++) { Material val = _materials[i]; if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } _materials.Clear(); _lines.Clear(); _stateReplicator = null; } static LaserRoomComponent() { ClassInjector.RegisterTypeInIl2Cpp(); } } public sealed class LaserRoomDefinition { public int Count { get; set; } public bool Enabled { get; set; } = true; public bool StartEnabled { get; set; } = true; public List LaserGroup { get; set; } = new List(); public List SensorGroup { get; set; } = new List(); public LaserRoomVec3 StartPosition { get; set; } = new LaserRoomVec3 { x = 0f, y = 1.5f, z = 0f }; public LaserRoomVec3 EndPosition { get; set; } = new LaserRoomVec3 { x = 10f, y = 1.5f, z = 0f }; public float Radius { get; set; } = 0.06f; public float DamagePerSecond { get; set; } = 8f; public bool DamagePlayers { get; set; } = true; public int VisualLayers { get; set; } = 1; public float CoreWidthScale { get; set; } = 1f; public float GlowWidthScale { get; set; } = 1f; public float LightIntensity { get; set; } public float LightRange { get; set; } = 3f; public LaserRoomVec4 Color { get; set; } = new LaserRoomVec4 { r = 1f, g = 0f, b = 0f, a = 1f }; public string SensorType { get; set; } = "BASIC"; public float MovingSpeedMulti { get; set; } = 1f; public List MovingPosition { get; set; } = new List { new LaserRoomVec3() }; } public sealed class LaserRoomSensorDefinition { public LaserRoomVec3 StartPosition { get; set; } = new LaserRoomVec3 { x = 0f, y = 1.5f, z = 0f }; public LaserRoomVec3 EndPosition { get; set; } = new LaserRoomVec3 { x = 10f, y = 1.5f, z = 0f }; public List MovingPosition { get; set; } = new List { new LaserRoomVec3() }; } public sealed class LaserRoomVec4 { public float r { get; set; } public float g { get; set; } public float b { get; set; } public float a { get; set; } = 1f; } internal static class LaserRoomEvents { internal static void ToggleLaserRoom(WardenObjectiveEventData eventData) { LaserRoomManager.Current.SetLaserEnabledFromEvent(eventData); } } internal sealed class LaserRoomManager { internal sealed class LaserRoomBuildItem { internal readonly LaserRoomDefinition Definition; internal readonly LaserRoomSensorDefinition Sensor; internal readonly int SensorIndex; internal LaserRoomBuildItem(LaserRoomDefinition definition, LaserRoomSensorDefinition sensor, int sensorIndex) { Definition = definition; Sensor = sensor; SensorIndex = sensorIndex; } } private sealed class CachedLaserRoomDefinitionFile { internal readonly long LastWriteUtcTicks; internal readonly long Length; internal readonly uint MainLevelLayout; internal readonly GenericExpeditionDefinition Definition; internal CachedLaserRoomDefinitionFile(long lastWriteUtcTicks, long length, uint mainLevelLayout, GenericExpeditionDefinition definition) { LastWriteUtcTicks = lastWriteUtcTicks; Length = length; MainLevelLayout = mainLevelLayout; Definition = definition; } } private const int ImmediateBuildLimit = 8; private const int DeferredBuildPerFrame = 4; private readonly string _definitionPath = Path.Combine(MTFOPathAPI.CustomPath, "AddEvents", "LaserRoom"); private readonly Dictionary> _definitions = new Dictionary>(); private readonly Dictionary> _lasers = new Dictionary>(); private readonly Dictionary _definitionCache = new Dictionary(StringComparer.OrdinalIgnoreCase); private readonly Dictionary _desiredEnabledStates = new Dictionary(); private LiveEditListener? _liveEditListener; private LaserRoomBuildDriver? _buildDriver; private int _buildGeneration; public static LaserRoomManager Current { get; } = new LaserRoomManager(); private LaserRoomManager() { LevelAPI.OnBuildDone += Build; LevelAPI.OnLevelCleanup += Clear; } internal void Init() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown bool flag = default(bool); try { EnsureDefinitionPath(); ReloadDefinitionsFromDisk(); if (_liveEditListener == null) { _liveEditListener = LiveEdit.CreateListener(_definitionPath, "*.json", true); _liveEditListener.FileChanged += new LiveEditEventHandler(FileChanged); } ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(31, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom definitions path: '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_definitionPath); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'."); } log.LogMessage(val); } } catch (Exception ex) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(25, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LaserRoom Init failed: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log.LogError(val2); } } } private void EnsureDefinitionPath() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown Directory.CreateDirectory(_definitionPath); string text = Path.Combine(_definitionPath, "Template.json"); if (File.Exists(text)) { return; } File.WriteAllText(text, CreateTemplateJson()); ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(33, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom template generated: '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'."); } log.LogMessage(val); } } private string CreateTemplateJson() { return "{\n \"MainLevelLayout\": \"Layout-T-L1\",\n \"Definitions\": [\n {\n \"Count\": 0,\n \"Enabled\": true,\n \"StartEnabled\": true,\n \"Radius\": 0.06,\n \"DamagePerSecond\": 8.0,\n \"DamagePlayers\": true,\n \"VisualLayers\": 1,\n \"CoreWidthScale\": 1.0,\n \"GlowWidthScale\": 1.0,\n \"LightIntensity\": 0.0,\n \"LightRange\": 3.0,\n \"Color\": { \"r\": 1.0, \"g\": 0.0, \"b\": 0.0, \"a\": 1.0 },\n \"SensorType\": \"BASIC\",\n \"MovingSpeedMulti\": 1.0,\n \"LaserGroup\": [\n {\n \"StartPosition\": { \"x\": 100.0, \"y\": 1.5, \"z\": -50.0 },\n \"EndPosition\": { \"x\": 112.0, \"y\": 1.5, \"z\": -50.0 },\n \"MovingPosition\": [\n { \"x\": 100.0, \"y\": 1.5, \"z\": -50.0 }\n ]\n }\n ]\n }\n ]\n}\n"; } private void FileChanged(LiveEditEventArgs e) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom LiveEdit file changed: '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(e.FullPath); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'."); } log.LogMessage(val); } LiveEdit.TryReadFileContent(e.FullPath, (Action)delegate(string content) { if (TryLoadDefinitionContent(content, e.FullPath, out uint mainLevelLayout, out GenericExpeditionDefinition conf) && conf != null) { TryRefreshDefinitionCache(e.FullPath, mainLevelLayout, conf); AddDefinitions(mainLevelLayout, conf, e.FullPath); } }); } private void ReloadDefinitionsFromDisk() { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Expected O, but got Unknown Dictionary> dictionary = new Dictionary>(); int num = 0; int num2 = 0; HashSet hashSet = new HashSet(StringComparer.OrdinalIgnoreCase); bool flag = default(bool); ManualLogSource log; foreach (string item in Directory.EnumerateFiles(_definitionPath, "*.json", SearchOption.TopDirectoryOnly)) { try { hashSet.Add(item); if (!TryLoadDefinitionFile(item, out uint mainLevelLayout, out GenericExpeditionDefinition conf) || conf == null) { num2++; continue; } AddDefinitions(dictionary, mainLevelLayout, conf, item); num++; } catch (Exception ex) { num2++; _definitionCache.Remove(item); log = AddEventsRuntime.Log; if (log != null) { BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(39, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom config load failed for '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(item); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogError(val); } } } PruneDefinitionCache(hashSet); _definitions.Clear(); foreach (KeyValuePair> item2 in dictionary) { _definitions[item2.Key] = item2.Value; } string text = ((dictionary.Count == 0) ? "" : string.Join(",", dictionary.Keys.OrderBy((uint id) => id))); log = AddEventsRuntime.Log; if (log != null) { BepInExMessageLogInterpolatedStringHandler val2 = new BepInExMessageLogInterpolatedStringHandler(80, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LaserRoom config reload complete. FilesLoaded="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", FilesFailed="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", MainLevelLayouts="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log.LogMessage(val2); } } private bool TryLoadDefinitionFile(string file, out uint mainLevelLayout, out GenericExpeditionDefinition? conf) { mainLevelLayout = 0u; conf = null; FileInfo fileInfo = new FileInfo(file); if (_definitionCache.TryGetValue(file, out CachedLaserRoomDefinitionFile value) && value.LastWriteUtcTicks == fileInfo.LastWriteTimeUtc.Ticks && value.Length == fileInfo.Length) { mainLevelLayout = value.MainLevelLayout; conf = value.Definition; return conf != null; } string content = File.ReadAllText(file); if (!TryLoadDefinitionContent(content, file, out mainLevelLayout, out conf) || conf == null) { _definitionCache.Remove(file); return false; } _definitionCache[file] = new CachedLaserRoomDefinitionFile(fileInfo.LastWriteTimeUtc.Ticks, fileInfo.Length, mainLevelLayout, conf); return true; } private bool TryLoadDefinitionContent(string content, string file, out uint mainLevelLayout, out GenericExpeditionDefinition? conf) { //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown mainLevelLayout = 0u; conf = null; bool flag2 = default(bool); try { using JsonDocument jsonDocument = JsonDocument.Parse(content, new JsonDocumentOptions { CommentHandling = JsonCommentHandling.Skip, AllowTrailingCommas = true }); ManualLogSource log; if (!TryGetPropertyCaseInsensitive(jsonDocument.RootElement, "MainLevelLayout", out var value)) { log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom config '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(file); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' is missing MainLevelLayout."); } log.LogError(val); } return false; } if (!LaserRoomConfigResolver.TryResolveMainLevelLayoutForExternalConfig(value, out mainLevelLayout, out string resolvedBy)) { log = AddEventsRuntime.Log; if (log != null) { BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(60, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom config '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(file); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' MainLevelLayout could not be resolved: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogError(val); } return false; } string text = RewriteMainLevelLayout(jsonDocument.RootElement, mainLevelLayout); conf = EOSJson.Deserialize>(text); if (conf == null) { log = AddEventsRuntime.Log; if (log != null) { BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(41, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom config '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(file); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' deserialized to null."); } log.LogError(val); } return false; } conf.MainLevelLayout = mainLevelLayout; log = AddEventsRuntime.Log; if (log != null) { BepInExMessageLogInterpolatedStringHandler val2 = new BepInExMessageLogInterpolatedStringHandler(52, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LaserRoom config '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(file); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' MainLevelLayout resolved as "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(mainLevelLayout); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(resolvedBy); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(")."); } log.LogMessage(val2); } return true; } catch (Exception ex) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(36, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom config '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(file); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' parse failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogError(val); } return false; } } private static bool TryGetPropertyCaseInsensitive(JsonElement element, string name, out JsonElement value) { foreach (JsonProperty item in element.EnumerateObject()) { if (string.Equals(item.Name, name, StringComparison.OrdinalIgnoreCase)) { value = item.Value; return true; } } value = default(JsonElement); return false; } private static string RewriteMainLevelLayout(JsonElement root, uint mainLevelLayout) { using MemoryStream memoryStream = new MemoryStream(); using (Utf8JsonWriter utf8JsonWriter = new Utf8JsonWriter((Stream)memoryStream, new JsonWriterOptions { Indented = false })) { utf8JsonWriter.WriteStartObject(); foreach (JsonProperty item in root.EnumerateObject()) { if (string.Equals(item.Name, "MainLevelLayout", StringComparison.OrdinalIgnoreCase)) { utf8JsonWriter.WriteNumber("MainLevelLayout", mainLevelLayout); } else { item.WriteTo(utf8JsonWriter); } } utf8JsonWriter.WriteEndObject(); } return Encoding.UTF8.GetString(memoryStream.ToArray()); } private void AddDefinitions(uint mainLevelLayout, GenericExpeditionDefinition conf, string file) { AddDefinitions(_definitions, mainLevelLayout, conf, file); } private static void AddDefinitions(Dictionary> target, uint mainLevelLayout, GenericExpeditionDefinition conf, string file) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown conf.MainLevelLayout = mainLevelLayout; if (target.ContainsKey(mainLevelLayout)) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(63, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom config reload replaced MainLevelLayout "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(mainLevelLayout); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" from file '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(file); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'."); } log.LogMessage(val); } } target[mainLevelLayout] = conf; } private void Build() { //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Expected O, but got Unknown bool flag = default(bool); try { ReloadDefinitionsFromDisk(); if (RundownManager.ActiveExpedition == null) { ManualLogSource? log = AddEventsRuntime.Log; if (log != null) { log.LogWarning((object)"LaserRoom Build skipped: ActiveExpedition is null."); } return; } uint levelLayoutData = RundownManager.ActiveExpedition.LevelLayoutData; ManualLogSource log2; if (!_definitions.TryGetValue(levelLayoutData, out GenericExpeditionDefinition value)) { log2 = AddEventsRuntime.Log; if (log2 != null) { BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(63, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom Build: no LaserRoom definitions for LevelLayoutData="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(levelLayoutData); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log2.LogMessage(val); } return; } Clear(); List list = new List(); foreach (LaserRoomDefinition definition in value.Definitions) { if (definition.Enabled) { _desiredEnabledStates[definition.Count] = definition.StartEnabled; List sensors = GetSensors(definition); for (int i = 0; i < sensors.Count; i++) { list.Add(new LaserRoomBuildItem(definition, sensors[i], i)); } } } if (list.Count > 8) { StartDeferredBuild(list, levelLayoutData, value.Definitions.Count); return; } int num = 0; for (int j = 0; j < list.Count; j++) { if (BuildLaserSensor(list[j].Definition, list[j].Sensor, list[j].SensorIndex)) { num++; } } log2 = AddEventsRuntime.Log; if (log2 != null) { BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(57, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom Build: LevelLayoutData="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(levelLayoutData); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Definitions="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value.Definitions.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Lasers="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log2.LogMessage(val); } } catch (Exception ex) { ManualLogSource log2 = AddEventsRuntime.Log; if (log2 != null) { BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(26, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LaserRoom Build failed: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex.Message); } log2.LogError(val2); } } } private int BuildLaser(LaserRoomDefinition def) { if (!def.Enabled) { return 0; } List sensors = GetSensors(def); int num = 0; for (int i = 0; i < sensors.Count; i++) { if (BuildLaserSensor(def, sensors[i], i)) { num++; } } return num; } private bool BuildLaserSensor(LaserRoomDefinition def, LaserRoomSensorDefinition sensor, int sensorIndex) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown GameObject val = new GameObject($"LaserRoom_{def.Count}_{sensorIndex}"); AddEventsLevelObjectTracker.Current.Track(val, "LaserRoom"); LaserRoomComponent laserRoomComponent = val.AddComponent(); laserRoomComponent.Definition = def; laserRoomComponent.Sensor = sensor; laserRoomComponent.Setup(); if (_desiredEnabledStates.TryGetValue(def.Count, out var value) && value != def.StartEnabled) { laserRoomComponent.SetEnabled(value); } if (!_lasers.TryGetValue(def.Count, out List value2)) { value2 = new List(); _lasers[def.Count] = value2; } value2.Add(laserRoomComponent); return true; } private static List GetSensors(LaserRoomDefinition def) { if (def.LaserGroup != null && def.LaserGroup.Count > 0) { return def.LaserGroup; } if (def.SensorGroup != null && def.SensorGroup.Count > 0) { return def.SensorGroup; } return new List { new LaserRoomSensorDefinition { StartPosition = def.StartPosition, EndPosition = def.EndPosition, MovingPosition = (def.MovingPosition ?? new List()) } }; } internal void SetLaserEnabledFromEvent(WardenObjectiveEventData eventData) { if (AddEventsNetworkEventProxy.EnsureHostExecution(AddEventsCustomEventType.ToggleLaserRoom, eventData)) { SetLaserEnabled(eventData.Count, eventData.Enabled); } } internal void SetLaserEnabled(int count, bool enabled) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown _desiredEnabledStates[count] = enabled; bool flag = default(bool); ManualLogSource log; if (!_lasers.TryGetValue(count, out List value) || value.Count == 0) { log = AddEventsRuntime.Log; if (log != null) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(41, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(enabled ? "enable" : "disable"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" skipped: Count="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" was not found."); } log.LogWarning(val); } return; } int num = 0; foreach (LaserRoomComponent item in value) { if (!((Object)(object)item == (Object)null)) { item.SetEnabled(enabled); num++; } } log = AddEventsRuntime.Log; if (log != null) { BepInExMessageLogInterpolatedStringHandler val2 = new BepInExMessageLogInterpolatedStringHandler(28, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LaserRoom "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(enabled ? "enabled" : "disabled"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" Count="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", Changed="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log.LogMessage(val2); } } private void Clear() { _buildGeneration++; if ((Object)(object)_buildDriver != (Object)null) { _buildDriver.Cancel(); } foreach (List value in _lasers.Values) { foreach (LaserRoomComponent item in value) { if ((Object)(object)item != (Object)null) { Object.Destroy((Object)(object)((Component)item).gameObject); } } } _lasers.Clear(); _desiredEnabledStates.Clear(); } private void StartDeferredBuild(List buildItems, uint layoutId, int definitionCount) { //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown EnsureBuildDriver(); bool flag = default(bool); ManualLogSource log; if ((Object)(object)_buildDriver == (Object)null) { int num = 0; for (int i = 0; i < buildItems.Count; i++) { if (BuildLaserSensor(buildItems[i].Definition, buildItems[i].Sensor, buildItems[i].SensorIndex)) { num++; } } log = AddEventsRuntime.Log; if (log != null) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(106, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom deferred build driver unavailable; built synchronously. LevelLayoutData="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(layoutId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Definitions="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(definitionCount); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Lasers="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogWarning(val); } return; } int buildGeneration = _buildGeneration; _buildDriver.Begin(this, buildGeneration, layoutId, definitionCount, buildItems, 4); log = AddEventsRuntime.Log; if (log != null) { BepInExMessageLogInterpolatedStringHandler val2 = new BepInExMessageLogInterpolatedStringHandler(84, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LaserRoom Build deferred: LevelLayoutData="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(layoutId); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", Definitions="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(definitionCount); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", PendingLasers="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(buildItems.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", PerFrame="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(4); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log.LogMessage(val2); } } private void EnsureBuildDriver() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if (!((Object)(object)_buildDriver != (Object)null)) { GameObject val = new GameObject("LaserRoom_BuildDriver"); Object.DontDestroyOnLoad((Object)(object)val); _buildDriver = val.AddComponent(); } } internal bool BuildDeferredItem(int generation, LaserRoomBuildItem item) { if (generation == _buildGeneration) { return BuildLaserSensor(item.Definition, item.Sensor, item.SensorIndex); } return false; } internal bool IsBuildGenerationActive(int generation) { return generation == _buildGeneration; } private void TryRefreshDefinitionCache(string file, uint mainLevelLayout, GenericExpeditionDefinition conf) { try { FileInfo fileInfo = new FileInfo(file); _definitionCache[file] = new CachedLaserRoomDefinitionFile(fileInfo.LastWriteTimeUtc.Ticks, fileInfo.Length, mainLevelLayout, conf); } catch { _definitionCache.Remove(file); } } private void PruneDefinitionCache(HashSet seenFiles) { List list = _definitionCache.Keys.Where((string file) => !seenFiles.Contains(file)).ToList(); for (int num = 0; num < list.Count; num++) { _definitionCache.Remove(list[num]); } } } internal sealed class LaserRoomBuildDriver : MonoBehaviour { private LaserRoomManager? _manager; private List? _items; private int _generation; private int _index; private int _built; private int _perFrame = 4; private uint _layoutId; private int _definitionCount; internal void Begin(LaserRoomManager manager, int generation, uint layoutId, int definitionCount, List items, int perFrame) { _manager = manager; _generation = generation; _layoutId = layoutId; _definitionCount = definitionCount; _items = items; _index = 0; _built = 0; _perFrame = Mathf.Max(1, perFrame); ((Behaviour)this).enabled = true; } internal void Cancel() { _items = null; _manager = null; ((Behaviour)this).enabled = false; } private void Update() { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown if (_manager == null || _items == null) { ((Behaviour)this).enabled = false; return; } if (!_manager.IsBuildGenerationActive(_generation)) { Cancel(); return; } int perFrame = _perFrame; while (perFrame-- > 0 && _items != null && _index < _items.Count) { if (_manager.BuildDeferredItem(_generation, _items[_index])) { _built++; } _index++; } if (_items == null || _index < _items.Count) { return; } ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(75, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom deferred build complete: LevelLayoutData="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_layoutId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Definitions="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_definitionCount); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Lasers="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(_built); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogMessage(val); } Cancel(); } static LaserRoomBuildDriver() { ClassInjector.RegisterTypeInIl2Cpp(); } } internal sealed class AddEventsLevelObjectTracker { private readonly Dictionary _trackedObjects = new Dictionary(); public static AddEventsLevelObjectTracker Current { get; } = new AddEventsLevelObjectTracker(); internal void Track(GameObject go, string owner) { if (!((Object)(object)go == (Object)null)) { int instanceID = ((Object)go).GetInstanceID(); if (!_trackedObjects.ContainsKey(instanceID)) { _trackedObjects[instanceID] = new LaserRoomTrackedObject(go, owner); } } } internal void Forget(GameObject go) { if (!((Object)(object)go == (Object)null)) { _trackedObjects.Remove(((Object)go).GetInstanceID()); } } internal void Clear() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown int num = 0; int num2 = 0; bool flag = default(bool); foreach (LaserRoomTrackedObject value in _trackedObjects.Values) { GameObject gameObject = value.GameObject; if ((Object)(object)gameObject == (Object)null) { num2++; continue; } num++; try { Object.Destroy((Object)(object)gameObject); } catch (Exception ex) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(36, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom cleanup failed for '"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(value.Owner); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(((Object)gameObject).name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("': "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } } if (num > 0 || num2 > 0) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExMessageLogInterpolatedStringHandler val2 = new BepInExMessageLogInterpolatedStringHandler(67, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("LaserRoom level object cleanup: Destroyed="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", AlreadyGone="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", Tracked="); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(_trackedObjects.Count); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("."); } log.LogMessage(val2); } } _trackedObjects.Clear(); } private AddEventsLevelObjectTracker() { } } internal readonly struct LaserRoomTrackedObject { internal readonly GameObject GameObject; internal readonly string Owner; internal LaserRoomTrackedObject(GameObject gameObject, string owner) { GameObject = gameObject; Owner = owner; } } internal sealed class AddEventsNetworkStateAudit { public static AddEventsNetworkStateAudit Current { get; } = new AddEventsNetworkStateAudit(); internal bool CanMasterWrite(string owner, string operation) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown if (SNet.IsMaster) { return true; } ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(92, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom network audit blocked client state write: Owner="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(owner); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Operation="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(operation); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", IsMaster="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(SNet.IsMaster); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", InLobby="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(SNet.IsInLobby); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogWarning(val); } return false; } internal void ReplicatorCreated(string owner, uint id, string lifetime) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(88, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom network audit replicator created: Owner="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(owner); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ID="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(id); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Lifetime="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(lifetime); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", IsMaster="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(SNet.IsMaster); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", InLobby="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(SNet.IsInLobby); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogMessage(val); } } internal void ReplicatorFailed(string owner, string reason) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(80, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom network audit replicator failed: Owner="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(owner); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", Reason="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(reason); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", IsMaster="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(SNet.IsMaster); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", InLobby="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(SNet.IsInLobby); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogError(val); } } internal void StateRecall(string owner, string fromState, string toState) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(62, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom network audit state recall: Owner="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(owner); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(fromState); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" => "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(toState); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", IsMaster="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(SNet.IsMaster); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogMessage(val); } } internal void OnLevelBoundary(string stage) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExMessageLogInterpolatedStringHandler val = new BepInExMessageLogInterpolatedStringHandler(62, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom network audit level boundary: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(stage); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", IsMaster="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(SNet.IsMaster); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", InLobby="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(SNet.IsInLobby); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogMessage(val); } } private AddEventsNetworkStateAudit() { } } internal static class AddEventsOptimizationManager { private static bool _initialized; internal static void Init() { if (!_initialized) { _initialized = true; LevelAPI.OnBuildStart += OnBuildStart; LevelAPI.OnLevelCleanup += OnLevelCleanup; ManualLogSource? log = AddEventsRuntime.Log; if (log != null) { log.LogMessage((object)"LaserRoom optimization manager initialized."); } } } private static void OnBuildStart() { SafeInvoke("BuildStart", AddEventsLevelObjectTracker.Current.Clear); AddEventsNetworkStateAudit.Current.OnLevelBoundary("BuildStart"); } private static void OnLevelCleanup() { SafeInvoke("LevelCleanup", AddEventsLevelObjectTracker.Current.Clear); AddEventsNetworkStateAudit.Current.OnLevelBoundary("LevelCleanup"); } private static void SafeInvoke(string stage, Action action) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown try { action(); } catch (Exception ex) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(34, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("LaserRoom optimization "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(stage); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogError(val); } } } } internal static class PluginInfo { public const string GUID = "AddEvents"; public const string NAME = "AddEvents"; public const string VERSION = "1.1.3"; } [BepInPlugin("AddEvents", "AddEvents", "1.1.3")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BasePlugin { private Harmony? _harmony; public override void Load() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown AddEventsRuntime.Log = ((BasePlugin)this).Log; _harmony = new Harmony("AddEvents"); SafePatchAll(_harmony, ((BasePlugin)this).Log); AddEventsType2004SidecarStore.ScanDiskForDefinitions(); AddEventsType2005SidecarStore.ScanDiskForDefinitions(); AddEventsNetworkEventProxy.Init(); AddEventsCustomEventRegistry.RegisterDefaults(); AddEventsOptimizationManager.Init(); AddEventsDeathEventGroupManager.Current.Init(); AddEventsAllDownEventGroupManager.Current.Init(); LaserRoomManager.Current.Init(); ((BasePlugin)this).Log.LogMessage((object)"AddEvents plugin loaded."); } private static void SafePatchAll(Harmony harmony, ManualLogSource log) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown Type[] types = Assembly.GetExecutingAssembly().GetTypes(); bool flag = default(bool); foreach (Type type in types) { if (!type.GetCustomAttributes(typeof(HarmonyPatch), inherit: true).Any()) { continue; } try { harmony.CreateClassProcessor(type).Patch(); } catch (Exception ex) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(36, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Optional Harmony patch skipped: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(type.FullName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } } } internal static class AddEventsRuntime { internal static ManualLogSource? Log; private static float _lastThrottledLogTime; internal static uint GetCurrentLevelLayoutId() { try { return RundownManager.ActiveExpedition.LevelLayoutData; } catch { return 0u; } } internal static void LogThrottled(string message) { if (!(Time.realtimeSinceStartup - _lastThrottledLogTime < 1f)) { _lastThrottledLogTime = Time.realtimeSinceStartup; ManualLogSource? log = Log; if (log != null) { log.LogWarning((object)message); } } } } internal static class AddEventsStateReplicatorCompat { internal static StateReplicator? Create(uint id, T initialState, LifeTimeType lifeTimeType, string owner) where T : struct { //IL_000a: 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_003a: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Expected O, but got Unknown //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Expected O, but got Unknown //IL_000d: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Expected O, but got Unknown //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Expected O, but got Unknown if (!CanCreateReplicator(owner)) { return null; } LifeTimeType lifeTimeType2 = (LifeTimeType)(((int)lifeTimeType == 0) ? 1 : ((int)lifeTimeType)); Type typeFromHandle; bool flag = default(bool); ManualLogSource log; try { typeFromHandle = typeof(StateReplicator); } catch (Exception ex) { log = AddEventsRuntime.Log; if (log != null) { BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(75, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(owner); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": StateReplicator generic type could not be constructed for state type "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(typeof(T).FullName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogError(val); } return null; } foreach (MethodInfo item in from m in typeFromHandle.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic) where m.Name == "Create" select m) { if (!TryBuildArguments(item, id, initialState, lifeTimeType2, out object[] args)) { continue; } try { if (item.Invoke(null, args) is StateReplicator result) { return result; } } catch (TargetInvocationException ex2) { log = AddEventsRuntime.Log; if (log != null) { BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(51, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(owner); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": StateReplicator.Create reflection call failed: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex2.InnerException?.GetType().Name ?? ex2.GetType().Name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex2.InnerException?.Message ?? ex2.Message); } log.LogWarning(val2); } } catch (Exception ex3) { log = AddEventsRuntime.Log; if (log != null) { BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(51, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(owner); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": StateReplicator.Create reflection call failed: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex3.GetType().Name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(ex3.Message); } log.LogWarning(val2); } } } StateReplicator val3 = TryCreateLocalReplicator(initialState, owner); if (val3 != null) { log = AddEventsRuntime.Log; if (log != null) { BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(259, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted(owner); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": FloLib StateReplicator.Create signature/lifetime is not compatible with this LaserRoom build. Falling back to a local unsynced StateReplicator so gameplay construction can continue. Multiplayer sync for this state may be unavailable until FloLib is updated."); } log.LogWarning(val2); } return val3; } log = AddEventsRuntime.Log; if (log != null) { BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(123, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(owner); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": could not create StateReplicator. No compatible Create method or fallback constructor was found in the loaded FloLib.dll."); } log.LogError(val); } return null; } private static bool CanCreateReplicator(string owner) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_006d: Unknown result type (might be due to invalid IL or missing references) bool flag = default(bool); try { if (SNet.IsInLobby || (int)GameStateManager.CurrentStateName == 10) { return true; } ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(117, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(owner); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": StateReplicator creation delayed/skipped because network level state is not ready. IsMaster="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(SNet.IsMaster); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", InLobby="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(SNet.IsInLobby); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", GameState="); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(GameStateManager.CurrentStateName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } log.LogWarning(val); } return false; } catch (Exception ex) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(95, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(owner); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": StateReplicator creation delayed/skipped because network level state could not be queried: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } return false; } } private static bool TryBuildArguments(MethodInfo method, uint id, T initialState, LifeTimeType lifeTimeType, out object?[] args) where T : struct { //IL_00ff: Unknown result type (might be due to invalid IL or missing references) ParameterInfo[] parameters = method.GetParameters(); args = new object[parameters.Length]; bool result = false; for (int i = 0; i < parameters.Length; i++) { ParameterInfo parameterInfo = parameters[i]; Type parameterType = parameterInfo.ParameterType; if (parameterType == typeof(uint) || parameterType == typeof(uint)) { args[i] = id; continue; } if ((parameterType == typeof(int) || parameterType == typeof(int)) && (parameterInfo.Name ?? string.Empty).IndexOf("id", StringComparison.OrdinalIgnoreCase) >= 0) { args[i] = (int)id; continue; } if (parameterType == typeof(T) || parameterType.IsAssignableFrom(typeof(T))) { args[i] = initialState; result = true; continue; } if (parameterType == typeof(LifeTimeType)) { args[i] = lifeTimeType; continue; } if (parameterType == typeof(bool)) { args[i] = false; continue; } if (parameterType.IsEnum) { Array values = Enum.GetValues(parameterType); args[i] = ((values.Length > 0) ? values.GetValue(0) : Activator.CreateInstance(parameterType)); continue; } if (parameterInfo.HasDefaultValue) { args[i] = parameterInfo.DefaultValue; continue; } if (!parameterType.IsValueType) { args[i] = null; continue; } return false; } return result; } private static StateReplicator? TryCreateLocalReplicator(T initialState, string owner) where T : struct { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown ConstructorInfo[] constructors = typeof(StateReplicator).GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); bool flag = default(bool); foreach (ConstructorInfo constructorInfo in constructors) { ParameterInfo[] parameters = constructorInfo.GetParameters(); if (parameters.Length != 1) { continue; } Type parameterType = parameters[0].ParameterType; if (parameterType != typeof(T) && !parameterType.IsAssignableFrom(typeof(T))) { continue; } try { return constructorInfo.Invoke(new object[1] { initialState }) as StateReplicator; } catch (Exception ex) { ManualLogSource log = AddEventsRuntime.Log; if (log != null) { BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(55, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(owner); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": local StateReplicator constructor fallback failed: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.GetType().Name); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted(ex.Message); } log.LogWarning(val); } } } return null; } } public sealed class LaserRoomVec3 { public float x { get; set; } public float y { get; set; } public float z { get; set; } public Vector3 ToVector3() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(x, y, z); } } }