The current BepInExPack is broken due to the Oakveil update, and mods installed through a mod manager may not work. Join the modding Discord for more information.
Decompiled source of RetroCamera v1.2.1
RetroCamera.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Text.Json; using System.Text.Json.Nodes; using System.Text.Json.Serialization; using BepInEx; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP.Hook; using BepInEx.Unity.IL2CPP.Utils.Collections; using HarmonyLib; using Iced.Intel; using Il2CppInterop.Common; using Il2CppInterop.Runtime; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppInterop.Runtime.Runtime; using Il2CppInterop.Runtime.Runtime.VersionSpecific.MethodInfo; using Il2CppSystem; using Il2CppSystem.Collections.Generic; using Il2CppSystem.Text; using Microsoft.CodeAnalysis; using ProjectM; using ProjectM.CastleBuilding; using ProjectM.Gameplay.Systems; using ProjectM.Network; using ProjectM.Physics; using ProjectM.Presentation; using ProjectM.Scripting; using ProjectM.Sequencer; using ProjectM.Shared; using ProjectM.UI; using RetroCamera.Behaviours; using RetroCamera.Configuration; using RetroCamera.Patches; using RetroCamera.Systems; using RetroCamera.Utilities; using StunShared.UI; using Stunlock.Core; using Stunlock.Localization; using TMPro; using Unity.Collections; using Unity.Entities; using Unity.Mathematics; using Unity.Physics; using Unity.Transforms; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("RetroCamera")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.1.0")] [assembly: AssemblyInformationalVersion("1.2.1")] [assembly: AssemblyProduct("RetroCamera")] [assembly: AssemblyTitle("RetroCamera")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.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] [Microsoft.CodeAnalysis.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; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace RetroCamera { internal class Core { public static World _client; private static MonoBehaviour _monoBehaviour; public static bool _initialized; public static EntityManager EntityManager => _client.EntityManager; public static ClientScriptMapper ClientScriptMapper { get; set; } public static ClientGameManager ClientGameManager { get; set; } public static ZoomModifierSystem ZoomModifierSystem { get; set; } public static TopdownCameraSystem TopdownCameraSystem { get; set; } public static PrefabCollectionSystem PrefabCollectionSystem { get; set; } public static UIDataSystem UIDataSystem { get; set; } public static CursorPositionSystem CursorPositionSystem { get; set; } public static InputActionSystem InputActionSystem { get; set; } public static ManualLogSource Log => Plugin.LogInstance; public static void Initialize(GameDataManager __instance) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) if (!_initialized) { _client = ((ComponentSystemBase)__instance).World; ZoomModifierSystem = _client.GetExistingSystemManaged<ZoomModifierSystem>(); ((ComponentSystemBase)ZoomModifierSystem).Enabled = false; TopdownCameraSystem = _client.GetExistingSystemManaged<TopdownCameraSystem>(); PrefabCollectionSystem = _client.GetExistingSystemManaged<PrefabCollectionSystem>(); UIDataSystem = _client.GetExistingSystemManaged<UIDataSystem>(); CursorPositionSystem = _client.GetExistingSystemManaged<CursorPositionSystem>(); ClientScriptMapper = _client.GetExistingSystemManaged<ClientScriptMapper>(); ClientGameManager = ClientScriptMapper._ClientGameManager; InputActionSystem = _client.GetExistingSystemManaged<InputActionSystem>(); TopdownCameraSystemHooks.Initialize(); _initialized = true; } } public static Coroutine StartCoroutine(IEnumerator routine) { //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) //IL_0027: Expected O, but got Unknown if ((Object)(object)_monoBehaviour == (Object)null) { GameObject val = new GameObject("RetroCamera"); _monoBehaviour = (MonoBehaviour)(object)val.AddComponent<IgnorePhysicsDebugSystem>(); Object.DontDestroyOnLoad((Object)val); } return _monoBehaviour.StartCoroutine(CollectionExtensions.WrapToIl2Cpp(routine)); } public static void ResetStates() { ClearSkies.Reset(); TopdownCameraSystemHooks.Dispose(); OptionsMenuPatches.Reset(); _initialized = false; } public static void LogEntity(World world, Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown StringBuilder val = new StringBuilder(); bool flag = default(bool); try { EntityDebuggingUtility.DumpEntity(world, entity, true, val); ManualLogSource log = Log; BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(13, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Entity Dump:\n"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val).ToString()); } log.LogInfo(val2); } catch (Exception ex) { ManualLogSource log2 = Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(22, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Error dumping entity: "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message); } log2.LogWarning(val3); } } public static EntityQuery BuildEntityQuery(EntityManager entityManager, ComponentType[] all, EntityQueryOptions options) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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) EntityQueryBuilder val = default(EntityQueryBuilder); ((EntityQueryBuilder)(ref val))..ctor(AllocatorHandle.op_Implicit((Allocator)2)); foreach (ComponentType val2 in all) { ((EntityQueryBuilder)(ref val)).AddAll(val2); } ((EntityQueryBuilder)(ref val)).WithOptions(options); return ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val); } } internal static class Extensions { public delegate void WithRefHandler<T>(ref T item); private static EntityManager EntityManager => Core.EntityManager; private static PrefabCollectionSystem PrefabCollectionSystem => Core.PrefabCollectionSystem; public static void With<T>(this Entity entity, WithRefHandler<T> action) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) T item = entity.ReadRW<T>(); action(ref item); EntityManager entityManager = EntityManager; ((EntityManager)(ref entityManager)).SetComponentData<T>(entity, item); } public static void AddWith<T>(this Entity entity, WithRefHandler<T> action) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (!entity.Has<T>()) { entity.Add<T>(); } entity.With(action); } public static void HasWith<T>(this Entity entity, WithRefHandler<T> action) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (entity.Has<T>()) { entity.With(action); } } public unsafe static void Write<T>(this Entity entity, T componentData) where T : struct { //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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0); byte[] array = StructureToByteArray(componentData); int num = Marshal.SizeOf<T>(); fixed (byte* ptr = array) { EntityManager entityManager = EntityManager; ((EntityManager)(ref entityManager)).SetComponentDataRaw(entity, val.TypeIndex, (void*)ptr, num); } } public static byte[] StructureToByteArray<T>(T structure) where T : struct { int num = Marshal.SizeOf(structure); byte[] array = new byte[num]; IntPtr intPtr = Marshal.AllocHGlobal(num); Marshal.StructureToPtr(structure, intPtr, fDeleteOld: true); Marshal.Copy(intPtr, array, 0, num); Marshal.FreeHGlobal(intPtr); return array; } public unsafe static T ReadRW<T>(this Entity entity) where T : struct { //IL_000d: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0); EntityManager entityManager = EntityManager; return Marshal.PtrToStructure<T>(new IntPtr(((EntityManager)(ref entityManager)).GetComponentDataRawRW(entity, val.TypeIndex))); } public unsafe static T Read<T>(this Entity entity) where T : struct { //IL_000d: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0); EntityManager entityManager = EntityManager; return Marshal.PtrToStructure<T>(new IntPtr(((EntityManager)(ref entityManager)).GetComponentDataRawRO(entity, val.TypeIndex))); } public static DynamicBuffer<T> ReadBuffer<T>(this Entity entity) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = EntityManager; return ((EntityManager)(ref entityManager)).GetBuffer<T>(entity, false); } public static DynamicBuffer<T> AddBuffer<T>(this Entity entity) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = EntityManager; return ((EntityManager)(ref entityManager)).AddBuffer<T>(entity); } public static bool TryGetComponent<T>(this Entity entity, out T componentData) where T : struct { //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) componentData = default(T); if (entity.Has<T>()) { componentData = entity.Read<T>(); return true; } return false; } public static bool TryGetBuffer<T>(this Entity entity, out DynamicBuffer<T> buffer) where T : struct { //IL_0001: 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_0016: Unknown result type (might be due to invalid IL or missing references) buffer = default(DynamicBuffer<T>); if (entity.Has<T>()) { buffer = entity.ReadBuffer<T>(); return true; } return false; } public static bool TryRemoveComponent<T>(this Entity entity) where T : struct { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (entity.Has<T>()) { entity.Remove<T>(); return true; } return false; } public static bool Has<T>(this Entity entity) { //IL_000d: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) ComponentType val = default(ComponentType); ((ComponentType)(ref val))..ctor(Il2CppType.Of<T>(), (AccessMode)0); EntityManager entityManager = EntityManager; return ((EntityManager)(ref entityManager)).HasComponent(entity, val); } public static void LogComponentTypes(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_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) //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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = EntityManager; Enumerator<ComponentType> enumerator = ((EntityManager)(ref entityManager)).GetComponentTypes(entity, (Allocator)2).GetEnumerator(); Core.Log.LogInfo((object)"==="); bool flag = default(bool); while (enumerator.MoveNext()) { ComponentType current = enumerator.Current; ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(0, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ComponentType>(current); } log.LogInfo(val); } Core.Log.LogInfo((object)"==="); enumerator.Dispose(); } public static void Add<T>(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = EntityManager; ((EntityManager)(ref entityManager)).AddComponent(entity, new ComponentType(Il2CppType.Of<T>(), (AccessMode)0)); } public static void Remove<T>(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = EntityManager; ((EntityManager)(ref entityManager)).RemoveComponent(entity, new ComponentType(Il2CppType.Of<T>(), (AccessMode)0)); } public static bool TryGetFollowedPlayer(this Entity entity, out Entity player) { //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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) player = Entity.Null; if (entity.Has<Follower>()) { Entity value = entity.Read<Follower>().Followed._Value; if (value.IsPlayer()) { player = value; return true; } } return false; } public static bool TryGetPlayer(this Entity entity, out Entity player) { //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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) player = Entity.Null; if (entity.Has<PlayerCharacter>()) { player = entity; return true; } return false; } public static bool IsPlayer(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (entity.Has<VampireTag>()) { return true; } return false; } public static bool IsDifferentPlayer(this Entity entity, Entity target) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (entity.IsPlayer() && target.IsPlayer() && !((Entity)(ref entity)).Equals(target)) { return true; } return false; } public static bool IsFollowingPlayer(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (entity.Has<Follower>() && entity.Read<Follower>().Followed._Value.IsPlayer()) { return true; } return false; } public static Entity GetBuffTarget(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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) return CreateGameplayEventServerUtility.GetBuffTarget(EntityManager, entity); } public static Entity GetSpellTarget(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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) return CreateGameplayEventServerUtility.GetSpellTarget(EntityManager, entity); } public static bool TryGetTeamEntity(this Entity entity, out Entity teamEntity) { //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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) teamEntity = Entity.Null; if (entity.TryGetComponent<TeamReference>(out TeamReference componentData)) { Entity value = componentData.Value._Value; if (value.Exists()) { teamEntity = value; return true; } } return false; } public static bool Exists(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) if (entity.HasValue()) { EntityManager entityManager = EntityManager; return ((EntityManager)(ref entityManager)).Exists(entity); } return false; } public static bool HasValue(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return entity != Entity.Null; } public static bool IsDisabled(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return entity.Has<Disabled>(); } public static bool IsVBlood(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return entity.Has<VBloodUnit>(); } public static ulong GetSteamId(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (entity.TryGetComponent<PlayerCharacter>(out PlayerCharacter componentData)) { return componentData.UserEntity.Read<User>().PlatformId; } if (entity.TryGetComponent<User>(out User componentData2)) { return componentData2.PlatformId; } return 0uL; } public static void ForEach<T>(this IEnumerable<T> source, Action<T> action) { foreach (T item in source) { action(item); } } public static PrefabGUID GetPrefabGuid(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (entity.TryGetComponent<PrefabGUID>(out PrefabGUID componentData)) { return componentData; } return PrefabGUID.Empty; } public static bool IsEmpty(this Entity entity) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return ((Entity)(ref entity)).Equals(Entity.Null); } public static Entity GetUserEntity(this Entity entity) { //IL_0000: 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_000a: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (entity.TryGetComponent<PlayerCharacter>(out PlayerCharacter componentData)) { return componentData.UserEntity; } if (entity.TryGetComponent<UserOwner>(out UserOwner componentData2)) { return ((NetworkedEntity)(ref componentData2.Owner)).GetEntityOnServer(); } return Entity.Null; } public static User GetUser(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (entity.TryGetComponent<PlayerCharacter>(out PlayerCharacter componentData) && componentData.UserEntity.TryGetComponent<User>(out User componentData2)) { return componentData2; } if (entity.TryGetComponent<User>(out componentData2)) { return componentData2; } return User.Empty; } public static int GetTerritoryIndex(this Entity entity) { //IL_0000: 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 (entity.TryGetComponent<CastleTerritory>(out CastleTerritory componentData)) { return componentData.CastleTerritoryIndex; } return -1; } public static void Destroy(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (entity.Exists()) { DestroyUtility.Destroy(EntityManager, entity, (DestroyDebugReason)0, (string)null, 0); } } public static void DestroyBuff(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (entity.Exists()) { DestroyUtility.Destroy(EntityManager, entity, (DestroyDebugReason)13, (string)null, 0); } } public static NetworkId GetNetworkId(this Entity entity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) if (entity.TryGetComponent<NetworkId>(out NetworkId componentData)) { return componentData; } return NetworkId.Empty; } public static Coroutine Start(this IEnumerator routine) { return Core.StartCoroutine(routine); } private static EntityQuery BuildEntityQuery(this EntityManager entityManager, ComponentType[] all) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) EntityQueryBuilder val = default(EntityQueryBuilder); ((EntityQueryBuilder)(ref val))..ctor(AllocatorHandle.op_Implicit((Allocator)2)); foreach (ComponentType val2 in all) { ((EntityQueryBuilder)(ref val)).AddAll(val2); } return ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val); } private static EntityQuery BuildEntityQuery(this EntityManager entityManager, ComponentType[] all, EntityQueryOptions options) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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) EntityQueryBuilder val = default(EntityQueryBuilder); ((EntityQueryBuilder)(ref val))..ctor(AllocatorHandle.op_Implicit((Allocator)2)); foreach (ComponentType val2 in all) { ((EntityQueryBuilder)(ref val)).AddAll(val2); } ((EntityQueryBuilder)(ref val)).WithOptions(options); return ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val); } private static EntityQuery BuildEntityQuery(this EntityManager entityManager, ComponentType[] all, ComponentType[] none, EntityQueryOptions options) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) EntityQueryBuilder val = default(EntityQueryBuilder); ((EntityQueryBuilder)(ref val))..ctor(AllocatorHandle.op_Implicit((Allocator)2)); ComponentType[] array = all; foreach (ComponentType val2 in array) { ((EntityQueryBuilder)(ref val)).AddAll(val2); } array = none; foreach (ComponentType val3 in array) { ((EntityQueryBuilder)(ref val)).AddNone(val3); } ((EntityQueryBuilder)(ref val)).WithOptions(options); return ((EntityManager)(ref entityManager)).CreateEntityQuery(ref val); } private static int[] GenerateDefaultIndices(int length) { int[] array = new int[length]; for (int i = 0; i < length; i++) { array[i] = i; } return array; } public static float3 GetPosition(this Entity entity) { //IL_0000: 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_000a: 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) if (entity.TryGetComponent<Translation>(out Translation componentData)) { return componentData.Value; } return float3.zero; } public static int2 GetCoordinate(this Entity entity) { //IL_0000: 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_000a: 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) if (entity.TryGetComponent<TilePosition>(out TilePosition componentData)) { return componentData.Tile; } return int2.zero; } } [BepInPlugin("io.zfolmt.RetroCamera", "RetroCamera", "1.2.1")] internal class Plugin : BasePlugin { private Harmony _harmony; internal static Plugin Instance { get; private set; } public static ManualLogSource LogInstance => ((BasePlugin)Instance).Log; public override void Load() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown Instance = this; ((BasePlugin)this).AddComponent<RetroCamera.Systems.RetroCamera>(); _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(20, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("RetroCamera"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.2.1"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] loaded on client!"); } log.LogInfo(val); } public override bool Unload() { TopdownCameraSystemHooks.Dispose(); _harmony.UnpatchSelf(); return true; } } internal static class Settings { public const float FIRST_PERSON_FORWARD_OFFSET = 1.65f; public const float MOUNTED_OFFSET = 1.6f; public const float HEAD_HEIGHT_OFFSET = 1.05f; public const float SHOULDER_RIGHT_OFFSET = 0.8f; private const float ZOOM_OFFSET = 2f; private static Toggle _enabledOption; private static Slider _fieldOfViewOption; private static Toggle _alwaysShowCrosshairOption; private static Toggle _actionModeCrosshairOption; private static Toggle _firstPersonEnabledOption; private static Slider _aimOffsetXOption; private static Slider _aimOffsetYOption; private static Toggle _lockCameraZoomOption; private static Slider _lockCameraZoomDistanceOption; private static Slider _minZoomOption; private static Slider _maxZoomOption; private static Toggle _lockCamerPitchOption; private static Slider _lockCameraPitchAngleOption; private static Slider _minPitchOption; private static Slider _maxPitchOption; private static Toggle _overTheShoulderOption; private static Slider _overTheShoulderXOption; private static Slider _overTheShoulderYOption; private static Keybinding _enabledKeybind; private static Keybinding _actionModeKeybind; private static Keybinding _toggleHUDKeybind; private static Keybinding _toggleFogKeybind; private static Keybinding _completeTutorialKeybind; private static Keybinding _cycleCameraKeybind; public static bool Enabled { get { return _enabledOption.Value; } set { _enabledOption.SetValue(value); } } public static bool FirstPersonEnabled { get { return _firstPersonEnabledOption.Value; } set { _firstPersonEnabledOption.SetValue(value); } } public static bool AlwaysShowCrosshair { get { return _alwaysShowCrosshairOption.Value; } set { _alwaysShowCrosshairOption.SetValue(value); } } public static bool ActionModeCrosshair { get { return _actionModeCrosshairOption.Value; } set { _actionModeCrosshairOption.SetValue(value); } } public static float FieldOfView { get { return _fieldOfViewOption.Value; } set { _fieldOfViewOption.SetValue(value); } } public static int AimOffsetX { get { return (int)((float)Screen.width * (_aimOffsetXOption.Value / 100f)); } set { _aimOffsetXOption.SetValue(Mathf.Clamp(value / Screen.width, -25, 25)); } } public static int AimOffsetY { get { return (int)((float)Screen.height * (_aimOffsetYOption.Value / 100f)); } set { _aimOffsetYOption.SetValue(Mathf.Clamp(value / Screen.width, -25, 25)); } } public static bool LockZoom { get { return _lockCameraZoomOption.Value; } set { _lockCameraZoomOption.SetValue(value); } } public static float LockZoomDistance { get { return _lockCameraZoomDistanceOption.Value; } set { _lockCameraZoomDistanceOption.SetValue(value); } } public static float MinZoom { get { return _minZoomOption.Value; } set { _minZoomOption.SetValue(value); } } public static float MaxZoom { get { return _maxZoomOption.Value; } set { _maxZoomOption.SetValue(value); } } public static bool LockPitch { get { return _lockCamerPitchOption.Value; } set { _lockCamerPitchOption.SetValue(value); } } public static float LockPitchAngle { get { return _lockCameraPitchAngleOption.Value * ((float)Math.PI / 180f); } set { _lockCameraPitchAngleOption.SetValue(Mathf.Clamp(value * 57.29578f, 0f, 90f)); } } public static float MinPitch { get { return _minPitchOption.Value * ((float)Math.PI / 180f); } set { _minPitchOption.SetValue(Mathf.Clamp(value * 57.29578f, 0f, 90f)); } } public static float MaxPitch { get { return _maxPitchOption.Value * ((float)Math.PI / 180f); } set { _maxPitchOption.SetValue(Mathf.Clamp(value * 57.29578f, 0f, 90f)); } } public static bool OverTheShoulder { get { return _overTheShoulderOption.Value; } set { _overTheShoulderOption.SetValue(value); } } public static float OverTheShoulderX { get { return _overTheShoulderXOption.Value; } set { _overTheShoulderXOption.SetValue(value); } } public static float OverTheShoulderY { get { return _overTheShoulderYOption.Value; } set { _overTheShoulderYOption.SetValue(value); } } public static void Initialize() { try { RegisterOptions(); RegisterKeybinds(); TryLoadOptions(); TryLoadKeybinds(); Persistence.SaveOptions(); Persistence.SaveKeybinds(); } catch (Exception ex) { Core.Log.LogError((object)ex); } } public static void AddEnabledListener(MenuOption<bool>.OptionChangedHandler<bool> handler) { _enabledOption.AddListener(handler); } public static void AddFieldOfViewListener(MenuOption<float>.OptionChangedHandler<float> handler) { _fieldOfViewOption.AddListener(handler); } public static void AddHideHUDListener(Keybinding.KeyHandler action) { _toggleHUDKeybind.AddKeyDownListener(action); } public static void AddHideFogListener(Keybinding.KeyHandler action) { _toggleFogKeybind.AddKeyDownListener(action); } public static void AddCompleteTutorialListener(Keybinding.KeyHandler action) { _completeTutorialKeybind.AddKeyDownListener(action); } public static void AddCycleCameraListener(Keybinding.KeyHandler action) { _cycleCameraKeybind.AddKeyDownListener(action); } private static void RegisterOptions() { _enabledOption = OptionsManager.AddToggle("Enabled", "Enable or disable RetroCamera", defaultValue: true); _firstPersonEnabledOption = OptionsManager.AddToggle("First Person", "Enable zooming in far enough for first-person view", defaultValue: true); _alwaysShowCrosshairOption = OptionsManager.AddToggle("Always Show Crosshair", "Keep crosshair visible always", defaultValue: false); _actionModeCrosshairOption = OptionsManager.AddToggle("Action Mode Crosshair", "Show crosshair during action mode", defaultValue: false); _fieldOfViewOption = OptionsManager.AddSlider("FOV", "Camera field of view", 50f, 90f, 60f); OptionsManager.AddDivider("Third Person Zoom"); _minZoomOption = OptionsManager.AddSlider("Min Zoom", "Minimum zoom", 1f, 15f, 1f); _maxZoomOption = OptionsManager.AddSlider("Max Zoom", "Maximum zoom", 5f, 20f, 15f); _lockCameraZoomOption = OptionsManager.AddToggle("Lock Zoom", "Lock zoom distance", defaultValue: false); _lockCameraZoomDistanceOption = OptionsManager.AddSlider("Locked Zoom Distance", "Fixed zoom distance when locked", 1f, 20f, 15f); OptionsManager.AddDivider("Third Person Pitch"); _minPitchOption = OptionsManager.AddSlider("Min Pitch", "Minimum camera pitch", 0f, 90f, 10f); _maxPitchOption = OptionsManager.AddSlider("Max Pitch", "Maximum camera pitch", 0f, 90f, 90f); _lockCamerPitchOption = OptionsManager.AddToggle("Lock Pitch", "Lock camera pitch", defaultValue: false); _lockCameraPitchAngleOption = OptionsManager.AddSlider("Locked Pitch Angle", "Fixed pitch angle when locked", 0f, 90f, 60f); OptionsManager.AddDivider("Third Person Aiming"); _aimOffsetXOption = OptionsManager.AddSlider("Aiming Horizontal Offset", "Aim horizontal offset", -25f, 25f, 0f); _aimOffsetYOption = OptionsManager.AddSlider("Aiming Vertical Offset", "Aim vertical offset", -25f, 25f, 0f); OptionsManager.AddDivider("Over Shoulder"); _overTheShoulderOption = OptionsManager.AddToggle("Enable Shoulder Offset", "Enable over-the-shoulder camera", defaultValue: false); _overTheShoulderXOption = OptionsManager.AddSlider("Shoulder Horizontal Offset", "Shoulder view horizontal offset", 1f, 4f, 1f); _overTheShoulderYOption = OptionsManager.AddSlider("Shoulder Vertical Offset", "Shoulder view vertical offset", 1f, 8f, 1f); _minZoomOption.AddListener(delegate(float value) { if (value + 2f > MaxZoom && value + 2f < _maxZoomOption.MaxValue) { _maxZoomOption.SetValue(value + 2f); } else if (value + 2f > _maxZoomOption.MaxValue) { _minZoomOption.SetValue(_maxZoomOption.MaxValue - 2f); } }); _maxZoomOption.AddListener(delegate(float value) { if (value - 2f < MinZoom && value - 2f > _minZoomOption.MinValue) { _minZoomOption.SetValue(value - 2f); } else if (value - 2f < _minZoomOption.MinValue) { _maxZoomOption.SetValue(_minZoomOption.MinValue + 2f); } }); _minPitchOption.AddListener(delegate(float value) { if (value > _maxPitchOption.Value && value < _maxPitchOption.MaxValue) { _maxPitchOption.SetValue(value); } else if (value > _maxPitchOption.MaxValue) { _minPitchOption.SetValue(_maxPitchOption.MaxValue); } }); _maxPitchOption.AddListener(delegate(float value) { if (value < _minPitchOption.Value && value > _minPitchOption.MinValue) { _minPitchOption.SetValue(value); } else if (value < _minPitchOption.MinValue) { _maxPitchOption.SetValue(_minPitchOption.MinValue); } }); } private static void RegisterKeybinds() { _enabledKeybind = KeybindsManager.AddKeybind("Toggle RetroCamera", "Enable or disable RetroCamera functions", (KeyCode)91); _enabledKeybind.AddKeyDownListener(delegate { _enabledOption.SetValue(!Enabled); }); _actionModeKeybind = KeybindsManager.AddKeybind("Toggle Action Mode", "Toggle action mode", (KeyCode)93); _actionModeKeybind.AddKeyDownListener(delegate { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) if (Enabled && !CameraState._isFirstPerson) { CameraState._isMouseLocked = !CameraState._isMouseLocked; CameraState._isActionMode = !CameraState._isActionMode; if (CameraState.IsMenuOpen) { CameraState.IsMenuOpen = false; } if (ActionWheelSystemPatch._wheelVisible) { ActionWheelSystemPatch._wheelVisible = false; } CursorLockMode lockState = Cursor.lockState; if (((object)(CursorLockMode)(ref lockState)).Equals((object)(CursorLockMode)1) && (!CameraState._isActionMode || !CameraState._isMouseLocked)) { Cursor.lockState = (CursorLockMode)0; } } }); _toggleHUDKeybind = KeybindsManager.AddKeybind("Toggle HUD", "Toggle HUD visibility", (KeyCode)92); _toggleFogKeybind = KeybindsManager.AddKeybind("Toggle Fog/Clouds", "Toggle visibility of fog and clouds (cloud ground shadows also affected)", (KeyCode)61); _completeTutorialKeybind = KeybindsManager.AddKeybind("Complete Tutorial", "Pushes button for completed tutorials if applicable", (KeyCode)45); } public static bool TryLoadOptions() { Dictionary<string, MenuOption> dictionary = Persistence.LoadOptions(); if (dictionary == null) { return false; } foreach (var (key, other) in dictionary) { if (OptionsManager.Options.TryGetValue(key, out var value)) { value.ApplySaved(other); } } return true; } public static bool TryLoadKeybinds() { Dictionary<string, Keybinding> dictionary = Persistence.LoadKeybinds(); if (dictionary == null) { return false; } foreach (var (key, keybind) in dictionary) { if (KeybindsManager.Keybinds.TryGetValue(key, out var value)) { value.ApplySaved(keybind); } } return true; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "io.zfolmt.RetroCamera"; public const string PLUGIN_NAME = "RetroCamera"; public const string PLUGIN_VERSION = "1.2.1"; } } namespace RetroCamera.Utilities { internal static class CameraState { public enum BehaviourType { Default, FirstPerson, ThirdPerson } public enum CameraAimMode { Default, Forward } public static bool _isUIHidden; public static bool _isFirstPerson; public static bool _isActionMode; public static bool _isMouseLocked; public static bool _isShapeshifted; public static bool _isMounted; public static bool _inBuildMode; public static bool _validGameplayInputState; public static bool _usingMouseWheel; public static BehaviourType _currentBehaviourType = BehaviourType.Default; public static Dictionary<BehaviourType, CameraBehaviour> _cameraBehaviours = new Dictionary<BehaviourType, CameraBehaviour>(); public static InputState _gameplayInputState; public static string _shapeshiftName; private static int _menusOpen; public static bool IsMenuOpen { get { return _menusOpen > 0; } set { _menusOpen = (value ? (_menusOpen + 1) : Mathf.Max(0, _menusOpen - 1)); } } public static CameraBehaviour CurrentCameraBehaviour { get { if (_cameraBehaviours.ContainsKey(_currentBehaviourType)) { return _cameraBehaviours[_currentBehaviourType]; } return null; } } public static void RegisterCameraBehaviour(CameraBehaviour behaviour) { _cameraBehaviours.Add(behaviour.BehaviourType, behaviour); } public static void Reset() { _isUIHidden = false; _isFirstPerson = false; _isActionMode = false; _isMouseLocked = false; _isShapeshifted = false; _isMounted = false; _inBuildMode = false; _shapeshiftName = ""; _validGameplayInputState = false; CurrentCameraBehaviour?.Deactivate(); _currentBehaviourType = BehaviourType.Default; } } internal static class ClearSkies { private static BatFormFog _primaryMaterial; private static Material _secondaryMaterial; private static float _cloudiness; public static Entity _dayNightCycleSingleton; private static bool _isActive; private const float CLOUDINESS = 0.65f; private const string MATERIAL = "Hidden/Shader/BatFormFog"; public static bool _initialized; private static EntityManager EntityManager => Core.EntityManager; public static void ToggleFog() { _isActive = !_isActive; if (_isActive) { RemoveFog(); } else { RestoreFog(); } } private static void RemoveFog() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (!_dayNightCycleSingleton.Exists()) { GetDayNightCycleSingleton(); } if ((Object)(object)_primaryMaterial == (Object)null) { GetBatFormFogMaterial(); } if (!((Object)(object)_primaryMaterial == (Object)null)) { _secondaryMaterial = new Material(_primaryMaterial.m_Material); _dayNightCycleSingleton.HasWith<DayNightCycle>((Extensions.WithRefHandler<DayNightCycle>)delegate(ref DayNightCycle dayNightCycle) { _cloudiness = dayNightCycle.Cloudiness; dayNightCycle.Cloudiness = 0f; }); Object.Destroy((Object)(object)_primaryMaterial.m_Material); } } private static void RestoreFog() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (!_dayNightCycleSingleton.Exists()) { GetDayNightCycleSingleton(); } if (!((Object)(object)_secondaryMaterial == (Object)null)) { _primaryMaterial.m_Material = new Material(_secondaryMaterial); _dayNightCycleSingleton.HasWith<DayNightCycle>((Extensions.WithRefHandler<DayNightCycle>)delegate(ref DayNightCycle dayNightCycle) { dayNightCycle.Cloudiness = _cloudiness; }); } } public static void Initialize() { GetBatFormFogMaterial(); GetDayNightCycleSingleton(); } private static void GetBatFormFogMaterial() { if (!((Object)(object)_primaryMaterial != (Object)null)) { _primaryMaterial = ((IEnumerable<BatFormFog>)Object.FindObjectsOfType<BatFormFog>()).LastOrDefault((Func<BatFormFog, bool>)((BatFormFog batFormFog) => (Object)(object)batFormFog.m_Material != (Object)null && ((Object)batFormFog.m_Material).name.Contains("Hidden/Shader/BatFormFog"))); if ((Object)(object)_primaryMaterial != (Object)null) { _ = (Object)(object)_primaryMaterial.m_Material != (Object)null; } else _ = 0; } } private static void GetDayNightCycleSingleton() { //IL_0000: 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_0011: 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_0022: Unknown result type (might be due to invalid IL or missing references) _dayNightCycleSingleton = (SingletonAccessor<DayNightCycle>.TryGetSingletonEntityWasteful(EntityManager, ref _dayNightCycleSingleton) ? _dayNightCycleSingleton : Entity.Null); if (_dayNightCycleSingleton.Exists()) { _initialized = true; } } public static void Reset() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) _primaryMaterial = null; _secondaryMaterial = null; _cloudiness = 0.65f; _dayNightCycleSingleton = Entity.Null; _isActive = false; } } internal static class MethodResolver { private static ulong ExtractTargetAddress(in Instruction instruction) { //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Invalid comparison between Unknown and I4 OpKind op0Kind = ((Instruction)(ref instruction)).Op0Kind; if ((int)op0Kind != 4) { if ((int)op0Kind == 5) { return ((Instruction)(ref instruction)).FarBranch32; } return ((Instruction)(ref instruction)).NearBranchTarget; } return ((Instruction)(ref instruction)).FarBranch16; } private unsafe static IntPtr ResolveMethodPointer(IntPtr methodPointer) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Invalid comparison between Unknown and I4 //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Invalid comparison between Unknown and I4 //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Invalid comparison between Unknown and I4 //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Invalid comparison between Unknown and I4 //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Invalid comparison between Unknown and I4 StreamCodeReader val = new StreamCodeReader((Stream)new UnmanagedMemoryStream((byte*)(void*)methodPointer, 256L, 256L, FileAccess.Read)); Decoder val2 = Decoder.Create((IntPtr.Size == 8) ? 64 : 32, (CodeReader)(object)val, (DecoderOptions)0); val2.IP = (ulong)methodPointer.ToInt64(); Instruction instruction = default(Instruction); while ((int)((Instruction)(ref instruction)).Mnemonic != 1620) { val2.Decode(ref instruction); if ((int)((Instruction)(ref instruction)).Mnemonic != 308 && (int)((Instruction)(ref instruction)).Mnemonic != 7) { return methodPointer; } if ((int)((Instruction)(ref instruction)).Mnemonic == 7 && ((Instruction)(ref instruction)).Immediate32 != 16) { return methodPointer; } if ((int)((Instruction)(ref instruction)).Mnemonic == 308) { return new IntPtr((long)ExtractTargetAddress(in instruction)); } } return methodPointer; } public static IntPtr ResolveFromMethodInfo(INativeMethodInfoStruct methodInfo) { return ResolveMethodPointer(methodInfo.MethodPointer); } public unsafe static IntPtr ResolveFromMethodInfo(MethodInfo method) { INativeMethodInfoStruct val = UnityVersionHandler.Wrap((Il2CppMethodInfo*)(void*)(IntPtr)((Il2CppInteropUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod((MethodBase)method) ?? throw new Exception($"Couldn't obtain method info for {method}")).GetValue(null) ?? ((object)IntPtr.Zero))); if (val != null) { return ResolveFromMethodInfo(val); } throw new Exception($"Method info for {method} is invalid"); } } internal static class NativeDetour { public static INativeDetour Create<T>(Type type, string innerTypeName, string methodName, T to, out T original) where T : Delegate { return Create(GetInnerType(type, innerTypeName), methodName, to, out original); } public static INativeDetour Create<T>(Type type, string methodName, T to, out T original) where T : Delegate { return Create(type.GetMethod(methodName, AccessTools.all), to, out original); } private static INativeDetour Create<T>(MethodInfo method, T to, out T original) where T : Delegate { return INativeDetour.CreateAndApply<T>(MethodResolver.ResolveFromMethodInfo(method), to, ref original); } private static Type GetInnerType(Type type, string innerTypeName) { return type.GetNestedTypes().First((Type x) => x.Name.Contains(innerTypeName)); } } internal static class Persistence { private static readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions { WriteIndented = true, IncludeFields = true, Converters = { (JsonConverter)new MenuOptionJsonConverter() } }; private static readonly string _directoryPath = Path.Join(Paths.ConfigPath, "RetroCamera"); private const string KEYBINDS_KEY = "Keybinds"; private const string OPTIONS_KEY = "Options"; private static readonly string _keybindsJson = Path.Combine(_directoryPath, "Keybinds.json"); private static readonly string _settingsJson = Path.Combine(_directoryPath, "Options.json"); private static readonly Dictionary<string, string> _filePaths = new Dictionary<string, string> { { "Keybinds", _keybindsJson }, { "Options", _settingsJson } }; public static void SaveKeybinds() { SaveDictionary(KeybindsManager.Keybinds, "Keybinds"); } public static void SaveOptions() { SaveDictionary(OptionsManager.Options, "Options"); } public static Dictionary<string, Keybinding> LoadKeybinds() { return LoadDictionary<string, Keybinding>("Keybinds"); } public static Dictionary<string, MenuOption> LoadOptions() { return LoadDictionary<string, MenuOption>("Options"); } private static Dictionary<T, U> LoadDictionary<T, U>(string fileKey) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown if (!_filePaths.TryGetValue(fileKey, out var value)) { return null; } try { if (!Directory.Exists(_directoryPath)) { Directory.CreateDirectory(_directoryPath); } if (!File.Exists(value)) { File.Create(value).Dispose(); return new Dictionary<T, U>(); } string text = File.ReadAllText(value); return Utility.IsNullOrWhiteSpace(text) ? new Dictionary<T, U>() : JsonSerializer.Deserialize<Dictionary<T, U>>(text, _jsonOptions); } catch (IOException ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(33, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to deserialize "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(fileKey); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" contents: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogWarning(val); return null; } } private static void SaveDictionary<T, U>(IReadOnlyDictionary<T, U> fileData, string fileKey) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown if (!_filePaths.TryGetValue(fileKey, out var value)) { return; } try { if (!Directory.Exists(_directoryPath)) { Directory.CreateDirectory(_directoryPath); } string contents = JsonSerializer.Serialize(fileData, _jsonOptions); File.WriteAllText(value, contents); } catch (IOException ex) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(31, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to serialize "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(fileKey); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" contents: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } log.LogWarning(val); } } } internal class MenuOptionJsonConverter : JsonConverter<MenuOption> { private const string TYPE_PROPERTY = "OptionType"; public override MenuOption Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { using JsonDocument jsonDocument = JsonDocument.ParseValue(ref reader); JsonElement rootElement = jsonDocument.RootElement; if (!rootElement.TryGetProperty("OptionType", out var value)) { throw new JsonException("Missing 'OptionType' in MenuOption JSON converter!"); } string @string = value.GetString(); return @string switch { "Toggle" => JsonSerializer.Deserialize<Toggle>(rootElement.GetRawText(), options), "Slider" => JsonSerializer.Deserialize<Slider>(rootElement.GetRawText(), options), "Dropdown" => JsonSerializer.Deserialize<Dropdown>(rootElement.GetRawText(), options), _ => throw new JsonException("Unknown MenuOption type '" + @string + "'"), }; } public override void Write(Utf8JsonWriter writer, MenuOption value, JsonSerializerOptions options) { using JsonDocument jsonDocument = JsonSerializer.SerializeToDocument(value, value.GetType(), options); JsonObject jsonObject = JsonNode.Parse(jsonDocument.RootElement.GetRawText()).AsObject(); jsonObject["OptionType"] = value.GetType().Name; jsonObject.WriteTo(writer, options); } } } namespace RetroCamera.Systems { public class RetroCamera : MonoBehaviour { private static Entity _localCharacter; private static GameObject _crosshairPrefab; private static GameObject _crosshair; private static CanvasScaler _canvasScaler; private static Camera _gameCamera; private static bool _gameFocused = true; private static bool _listening = false; private static GameObject _journalClaimButtonObject; private static readonly Dictionary<CameraType, Camera> _cameras = new Dictionary<CameraType, Camera>(); private static Camera _camera; private static CameraUser _cameraUser; private static EntityQuery _cameraQuery; private static EntityManager EntityManager => Core.EntityManager; private static ZoomModifierSystem ZoomModifierSystem => Core.ZoomModifierSystem; public static void Enabled(bool enabled) { Settings.Enabled = enabled; UpdateEnabled(enabled); } public static void ActionMode(bool enabled) { CameraState._isMouseLocked = enabled; CameraState._isActionMode = enabled; } private static void UpdateEnabled(bool enabled) { if (ZoomModifierSystem != null) { ((ComponentSystemBase)ZoomModifierSystem).Enabled = !enabled; } if ((Object)(object)_crosshair != (Object)null) { _crosshair.active = enabled && Settings.AlwaysShowCrosshair && !CameraState._inBuildMode; } if (!enabled) { Cursor.visible = true; ActionMode(enabled: false); } } private static void UpdateFieldOfView(float fov) { if ((Object)(object)_gameCamera != (Object)null) { _gameCamera.fieldOfView = fov; } } private static void ToggleHUD() { CameraState._isUIHidden = !CameraState._isUIHidden; DisableUISettings.SetHideHUD(CameraState._isUIHidden, Core._client); } private static void ToggleFog() { ClearSkies.ToggleFog(); } private void Awake() { Settings.Initialize(); RegisterBehaviours(); } private static void RegisterBehaviours() { CameraState.RegisterCameraBehaviour(new FirstPersonCameraBehaviour()); CameraState.RegisterCameraBehaviour(new ThirdPersonCameraBehaviour()); } private static void AddListeners() { Settings.AddEnabledListener(UpdateEnabled); Settings.AddFieldOfViewListener(UpdateFieldOfView); Settings.AddHideHUDListener(ToggleHUD); Settings.AddHideFogListener(ToggleFog); Settings.AddCompleteTutorialListener(CompleteTutorial); } private static void CompleteTutorial() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown if ((Object)(object)_journalClaimButtonObject == (Object)null) { _journalClaimButtonObject = GameObject.Find("HUDCanvas(Clone)/JournalCanvas/JournalParent(Clone)/Content/Layout/JournalEntry_Multi/ButtonParent/ClaimButton"); } if ((Object)(object)_journalClaimButtonObject != (Object)null) { SimpleStunButton component = _journalClaimButtonObject.GetComponent<SimpleStunButton>(); if (component != null) { component.Press(); } return; } ManualLogSource log = Core.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(45, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[RetroCamera] Journal claim button not found!"); } log.LogWarning(val); } private static void CycleCamera() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Expected O, but got Unknown //IL_0161: Unknown result type (might be due to invalid IL or missing references) try { if (!((Object)_camera).Equals((Object)null)) { return; } ComponentType[] all = (ComponentType[])(object)new ComponentType[1] { ComponentType.ReadOnly(Il2CppType.Of<CameraUser>()) }; _cameraQuery = Core.BuildEntityQuery(EntityManager, all, (EntityQueryOptions)195); _cameraUser = (CameraUser)(((EntityQuery)(ref _cameraQuery)).ToEntityArray(AllocatorHandle.op_Implicit((Allocator)2))[0].TryGetComponent<CameraUser>(out CameraUser componentData) ? componentData : default(CameraUser)); _camera = CameraUtilities.FindActiveCamera(EntityManager, _cameraQuery); bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val; if (((Object)_camera).Equals((Object)null)) { ManualLogSource log = Core.Log; val = new BepInExWarningLogInterpolatedStringHandler(29, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[RetroCamera] Camera is null!"); } log.LogWarning(val); } else { ManualLogSource log2 = Core.Log; val = new BepInExWarningLogInterpolatedStringHandler(29, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[RetroCamera] Camera found - "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((Object)_camera).name); } log2.LogWarning(val); } if (!_cameraUser.CameraEntity.Exists()) { ManualLogSource log3 = Core.Log; val = new BepInExWarningLogInterpolatedStringHandler(50, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[RetroCamera] Camera entity on CameraUser is null!"); } log3.LogWarning(val); return; } ManualLogSource log4 = Core.Log; val = new BepInExWarningLogInterpolatedStringHandler(49, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[RetroCamera] Camera entity on CameraUser exists!"); } log4.LogWarning(val); Core.LogEntity(Core._client, _cameraUser.CameraEntity); } catch (Exception ex) { Core.Log.LogWarning((object)ex); } } private static void GetOrCreateObjects() { if ((Object)(object)_crosshairPrefab == (Object)null) { BuildCrosshair(); } if ((Object)(object)_gameCamera == (Object)null) { _gameCamera = CameraManager.GetCamera(); } } private void Update() { if (Core._initialized && _gameFocused && Settings.Enabled) { if (!_listening) { _listening = true; AddListeners(); } if ((Object)(object)_crosshairPrefab == (Object)null) { BuildCrosshair(); } if ((Object)(object)_gameCamera == (Object)null) { _gameCamera = CameraManager.GetCamera(); } UpdateCrosshair(); } } private void OnApplicationFocus(bool hasFocus) { _gameFocused = hasFocus; } private static void BuildCrosshair() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0074: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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) try { CursorData val = ((IEnumerable<CursorData>)CursorController._CursorDatas).First((CursorData x) => (int)x.CursorType == 0); if (val != null) { _crosshairPrefab = new GameObject("Crosshair") { active = false }; _crosshairPrefab.AddComponent<CanvasRenderer>(); RectTransform obj = _crosshairPrefab.AddComponent<RectTransform>(); ((Component)obj).transform.SetSiblingIndex(1); obj.pivot = new Vector2(0.5f, 0.5f); obj.anchorMin = new Vector2(0.5f, 0.5f); obj.anchorMax = new Vector2(0.5f, 0.5f); obj.sizeDelta = new Vector2(32f, 32f); ((Transform)obj).localScale = new Vector3(1.2f, 1.2f, 1.2f); ((Transform)obj).localPosition = new Vector3(0f, 0f, 0f); _crosshairPrefab.AddComponent<Image>().sprite = Sprite.Create(val.Texture, new Rect(0f, 0f, (float)((Texture)val.Texture).width, (float)((Texture)val.Texture).height), new Vector2(0.5f, 0.5f), 100f); _crosshairPrefab.active = false; } } catch (Exception ex) { Core.Log.LogError((object)ex); } } private static void UpdateCrosshair() { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) try { bool visible = true; bool flag = false; if ((Object)(object)_crosshair == (Object)null && (Object)(object)_crosshairPrefab != (Object)null) { GameObject val = GameObject.Find("HUDCanvas(Clone)/Canvas"); if ((Object)(object)val == (Object)null) { return; } _canvasScaler = val.GetComponent<CanvasScaler>(); _crosshair = Object.Instantiate<GameObject>(_crosshairPrefab, val.transform); _crosshair.active = true; } if (CameraState._validGameplayInputState && (CameraState._isMouseLocked || ((InputState)(ref CameraState._gameplayInputState)).IsInputPressed((ButtonInputAction)500)) && !CameraState.IsMenuOpen) { flag = CameraState._isFirstPerson || (CameraState._isActionMode && Settings.ActionModeCrosshair); visible = CameraState._usingMouseWheel; } if ((Object)(object)_crosshair != (Object)null) { _crosshair.active = (flag || Settings.AlwaysShowCrosshair) && !CameraState._inBuildMode; if (CameraState._isFirstPerson) { _crosshair.transform.localPosition = Vector3.zero; } else if ((Object)(object)_canvasScaler != (Object)null) { _crosshair.transform.localPosition = new Vector3((float)Settings.AimOffsetX * (_canvasScaler.referenceResolution.x / (float)Screen.width), (float)Settings.AimOffsetY * (_canvasScaler.referenceResolution.y / (float)Screen.height), 0f); } } Cursor.visible = visible; } catch (Exception ex) { Core.Log.LogError((object)ex); } } } } namespace RetroCamera.Patches { [HarmonyPatch] internal static class ActionWheelSystemPatch { public static bool _wheelVisible; [HarmonyPatch(typeof(ActionWheelSystem), "OnUpdate")] [HarmonyPostfix] private static void OnUpdatePostfix(ActionWheelSystem __instance) { if (_wheelVisible) { if ((Object)(object)__instance._CurrentActiveWheel != (Object)null && !__instance._CurrentActiveWheel.IsVisible()) { CameraState.IsMenuOpen = false; _wheelVisible = false; } else if ((Object)(object)__instance._CurrentActiveWheel == (Object)null) { CameraState.IsMenuOpen = false; _wheelVisible = false; } } else if ((Object)(object)__instance._CurrentActiveWheel != (Object)null && __instance._CurrentActiveWheel.IsVisible()) { _wheelVisible = true; CameraState.IsMenuOpen = true; } } } [HarmonyPatch] internal static class EscapeMenuViewPatch { public static bool IsEscapeMenuOpen; [HarmonyPatch(typeof(EscapeMenuView), "OnEnable")] [HarmonyPostfix] private static void OnEnablePostfix() { Enable(); } [HarmonyPatch(typeof(EscapeMenuView), "OnDestroy")] [HarmonyPostfix] private static void OnDestroyPostfix() { Disable(); } private static void Enable() { if (!IsEscapeMenuOpen) { IsEscapeMenuOpen = true; CameraState.IsMenuOpen = true; } } private static void Disable() { if (IsEscapeMenuOpen) { IsEscapeMenuOpen = false; CameraState.IsMenuOpen = false; } } } [HarmonyPatch] internal static class GameplayInputSystemPatch { [HarmonyPatch(typeof(GameplayInputSystem), "HandleInput")] [HarmonyPrefix] private unsafe static void HandleInputPrefix(ref InputState inputState) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) CameraState._validGameplayInputState = true; CameraState._gameplayInputState = inputState; if (Settings.Enabled && CameraState._isMouseLocked && !CameraState.IsMenuOpen && !((InputState)(ref inputState)).IsInputPressed((ButtonInputAction)500)) { inputState.InputsPressed.m_ListData->AddNoResize((ButtonInputAction)500); } } } [HarmonyPatch] internal static class HUDElementComponentPatch { [HarmonyPatch(typeof(HUDElementComponent), "UpdateVisibility")] [HarmonyPostfix] private static void UpdateVisibilityPostfix(HUDElementComponent __instance) { if (!((Object)((Component)__instance).gameObject).name.Equals("InteractorEntry(Clone)")) { return; } foreach (CanvasGroup componentsInChild in ((Component)__instance).GetComponentsInChildren<CanvasGroup>()) { componentsInChild.alpha = 1f; } } } [HarmonyPatch] internal static class HUDMenuPatch { [HarmonyPatch(typeof(HUDMenu), "OnEnable")] [HarmonyPostfix] private static void OnEnablePostfix() { CameraState.IsMenuOpen = true; } [HarmonyPatch(typeof(HUDMenu), "OnDisable")] [HarmonyPostfix] private static void OnDisablePostfix() { CameraState.IsMenuOpen = false; } } [HarmonyPatch] internal static class InitializationPatches { [HarmonyPatch(typeof(GameDataManager), "OnUpdate")] [HarmonyPostfix] private static void OnUpdatePostfix(GameDataManager __instance) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown bool flag = default(bool); try { if (!__instance.GameDataInitialized || Core._initialized) { return; } Core.Initialize(__instance); if (Core._initialized) { ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(25, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("RetroCamera"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.2.1"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] initialized on client!"); } log.LogInfo(val); } } catch (Exception ex) { ManualLogSource log2 = Core.Log; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(57, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("RetroCamera"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("1.2.1"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] failed to initialize on client, exiting on try-catch: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex); } log2.LogError(val2); } } [HarmonyPatch(typeof(ClientBootstrapSystem), "OnDestroy")] [HarmonyPrefix] private static void OnDestroyPrefix(ClientBootstrapSystem __instance) { Core.ResetStates(); } [HarmonyPatch(typeof(UICanvasSystem), "UpdateHideIfDisabled")] [HarmonyPostfix] private static void OnUpdatePostfix(UICanvasBase canvas) { if (Core._initialized && !ClearSkies._initialized) { ClearSkies.Initialize(); } } } [HarmonyPatch] internal static class InputActionSystemPatch { [HarmonyPatch(typeof(TopdownCameraSystem), "OnUpdate")] [HarmonyPrefix] private static void OnUpdatePrefix(TopdownCameraSystem __instance) { //IL_000d: 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) if (Settings.Enabled) { __instance._ZoomModifierSystem._ZoomModifiers.Clear(); } } [HarmonyPatch(typeof(InputActionSystem), "OnCreate")] [HarmonyPostfix] private static void OnCreatePostfix(InputActionSystem __instance) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown __instance._LoadedInputActions.Disable(); InputActionMap val = new InputActionMap("Retro Camera"); CollectionExtensions.AddItem<InputActionMap>((IEnumerable<InputActionMap>)__instance._LoadedInputActions.m_ActionMaps, val); __instance._LoadedInputActions.Enable(); } [HarmonyPatch(typeof(InputActionSystem), "OnUpdate")] [HarmonyPrefix] private static void OnUpdatePrefix() { foreach (Keybinding value in KeybindsManager.Keybinds.Values) { if (IsKeybindDown(value)) { value.KeyDown(); } if (IsKeybindUp(value)) { value.KeyUp(); } if (IsKeybindPressed(value)) { value.KeyPressed(); } } } private static bool IsKeybindDown(Keybinding keybind) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!Input.GetKeyDown(keybind.Primary)) { return Input.GetKeyDown(keybind.Secondary); } return true; } private static bool IsKeybindUp(Keybinding keybind) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!Input.GetKeyUp(keybind.Primary)) { return Input.GetKeyUp(keybind.Secondary); } return true; } private static bool IsKeybindPressed(Keybinding keybind) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (!Input.GetKey(keybind.Primary)) { return Input.GetKey(keybind.Secondary); } return true; } } [HarmonyPatch] internal static class MainMenuPatch { private static MainMenuNewView _mainMenuNewView; private const string DISCORD_LOGO_PATH = "RetroCamera.Resources.ModDiscordLogo.png"; private const string CAMERA_LOGO_PATH = "RetroCamera.Resources.RetroCameraLogo.png"; private const string CAMERA_GLOW_PATH = "RetroCamera.Resources.Glow03.png"; private const string DISCORD_BUTTON = "Modding Discord"; private const string DISCORD_LINK = "https://discord.com/invite/QG2FmueAG9"; private const string DONATION_BUTTON = "Support Development"; private const string KOFI_LINK = "https://ko-fi.com/zfolmt"; private const string PATREON_LINK = "https://www.patreon.com/c/zfolmt"; private static readonly float _aspectRatio = Screen.width / Screen.height; private static NewsPanelEntry _newsPanelEntry; private static NewsPanel _newsPanel; private static bool _newsPanelInitialized = false; [HarmonyPatch(typeof(MainMenuNewView), "SetConsoleReady")] [HarmonyPostfix] private static void SetConsoleReadyPostfix() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown bool flag = default(bool); try { ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(33, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MainMenuNewView.SetConsoleReady]"); } log.LogWarning(val); _mainMenuNewView = Object.FindObjectOfType<MainMenuNewView>(); _newsPanel = _mainMenuNewView.News; if (_newsPanel._NewsEntries.Elements.Count != 0 || _newsPanel._NewsManagerSystem._NewsData.News.Count != 0) { Reset(); } InitializeNewsEntries(); } catch (Exception ex) { ManualLogSource log2 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(41, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[MainMenuNewView.SetConsoleReady] error: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } log2.LogWarning(val); } } public static void Reset() { Enumerator<NewsPanelEntry> enumerator = _newsPanel._NewsEntries._Elements_k__BackingField.GetEnumerator(); while (enumerator.MoveNext()) { NewsPanelEntry current = enumerator.Current; if ((Object)(object)current != (Object)null) { Object.Destroy((Object)(object)((Component)current).gameObject); } } enumerator = _newsPanel._NewsEntries.Elements.GetEnumerator(); while (enumerator.MoveNext()) { NewsPanelEntry current2 = enumerator.Current; if ((Object)(object)current2 != (Object)null) { Object.Destroy((Object)(object)((Component)current2).gameObject); } } _newsPanel._NewsEntries._Elements_k__BackingField.Clear(); _newsPanel._NewsEntries.Elements.Clear(); _newsPanel._NewsManagerSystem._NewsData.News.Clear(); } private static void InitializeNewsEntries() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown ManualLogSource log = Core.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(49, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[InitializeNewsEntries()] Initializing NewsPanel!"); } log.LogWarning(val); if ((Object)(object)_newsPanel == (Object)null) { ManualLogSource log2 = Core.Log; val = new BepInExWarningLogInterpolatedStringHandler(44, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[InitializeNewsEntries()] NewsPanel is null!"); } log2.LogWarning(val); return; } Assembly executingAssembly = Assembly.GetExecutingAssembly(); CreateNewsEntry(executingAssembly, "RetroCamera.Resources.ModDiscordLogo.png", "Modding Discord", "https://discord.com/invite/QG2FmueAG9"); CreateNewsEntry(executingAssembly, "RetroCamera.Resources.RetroCameraLogo.png", "Support Development", "https://ko-fi.com/zfolmt"); ManualLogSource log3 = Core.Log; val = new BepInExWarningLogInterpolatedStringHandler(40, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[InitializeNewsEntries()] NewsEntries - "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_newsPanel._NewsEntries.Elements.Count); } log3.LogWarning(val); _newsPanel._NewsEntries.StartUpdate(); } private static void CreateNewsEntry(Assembly assembly, string resourcePath, string buttonText, string urlToOpen) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Expected O, but got Unknown //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Expected O, but got Unknown //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Expected O, but got Unknown if (!TryGet2DTextureFromResource(assembly, resourcePath, out var texture)) { return; } NewsPanelEntry val = _newsPanel._NewsEntries.InstantiateElement(); SimpleStunButton imageButton = val.ImageButton; NewsPanelEntryData val2 = new NewsPanelEntryData(); bool flag = default(bool); if ((Object)(object)val == (Object)null || val2 == null) { ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(66, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[CreateNewsEntry()] NewsPanelEntry and/or NewsPanelEntryData null!"); } log.LogWarning(val3); return; } val2.Duration = 15f; val2._HasLink = true; val2.LinkURL = urlToOpen; val._Data = val2; val._Texture = texture; val.Image.m_Texture = (Texture)(object)texture; ((Graphic)val.Image).m_Color = Color.white; val.Image.m_UVRect = new Rect(-0.475f, -0.125f, 1.95f, 1.25f); GameObject val4 = FindTargetGameObject(((Component)imageButton).gameObject.transform, "Title"); GameObject val5 = FindTargetGameObject(((Component)imageButton).gameObject.transform, "OpenLinkInputContextEntry"); if ((Object)(object)val4 == (Object)null) { ManualLogSource log2 = Core.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(34, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[CreateNewsEntry()] Title is null!"); } log2.LogWarning(val3); } if ((Object)(object)val5 == (Object)null) { ManualLogSource log3 = Core.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(54, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[CreateNewsEntry()] OpenLinkInputContextEntry is null!"); } log3.LogWarning(val3); } TextMeshProUGUI obj = ((val4 != null) ? val4.GetComponent<TextMeshProUGUI>() : null); if (obj != null) { ((TMP_Text)obj).SetText(buttonText, true); } if (val5 != null) { val5.SetActive(false); } if ((Object)(object)obj == (Object)null) { ManualLogSource log4 = Core.Log; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(44, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[CreateNewsEntry()] TextMeshProUGUI is null!"); } log4.LogWarning(val3); } _newsPanel._NewsManagerSystem._NewsData.News.Add(val._Data); } private static bool TryGetSpriteFromResource(Assembly assembly, string resourcePath, out Sprite sprite) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) using Stream stream = assembly.GetManifestResourceStream(resourcePath); if (stream != null) { Texture2D val = stream.LoadTextureFromStream((FilterMode)1); if ((Object)(object)val != (Object)null) { sprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); return true; } } else { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(26, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to load resource - "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(resourcePath); } log.LogError(val2); } sprite = null; return false; } private static bool TryGet2DTextureFromResource(Assembly assembly, string resourcePath, out Texture2D texture) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown using Stream stream = assembly?.GetManifestResourceStream(resourcePath); if (stream != null) { texture = stream?.LoadTextureFromStream((FilterMode)1); if ((Object)(object)texture != (Object)null) { return true; } } else { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(26, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to load resource - "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(resourcePath); } log.LogError(val); } texture = null; return false; } public static Texture2D LoadTextureFromStream(this Stream stream, FilterMode filterMode = 1) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown byte[] array = new byte[stream.Length]; stream.Read(array, 0, array.Length); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false, false); ImageConversion.LoadImage(val, Il2CppStructArray<byte>.op_Implicit(array), false); ((Texture)val).filterMode = filterMode; ((Texture)val).wrapMode = (TextureWrapMode)1; return val; } public static void CleanTransparentPixels(Texture2D texture) { Color[] array = Il2CppArrayBase<Color>.op_Implicit((Il2CppArrayBase<Color>)(object)texture.GetPixels()); for (int i = 0; i < array.Length; i++) { if (array[i].a <= 0.001f) { array[i].r = 0f; array[i].g = 0f; array[i].b = 0f; } } texture.SetPixels(Il2CppStructArray<Color>.op_Implicit(array)); texture.Apply(); } private static void OpenURLs(List<string> urls) { foreach (string url in urls) { Application.OpenURL(url); } } public static GameObject FindTargetGameObject(Transform root, string targetName) { //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Expected O, but got Unknown Stack<(Transform, int)> stack = new Stack<(Transform, int)>(); stack.Push((root, 0)); HashSet<Transform> hashSet = new HashSet<Transform>(); Il2CppArrayBase<Transform> componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true); List<Transform> list = new List<Transform>(); foreach (Transform item in componentsInChildren) { list.Add(item); } List<Transform> list2 = list; while (stack.Count > 0) { var (val, num) = stack.Pop(); if (!hashSet.Add(val)) { continue; } if (((Object)((Component)val).gameObject).name.Equals(targetName, StringComparison.OrdinalIgnoreCase)) { return ((Component)val).gameObject; } foreach (Transform item2 in list2) { if ((Object)(object)item2.parent == (Object)(object)val) { stack.Push((item2, num + 1)); } } } ManualLogSource log = Core.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(34, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("GameObject with name '"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(targetName); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' not found!"); } log.LogWarning(val2); return null; } public static void FindGameObjects(Transform root, string filePath = "", bool includeInactive = false) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_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) Stack<(Transform, int)> stack = new Stack<(Transform, int)>(); stack.Push((root, 0)); HashSet<Transform> hashSet = new HashSet<Transform>(); Il2CppArrayBase<Transform> componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(includeInactive); List<Transform> list = new List<Transform>(); foreach (Transform item in componentsInChildren) { list.Add(item); } List<Transform> list2 = list; ManualLogSource log = Core.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(19, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Found "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(list2.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" GameObjects!"); } log.LogWarning(val); Scene scene; if (string.IsNullOrEmpty(filePath)) { while (stack.Count > 0) { var (val2, num) = stack.Pop(); if (!hashSet.Add(val2)) { continue; } List<string> values = FindGameObjectComponents(((Component)val2).gameObject); string text = new string('|', num); ManualLogSource log2 = Core.Log; BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(8, 4, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Object)((Component)val2).gameObject).name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" | "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(string.Join(",", values)); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" | ["); scene = ((Component)val2).gameObject.scene; ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((Scene)(ref scene)).name); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("]"); } log2.LogInfo(val3); foreach (Transform item2 in list2) { if ((Object)(object)item2.parent == (Object)(object)val2) { stack.Push((item2, num + 1)); } } } ret