Decompiled source of RetroCamera v1.4.4
RetroCamera.dll
Decompiled 3 weeks 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.4.4.0")] [assembly: AssemblyInformationalVersion("1.4.4")] [assembly: AssemblyProduct("RetroCamera")] [assembly: AssemblyTitle("RetroCamera")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.4.4.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 Entity _localCharacter = Entity.Null; private static Entity _localUser = Entity.Null; private static MonoBehaviour _monoBehaviour; public static bool _initialized = false; public static Entity LocalCharacter { get { //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_002e: 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 (!(_localCharacter != Entity.Null)) { if (!ConsoleShared.TryGetLocalCharacterInCurrentWorld(ref _localCharacter, _client)) { return Entity.Null; } return _localCharacter; } return _localCharacter; } } public static Entity LocalUser { get { //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_002e: 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 (!(_localUser != Entity.Null)) { if (!ConsoleShared.TryGetLocalUserInCurrentWorld(ref _localUser, _client)) { return Entity.Null; } return _localUser; } return _localUser; } } public static EntityManager EntityManager => _client.EntityManager; public static ClientScriptMapper ClientScriptMapper { get; set; } public static ClientGameManager ClientGameManager { get; set; } public static GameDataSystem GameDataSystem { get; set; } public static ZoomModifierSystem ZoomModifierSystem { get; set; } public static TopdownCameraSystem TopdownCameraSystem { get; set; } public static TargetInfoParentSystem TargetInfoParentSystem { get; set; } public static PrefabCollectionSystem PrefabCollectionSystem { get; set; } public static ActionWheelSystem ActionWheelSystem { get; set; } public static UIDataSystem UIDataSystem { get; set; } public static CursorPositionSystem CursorPositionSystem { get; set; } public static InputActionSystem InputActionSystem { get; set; } public static LocalUserSystem LocalUserSystem { get; set; } public static ManualLogSource Log => Plugin.LogInstance; public static void Initialize(GameDataManager __instance) { //IL_009b: 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>(); TargetInfoParentSystem = _client.GetExistingSystemManaged<TargetInfoParentSystem>(); PrefabCollectionSystem = _client.GetExistingSystemManaged<PrefabCollectionSystem>(); ActionWheelSystem = _client.GetExistingSystemManaged<ActionWheelSystem>(); UIDataSystem = _client.GetExistingSystemManaged<UIDataSystem>(); CursorPositionSystem = _client.GetExistingSystemManaged<CursorPositionSystem>(); ClientScriptMapper = _client.GetExistingSystemManaged<ClientScriptMapper>(); ClientGameManager = ClientScriptMapper._ClientGameManager; GameDataSystem = _client.GetExistingSystemManaged<GameDataSystem>(); InputActionSystem = _client.GetExistingSystemManaged<InputActionSystem>(); LocalUserSystem = _client.GetExistingSystemManaged<LocalUserSystem>(); 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(); RetroCamera.Systems.RetroCamera.ResetState(); _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.Read<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 static void Write<T>(this Entity entity, T componentData) 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) EntityManager entityManager = EntityManager; ((EntityManager)(ref entityManager)).SetComponentData<T>(entity, componentData); } public static T Read<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) EntityManager entityManager = EntityManager; return ((EntityManager)(ref entityManager)).GetComponentData<T>(entity); } 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 TryRemove<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) 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_000f: Unknown result type (might be due to invalid IL or missing references) EntityManager entityManager = EntityManager; return ((EntityManager)(ref entityManager)).HasComponent(entity, new ComponentType(Il2CppType.Of<T>(), (AccessMode)0)); } 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 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.4.4")] 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_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown Instance = this; bool flag = default(bool); if (Application.productName == "VRisingServer") { ManualLogSource log = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(22, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("RetroCamera"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.4.4"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] is a client mod! ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Application.productName); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } log.LogInfo(val); } else { ((BasePlugin)this).AddComponent<RetroCamera.Systems.RetroCamera>(); _harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); ManualLogSource log2 = Core.Log; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(20, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("RetroCamera"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("["); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.4.4"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("] loaded on client!"); } log2.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 Toggle _firstPersonEnabledOption; private static Toggle _commandWheelEnabled; private static Slider _fieldOfViewOption; private static Slider _crosshairSize; private static Toggle _alwaysShowCrosshairOption; private static Toggle _actionModeCrosshairOption; private static Toggle _hideCharacterInfoPanel; 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 _toggleSocialWheel; public static bool _wasDisabled; 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 CommandWheelEnabled { get { return _commandWheelEnabled.Value; } set { _commandWheelEnabled.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 float CrosshairSize { get { return _crosshairSize.Value; } set { _crosshairSize.SetValue(value); } } public static bool HideCharacterInfoPanel { get { return _hideCharacterInfoPanel.Value; } set { _hideCharacterInfoPanel.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(); QuipManager.TryLoadCommands(); 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 AddSocialWheelPressedListener(Keybinding.KeyHandler action) { _toggleSocialWheel.AddKeyPressedListener(action); } public static void AddSocialWheelUpListener(Keybinding.KeyHandler action) { _toggleSocialWheel.AddKeyUpListener(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); _commandWheelEnabled = OptionsManager.AddToggle("Command Wheel", "Enable command wheel", defaultValue: false); _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); _hideCharacterInfoPanel = OptionsManager.AddToggle("Hide Character Info Panel", "Removes character info panel from the top of the screen during action mode", defaultValue: false); _fieldOfViewOption = OptionsManager.AddSlider("FOV", "Camera field of view", 50f, 90f, 60f); _crosshairSize = OptionsManager.AddSlider("Crosshair Size", "Crosshair size scaling", 1f, 5f, 1f); OptionsManager.AddDivider("Third Person Zoom"); _minZoomOption = OptionsManager.AddSlider("Min Zoom", "Minimum zoom", 1f, 15f, 1f); _maxZoomOption = OptionsManager.AddSlider("Max Zoom", "Maximum zoom", 5f, 30f, 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", -10f, 10f, 0f); _overTheShoulderYOption = OptionsManager.AddSlider("Shoulder Vertical Offset", "Shoulder view vertical offset", -10f, 10f, 0f); _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 { //IL_0035: 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) if (!EscapeMenuViewPatch._isServerPaused) { _enabledOption.SetValue(!Enabled); } if (Enabled && (CameraState._isFirstPerson || CameraState._isActionMode)) { Cursor.lockState = (CursorLockMode)1; } else { CursorLockMode lockState2 = Cursor.lockState; if (((object)(CursorLockMode)(ref lockState2)).Equals((object)(CursorLockMode)1) && !Enabled) { Cursor.lockState = (CursorLockMode)0; } } }); _actionModeKeybind = KeybindsManager.AddKeybind("Toggle Action Mode", "Toggle action mode", (KeyCode)93); _actionModeKeybind.AddKeyDownListener(delegate { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) CursorLockMode lockState; if (_wasDisabled && Enabled && !CameraState._isFirstPerson) { _wasDisabled = false; CameraState._isMouseLocked = !CameraState._isMouseLocked; CameraState._isActionMode = !CameraState._isActionMode; if (CameraState.IsMenuOpen) { CameraState.IsMenuOpen = false; } if (ActionWheelSystemPatch._wheelVisible) { ActionWheelSystemPatch._wheelVisible = false; } lockState = Cursor.lockState; if (((object)(CursorLockMode)(ref lockState)).Equals((object)(CursorLockMode)1) && (!CameraState._isActionMode || !CameraState._isMouseLocked)) { Cursor.lockState = (CursorLockMode)0; } _enabledOption.SetValue(value: false); } else if (Enabled && !CameraState._isFirstPerson) { CameraState._isMouseLocked = !CameraState._isMouseLocked; CameraState._isActionMode = !CameraState._isActionMode; if (CameraState.IsMenuOpen) { CameraState.IsMenuOpen = false; } if (ActionWheelSystemPatch._wheelVisible) { ActionWheelSystemPatch._wheelVisible = false; } lockState = Cursor.lockState; if (((object)(CursorLockMode)(ref lockState)).Equals((object)(CursorLockMode)1) && (!CameraState._isActionMode || !CameraState._isMouseLocked)) { Cursor.lockState = (CursorLockMode)0; } } else if (!Enabled && !CameraState._isFirstPerson && !CameraState.IsMenuOpen && !EscapeMenuViewPatch._isServerPaused) { _wasDisabled = true; _enabledOption.SetValue(value: true); CameraState._isMouseLocked = !CameraState._isMouseLocked; CameraState._isActionMode = !CameraState._isActionMode; if (CameraState.IsMenuOpen) { CameraState.IsMenuOpen = false; } if (ActionWheelSystemPatch._wheelVisible) { ActionWheelSystemPatch._wheelVisible = false; } 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); _toggleSocialWheel = KeybindsManager.AddKeybind("Use Social Wheel", "Toggle social wheel visibility", (KeyCode)307); } public static bool TryLoadOptions() { Dictionary<string, MenuOption> dictionary = Persistence.LoadOptions(); if (dictionary == null) { Core.Log.LogWarning((object)"No options saved!"); 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) { Core.Log.LogWarning((object)"No keybinds saved!"); 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.4.4"; } } 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 const string COMMANDS_KEY = "Commands"; private static readonly string _keybindsJson = Path.Combine(_directoryPath, "Keybinds.json"); private static readonly string _settingsJson = Path.Combine(_directoryPath, "Options.json"); private static readonly string _commandsJson = Path.Combine(_directoryPath, "Commands.json"); private static readonly Dictionary<string, string> _filePaths = new Dictionary<string, string> { { "Keybinds", _keybindsJson }, { "Options", _settingsJson }, { "Commands", _commandsJson } }; public static void SaveKeybinds() { SaveDictionary(KeybindsManager.Keybinds, "Keybinds"); } public static void SaveOptions() { SaveDictionary(OptionsManager.Options, "Options"); } public static void SaveCommands() { SaveDictionary(QuipManager.CommandQuips, "Commands"); } public static Dictionary<string, Keybinding> LoadKeybinds() { return LoadDictionary<string, Keybinding>("Keybinds"); } public static Dictionary<string, MenuOption> LoadOptions() { return LoadDictionary<string, MenuOption>("Options"); } public static Dictionary<int, QuipManager.Command> LoadCommands() { return LoadDictionary<int, QuipManager.Command>("Commands"); } private static Dictionary<T, U> LoadDictionary<T, U>(string fileKey) { //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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(); if (fileKey == "Commands" && typeof(T) == typeof(int) && typeof(U) == typeof(QuipManager.Command)) { Dictionary<int, QuipManager.Command> dictionary = new Dictionary<int, QuipManager.Command>(); for (int i = 0; i < 8; i++) { dictionary[i] = new QuipManager.Command { Name = "", InputString = "" }; } File.WriteAllText(value, JsonSerializer.Serialize(dictionary, _jsonOptions)); return dictionary as Dictionary<T, U>; } 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); } } internal static class Quips { private static FromCharacter? _fromCharacter; private static readonly ComponentType[] _componentTypes = (ComponentType[])(object)new ComponentType[4] { ComponentType.ReadOnly(Il2CppType.Of<FromCharacter>()), ComponentType.ReadOnly(Il2CppType.Of<NetworkEventType>()), ComponentType.ReadOnly(Il2CppType.Of<SendNetworkEventTag>()), ComponentType.ReadOnly(Il2CppType.Of<ChatMessageEvent>()) }; private static readonly NetworkEventType _networkEventType = new NetworkEventType { IsAdminEvent = false, EventId = NetworkEvents.EventId_ChatMessageEvent, IsDebugEvent = false }; private static EntityManager EntityManager => Core.EntityManager; private static Entity LocalCharacter => Core.LocalCharacter; private static Entity LocalUser => Core.LocalUser; private static NetworkId NetworkId => LocalUser.GetNetworkId(); public static FromCharacter FromCharacter { get { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0046: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) FromCharacter valueOrDefault = _fromCharacter.GetValueOrDefault(); if (!_fromCharacter.HasValue) { FromCharacter val = default(FromCharacter); val.Character = LocalCharacter; val.User = LocalUser; valueOrDefault = val; _fromCharacter = valueOrDefault; return valueOrDefault; } return valueOrDefault; } } public static void SendCommandQuip(QuipManager.CommandQuip commandQuip) { //IL_0012: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown string name = commandQuip.Name; string command = commandQuip.Command; ChatMessageEvent val = default(ChatMessageEvent); val.MessageText = new FixedString512Bytes(command); val.MessageType = (ChatMessageType)4; val.ReceiverEntity = NetworkId; ChatMessageEvent componentData = val; EntityManager entityManager = EntityManager; Entity entity = ((EntityManager)(ref entityManager)).CreateEntity(_componentTypes); entity.Write<FromCharacter>(FromCharacter); entity.Write<NetworkEventType>(_networkEventType); entity.Write<ChatMessageEvent>(componentData); ManualLogSource log = Core.Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(3, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(name); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" - "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(command); } log.LogInfo(val2); } } } namespace RetroCamera.Systems { public class RetroCamera : MonoBehaviour { 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 _characterInfoPanel; private static GameObject _journalClaimButtonObject; private static bool _socialWheelActive = false; private static ActionWheel _socialWheel; public static bool _shouldActivateWheel = false; private static Entity _rootPrefabCollection; private static bool _socialWheelInitialized = false; private static ZoomModifierSystem ZoomModifierSystem => Core.ZoomModifierSystem; private static ActionWheelSystem ActionWheelSystem => Core.ActionWheelSystem; public static Camera GameCamera => _gameCamera; private static bool HideCharacterInfoPanel => Settings.HideCharacterInfoPanel; public static bool SocialWheelActive => _socialWheelActive; public static ActionWheel SocialWheel => _socialWheel; 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() { if (Settings.Enabled) { CameraState._isUIHidden = !CameraState._isUIHidden; DisableUISettings.SetHideHUD(CameraState._isUIHidden, Core._client); } } private static void ToggleFog() { if (Settings.Enabled) { 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.AddSocialWheelPressedListener(SocialWheelKeyPressed); Settings.AddSocialWheelUpListener(SocialWheelKeyUp); Settings.AddCompleteTutorialListener(CompleteTutorial); } private static void CompleteTutorial() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown if (!Settings.Enabled) { return; } 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 SocialWheelKeyPressed() { //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_0008: 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) //IL_0034: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) if (!Settings.CommandWheelEnabled) { return; } if (!_rootPrefabCollection.Exists() || (Object)(object)_socialWheel == (Object)null) { ManualLogSource log = Core.Log; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(41, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[RetroCamera] Initializing SocialWheel..."); } log.LogWarning(val); ActionWheelSystem actionWheelSystem = ActionWheelSystem; if (actionWheelSystem != null) { actionWheelSystem._RootPrefabCollectionAccessor.TryGetSingletonEntity(ref _rootPrefabCollection); } if (!_socialWheelInitialized && _rootPrefabCollection.TryGetComponent<RootPrefabCollection>(out RootPrefabCollection componentData) && ((RootPrefabCollection)(ref componentData)).GeneralGameplayCollectionPrefab.TryGetComponent<GeneralGameplayCollection>(out GeneralGameplayCollection componentData2)) { foreach (KeyValuePair<int, QuipManager.CommandQuip> commandQuip in QuipManager.CommandQuips) { if (!string.IsNullOrEmpty(commandQuip.Value.Name) && !string.IsNullOrEmpty(commandQuip.Value.Command)) { ChatQuip val2 = componentData2.ChatQuips[commandQuip.Key]; val2.Text = commandQuip.Value.NameKey; componentData2.ChatQuips[commandQuip.Key] = val2; } } ActionWheelSystem.InitializeSocialWheel(true, componentData2); _socialWheelInitialized = true; try { LocalizationManager.LocalizeText(); } catch (Exception ex) { ManualLogSource log2 = Core.Log; BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(47, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[RetroCamera.Update] Failed to localize keys - "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message); } log2.LogError(val3); } try { List<ActionWheelData> socialWheelDataList = ActionWheelSystem._SocialWheelDataList; _ = ActionWheelSystem._SocialWheelShortcutList; foreach (KeyValuePair<int, QuipManager.CommandQuip> commandQuip2 in QuipManager.CommandQuips) { if (!string.IsNullOrEmpty(commandQuip2.Value.Name) && !string.IsNullOrEmpty(commandQuip2.Value.Command)) { socialWheelDataList[commandQuip2.Key].Name = commandQuip2.Value.NameKey; } } } catch (Exception ex2) { Core.Log.LogError((object)ex2); } } ActionWheelSystem actionWheelSystem2 = ActionWheelSystem; _socialWheel = ((actionWheelSystem2 != null) ? actionWheelSystem2._SocialWheel : null); foreach (ActionWheelShortcut item in (Il2CppArrayBase<ActionWheelShortcut>)(object)_socialWheel.ActionWheelShortcuts) { if (item != null) { GameObject gameObject = ((Component)item).gameObject; if (gameObject != null) { gameObject.SetActive(false); } } } ((Component)_socialWheel).gameObject.SetActive(true); } if (!_socialWheelActive) { _shouldActivateWheel = true; _socialWheelActive = true; ActionWheelSystem._CurrentActiveWheel = SocialWheel; } } private static void SocialWheelKeyUp() { if (Settings.CommandWheelEnabled && _socialWheelActive) { _socialWheelActive = false; ActionWheelSystem.HideCurrentWheel(); ((Component)_socialWheel).gameObject.SetActive(false); ActionWheelSystem._CurrentActiveWheel = null; } } private void Update() { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown if (!Core._initialized || !_gameFocused || !Settings.Enabled) { return; } if (!_listening) { _listening = true; AddListeners(); } if ((Object)(object)_crosshairPrefab == (Object)null) { BuildCrosshair(); } if ((Object)(object)_gameCamera == (Object)null) { _gameCamera = CameraManager.GetCamera(); } if ((Object)(object)_characterInfoPanel == (Object)null) { GameObject obj = GameObject.Find("HUDCanvas(Clone)/TargetInfoPanelCanvas"); _characterInfoPanel = ((obj != null) ? ((Component)obj.transform.GetChild(0)).gameObject : null); bool flag = default(bool); if ((Object)(object)_characterInfoPanel == (Object)null) { ManualLogSource log = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(47, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[RetroCamera] CharacterInfoPanel (0) not found!"); } log.LogWarning(val); } else { ManualLogSource log2 = Core.Log; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(43, 0, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[RetroCamera] CharacterInfoPanel (0) found!"); } log2.LogWarning(val); } } UpdateCrosshair(); } private void OnApplicationFocus(bool hasFocus) { _gameFocused = hasFocus; if (hasFocus) { CameraState.IsMenuOpen = false; } } 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_0113: 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) 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 = Vector3.one; ((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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) try { bool flag = true; bool flag2 = 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; } bool flag3 = false; if (CameraState._validGameplayInputState) { flag3 = ((InputState)(ref CameraState._gameplayInputState)).IsInputPressed((ButtonInputAction)500); } bool flag4 = CameraState._validGameplayInputState && (CameraState._isMouseLocked || flag3); if (flag4 && !CameraState.IsMenuOpen) { if (CameraState._isActionMode && HideCharacterInfoPanel) { _characterInfoPanel.SetActive(false); } else { _characterInfoPanel.SetActive(true); } flag2 = CameraState._isFirstPerson || (CameraState._isActionMode && Settings.ActionModeCrosshair); flag = CameraState._usingMouseWheel; } else if (flag4 && CameraState._inBuildMode) { flag2 = Settings.AlwaysShowCrosshair; flag = false; } if ((Object)(object)_crosshair != (Object)null) { _crosshair.active = flag2 || Settings.AlwaysShowCrosshair; float crosshairSize = Settings.CrosshairSize; _crosshair.transform.localScale = new Vector3(crosshairSize, crosshairSize, crosshairSize); 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); } } if (CameraState._inBuildMode && !flag3 && !flag) { flag = true; } else if (CameraState.IsMenuOpen && flag3) { flag = false; } Cursor.visible = flag; } catch (Exception ex) { Core.Log.LogError((object)ex); } } public static void ResetState() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) _socialWheel = null; _socialWheelActive = false; _socialWheelInitialized = false; _shouldActivateWheel = false; _rootPrefabCollection = Entity.Null; } } } namespace RetroCamera.Patches { [HarmonyPatch] internal static class ActionWheelSystemPatch { public static bool _wheelVisible = false; private static DateTime _wheelOpened = DateTime.MinValue; private static DateTime _lastQuipSendTime = DateTime.MinValue; private const float QUIP_COOLDOWN_SECONDS = 0.5f; [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(typeof(ActionWheelSystem), "SendQuipChatMessage")] [HarmonyPrefix] private static bool SendQuipChatMessagePrefix(byte index) { DateTime utcNow = DateTime.UtcNow; if (_wheelOpened.Equals(DateTime.MinValue)) { _wheelOpened = utcNow; } if ((utcNow - _wheelOpened).TotalSeconds < 0.10000000149011612) { return false; } if ((utcNow - _lastQuipSendTime).TotalSeconds < 0.5) { return false; } _lastQuipSendTime = utcNow; if (QuipManager.CommandQuips.TryGetValue(index, out var value)) { Quips.SendCommandQuip(value); return false; } return true; } [HarmonyPatch(typeof(ActionWheelSystem), "HideCurrentWheel")] [HarmonyPrefix] private static bool HideCurrentWheelPrefix(ActionWheelSystem __instance) { if (RetroCamera.Systems.RetroCamera.SocialWheelActive) { return false; } if (!_wheelOpened.Equals(DateTime.MinValue)) { _wheelOpened = DateTime.MinValue; } return true; } [HarmonyPatch(typeof(ActionWheelSystem), "UpdateAndShowWheel")] [HarmonyPrefix] private static void UpdateAndShowWheelPrefix(ActionWheelSystem __instance) { } } [HarmonyPatch] internal static class EscapeMenuViewPatch { private static readonly WaitForSeconds _resumeDelay = new WaitForSeconds(0.25f); public static bool _isEscapeMenuOpen = false; public static bool _isServerPaused = false; private static bool _wasEnabled = false; private static bool _wasActionMode = false; [HarmonyPatch(typeof(EscapeMenuView), "OnButtonClick_Pause")] [HarmonyPrefix] private static void OnPausePrefix() { _isServerPaused = !_isServerPaused; if (_isServerPaused) { _wasEnabled = Settings.Enabled; _wasActionMode = CameraState._isActionMode; Settings.Enabled = false; } } [HarmonyPatch(typeof(EscapeMenuView), "OnButtonClick_Pause")] [HarmonyPostfix] private static void OnPausePostfix() { OnResumeRoutine().Start(); } private static IEnumerator OnResumeRoutine() { yield return _resumeDelay; if (!_isServerPaused && _wasEnabled && !_isServerPaused) { Settings.Enabled = _wasEnabled; if (_wasActionMode && !CameraState._isFirstPerson) { Settings._wasDisabled = !_wasEnabled; Settings.Enabled = true; CameraState._isMouseLocked = !CameraState._isMouseLocked; CameraState._isActionMode = !CameraState._isActionMode; } else if (_wasEnabled && CameraState.IsMenuOpen) { CameraState.IsMenuOpen = false; } _wasEnabled = false; } } [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.4.4"); ((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.4.4"); ((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) return Input.GetKeyDown(keybind.Primary); } private static bool IsKeybindUp(Keybinding keybind) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return Input.GetKeyUp(keybind.Primary); } private static bool IsKeybindPressed(Keybinding keybind) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return Input.GetKey(keybind.Primary); } } [HarmonyPatch] internal static class