Decompiled source of 2Doors LogoTrials v1.0.0
BepInEx/plugins/Empress-2Doors/Repo2.dll
Decompiled 6 hours 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.Versioning; using System.Security.Cryptography; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ExitGames.Client.Photon; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using REPOLib.Modules; using REPOLib.Objects.Sdk; using UnityEngine; using UnityEngine.AI; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Empress")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Empress 2 Doors for REPO.")] [assembly: AssemblyFileVersion("0.3.14.0")] [assembly: AssemblyInformationalVersion("0.3.14")] [assembly: AssemblyProduct("2 Doors")] [assembly: AssemblyTitle("Repo2")] [assembly: AssemblyVersion("0.3.14.0")] [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 Repo2Mod { internal sealed class Repo2DoorsRunController : MonoBehaviourPun { private Repo2DoorRoomVisual[] rooms = Array.Empty<Repo2DoorRoomVisual>(); private bool[] solvedRooms = Array.Empty<bool>(); private readonly HashSet<int> eligibleContinueVoters = new HashSet<int>(); private readonly Dictionary<int, bool> continueVotes = new Dictionary<int, bool>(); private int focusedRoomIndex = -1; private bool awaitingDecision; private int pendingRoomIndex = -1; private bool localVoteEligible; private bool localVoteSubmitted; private int displayVoteYesCount; private int displayVoteNoCount; private int displayVoteRequiredCount; private bool finishQueued; internal int TotalRooms => rooms.Length; internal int SolvedRooms => CountSolvedRooms(); internal void Configure(IReadOnlyList<Repo2DoorRoomVisual> roomList) { rooms = new Repo2DoorRoomVisual[roomList.Count]; solvedRooms = new bool[roomList.Count]; ResetContinueVoteState(); for (int i = 0; i < roomList.Count; i++) { rooms[i] = roomList[i]; rooms[i].SetSolvedState(value: false); rooms[i].SetFocused(focused: false); } PrimeUpcomingRooms(0); Repo2Runtime.Instance?.UpdateDoorProgress(0); } private void Update() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) if (!Repo2Runtime.IsRepo2RunActive || rooms.Length == 0 || (Object)(object)PlayerAvatar.instance == (Object)null) { return; } HandleContinueInput(); int num = ResolveNearestRoom(((Component)PlayerAvatar.instance).transform.position); if (num != focusedRoomIndex) { if (focusedRoomIndex >= 0 && focusedRoomIndex < rooms.Length) { rooms[focusedRoomIndex].SetFocused(focused: false); } focusedRoomIndex = num; if (focusedRoomIndex >= 0 && focusedRoomIndex < rooms.Length) { Repo2DoorRoomVisual repo2DoorRoomVisual = rooms[focusedRoomIndex]; repo2DoorRoomVisual.SetFocused(focused: true); repo2DoorRoomVisual.WarmVisuals(); PrimeUpcomingRooms(focusedRoomIndex); Repo2Runtime.Instance?.SetFocusedQuestion(repo2DoorRoomVisual.RoomNumber, repo2DoorRoomVisual.QuestionPrompt, repo2DoorRoomVisual.LeftChoiceLabel, repo2DoorRoomVisual.RightChoiceLabel, repo2DoorRoomVisual.Reward); } } } internal void TryChooseDoor(int roomIndex, bool isCorrect, PlayerAvatar avatar) { if (roomIndex < 0 || roomIndex >= rooms.Length || (Object)(object)avatar == (Object)null || Repo2AvatarUtil.IsDisabledAvatar(avatar) || awaitingDecision) { return; } bool isPhotonRoomActive = Repo2Runtime.IsPhotonRoomActive; if (isCorrect) { if (isPhotonRoomActive && !PhotonNetwork.IsMasterClient) { ((MonoBehaviourPun)this).photonView.RPC("RequestSolveRoomRPC", (RpcTarget)2, new object[1] { roomIndex }); } else { ResolveSolvedRoom(roomIndex); } } else { avatar.PlayerDeath(-1); } } [PunRPC] private void RequestSolveRoomRPC(int roomIndex, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (Repo2Runtime.IsPhotonRoomActive && PhotonNetwork.IsMasterClient && info.Sender != null) { ResolveSolvedRoom(roomIndex); } } private void ResolveSolvedRoom(int roomIndex) { if (roomIndex >= 0 && roomIndex < solvedRooms.Length && !solvedRooms[roomIndex]) { solvedRooms[roomIndex] = true; int reward = rooms[roomIndex].Reward; int num = SemiFunc.StatGetRunCurrency() + reward; if (roomIndex == rooms.Length - 1) { num += Repo2Plugin.FinalReward.Value; } SemiFunc.StatSetRunCurrency(num); if (Repo2Runtime.IsPhotonRoomActive) { ((MonoBehaviourPun)this).photonView.RPC("ApplySolvedRoomRPC", (RpcTarget)3, new object[1] { roomIndex }); } else { ApplySolvedRoomLocal(roomIndex); } if (roomIndex == rooms.Length - 1 && !finishQueued) { finishQueued = true; ((MonoBehaviour)this).StartCoroutine(FinishRunRoutine()); } else { BeginContinuePrompt(roomIndex); } } } [PunRPC] private void ApplySolvedRoomRPC(int roomIndex, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!Repo2Runtime.IsPhotonRoomActive || SemiFunc.MasterOnlyRPC(info)) { ApplySolvedRoomLocal(roomIndex); } } private void ApplySolvedRoomLocal(int roomIndex) { if (roomIndex >= 0 && roomIndex < solvedRooms.Length) { solvedRooms[roomIndex] = true; rooms[roomIndex].SetSolvedState(value: true); Repo2Runtime.Instance?.UpdateDoorProgress(CountSolvedRooms()); } } private void BeginContinuePrompt(int roomIndex) { if (awaitingDecision) { return; } if (Repo2Runtime.IsPhotonRoomActive) { if (PhotonNetwork.IsMasterClient) { ((MonoBehaviourPun)this).photonView.RPC("PlayCorrectDoorChimeRPC", (RpcTarget)0, Array.Empty<object>()); BeginContinuePromptVoteHost(roomIndex); } } else { Repo2Runtime.Instance?.PlayCorrectDoorChime(); BeginContinuePromptLocal(roomIndex); } } [PunRPC] private void PlayCorrectDoorChimeRPC(PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!Repo2Runtime.IsPhotonRoomActive || SemiFunc.MasterOnlyRPC(info)) { Repo2Runtime.Instance?.PlayCorrectDoorChime(); } } [PunRPC] private void SyncContinuePromptRPC(int roomIndex, int yesCount, int noCount, int requiredCount, int[] eligibleActorNumbers, int[] submittedActorNumbers, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!Repo2Runtime.IsPhotonRoomActive || SemiFunc.MasterOnlyRPC(info)) { ApplyContinuePromptStateLocal(roomIndex, yesCount, noCount, requiredCount, eligibleActorNumbers, submittedActorNumbers); } } private void BeginContinuePromptLocal(int roomIndex) { if (roomIndex >= 0 && roomIndex < rooms.Length) { awaitingDecision = true; pendingRoomIndex = roomIndex; localVoteEligible = true; localVoteSubmitted = false; displayVoteYesCount = 0; displayVoteNoCount = 0; displayVoteRequiredCount = 1; Repo2Runtime.Instance?.ShowContinuePrompt(); } } private void HandleContinueInput() { if (!awaitingDecision || !Repo2Runtime.IsRepo2RunActive || rooms.Length == 0 || !SemiFunc.NoTextInputsActive()) { return; } if (Repo2Runtime.IsPhotonRoomActive) { if (localVoteEligible && !localVoteSubmitted) { if (Input.GetKeyDown((KeyCode)121)) { SubmitLocalContinueVote(continueRun: true); } else if (Input.GetKeyDown((KeyCode)110)) { SubmitLocalContinueVote(continueRun: false); } } } else if (Input.GetKeyDown((KeyCode)121)) { ContinueRunLocal(pendingRoomIndex); } else if (Input.GetKeyDown((KeyCode)110)) { CashOutLocal(); } } [PunRPC] private void SubmitContinueVoteRPC(int roomIndex, bool continueRun, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0021: 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) if (Repo2Runtime.IsPhotonRoomActive && PhotonNetwork.IsMasterClient && awaitingDecision && roomIndex == pendingRoomIndex && info.Sender != null) { RegisterContinueVote(info.Sender.ActorNumber, continueRun); } } [PunRPC] private void ContinueRunRPC(int roomIndex, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!Repo2Runtime.IsPhotonRoomActive || SemiFunc.MasterOnlyRPC(info)) { ContinueRunLocal(roomIndex); } } private void ContinueRunLocal(int roomIndex) { ResetContinueVoteState(); Repo2Runtime.Instance?.ClearContinuePrompt(); int num = roomIndex + 1; if (num < rooms.Length) { PrimeUpcomingRooms(num); ((MonoBehaviour)this).StartCoroutine(AdvanceLocalAvatarsToNextRoomRoutine(num)); } } [PunRPC] private void CashOutRunRPC(int roomIndex, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) if (!Repo2Runtime.IsPhotonRoomActive || SemiFunc.MasterOnlyRPC(info)) { CashOutLocal(); } } private void CashOutLocal() { ResetContinueVoteState(); Repo2Runtime.Instance?.ClearContinuePrompt(); if (SemiFunc.IsMasterClientOrSingleplayer()) { RunManager.instance.ChangeLevel(true, false, (ChangeLevelType)0); } } private IEnumerator AdvanceLocalAvatarsToNextRoomRoutine(int nextIndex) { yield return null; int teleportedCount2 = AdvanceLocalAvatarsToNextRoom(nextIndex); yield return (object)new WaitForEndOfFrame(); teleportedCount2 += AdvanceLocalAvatarsToNextRoom(nextIndex); if (teleportedCount2 <= 0) { Repo2Plugin.Log.LogWarning((object)$"2 Doors could not find a local avatar to teleport for room {nextIndex + 1}."); } else { Repo2Plugin.Log.LogInfo((object)$"2 Doors teleported {teleportedCount2} local avatar pass(es) into room {nextIndex + 1}."); } } private int AdvanceLocalAvatarsToNextRoom(int nextIndex) { if (nextIndex < 0 || nextIndex >= rooms.Length) { return 0; } int num = 0; if ((Object)(object)GameDirector.instance == (Object)null) { return TeleportFallbackAvatar(nextIndex); } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!((Object)(object)player == (Object)null) && Repo2AvatarUtil.IsLocalAvatar(player)) { rooms[nextIndex].TeleportLocalAvatar(player); num++; } } if (num > 0) { return num; } return TeleportFallbackAvatar(nextIndex); } private int TeleportFallbackAvatar(int nextIndex) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar instance = PlayerAvatar.instance; if ((Object)(object)instance != (Object)null && Repo2AvatarUtil.IsLocalAvatar(instance)) { rooms[nextIndex].TeleportLocalAvatar(instance); return 1; } if ((Object)(object)PlayerController.instance != (Object)null && rooms[nextIndex].TryGetEntryPose(PlayerAvatar.instance, out var position, out var rotation)) { Repo2DoorsAvatarTransfer.TeleportLocalPlayerFallback(position, rotation); return 1; } return 0; } private void PrimeUpcomingRooms(int roomIndex) { if (roomIndex >= 0 && roomIndex < rooms.Length) { for (int i = roomIndex; i < Mathf.Min(rooms.Length, roomIndex + 4); i++) { rooms[i].WarmVisuals(); } } } private IEnumerator FinishRunRoutine() { yield return (object)new WaitForSeconds(1.35f); if (SemiFunc.IsMasterClientOrSingleplayer()) { RunManager.instance.ChangeLevel(true, false, (ChangeLevelType)0); } } private int ResolveNearestRoom(Vector3 position) { //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_001f: Unknown result type (might be due to invalid IL or missing references) int result = 0; float num = float.PositiveInfinity; for (int i = 0; i < rooms.Length; i++) { float num2 = Vector3.SqrMagnitude(((Component)rooms[i]).transform.position - position); if (num2 < num) { num = num2; result = i; } } return result; } private int CountSolvedRooms() { int num = 0; for (int i = 0; i < solvedRooms.Length; i++) { if (solvedRooms[i]) { num++; } } return num; } private void BeginContinuePromptVoteHost(int roomIndex) { if (roomIndex < 0 || roomIndex >= rooms.Length) { return; } awaitingDecision = true; pendingRoomIndex = roomIndex; eligibleContinueVoters.Clear(); continueVotes.Clear(); foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (IsEligibleContinueVoter(player)) { int num = ResolveActorNumber(player); if (num > 0) { eligibleContinueVoters.Add(num); } } } if (eligibleContinueVoters.Count == 0 && PhotonNetwork.LocalPlayer != null) { eligibleContinueVoters.Add(PhotonNetwork.LocalPlayer.ActorNumber); } BroadcastContinuePromptState(); } private void ApplyContinuePromptStateLocal(int roomIndex, int yesCount, int noCount, int requiredCount, int[] eligibleActorNumbers, int[] submittedActorNumbers) { if (roomIndex >= 0 && roomIndex < rooms.Length) { awaitingDecision = true; pendingRoomIndex = roomIndex; displayVoteYesCount = Mathf.Max(0, yesCount); displayVoteNoCount = Mathf.Max(0, noCount); displayVoteRequiredCount = Mathf.Max(1, requiredCount); int num = ((PhotonNetwork.LocalPlayer != null) ? PhotonNetwork.LocalPlayer.ActorNumber : 0); localVoteEligible = num > 0 && Array.IndexOf(eligibleActorNumbers, num) >= 0; localVoteSubmitted = localVoteEligible && Array.IndexOf(submittedActorNumbers, num) >= 0; Repo2Runtime.Instance?.ShowContinuePrompt(localVoteEligible, localVoteSubmitted, displayVoteYesCount, displayVoteNoCount, displayVoteRequiredCount); } } private void SubmitLocalContinueVote(bool continueRun) { if (Repo2Runtime.IsPhotonRoomActive && localVoteEligible && !localVoteSubmitted) { localVoteSubmitted = true; Repo2Runtime.Instance?.ShowContinuePrompt(localVoteEligible, localVoteSubmitted, displayVoteYesCount, displayVoteNoCount, displayVoteRequiredCount); if (PhotonNetwork.IsMasterClient) { int actorNumber = ((PhotonNetwork.LocalPlayer != null) ? PhotonNetwork.LocalPlayer.ActorNumber : 0); RegisterContinueVote(actorNumber, continueRun); } else { ((MonoBehaviourPun)this).photonView.RPC("SubmitContinueVoteRPC", (RpcTarget)2, new object[2] { pendingRoomIndex, continueRun }); } } } private void RegisterContinueVote(int actorNumber, bool continueRun) { if (!awaitingDecision || pendingRoomIndex < 0 || !eligibleContinueVoters.Contains(actorNumber)) { return; } continueVotes[actorNumber] = continueRun; BroadcastContinuePromptState(); if (continueVotes.Count < eligibleContinueVoters.Count) { return; } int num = 0; foreach (bool value in continueVotes.Values) { if (value) { num++; } } int num2 = continueVotes.Count - num; if (num > num2) { ((MonoBehaviourPun)this).photonView.RPC("ContinueRunRPC", (RpcTarget)0, new object[1] { pendingRoomIndex }); } else { ((MonoBehaviourPun)this).photonView.RPC("CashOutRunRPC", (RpcTarget)0, new object[1] { pendingRoomIndex }); } } private void BroadcastContinuePromptState() { int num = 0; foreach (bool value in continueVotes.Values) { if (value) { num++; } } int num2 = continueVotes.Count - num; int[] array = new int[eligibleContinueVoters.Count]; eligibleContinueVoters.CopyTo(array); int[] array2 = new int[continueVotes.Count]; continueVotes.Keys.CopyTo(array2, 0); ((MonoBehaviourPun)this).photonView.RPC("SyncContinuePromptRPC", (RpcTarget)0, new object[6] { pendingRoomIndex, num, num2, eligibleContinueVoters.Count, array, array2 }); } private void ResetContinueVoteState() { awaitingDecision = false; pendingRoomIndex = -1; localVoteEligible = false; localVoteSubmitted = false; displayVoteYesCount = 0; displayVoteNoCount = 0; displayVoteRequiredCount = 0; eligibleContinueVoters.Clear(); continueVotes.Clear(); } private static bool IsEligibleContinueVoter(PlayerAvatar? avatar) { if ((Object)(object)avatar != (Object)null && !Repo2AvatarUtil.IsDisabledAvatar(avatar) && !Repo2Reflect.GetField(avatar, "deadSet", fallback: false)) { return ResolveActorNumber(avatar) > 0; } return false; } private static int ResolveActorNumber(PlayerAvatar avatar) { if ((Object)(object)avatar == (Object)null) { return 0; } PhotonView val = (((Object)(object)avatar.photonView != (Object)null) ? avatar.photonView : ((Component)avatar).GetComponent<PhotonView>()); if ((Object)(object)val == (Object)null) { return 0; } return val.OwnerActorNr; } } internal sealed class Repo2DoorChoiceTrigger : MonoBehaviour { internal Repo2DoorsRunController Controller; internal int RoomIndex; internal bool IsCorrect; private void OnTriggerEnter(Collider other) { PlayerAvatar componentInParent = ((Component)other).GetComponentInParent<PlayerAvatar>(); if (!((Object)(object)componentInParent == (Object)null) && Repo2AvatarUtil.IsLocalAvatar(componentInParent)) { Controller.TryChooseDoor(RoomIndex, IsCorrect, componentInParent); } } } internal sealed class Repo2DoorRoomVisual : MonoBehaviour { private Light? focusLight; private Repo2LogoPanel? leftPanel; private Repo2LogoPanel? rightPanel; private TextMesh? promptText; private TextMesh? metaText; private Transform? entryAnchor; private bool solved; internal int RoomNumber { get; private set; } internal string QuestionPrompt { get; private set; } = string.Empty; internal string LeftChoiceLabel { get; private set; } = string.Empty; internal string RightChoiceLabel { get; private set; } = string.Empty; internal int Reward { get; private set; } internal bool CorrectIsLeft { get; private set; } internal void Configure(int roomNumber, string questionPrompt, string leftChoiceLabel, string rightChoiceLabel, int reward, bool correctIsLeft, Repo2LogoPanel leftLogoPanel, Repo2LogoPanel rightLogoPanel, TextMesh? questionText, TextMesh? roomMetaText, Light roomFocusLight, Transform roomEntryAnchor) { RoomNumber = roomNumber; QuestionPrompt = questionPrompt; LeftChoiceLabel = leftChoiceLabel; RightChoiceLabel = rightChoiceLabel; Reward = reward; CorrectIsLeft = correctIsLeft; leftPanel = leftLogoPanel; rightPanel = rightLogoPanel; promptText = questionText; metaText = roomMetaText; focusLight = roomFocusLight; entryAnchor = roomEntryAnchor; if ((Object)(object)promptText != (Object)null) { promptText.text = Wrap(questionPrompt, 22); } if ((Object)(object)metaText != (Object)null) { metaText.text = $"QUESTION {roomNumber}\nSURVIVE FOR {Repo2DoorsCurrency.FormatReward(reward)}"; } leftPanel.SetSolvedState(isSolved: false, correctIsLeft); rightPanel.SetSolvedState(isSolved: false, !correctIsLeft); leftPanel.EnsureTextureRequested(); rightPanel.EnsureTextureRequested(); } internal void WarmVisuals() { leftPanel?.EnsureTextureRequested(); rightPanel?.EnsureTextureRequested(); } internal void TeleportLocalAvatar(PlayerAvatar avatar) { //IL_000f: 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 (TryGetEntryPose(avatar, out var position, out var rotation)) { Repo2DoorsAvatarTransfer.TeleportAvatar(avatar, position, rotation); } } internal bool TryGetEntryPose(out Vector3 position, out Quaternion rotation) { return TryGetEntryPose(PlayerAvatar.instance, out position, out rotation); } internal bool TryGetEntryPose(PlayerAvatar? avatar, out Vector3 position, out Quaternion rotation) { //IL_000f: 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) if ((Object)(object)entryAnchor == (Object)null) { position = default(Vector3); rotation = Quaternion.identity; return false; } return Repo2DoorsAvatarTransfer.TryResolveRoomEntryPose(entryAnchor, avatar, out position, out rotation); } internal void SetSolvedState(bool value) { solved = value; if ((Object)(object)metaText != (Object)null) { metaText.text = (value ? string.Format("QUESTION {0}\nANSWER: {1}", RoomNumber, CorrectIsLeft ? "LEFT" : "RIGHT") : $"QUESTION {RoomNumber}\nSURVIVE FOR {Repo2DoorsCurrency.FormatReward(Reward)}"); } if ((Object)(object)leftPanel != (Object)null) { leftPanel.SetSolvedState(value, CorrectIsLeft); } if ((Object)(object)rightPanel != (Object)null) { rightPanel.SetSolvedState(value, !CorrectIsLeft); } } internal void SetFocused(bool focused) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)focusLight != (Object)null) { focusLight.intensity = ((!focused) ? (solved ? 1.25f : 1.85f) : (solved ? 2.6f : 3.6f)); } if ((Object)(object)promptText != (Object)null) { promptText.color = (Color)(focused ? Color.white : new Color(0.85f, 0.92f, 1f)); } } private static string Wrap(string value, int width) { if (string.IsNullOrWhiteSpace(value) || value.Length <= width) { return value; } List<string> list = new List<string>(); string[] array = value.Split(' '); string text = string.Empty; string[] array2 = array; foreach (string text2 in array2) { string text3 = (string.IsNullOrEmpty(text) ? text2 : (text + " " + text2)); if (text3.Length <= width) { text = text3; continue; } if (!string.IsNullOrEmpty(text)) { list.Add(text); } text = text2; } if (!string.IsNullOrEmpty(text)) { list.Add(text); } return string.Join("\n", list); } } internal sealed class Repo2LogoPanel : MonoBehaviour { internal Renderer? ScreenRenderer; internal RawImage? ScreenImage; internal AspectRatioFitter? AspectFitter; internal Renderer FrameRenderer; internal Light IndicatorLight; internal string LogoKey = string.Empty; internal string LogoUrl = string.Empty; internal Color AccentColor = Color.white; internal bool UseFakeVariant; internal int VariantSeed; private bool initialized; private bool solved; private bool correct; private bool requestStarted; private Material? screenMaterial; private Material? frameMaterial; internal void Initialize() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) if (!initialized) { initialized = true; Repo2DoorsLogoService.Initialize(); screenMaterial = (((Object)(object)ScreenRenderer != (Object)null) ? ScreenRenderer.material : null); frameMaterial = FrameRenderer.material; if ((Object)(object)ScreenImage != (Object)null) { ScreenImage.texture = null; ((Graphic)ScreenImage).color = Color.white; ((Graphic)ScreenImage).raycastTarget = false; } ApplyTexture(Repo2DoorsLogoService.GetPlaceholderTexture(AccentColor, UseFakeVariant, VariantSeed)); ApplyIdleColors(); } } internal void EnsureTextureRequested() { if (initialized && !requestStarted) { requestStarted = true; ((MonoBehaviour)this).StartCoroutine(LoadPanelTextureRoutine()); } } internal void SetSolvedState(bool isSolved, bool isCorrect) { solved = isSolved; correct = isCorrect; ApplyIdleColors(); } private IEnumerator LoadPanelTextureRoutine() { Texture2D loadedTexture = null; yield return Repo2DoorsLogoService.LoadPanelTexture(LogoUrl, LogoKey, AccentColor, UseFakeVariant, VariantSeed, delegate(Texture2D texture) { loadedTexture = texture; }); if ((Object)(object)loadedTexture != (Object)null) { ApplyTexture(loadedTexture); } ApplyIdleColors(); } private void ApplyTexture(Texture2D texture) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)texture == (Object)null)) { if ((Object)(object)ScreenImage != (Object)null) { ScreenImage.texture = (Texture)(object)texture; ((Graphic)ScreenImage).color = Color.white; } if ((Object)(object)AspectFitter != (Object)null) { AspectFitter.aspectRatio = ((((Texture)texture).height <= 0) ? 1f : ((float)((Texture)texture).width / (float)((Texture)texture).height)); } if ((Object)(object)screenMaterial != (Object)null) { SetTextureIfPresent(screenMaterial, "_BaseColorMap", (Texture)(object)texture); SetTextureIfPresent(screenMaterial, "_BaseMap", (Texture)(object)texture); SetTextureIfPresent(screenMaterial, "_MainTex", (Texture)(object)texture); screenMaterial.mainTexture = (Texture)(object)texture; SetColorIfPresent(screenMaterial, "_Color", Color.white); SetColorIfPresent(screenMaterial, "_BaseColor", Color.white); SetColorIfPresent(screenMaterial, "_EmissionColor", Color.white * 0.08f); } } } private void ApplyIdleColors() { //IL_001e: 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_0038: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) Color val = default(Color); ((Color)(ref val))..ctor(0.34f, 0.36f, 0.4f); Color val2 = (Color)((!solved) ? val : (correct ? new Color(0.18f, 0.95f, 0.55f) : new Color(1f, 0.16f, 0.22f))); Color val3 = ((!solved) ? new Color(0.08f, 0.1f, 0.14f) : (correct ? new Color(0.97f, 1f, 0.98f) : new Color(0.24f, 0.07f, 0.09f))); if ((Object)(object)frameMaterial != (Object)null) { if (frameMaterial.HasProperty("_Color")) { frameMaterial.SetColor("_Color", val2); } if (frameMaterial.HasProperty("_EmissionColor")) { frameMaterial.SetColor("_EmissionColor", val2 * 0.4f); } } if ((Object)(object)screenMaterial != (Object)null) { if ((Object)(object)screenMaterial.mainTexture == (Object)null && screenMaterial.HasProperty("_Color")) { screenMaterial.SetColor("_Color", val3); } if (screenMaterial.HasProperty("_EmissionColor")) { screenMaterial.SetColor("_EmissionColor", val2 * 0.12f); } } if ((Object)(object)ScreenImage != (Object)null) { ((Graphic)ScreenImage).color = Color.white; } if ((Object)(object)IndicatorLight != (Object)null) { IndicatorLight.color = val2; IndicatorLight.intensity = (solved ? 4.2f : 0.95f); } } private static void SetTextureIfPresent(Material material, string propertyName, Texture texture) { if (material.HasProperty(propertyName)) { material.SetTexture(propertyName, texture); } } private static void SetColorIfPresent(Material material, string propertyName, Color color) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (material.HasProperty(propertyName)) { material.SetColor(propertyName, color); } } } internal static class Repo2DoorsAvatarTransfer { private static readonly Vector3[] RoomEntryOffsets = (Vector3[])(object)new Vector3[8] { new Vector3(-4.2f, 0.08f, 0f), new Vector3(-1.4f, 0.08f, 0f), new Vector3(1.4f, 0.08f, 0f), new Vector3(4.2f, 0.08f, 0f), new Vector3(-2.8f, 0.08f, -1.8f), new Vector3(0f, 0.08f, -1.8f), new Vector3(2.8f, 0.08f, -1.8f), new Vector3(0f, 0.08f, -3.2f) }; internal static bool TryResolveRoomEntryPose(Transform? entryAnchor, PlayerAvatar? avatar, out Vector3 position, out Quaternion rotation) { //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_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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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) if ((Object)(object)entryAnchor == (Object)null) { position = default(Vector3); rotation = Quaternion.identity; return false; } int num = ResolveAvatarSlotIndex(avatar); Vector3 val = RoomEntryOffsets[num % RoomEntryOffsets.Length]; position = entryAnchor.TransformPoint(val); rotation = entryAnchor.rotation; return true; } internal static void TeleportAvatar(PlayerAvatar avatar, Vector3 destination, Quaternion rotation) { //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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)avatar == (Object)null || !Repo2AvatarUtil.IsLocalAvatar(avatar)) { return; } avatar.Spawn(destination, rotation); Rigidbody val = ((Component)avatar).GetComponent<Rigidbody>() ?? Repo2Reflect.GetField<Rigidbody>(avatar, "rb"); if ((Object)(object)val != (Object)null) { val.position = destination; val.rotation = rotation; if (!val.isKinematic) { val.velocity = Vector3.zero; val.angularVelocity = Vector3.zero; } } ((Component)avatar).transform.SetPositionAndRotation(destination, rotation); Repo2Reflect.SetField<Vector3>(avatar, "clientPosition", destination); Repo2Reflect.SetField<Vector3>(avatar, "clientPositionCurrent", destination); Repo2Reflect.SetField(avatar, "clientPositionDelta", 0f); Repo2Reflect.SetField<Quaternion>(avatar, "clientRotation", rotation); Repo2Reflect.SetField<Quaternion>(avatar, "clientRotationCurrent", rotation); Repo2Reflect.SetField<Vector3>(avatar, "spawnPosition", destination); Repo2Reflect.SetField<Quaternion>(avatar, "spawnRotation", rotation); Repo2Reflect.SetField<Vector3>(avatar, "rbVelocity", Vector3.zero); Repo2Reflect.SetField<Vector3>(avatar, "rbVelocityRaw", Vector3.zero); PlayerAvatarVisuals field = Repo2Reflect.GetField<PlayerAvatarVisuals>(avatar, "playerAvatarVisuals"); if ((Object)(object)field != (Object)null) { ((Component)field).transform.SetPositionAndRotation(destination, rotation); Repo2Reflect.SetField<Vector3>(field, "visualPosition", destination); } if ((Object)(object)PlayerController.instance != (Object)null) { StabilizeLocalController(destination, rotation); } PlayerLocalCamera field2 = Repo2Reflect.GetField<PlayerLocalCamera>(avatar, "localCamera"); if ((Object)(object)field2 != (Object)null) { field2.Teleported(); } if ((Object)(object)CameraAim.Instance != (Object)null) { CameraAim.Instance.SetPlayerAim(rotation, true); } if ((Object)(object)AssetManager.instance != (Object)null) { GameObject field3 = Repo2Reflect.GetField<GameObject>(AssetManager.instance, "prefabTeleportEffect"); if ((Object)(object)field3 != (Object)null) { Object.Instantiate<GameObject>(field3, destination, rotation); } } } internal static void TeleportLocalPlayerFallback(Vector3 destination, Quaternion rotation) { //IL_0058: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_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) if ((Object)(object)PlayerController.instance == (Object)null) { return; } Rigidbody component = ((Component)PlayerController.instance).GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { component.position = destination; component.rotation = rotation; if (!component.isKinematic) { component.velocity = Vector3.zero; component.angularVelocity = Vector3.zero; } } ((Component)PlayerController.instance).transform.SetPositionAndRotation(destination, rotation); StabilizeLocalController(destination, rotation); if ((Object)(object)CameraAim.Instance != (Object)null) { CameraAim.Instance.SetPlayerAim(rotation, true); } } internal static int StabilizeSpawnedLocalAvatars() { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) int num = 0; if ((Object)(object)GameDirector.instance != (Object)null) { foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!((Object)(object)player == (Object)null) && Repo2AvatarUtil.IsLocalAvatar(player)) { StabilizeSpawnedLocalAvatar(player); num++; } } } if (num > 0) { return num; } if ((Object)(object)PlayerAvatar.instance != (Object)null && Repo2AvatarUtil.IsLocalAvatar(PlayerAvatar.instance)) { StabilizeSpawnedLocalAvatar(PlayerAvatar.instance); return 1; } if ((Object)(object)PlayerController.instance != (Object)null) { StabilizeLocalController(((Component)PlayerController.instance).transform.position, ((Component)PlayerController.instance).transform.rotation); return 1; } return 0; } private static void StabilizeSpawnedLocalAvatar(PlayerAvatar avatar) { //IL_0044: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_0034: Unknown result type (might be due to invalid IL or missing references) Rigidbody val = ((Component)avatar).GetComponent<Rigidbody>() ?? Repo2Reflect.GetField<Rigidbody>(avatar, "rb"); if ((Object)(object)val != (Object)null && !val.isKinematic) { val.velocity = Vector3.zero; val.angularVelocity = Vector3.zero; } Vector3 position = ((Component)avatar).transform.position; Quaternion rotation = ((Component)avatar).transform.rotation; Repo2Reflect.SetField<Vector3>(avatar, "clientPosition", position); Repo2Reflect.SetField<Vector3>(avatar, "clientPositionCurrent", position); Repo2Reflect.SetField(avatar, "clientPositionDelta", 0f); Repo2Reflect.SetField<Quaternion>(avatar, "clientRotation", rotation); Repo2Reflect.SetField<Quaternion>(avatar, "clientRotationCurrent", rotation); Repo2Reflect.SetField<Vector3>(avatar, "rbVelocity", Vector3.zero); Repo2Reflect.SetField<Vector3>(avatar, "rbVelocityRaw", Vector3.zero); StabilizeLocalController(position, rotation); } private static void StabilizeLocalController(Vector3 destination, Quaternion rotation) { //IL_0018: 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_0052: 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_0068: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)PlayerController.instance == (Object)null) { return; } ((Component)PlayerController.instance).transform.SetPositionAndRotation(destination, rotation); Rigidbody val = (((Object)(object)PlayerController.instance.rb != (Object)null) ? PlayerController.instance.rb : ((Component)PlayerController.instance).GetComponent<Rigidbody>()); if ((Object)(object)val != (Object)null) { val.position = destination; val.rotation = rotation; if (!val.isKinematic) { val.velocity = Vector3.zero; val.angularVelocity = Vector3.zero; } } PlayerController.instance.InputDisable(0.45f); PlayerController.instance.Kinematic(0.25f); PlayerCollisionController collisionController = PlayerController.instance.CollisionController; if (collisionController != null) { collisionController.ResetFalling(); } Repo2Reflect.TryInvokeMethod(GameDirector.instance, "SetDisableInput", 0.3f); Repo2Reflect.SetField(PlayerController.instance, "VelocityIdle", value: true); Repo2Reflect.SetField<Vector3>(PlayerController.instance, "Velocity", Vector3.zero); Repo2Reflect.SetField<Vector3>(PlayerController.instance, "VelocityRelative", Vector3.zero); Repo2Reflect.SetField<Vector3>(PlayerController.instance, "VelocityRelativeNew", Vector3.zero); Repo2Reflect.SetField<Vector3>(PlayerController.instance, "VelocityImpulse", Vector3.zero); Repo2Reflect.SetField<Vector3>(PlayerController.instance, "positionPrevious", destination); } private static int ResolveAvatarSlotIndex(PlayerAvatar? avatar) { if (avatar == null) { avatar = PlayerAvatar.instance; } if ((Object)(object)avatar == (Object)null || (Object)(object)GameDirector.instance == (Object)null) { return 0; } List<(int, int, PlayerAvatar)> list = new List<(int, int, PlayerAvatar)>(); int num = 0; foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!((Object)(object)player == (Object)null)) { PhotonView component = ((Component)player).GetComponent<PhotonView>(); int item = (((Object)(object)component != (Object)null) ? component.OwnerActorNr : (int.MaxValue - num)); list.Add((item, num, player)); num++; } } list.Sort(delegate((int ActorNumber, int FallbackOrder, PlayerAvatar Avatar) left, (int ActorNumber, int FallbackOrder, PlayerAvatar Avatar) right) { int num2 = left.ActorNumber.CompareTo(right.ActorNumber); return (num2 == 0) ? left.FallbackOrder.CompareTo(right.FallbackOrder) : num2; }); for (int i = 0; i < list.Count; i++) { if ((Object)(object)list[i].Item3 == (Object)(object)avatar) { return i; } } return 0; } } internal static class Repo2DoorsLogoService { private const int CardWidth = 768; private const int CardHeight = 432; private const int FallbackSourceSize = 512; private static readonly Dictionary<string, Texture2D> TextureCache = new Dictionary<string, Texture2D>(); private static readonly HashSet<string> PendingTextureKeys = new HashSet<string>(); private static string cacheDirectory = string.Empty; private static string bundledCardsDirectory = string.Empty; private static bool initialized; internal static void Initialize() { if (!initialized) { initialized = true; cacheDirectory = Path.Combine(Paths.CachePath, "Repo2DoorsLogos"); Directory.CreateDirectory(cacheDirectory); string path = Path.GetDirectoryName(typeof(Repo2Plugin).Assembly.Location) ?? Paths.PluginPath; bundledCardsDirectory = Path.Combine(path, "doors-logos"); } } internal static Texture2D GetPlaceholderTexture(Color accentColor, bool counterfeit, int variantSeed) { //IL_0012: 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_002e: 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_006a: Unknown result type (might be due to invalid IL or missing references) Initialize(); string text = $"placeholder::{accentColor.r:F3}:{accentColor.g:F3}:{accentColor.b:F3}:{counterfeit}:{variantSeed}"; if (TextureCache.TryGetValue(text, out Texture2D value)) { return value; } Texture2D val = BuildCardTexture(GenerateFallbackSource(text, accentColor), accentColor, counterfeit, variantSeed); CacheTexture(text, val, persistToDisk: false); return val; } internal static IEnumerator LoadPanelTexture(string logoUrl, string logoKey, Color accentColor, bool counterfeit, int variantSeed, Action<Texture2D> onReady) { //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) Initialize(); string finalKey = (counterfeit ? $"panel::fake::{logoKey}::{variantSeed}" : ("panel::real::" + logoKey)); Texture2D val = TryLoadBundledPanelTexture(logoKey, counterfeit); if ((Object)(object)val != (Object)null) { CacheTexture(finalKey, val, persistToDisk: false); onReady(val); yield break; } Texture2D val2 = TryGetTexture(finalKey); if ((Object)(object)val2 != (Object)null) { onReady(val2); yield break; } Texture2D sourceTexture = null; yield return LoadSourceTexture(logoUrl, logoKey, accentColor, delegate(Texture2D texture) { sourceTexture = texture; }); if (sourceTexture == null) { sourceTexture = GenerateFallbackSource(logoKey, accentColor); } val2 = BuildCardTexture(sourceTexture, accentColor, counterfeit, variantSeed); CacheTexture(finalKey, val2, persistToDisk: true); onReady(val2); } private static IEnumerator LoadSourceTexture(string logoUrl, string logoKey, Color accentColor, Action<Texture2D> onReady) { //IL_000e: 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) string sourceKey = "source::" + logoKey; Texture2D val = TryGetTexture(sourceKey); if ((Object)(object)val != (Object)null) { onReady(val); yield break; } if (PendingTextureKeys.Contains(sourceKey)) { float timeoutAt = Time.unscaledTime + 12f; while (PendingTextureKeys.Contains(sourceKey) && Time.unscaledTime < timeoutAt) { yield return null; } val = TryGetTexture(sourceKey); if ((Object)(object)val != (Object)null) { onReady(val); yield break; } } PendingTextureKeys.Add(sourceKey); Texture2D val2 = null; if (val2 == null) { val2 = GenerateFallbackSource(logoKey, accentColor); } CacheTexture(sourceKey, val2, persistToDisk: true); PendingTextureKeys.Remove(sourceKey); onReady(val2); } private static Texture2D? TryGetTexture(string key) { if (TextureCache.TryGetValue(key, out Texture2D value)) { return value; } Texture2D val = LoadTextureFromDisk(GetCachePath(key)); if ((Object)(object)val != (Object)null) { CacheTexture(key, val, persistToDisk: false); } return val; } private static Texture2D? TryLoadBundledPanelTexture(string logoKey, bool counterfeit) { Initialize(); if (string.IsNullOrWhiteSpace(bundledCardsDirectory)) { return null; } string path = SanitizeAssetName(logoKey) + ".png"; string path2 = Path.Combine(bundledCardsDirectory, counterfeit ? "fake" : "real", path); return LoadTextureFromDisk(path2); } private static void CacheTexture(string key, Texture2D texture, bool persistToDisk) { if ((Object)(object)texture == (Object)null) { return; } ((Texture)texture).wrapMode = (TextureWrapMode)1; ((Texture)texture).filterMode = (FilterMode)1; ((Texture)texture).anisoLevel = 0; ((Object)texture).hideFlags = (HideFlags)61; TextureCache[key] = texture; if (!persistToDisk) { return; } try { File.WriteAllBytes(GetCachePath(key), ImageConversion.EncodeToPNG(texture)); } catch (Exception ex) { Repo2Plugin.Log.LogWarning((object)("2 Doors could not persist cached texture '" + key + "': " + ex.Message)); } } private static Texture2D? LoadTextureFromDisk(string path) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown try { if (!File.Exists(path)) { return null; } byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false) { name = Path.GetFileNameWithoutExtension(path), hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, anisoLevel = 2 }; if (!ImageConversion.LoadImage(val, array, false)) { Object.Destroy((Object)(object)val); return null; } return val; } catch (Exception ex) { Repo2Plugin.Log.LogWarning((object)("2 Doors could not read cached texture '" + path + "': " + ex.Message)); return null; } } private static string GetCachePath(string key) { string text = CreateSha1(key); return Path.Combine(cacheDirectory, text + ".png"); } private static string SanitizeAssetName(string value) { if (string.IsNullOrWhiteSpace(value)) { return "unknown"; } StringBuilder stringBuilder = new StringBuilder(value.Length); foreach (char c in value) { bool flag = char.IsLetterOrDigit(c); bool flag2 = flag; if (!flag2) { bool flag3 = ((c == '-' || c == '.' || c == '_') ? true : false); flag2 = flag3; } if (flag2) { stringBuilder.Append(char.ToLowerInvariant(c)); } else { stringBuilder.Append('_'); } } return stringBuilder.ToString(); } private static string CreateSha1(string value) { using SHA1 sHA = SHA1.Create(); byte[] array = sHA.ComputeHash(Encoding.UTF8.GetBytes(value)); StringBuilder stringBuilder = new StringBuilder(array.Length * 2); for (int i = 0; i < array.Length; i++) { stringBuilder.Append(array[i].ToString("x2")); } return stringBuilder.ToString(); } private static Texture2D CloneTexture(Texture2D source) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0038: 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_0047: Expected O, but got Unknown Texture2D val = new Texture2D(((Texture)source).width, ((Texture)source).height, (TextureFormat)4, false) { name = ((Object)source).name + " [Clone]", hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, anisoLevel = 2 }; try { val.SetPixels32(source.GetPixels32()); val.Apply(false, false); } catch { byte[] array = ImageConversion.EncodeToPNG(source); ImageConversion.LoadImage(val, array, false); } return val; } private static Texture2D GenerateFallbackSource(string logoKey, Color accentColor) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0039: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) int stableHash = GetStableHash(logoKey); Texture2D val = new Texture2D(512, 512, (TextureFormat)4, false) { name = "Fallback " + logoKey, hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)1 }; Color[] array = (Color[])(object)new Color[262144]; Color val2 = default(Color); ((Color)(ref val2))..ctor(0f, 0f, 0f, 0f); for (int i = 0; i < array.Length; i++) { array[i] = val2; } Rect val3 = default(Rect); ((Rect)(ref val3))..ctor(36f, 36f, 184f, 184f); Color color = Color.Lerp(Color.white, accentColor, 0.45f); DrawRing(array, 512, 512, ((Rect)(ref val3)).center, 66f, 18f, color); float num = 20f + (float)(stableHash & 0xF); DrawRoundedRect(array, 512, 512, new Rect(52f, 112f, 152f, num), accentColor, 8f); DrawRoundedRect(array, 512, 512, new Rect(88f, 80f, 80f + (float)((stableHash >> 4) & 0xF), 12f + (float)((stableHash >> 8) & 7)), Color.Lerp(Color.white, accentColor, 0.25f), 6f); if ((stableHash & 1) == 0) { DrawDiamond(array, 512, 512, new Vector2(128f, 128f), 46f, Color.Lerp(accentColor, Color.white, 0.25f)); } else { DrawFilledCircle(array, 512, 512, new Vector2(128f, 128f), 34f, Color.Lerp(accentColor, Color.white, 0.3f)); } val.SetPixels(array); val.Apply(false, false); return val; } private static Texture2D BuildCardTexture(Texture2D sourceLogo, Color accentColor, bool counterfeit, int variantSeed) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_002b: 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_003a: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(768, 432, (TextureFormat)4, false) { name = "2 Doors Card", hideFlags = (HideFlags)61, wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1, anisoLevel = 2 }; Color[] array = (Color[])(object)new Color[331776]; Color val2 = default(Color); ((Color)(ref val2))..ctor(0.05f, 0.06f, 0.09f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.08f, 0.1f, 0.16f); for (int i = 0; i < 432; i++) { float num = (float)i / (float)Mathf.Max(1, 431); Color val4 = Color.Lerp(val3, val2, num); for (int j = 0; j < 768; j++) { float num2 = (float)j / (float)Mathf.Max(1, 767); float num3 = Mathf.Clamp01(Mathf.Min(Mathf.Min(num2, 1f - num2), Mathf.Min(num, 1f - num)) * 2.5f); Color val5 = Color.Lerp(Color.black, val4, 0.65f + num3 * 0.35f); float num4 = Mathf.Clamp01(1f - Mathf.Abs(num2 - 0.5f) * 1.9f); val5 = Color.Lerp(val5, accentColor * 0.1f, num4 * 0.16f); array[i * 768 + j] = val5; } } DrawBorder(array, 768, 432, accentColor); DrawAccentStripe(array, 768, 432, accentColor, counterfeit); RectInt crop = FindOpaqueBounds(sourceLogo); Rect targetRect = default(Rect); ((Rect)(ref targetRect))..ctor(48f, 32f, 672f, 362f); CompositeLogo(array, 768, 432, sourceLogo, crop, targetRect, counterfeit, accentColor, variantSeed); val.SetPixels(array); val.Apply(false, false); return val; } private static void CompositeLogo(Color[] destination, int destWidth, int destHeight, Texture2D sourceLogo, RectInt crop, Rect targetRect, bool counterfeit, Color accentColor, int variantSeed) { //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) if (((RectInt)(ref crop)).width <= 0 || ((RectInt)(ref crop)).height <= 0) { return; } float num = (float)((RectInt)(ref crop)).width / (float)((RectInt)(ref crop)).height; float num2 = ((Rect)(ref targetRect)).width / ((Rect)(ref targetRect)).height; float num3 = ((num2 > num) ? (((Rect)(ref targetRect)).height * num) : ((Rect)(ref targetRect)).width); float num4 = ((num2 > num) ? ((Rect)(ref targetRect)).height : (((Rect)(ref targetRect)).width / num)); float num5 = ((Rect)(ref targetRect)).x + (((Rect)(ref targetRect)).width - num3) * 0.5f; float num6 = ((Rect)(ref targetRect)).y + (((Rect)(ref targetRect)).height - num4) * 0.5f; for (int i = 0; i < Mathf.CeilToInt(num4); i++) { for (int j = 0; j < Mathf.CeilToInt(num3); j++) { float num7 = ((num3 <= 1f) ? 0.5f : ((float)j / Mathf.Max(1f, num3 - 1f))); float num8 = ((num4 <= 1f) ? 0.5f : ((float)i / Mathf.Max(1f, num4 - 1f))); float num9 = Mathf.Lerp((float)((RectInt)(ref crop)).xMin / (float)((Texture)sourceLogo).width, (float)((RectInt)(ref crop)).xMax / (float)((Texture)sourceLogo).width, num7); float num10 = Mathf.Lerp((float)((RectInt)(ref crop)).yMin / (float)((Texture)sourceLogo).height, (float)((RectInt)(ref crop)).yMax / (float)((Texture)sourceLogo).height, num8); Color pixelBilinear = sourceLogo.GetPixelBilinear(num9, num10); if (!(pixelBilinear.a <= 0.01f)) { pixelBilinear = Color.Lerp(pixelBilinear, Color.white, 0.08f); int num11 = Mathf.RoundToInt(num5 + (float)j); int num12 = Mathf.RoundToInt(num6 + (float)i); if (num11 >= 0 && num11 < destWidth && num12 >= 0 && num12 < destHeight) { int num13 = num12 * destWidth + num11; destination[num13] = AlphaBlend(destination[num13], pixelBilinear); } } } } } private static RectInt FindOpaqueBounds(Texture2D source) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) Color32[] pixels = source.GetPixels32(); int num = ((Texture)source).width; int num2 = ((Texture)source).height; int num3 = -1; int num4 = -1; for (int i = 0; i < ((Texture)source).height; i++) { for (int j = 0; j < ((Texture)source).width; j++) { if (pixels[i * ((Texture)source).width + j].a > 12) { if (j < num) { num = j; } if (i < num2) { num2 = i; } if (j > num3) { num3 = j; } if (i > num4) { num4 = i; } } } } if (num3 < num || num4 < num2) { return new RectInt(0, 0, ((Texture)source).width, ((Texture)source).height); } return new RectInt(num, num2, num3 - num + 1, num4 - num2 + 1); } private static void DrawBorder(Color[] pixels, int width, int height, Color accentColor) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { bool flag = j < 6 || j >= width - 6 || i < 6 || i >= height - 6; if (j < 12 || j >= width - 12 || i < 12 || i >= height - 12) { int num = i * width + j; if (flag) { pixels[num] = AlphaBlend(pixels[num], accentColor * 0.95f); } else { pixels[num] = AlphaBlend(pixels[num], accentColor * 0.2f); } } } } } private static void DrawAccentStripe(Color[] pixels, int width, int height, Color accentColor, bool counterfeit) { //IL_0030: 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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) int num = 10; int num2 = height - num - 16; for (int i = num2; i < num2 + num; i++) { for (int j = 26; j < width - 26; j++) { float num3 = ((float)j - 26f) / Mathf.Max(1f, (float)width - 52f); Color val = Color.Lerp(accentColor * 0.5f, Color.white, num3 * 0.22f); pixels[i * width + j] = AlphaBlend(pixels[i * width + j], val * 0.72f); } } } private static void DrawRing(Color[] pixels, int width, int height, Vector2 center, float radius, float thickness, Color color) { //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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(0f, radius - thickness); float num2 = radius + thickness; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { float num3 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), center); if (!(num3 < num) && !(num3 > num2)) { float num4 = Mathf.Clamp01(1f - Mathf.Abs(num3 - radius) / Mathf.Max(1f, thickness)); int num5 = i * width + j; pixels[num5] = AlphaBlend(pixels[num5], new Color(color.r, color.g, color.b, num4)); } } } } private static void DrawFilledCircle(Color[] pixels, int width, int height, Vector2 center, float radius, Color color) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) float num = radius * radius; Vector2 val = default(Vector2); for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { ((Vector2)(ref val))..ctor((float)j + 0.5f, (float)i + 0.5f); Vector2 val2 = val - center; if (!(((Vector2)(ref val2)).sqrMagnitude > num)) { int num2 = i * width + j; pixels[num2] = AlphaBlend(pixels[num2], color); } } } } private static void DrawDiamond(Color[] pixels, int width, int height, Vector2 center, float radius, Color color) { //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) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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) for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { float num = Mathf.Abs((float)j + 0.5f - center.x); float num2 = Mathf.Abs((float)i + 0.5f - center.y); if (!(num + num2 > radius)) { int num3 = i * width + j; pixels[num3] = AlphaBlend(pixels[num3], color); } } } } private static void DrawRoundedRect(Color[] pixels, int width, int height, Rect rect, Color color, float radius) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //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) Vector2 min = ((Rect)(ref rect)).min; Vector2 max = ((Rect)(ref rect)).max; for (int i = Mathf.FloorToInt(min.y); i < Mathf.CeilToInt(max.y); i++) { for (int j = Mathf.FloorToInt(min.x); j < Mathf.CeilToInt(max.x); j++) { if (j >= 0 && j < width && i >= 0 && i < height) { float num = Mathf.Clamp((float)j + 0.5f, min.x + radius, max.x - radius); float num2 = Mathf.Clamp((float)i + 0.5f, min.y + radius, max.y - radius); float num3 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), new Vector2(num, num2)); if (!(num3 > radius)) { int num4 = i * width + j; pixels[num4] = AlphaBlend(pixels[num4], color); } } } } } private static Color AlphaBlend(Color background, Color overlay) { //IL_0000: 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_0011: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004d: 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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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) float num = overlay.a + background.a * (1f - overlay.a); if (num <= 0.0001f) { return Color.clear; } Color result = (overlay * overlay.a + background * background.a * (1f - overlay.a)) / num; result.a = num; return result; } private static int GetStableHash(string value) { using SHA1 sHA = SHA1.Create(); byte[] array = sHA.ComputeHash(Encoding.UTF8.GetBytes(value)); return (array[0] << 24) | (array[1] << 16) | (array[2] << 8) | array[3]; } } internal sealed class Repo2RunController : MonoBehaviour { internal string SectorName = string.Empty; internal int Seed; private float pulseTimer; private void Update() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) pulseTimer += Time.deltaTime; if (pulseTimer >= 2.5f) { pulseTimer = 0f; SemiFunc.CameraShakeDistance(((Component)this).transform.position, 0.1f, 0.15f, 0f, 22f); } } } internal sealed class Repo2PortalAnchor : MonoBehaviour { private static readonly Dictionary<int, float> Cooldowns = new Dictionary<int, float>(); internal Repo2PortalAnchor? Target; internal float CooldownSeconds = 1.2f; internal Vector3 ExitOffset = Vector3.forward * 2.25f; private void OnTriggerEnter(Collider other) { if ((Object)(object)Target == (Object)null) { return; } PlayerAvatar componentInParent = ((Component)other).GetComponentInParent<PlayerAvatar>(); if (!((Object)(object)componentInParent == (Object)null) && Repo2AvatarUtil.IsLocalAvatar(componentInParent)) { int instanceID = ((Object)componentInParent).GetInstanceID(); if (!Cooldowns.TryGetValue(instanceID, out var value) || !(value > Time.time)) { TeleportAvatar(componentInParent); Cooldowns[instanceID] = Time.time + CooldownSeconds; } } } private void TeleportAvatar(PlayerAvatar avatar) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //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_003e: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) Vector3 val = ((Component)Target).transform.position + ((Component)Target).transform.TransformDirection(ExitOffset); Quaternion rotation = ((Component)Target).transform.rotation; avatar.Spawn(val, rotation); Rigidbody component = ((Component)avatar).GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { component.velocity = Vector3.zero; component.angularVelocity = Vector3.zero; } if (Repo2AvatarUtil.IsLocalAvatar(avatar) && (Object)(object)PlayerController.instance != (Object)null) { ((Component)PlayerController.instance).transform.SetPositionAndRotation(val, rotation); } if ((Object)(object)AssetManager.instance != (Object)null) { GameObject field = Repo2Reflect.GetField<GameObject>(AssetManager.instance, "prefabTeleportEffect"); if ((Object)(object)field != (Object)null) { Object.Instantiate<GameObject>(field, val, rotation); } } } } internal sealed class Repo2PulseSentinel : MonoBehaviour { internal float Range = 6.5f; internal int Damage = 10; internal float FireCooldown = 1.8f; internal Light? CoreLight; private float fireTimer; private void Update() { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) ((Component)this).transform.Rotate(0f, 120f * Time.deltaTime, 0f, (Space)1); if ((Object)(object)CoreLight != (Object)null) { CoreLight.intensity = 2.5f + Mathf.Sin(Time.time * 5f) * 1.1f; } fireTimer -= Time.deltaTime; if (fireTimer > 0f) { return; } PlayerAvatar val = FindLocalTarget(); if (!((Object)(object)val == (Object)null)) { fireTimer = FireCooldown; PlayerHealth component = ((Component)val).GetComponent<PlayerHealth>(); if ((Object)(object)component != (Object)null) { component.HurtOther(Damage, ((Component)val).transform.position, false, -1); } SemiFunc.CameraShakeDistance(((Component)this).transform.position, 1.2f, 0.12f, 0f, 18f); } } private PlayerAvatar? FindLocalTarget() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)GameDirector.instance == (Object)null) { return null; } RaycastHit val2 = default(RaycastHit); foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!((Object)(object)player == (Object)null) && Repo2AvatarUtil.IsLocalAvatar(player) && !Repo2AvatarUtil.IsDisabledAvatar(player)) { Vector3 val = ((Component)player).transform.position - ((Component)this).transform.position; if (!(((Vector3)(ref val)).sqrMagnitude > Range * Range) && (!Physics.Raycast(((Component)this).transform.position + Vector3.up, ((Vector3)(ref val)).normalized, ref val2, Range, -1, (QueryTriggerInteraction)1) || !((Object)(object)((Component)((RaycastHit)(ref val2)).transform).GetComponentInParent<PlayerAvatar>() != (Object)(object)player))) { return player; } } } return null; } } internal sealed class Repo2GlitchMine : MonoBehaviour { internal float TriggerRadius = 2.4f; internal float ExplosionRadius = 4.5f; internal int Damage = 24; private float armTimer; private bool armed; private bool exploded; private Renderer? cachedRenderer; private void Awake() { cachedRenderer = ((Component)this).GetComponentInChildren<Renderer>(); } private void Update() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) if (exploded) { return; } if (!armed) { if (PlayerInRange(TriggerRadius)) { armed = true; armTimer = 0.85f; } return; } armTimer -= Time.deltaTime; if ((Object)(object)cachedRenderer != (Object)null && cachedRenderer.material.HasProperty("_EmissionColor")) { float num = Mathf.PingPong(Time.time * 8f, 1f); cachedRenderer.material.SetColor("_EmissionColor", Color.Lerp(Color.red * 0.1f, Color.white * 0.9f, num)); } if (armTimer <= 0f) { Explode(); } } private bool PlayerInRange(float radius) { //IL_0048: 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) if ((Object)(object)GameDirector.instance == (Object)null) { return false; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if ((Object)(object)player != (Object)null && Repo2AvatarUtil.IsLocalAvatar(player) && !Repo2AvatarUtil.IsDisabledAvatar(player) && Vector3.Distance(((Component)player).transform.position, ((Component)this).transform.position) <= radius) { return true; } } return false; } private void Explode() { //IL_000e: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) exploded = true; Transform transform = ((Component)this).transform; transform.localScale *= 1.75f; if ((Object)(object)GameDirector.instance != (Object)null) { foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!((Object)(object)player == (Object)null) && Repo2AvatarUtil.IsLocalAvatar(player) && !Repo2AvatarUtil.IsDisabledAvatar(player) && Vector3.Distance(((Component)player).transform.position, ((Component)this).transform.position) <= ExplosionRadius) { PlayerHealth component = ((Component)player).GetComponent<PlayerHealth>(); if ((Object)(object)component != (Object)null) { component.HurtOther(Damage, ((Component)player).transform.position, false, -1); } } } } SemiFunc.CameraShakeDistance(((Component)this).transform.position, 3.5f, 0.22f, 0f, 22f); Object.Destroy((Object)(object)((Component)this).gameObject, 0.08f); } } internal sealed class Repo2HunterDrone : MonoBehaviour { internal Vector3 PointA; internal Vector3 PointB; internal float MovementSpeed = 1.2f; internal float HurtRadius = 1.35f; internal int Damage = 12; private float damageTimer; private float phase; private void Start() { phase = Random.Range(0f, 10f); } private void Update() { //IL_0025: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.PingPong((Time.time + phase) * MovementSpeed, 1f); ((Component)this).transform.position = Vector3.Lerp(PointA, PointB, num); ((Component)this).transform.Rotate(0f, 180f * Time.deltaTime, 0f, (Space)1); damageTimer -= Time.deltaTime; if (damageTimer > 0f || (Object)(object)GameDirector.instance == (Object)null) { return; } foreach (PlayerAvatar player in GameDirector.instance.PlayerList) { if (!((Object)(object)player == (Object)null) && Repo2AvatarUtil.IsLocalAvatar(player) && !Repo2AvatarUtil.IsDisabledAvatar(player) && Vector3.Distance(((Component)player).transform.position, ((Component)this).transform.position) <= HurtRadius) { damageTimer = 1.1f; PlayerHealth component = ((Component)player).GetComponent<PlayerHealth>(); if ((Object)(object)component != (Object)null) { component.HurtOther(Damage, ((Component)player).transform.position, false, -1); } break; } } } } internal static class Repo2AvatarUtil { internal static bool IsLocalAvatar(PlayerAvatar avatar) { PhotonView component = ((Component)avatar).GetComponent<PhotonView>(); if (Repo2Runtime.IsPhotonRoomActive) { if ((Object)(object)component != (Object)null) { return component.IsMine; } return false; } return true; } internal static bool IsDisabledAvatar(PlayerAvatar avatar) { return Repo2Reflect.GetField(avatar, "isDisabled", fallback: false); } } internal static class Repo2DoorsGeneration { private sealed class DoorsBlueprint { internal string CourseName = "2 Doors"; internal List<DoorRoomData> Rooms = new List<DoorRoomData>(); } private sealed class DoorRoomData { internal int RoomNumber; internal Repo2DoorsQuestion Question; internal bool CorrectIsLeft; internal string LeftChoiceLabel = string.Empty; internal string RightChoiceLabel = string.Empty; internal int Reward; internal Vector3 WorldPosition; internal GameObject? RootObject; } private static class Repo2DoorsMaterialLibrary { internal static Material Floor; internal static Material Ceiling; internal static Material Wall; internal static Material Accent; internal static Material Question; internal static Material Transition; internal static Material Guide; private static bool initialized; internal static void Initialize() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) if (!initialized) { initialized = true; Shader shader = Shader.Find("HDRP/Lit") ?? Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard") ?? Shader.Find("Legacy Shaders/Diffuse"); Floor = Create("2 Doors Floor", shader, new Color(0.07f, 0.07f, 0.09f), new Color(0.01f, 0.01f, 0.02f)); Ceiling = Create("2 Doors Ceiling", shader, new Color(0.03f, 0.04f, 0.06f), Color.black); Wall = Create("2 Doors Wall", shader, new Color(0.11f, 0.13f, 0.17f), new Color(0.02f, 0.03f, 0.05f)); Accent = Create("2 Doors Accent", shader, new Color(0.08f, 0.32f, 0.6f), new Color(0.05f, 0.35f, 0.78f)); Question = Create("2 Doors Question", shader, new Color(0.04f, 0.05f, 0.08f), new Color(0.01f, 0.04f, 0.08f)); Transition = Create("2 Doors Transition", shader, new Color(0.02f, 0.03f, 0.05f), new Color(0.08f, 0.14f, 0.18f)); Guide = Create("2 Doors Guide", shader, new Color(0.93f, 0.95f, 0.98f), new Color(0.2f, 0.22f, 0.24f)); } } private static Material Create(string name, Shader shader, Color color, Color emission) { //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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(shader) { name = name, hideFlags = (HideFlags)61 }; if (val.HasProperty("_Color")) { val.SetColor("_Color", color); } if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", emission); } return val; } } private const float RoomWidth = 24f; private const float RoomLength = 20f; private const float RoomHeight = 8f; private const float WallThickness = 1f; private const float DoorWidth = 4.8f; private const float DoorHeight = 5.2f; private const float DoorOffsetX = 6.6f; private const float DoorTunnelLength = 4.4f; private const float RoomSpacingX = 58f; private const float RoomSpacingZ = 34f; private const int RoomColumns = 4; private static readonly string[] ModuleChecklistFields = new string[21] { "wallsInside", "wallsMap", "levelPointsEntrance", "levelPointsWaypoints", "levelPointsRoomVolume", "levelPointsNavmesh", "levelPointsConnected", "lightsMax", "lightsPrefab", "roomVolumeDoors", "roomVolumeHeight", "roomVolumeSpace", "navmeshConnected", "navmeshPitfalls", "valuablesAllTypes", "valuablesMaxed", "valuablesSwitch", "valuablesSwitchNavmesh", "valuablesTest", "ModulePropSwitchSetup", "ModulePropSwitchNavmesh" }; public static IEnumerator Generate(LevelGenerator generator) { Repo2Runtime runtime = Repo2Runtime.Instance; bool photonRoomActive = Repo2Runtime.IsPhotonRoomActive; bool spawnAuthority = !photonRoomActive || PhotonNetwork.IsMasterClient; yield return (object)new WaitForSeconds(0.2f); if (!photonRoomActive) { SetGeneratorField(generator, "AllPlayersReady", value: true); } while (!GetGeneratorField(generator, "AllPlayersReady", fallback: false)) { SetGeneratorField<LevelState>(generator, "State", (LevelState)1); yield return (object)new WaitForSeconds(0.1f); } ResetGenerator(generator); EnsureParents(generator); Level val = Repo2LevelRegistry.ResolveDoorsLevel() ?? (((Object)(object)RunManager.instance != (Object)null) ? RunManager.instance.levelCurrent : null); if ((Object)(object)val == (Object)null) { Repo2Plugin.Log.LogError((object)"2 Doors could not resolve its registered level before generation."); yield break; } Repo2LevelRegistry.ConsumePendingGeneration(); if ((Object)(object)RunManager.instance != (Object)null) { RunManager.instance.levelCurrent = val; } ConfigureDoorsLevel(val); SetGeneratorField<Level>(generator, "Level", val); yield return runtime.WaitForSharedSeed(); int currentRunSeed = runtime.CurrentRunSeed; DoorsBlueprint doorsBlueprint = BuildBlueprint(currentRunSeed, Repo2DoorsQuizData.TotalQuestions); runtime.BeginRun(doorsBlueprint.CourseName, currentRunSeed, doorsBlueprint.Rooms.Count, 1); ResetRoundDirector(); ResetValuableDirector(); BuildCourseLocal(generator, doorsBlueprint); ConfigureNavMeshSurface(generator, doorsBlueprint); SetGeneratorField(generator, "LevelWidth", 1); SetGeneratorField(generator, "LevelHeight", doorsBlueprint.Rooms.Count); SetGeneratorField(generator, "ModuleAmount", doorsBlueprint.Rooms.Count + 1); SetGeneratorField(generator, "ModulesSpawned", doorsBlueprint.Rooms.Count + 1); SetGeneratorField<LevelState>(generator, "State", (LevelState)3); EnvironmentDirector.Instance.Setup(); PostProcessing.Instance.Setup(); LevelMusic.instance.Setup(); ConstantMusic.instance.Setup(); while (GetGeneratorList<LevelPoint>(generator, "LevelPathPoints").Count == 0) { SetGeneratorField<LevelState>(generator, "State", (LevelState)9); yield return (object)new WaitForSeconds(0.1f); } SetGeneratorField<LevelState>(generator, "State", (LevelState)10); if (photonRoomActive) { GetGeneratorPhotonView(generator).RPC("ItemSetup", (RpcTarget)3, Array.Empty<object>()); } else { Repo2Reflect.TryInvokeMethod(generator, "ItemSetup"); } SetGeneratorField<LevelState>(generator, "State", (LevelState)11); Repo2Reflect.SetField(ValuableDirector.instance, "setupComplete", value: false); if (Repo2Reflect.TryInvokeMethod((object)ValuableDirector.instance, "SetupHost", out IEnumerator result) && result != null) { yield return ((MonoBehaviour)ValuableDirector.instance).StartCoroutine(result); } float valuableWait = 0f; while (!Repo2Reflect.GetField(ValuableDirector.instance, "setupComplete", fallback: false) && valuableWait < 3f) { valuableWait += 0.1f; yield return (object)new WaitForSeconds(0.1f); } Repo2Reflect.SetField(ValuableDirector.instance, "setupComplete", value: true); Repo2Reflect.TryInvokeMethod(generator, "NavMeshSetup"); yield return null; SnapLevelPointsToNavMesh(generator); while (GameDirector.instance.PlayerList.Count == 0) { SetGeneratorField<LevelState>(generator, "State", (LevelState)12); yield return (object)new WaitForSeconds(0.1f); } if (spawnAuthority) { Repo2Reflect.TryInvokeMethod(generator, "PlayerSpawn"); yield return null; } float spawnWait = 0f; while (spawnWait < 4f) { int generatorField = GetGeneratorField(generator, "playerSpawned", 0); int num = CountSpawnedPlayers(); if (generatorField >= GameDirector.instance.PlayerList.Count && num >= GameDirector.instance.PlayerList.Count) { break; } spawnWait += 0.1f; SetGeneratorField<LevelState>(generator, "State", (LevelState)13); yield return (object)new WaitForSeconds(0.1f); } SetGeneratorField(generator, "playerSpawned", Mathf.Max(GetGeneratorField(generator, "playerSpawned", 0), GameDirector.instance.PlayerList.Count)); int stabilizedSpawnPasses2 = Repo2DoorsAvatarTransfer.StabilizeSpawnedLocalAvatars(); yield return (object)new WaitForEndOfFrame(); stabilizedSpawnPasses2 += Repo2DoorsAvatarTransfer.StabilizeSpawnedLocalAvatars(); if (stabilizedSpawnPasses2 > 0) { Repo2Plugin.Log.LogInfo((object)$"2 Doors stabilized {stabilizedSpawnPasses2} local spawn pass(es) after room load."); } SetGeneratorField<LevelState>(generator, "State", (LevelState)15); if (photonRoomActive) { if (spawnAuthority) { GetGeneratorPhotonView(generator).RPC("GenerateDone", (RpcTarget)3, Array.Empty<object>()); } } else { CompleteGeneration(generator); } Repo2Reflect.TryInvokeMethod(SessionManager.instance, "CrownPlayer"); } private static void BuildCourseLocal(LevelGenerator generator, DoorsBlueprint blueprint) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) Repo2DoorsMaterialLibrary.Initialize(); Transform transform = GetOrCreateGeneratorParent(generator, "LevelParent", "Level").transform; Repo2DoorsRunController repo2DoorsRunController = ((Component)generator).GetComponent<Repo2DoorsRunController>() ?? ((Component)generator).gameObject.AddComponent<Repo2DoorsRunController>(); List<Repo2DoorRoomVisual> list = new List<Repo2DoorRoomVisual>(); LevelPoint val = CreateSupportRoom(transform); LevelPoint a = val; for (int i = 0; i < blueprint.Rooms.Count; i++) { DoorRoomData doorRoomData = blueprint.Rooms[i]; GameObject val2 = (doorRoomData.RootObject = CreateModuleRoot($"2 Doors Room {doorRoomData.RoomNumber}", transform, doorRoomData.WorldPosition, startRoom: false, i == 0, 0, i)); CreateRoomFrame(val2.transform); CreateRoomLighting(val2.transform, doorRoomData.Question.AccentColor); RoomVolume value = CreateRoomVolume(val2.transform, $"2 Doors Volume {doorRoomData.RoomNumber}", new Vector3(22f, 8f, 19f), truck: false, extraction: false); LevelPoint val3 = CreateLevelPoint(val2.transform, $"2 Doors Point {doorRoomData.RoomNumber}", Vector3.zero, truck: false); Repo2Reflect.SetField<RoomVolume>(val3, "Room", value); ConnectPoints(a, val3); a = val3; Transform roomEntryAnchor = CreateRoomEntryAnchor(val2.transform); if (i == 0) { CreateSpawnPoints(val2.transform); } TextMesh questionText = CreateQuestionBoard(val2.transform, doorRo