using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BepInEx;
using BepInEx.Configuration;
using MMTools;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Co-op Offscreen Preview")]
[assembly: AssemblyDescription("Low-overhead off-screen player camera preview for Cult of the Lamb co-op")]
[assembly: AssemblyCompany("COTLMP")]
[assembly: AssemblyProduct("Co-op Offscreen Preview")]
[assembly: ComVisible(false)]
[assembly: Guid("978566a8-4efc-43f6-b243-d659148910f5")]
[assembly: AssemblyFileVersion("0.3.0.0")]
[assembly: AssemblyVersion("0.3.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 CoopOffscreenPreview
{
[BepInPlugin("com.cody.cotl.coopoffscreenpreview", "Co-op Offscreen Preview", "0.3.0")]
public sealed class CoopOffscreenPreviewPlugin : BaseUnityPlugin
{
private sealed class PreviewSlot
{
public PlayerFarming Player;
public Camera Camera;
public GameObject CameraObject;
public RenderTexture Texture;
public Rect Rect;
public float NextRenderAt;
public bool Visible;
}
public const string PluginGuid = "com.cody.cotl.coopoffscreenpreview";
public const string PluginName = "Co-op Offscreen Preview";
public const string PluginVersion = "0.3.0";
private ConfigEntry<bool> _enabled;
private ConfigEntry<int> _textureWidth;
private ConfigEntry<int> _textureHeight;
private ConfigEntry<float> _updatesPerSecond;
private ConfigEntry<float> _previewWidth;
private ConfigEntry<float> _viewportPadding;
private ConfigEntry<float> _edgeMargin;
private ConfigEntry<float> _zoomMultiplier;
private ConfigEntry<KeyboardShortcut> _toggleShortcut;
private ConfigEntry<int> _configVersion;
private Camera _sourceCamera;
private readonly PreviewSlot[] _slots = new PreviewSlot[2]
{
new PreviewSlot(),
new PreviewSlot()
};
private bool _runtimeEnabled;
private GUIStyle _frameStyle;
private GUIStyle _labelStyle;
private Texture2D _frameTexture;
private Texture2D _labelTexture;
private void Awake()
{
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable the off-screen co-op player preview.");
_textureWidth = ((BaseUnityPlugin)this).Config.Bind<int>("Rendering", "TextureWidth", 512, "Horizontal render texture resolution.");
_textureHeight = ((BaseUnityPlugin)this).Config.Bind<int>("Rendering", "TextureHeight", 288, "Vertical render texture resolution.");
_updatesPerSecond = ((BaseUnityPlugin)this).Config.Bind<float>("Rendering", "UpdatesPerSecond", 0f, "Preview refresh cap. Set to 0 to render every game frame.");
_previewWidth = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "PreviewWidth", 360f, "Preview width in screen pixels at 1080p; scales with screen height.");
_viewportPadding = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "ViewportPadding", 0.04f, "How far beyond the main viewport a player must move before showing the preview.");
_edgeMargin = ((BaseUnityPlugin)this).Config.Bind<float>("Display", "EdgeMargin", 20f, "Gap between the preview and the screen edge at 1080p.");
_zoomMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Rendering", "ZoomMultiplier", 0.82f, "Preview camera distance relative to the main camera. Lower values zoom in.");
_toggleShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Controls", "TogglePreview", new KeyboardShortcut((KeyCode)291, Array.Empty<KeyCode>()), "Toggle the preview prototype.");
_configVersion = ((BaseUnityPlugin)this).Config.Bind<int>("Internal", "ConfigVersion", 0, "Configuration migration version. Managed by the plugin.");
MigrateLegacyDefaults();
_runtimeEnabled = _enabled.Value;
((BaseUnityPlugin)this).Logger.LogInfo((object)"Co-op Offscreen Preview 0.3.0 loaded. F10 toggles the preview.");
}
private void Update()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
KeyboardShortcut value = _toggleShortcut.Value;
if (((KeyboardShortcut)(ref value)).IsDown())
{
_runtimeEnabled = !_runtimeEnabled;
((BaseUnityPlugin)this).Logger.LogInfo((object)("Co-op off-screen preview " + (_runtimeEnabled ? "enabled." : "disabled.")));
}
if (!ShouldRun())
{
HidePreview();
return;
}
Camera main = Camera.main;
if ((Object)(object)main == (Object)null)
{
HidePreview();
return;
}
if (PreviewResourcesNeedRebuild(main))
{
RebuildPreviewCameras(main);
}
UpdatePreviewSlots(main);
}
private void LateUpdate()
{
if ((Object)(object)_sourceCamera == (Object)null)
{
return;
}
float value = _updatesPerSecond.Value;
for (int i = 0; i < _slots.Length; i++)
{
PreviewSlot previewSlot = _slots[i];
if (previewSlot.Visible && !((Object)(object)previewSlot.Player == (Object)null) && !((Object)(object)previewSlot.Camera == (Object)null) && !((Object)(object)previewSlot.Texture == (Object)null) && (!(value > 0f) || !(Time.unscaledTime < previewSlot.NextRenderAt)))
{
previewSlot.NextRenderAt = ((value > 0f) ? (Time.unscaledTime + 1f / Mathf.Clamp(value, 1f, 120f)) : 0f);
RenderPreview(_sourceCamera, previewSlot);
}
}
}
private void MigrateLegacyDefaults()
{
if (_configVersion.Value < 2)
{
if (_textureWidth.Value == 256)
{
_textureWidth.Value = 512;
}
if (_textureHeight.Value == 144)
{
_textureHeight.Value = 288;
}
if (Mathf.Approximately(_updatesPerSecond.Value, 12f))
{
_updatesPerSecond.Value = 0f;
}
if (Mathf.Approximately(_previewWidth.Value, 250f))
{
_previewWidth.Value = 360f;
}
_configVersion.Value = 2;
((BaseUnityPlugin)this).Config.Save();
}
}
private bool ShouldRun()
{
if (!_runtimeEnabled || !_enabled.Value || !CoopManager.CoopActive || PlayerFarming.playersCount < 2 || PlayerFarming.players == null || PlayerFarming.players.Count < 2)
{
return false;
}
if (Time.timeScale <= 0f || LetterBox.IsPlaying || MMConversation.isPlaying)
{
return false;
}
return true;
}
private bool PreviewResourcesNeedRebuild(Camera mainCamera)
{
int num = Mathf.Clamp(_textureWidth.Value, 128, 1024);
int num2 = Mathf.Clamp(_textureHeight.Value, 72, 576);
if ((Object)(object)_sourceCamera != (Object)(object)mainCamera)
{
return true;
}
for (int i = 0; i < _slots.Length; i++)
{
PreviewSlot previewSlot = _slots[i];
if ((Object)(object)previewSlot.Camera == (Object)null || (Object)(object)previewSlot.Texture == (Object)null || ((Texture)previewSlot.Texture).width != num || ((Texture)previewSlot.Texture).height != num2)
{
return true;
}
}
return false;
}
private void UpdatePreviewSlots(Camera mainCamera)
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: 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)
for (int i = 0; i < _slots.Length; i++)
{
_slots[i].Visible = false;
_slots[i].Player = null;
}
int num = 0;
float padding = Mathf.Clamp(_viewportPadding.Value, 0f, 0.25f);
for (int j = 0; j < PlayerFarming.players.Count; j++)
{
if (num >= _slots.Length)
{
break;
}
PlayerFarming val = PlayerFarming.players[j];
if (IsUsablePlayer(val))
{
Vector3 position = ((Component)val).transform.position;
if (!(ViewportOverflow(mainCamera.WorldToViewportPoint(position), padding) <= 0f))
{
PreviewSlot obj = _slots[num++];
obj.Player = val;
obj.Visible = true;
obj.Rect = CalculatePreviewRect(mainCamera, position);
}
}
}
ResolvePreviewOverlap();
}
private static bool IsUsablePlayer(PlayerFarming player)
{
if ((Object)(object)player != (Object)null && (Object)(object)((Component)player).gameObject != (Object)null && ((Component)player).gameObject.activeInHierarchy)
{
return !player.IsKnockedOut;
}
return false;
}
private static float ViewportOverflow(Vector3 viewport, float padding)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: 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_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: 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_0078: Unknown result type (might be due to invalid IL or missing references)
if (viewport.z <= 0f)
{
return 10f;
}
float num = 0f;
float num2 = 0f;
if (viewport.x < 0f - padding)
{
num = 0f - padding - viewport.x;
}
else if (viewport.x > 1f + padding)
{
num = viewport.x - (1f + padding);
}
if (viewport.y < 0f - padding)
{
num2 = 0f - padding - viewport.y;
}
else if (viewport.y > 1f + padding)
{
num2 = viewport.y - (1f + padding);
}
return Mathf.Max(num, num2);
}
private Rect CalculatePreviewRect(Camera mainCamera, Vector3 worldPosition)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: 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_0056: 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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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_0047: 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_0135: 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)
//IL_0157: 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_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: 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)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01be: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01df: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = mainCamera.WorldToScreenPoint(worldPosition);
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor((float)Screen.width * 0.5f, (float)Screen.height * 0.5f);
Vector2 val3 = ((!(val.z <= 0f)) ? (new Vector2(val.x, val.y) - val2) : (new Vector2(0f - val.x, 0f - val.y) - val2));
if (((Vector2)(ref val3)).sqrMagnitude < 0.001f)
{
val3 = Vector2.right;
}
((Vector2)(ref val3)).Normalize();
float num = Mathf.Clamp((float)Screen.height / 1080f, 0.65f, 1.7f);
float num2 = Mathf.Clamp(_previewWidth.Value, 160f, 420f) * num;
float num3 = (float)Mathf.Clamp(_textureWidth.Value, 128, 1024) / (float)Mathf.Clamp(_textureHeight.Value, 72, 576);
float num4 = num2 / num3;
float num5 = Mathf.Clamp(_edgeMargin.Value, 8f, 80f) * num;
float num6 = 22f * num;
float num7 = num2 * 0.5f;
float num8 = num4 * 0.5f;
float num9 = val2.x - num7 - num5 - num6;
float num10 = val2.y - num8 - num5 - num6;
float num11 = ((Mathf.Abs(val3.x) > 0.0001f) ? (num9 / Mathf.Abs(val3.x)) : float.PositiveInfinity);
float num12 = ((Mathf.Abs(val3.y) > 0.0001f) ? (num10 / Mathf.Abs(val3.y)) : float.PositiveInfinity);
float num13 = Mathf.Min(num11, num12);
Vector2 val4 = val2 + val3 * num13;
return new Rect(val4.x - num7, (float)Screen.height - val4.y - num8, num2, num4);
}
private void ResolvePreviewOverlap()
{
//IL_0029: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
PreviewSlot previewSlot = _slots[0];
PreviewSlot previewSlot2 = _slots[1];
if (previewSlot.Visible && previewSlot2.Visible && ((Rect)(ref previewSlot.Rect)).Overlaps(previewSlot2.Rect))
{
float num = Mathf.Clamp((float)Screen.height / 1080f, 0.65f, 1.7f);
float num2 = 12f * num;
Rect rect = previewSlot2.Rect;
if ((float)Screen.height - ((Rect)(ref previewSlot.Rect)).yMax >= ((Rect)(ref rect)).height + num2)
{
((Rect)(ref rect)).y = ((Rect)(ref previewSlot.Rect)).yMax + num2;
}
else if (((Rect)(ref previewSlot.Rect)).yMin >= ((Rect)(ref rect)).height + num2)
{
((Rect)(ref rect)).y = ((Rect)(ref previewSlot.Rect)).yMin - ((Rect)(ref rect)).height - num2;
}
else if (((Rect)(ref previewSlot.Rect)).center.x < (float)Screen.width * 0.5f)
{
((Rect)(ref rect)).x = ((Rect)(ref previewSlot.Rect)).xMax + num2;
}
else
{
((Rect)(ref rect)).x = ((Rect)(ref previewSlot.Rect)).xMin - ((Rect)(ref rect)).width - num2;
}
((Rect)(ref rect)).x = Mathf.Clamp(((Rect)(ref rect)).x, num2, (float)Screen.width - ((Rect)(ref rect)).width - num2);
((Rect)(ref rect)).y = Mathf.Clamp(((Rect)(ref rect)).y, num2, (float)Screen.height - ((Rect)(ref rect)).height - num2);
previewSlot2.Rect = rect;
}
}
private void RenderPreview(Camera mainCamera, PreviewSlot slot)
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: 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_007b: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
Transform obj = (((Object)(object)slot.Player.CameraBone != (Object)null) ? slot.Player.CameraBone.transform : ((Component)slot.Player).transform);
float num = Mathf.Clamp(_zoomMultiplier.Value, 0.45f, 1.35f);
Vector3 val = ((Component)mainCamera).transform.position - GetMainCameraFocus(mainCamera);
Vector3 val2 = obj.position + Vector3.back * 0.5f;
CopySafeCameraSettings(mainCamera, slot.Camera);
((Component)slot.Camera).transform.rotation = ((Component)mainCamera).transform.rotation;
((Component)slot.Camera).transform.position = val2 + val * num;
slot.Camera.targetTexture = slot.Texture;
slot.Camera.Render();
}
private static Vector3 GetMainCameraFocus(Camera mainCamera)
{
//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_0030: 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_0047: 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_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
CameraFollowTarget component = ((Component)mainCamera).GetComponent<CameraFollowTarget>();
if ((Object)(object)component != (Object)null)
{
return component.targetPosition;
}
Plane val = default(Plane);
((Plane)(ref val))..ctor(Vector3.forward, Vector3.zero);
Ray val2 = default(Ray);
((Ray)(ref val2))..ctor(((Component)mainCamera).transform.position, ((Component)mainCamera).transform.forward);
float num = default(float);
if (!((Plane)(ref val)).Raycast(val2, ref num))
{
return ((Component)mainCamera).transform.position + ((Component)mainCamera).transform.forward * 10f;
}
return ((Ray)(ref val2)).GetPoint(num);
}
private void RebuildPreviewCameras(Camera source)
{
//IL_0056: 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_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: 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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Expected O, but got Unknown
//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Expected O, but got Unknown
DestroyPreviewCameras();
_sourceCamera = source;
int num = Mathf.Clamp(_textureWidth.Value, 128, 1024);
int num2 = Mathf.Clamp(_textureHeight.Value, 72, 576);
for (int i = 0; i < _slots.Length; i++)
{
PreviewSlot previewSlot = _slots[i];
previewSlot.Texture = new RenderTexture(num, num2, 16, (RenderTextureFormat)7)
{
name = "CoopOffscreenPreviewRT" + (i + 1),
antiAliasing = 1,
useMipMap = false,
autoGenerateMips = false,
filterMode = (FilterMode)1,
wrapMode = (TextureWrapMode)1
};
previewSlot.Texture.Create();
previewSlot.CameraObject = new GameObject("Coop Offscreen Preview Camera " + (i + 1));
Object.DontDestroyOnLoad((Object)(object)previewSlot.CameraObject);
previewSlot.Camera = previewSlot.CameraObject.AddComponent<Camera>();
((Behaviour)previewSlot.Camera).enabled = false;
previewSlot.Camera.targetTexture = previewSlot.Texture;
CopySafeCameraSettings(source, previewSlot.Camera);
AudioListener component = previewSlot.CameraObject.GetComponent<AudioListener>();
if ((Object)(object)component != (Object)null)
{
((Behaviour)component).enabled = false;
}
}
}
private static void CopySafeCameraSettings(Camera source, Camera target)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
target.clearFlags = source.clearFlags;
target.backgroundColor = source.backgroundColor;
target.cullingMask = source.cullingMask & -33;
target.orthographic = source.orthographic;
target.orthographicSize = source.orthographicSize;
target.fieldOfView = source.fieldOfView;
target.nearClipPlane = source.nearClipPlane;
target.farClipPlane = source.farClipPlane;
target.aspect = 1.7777778f;
target.allowHDR = false;
target.allowMSAA = false;
target.depthTextureMode = (DepthTextureMode)0;
target.useOcclusionCulling = source.useOcclusionCulling;
target.renderingPath = (RenderingPath)1;
}
private void OnGUI()
{
//IL_0087: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
EnsureStyles();
for (int i = 0; i < _slots.Length; i++)
{
PreviewSlot previewSlot = _slots[i];
if (previewSlot.Visible && !((Object)(object)previewSlot.Texture == (Object)null) && !((Object)(object)previewSlot.Player == (Object)null))
{
GUI.Box(new Rect(((Rect)(ref previewSlot.Rect)).x - 4f, ((Rect)(ref previewSlot.Rect)).y - 4f, ((Rect)(ref previewSlot.Rect)).width + 8f, ((Rect)(ref previewSlot.Rect)).height + 8f), GUIContent.none, _frameStyle);
GUI.DrawTexture(previewSlot.Rect, (Texture)(object)previewSlot.Texture, (ScaleMode)1, false);
string text = (previewSlot.Player.isLamb ? "LAMB" : "GOAT");
GUI.Box(new Rect(((Rect)(ref previewSlot.Rect)).x + 7f, ((Rect)(ref previewSlot.Rect)).y + 7f, 64f, 24f), text, _labelStyle);
}
}
}
private void EnsureStyles()
{
//IL_001e: 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_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Expected O, but got Unknown
//IL_0087: 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_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
if (_frameStyle == null)
{
_frameTexture = MakeTexture(new Color(0.04f, 0.04f, 0.04f, 0.94f));
_labelTexture = MakeTexture(new Color(0f, 0f, 0f, 0.78f));
_frameStyle = new GUIStyle(GUI.skin.box);
_frameStyle.normal.background = _frameTexture;
_labelStyle = new GUIStyle(GUI.skin.box)
{
alignment = (TextAnchor)4,
fontSize = 12,
fontStyle = (FontStyle)1
};
_labelStyle.normal.background = _labelTexture;
_labelStyle.normal.textColor = Color.white;
}
}
private static Texture2D MakeTexture(Color color)
{
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
//IL_001f: Expected O, but got Unknown
Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
val.SetPixel(0, 0, color);
val.Apply();
Object.DontDestroyOnLoad((Object)val);
return val;
}
private void HidePreview()
{
for (int i = 0; i < _slots.Length; i++)
{
_slots[i].Visible = false;
_slots[i].Player = null;
}
}
private void OnDestroy()
{
DestroyPreviewCameras();
if ((Object)(object)_frameTexture != (Object)null)
{
Object.Destroy((Object)(object)_frameTexture);
}
if ((Object)(object)_labelTexture != (Object)null)
{
Object.Destroy((Object)(object)_labelTexture);
}
}
private void DestroyPreviewCameras()
{
for (int i = 0; i < _slots.Length; i++)
{
PreviewSlot previewSlot = _slots[i];
if ((Object)(object)previewSlot.Camera != (Object)null)
{
previewSlot.Camera.targetTexture = null;
}
if ((Object)(object)previewSlot.CameraObject != (Object)null)
{
Object.Destroy((Object)(object)previewSlot.CameraObject);
}
if ((Object)(object)previewSlot.Texture != (Object)null)
{
previewSlot.Texture.Release();
Object.Destroy((Object)(object)previewSlot.Texture);
}
previewSlot.Player = null;
previewSlot.Camera = null;
previewSlot.CameraObject = null;
previewSlot.Texture = null;
previewSlot.Visible = false;
previewSlot.NextRenderAt = 0f;
}
}
}
}