using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mirror;
using Steamworks;
using UnityEngine;
using UnityEngine.UIElements;
[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("StonewardsSessionVisibility")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e960074d778cd8209f5c4b8654d2deb1da5c5268")]
[assembly: AssemblyProduct("StonewardsSessionVisibility")]
[assembly: AssemblyTitle("StonewardsSessionVisibility")]
[assembly: AssemblyVersion("1.0.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 StonewardsSessionVisibility
{
[BepInPlugin("dev.stonewards.sessionvisibility", "Stonewards Session Visibility", "0.1.0")]
public sealed class SessionVisibilityPlugin : BaseUnityPlugin
{
private enum Mode
{
Friends = 1,
Public
}
public const string Guid = "dev.stonewards.sessionvisibility";
public const string Name = "Stonewards Session Visibility";
public const string Version = "0.1.0";
private Harmony _harmony;
private float _nextUIRefresh;
private int _lastDisplayedMode = -999;
private bool _lastDisplayedLocked;
private static SessionVisibilityPlugin _plugin;
private static Type _steamLobbyType;
private static FieldInfo _steamLobbyInstanceField;
private static FieldInfo _lobbyIdField;
private static PropertyInfo _hostedModeProperty;
private static MethodInfo _setHostedModeMethod;
private static VisualElement _sessionScreen;
private static VisualElement _sessionHeader;
private static Button _visibilityButton;
private static bool _buttonHovered;
private static Texture2D _normalButtonTexture;
private static Texture2D _hoverButtonTexture;
private static bool _sessionLayoutExpanded;
private const float ExtraSessionHeight = 82f;
private const int CornerTextureSize = 32;
private const int CornerSlice = 12;
private static bool Hosting
{
get
{
if (NetworkServer.active)
{
return NetworkClient.active;
}
return false;
}
}
private void Awake()
{
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Expected O, but got Unknown
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Expected O, but got Unknown
_plugin = this;
_steamLobbyType = AccessTools.TypeByName("SteamLobby");
if (_steamLobbyType != null)
{
_steamLobbyInstanceField = AccessTools.Field(_steamLobbyType, "Instance");
_lobbyIdField = AccessTools.Field(_steamLobbyType, "currentLobbyID");
}
Type? typeFromHandle = typeof(StoneWardsNetworkManager);
_hostedModeProperty = AccessTools.Property(typeFromHandle, "HostedLobbyVisibility");
_setHostedModeMethod = AccessTools.Method(typeFromHandle, "SetHostedLobbyVisibility", (Type[])null, (Type[])null);
_harmony = new Harmony("dev.stonewards.sessionvisibility");
Type type = AccessTools.TypeByName("UISessionSettings");
MethodInfo methodInfo = ((type == null) ? null : AccessTools.Method(type, "Awake", (Type[])null, (Type[])null));
MethodInfo methodInfo2 = AccessTools.Method(typeof(SessionVisibilityPlugin), "OnSessionSettingsAwake", (Type[])null, (Type[])null);
MethodInfo methodInfo3 = ((type == null) ? null : AccessTools.Method(type, "BaseShow", (Type[])null, (Type[])null));
MethodInfo methodInfo4 = AccessTools.Method(typeof(SessionVisibilityPlugin), "OnSessionSettingsShown", (Type[])null, (Type[])null);
if (methodInfo != null && methodInfo2 != null)
{
_harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
else
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not patch UISessionSettings.Awake; trying BaseShow instead.");
}
if (methodInfo3 != null && methodInfo4 != null)
{
_harmony.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(methodInfo4), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
else
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not patch UISessionSettings.BaseShow; menu integration may be unavailable.");
}
if (_steamLobbyType == null || _lobbyIdField == null || _hostedModeProperty == null || _setHostedModeMethod == null)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)"Lobby metadata differs from the inspected build. Switching will fail safely.");
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"Stonewards Session Visibility v0.1.0 initialized. Host-only; use Esc > Session.");
}
private void Update()
{
if (!(Time.unscaledTime < _nextUIRefresh))
{
_nextUIRefresh = Time.unscaledTime + 0.35f;
ExpandSessionLayout();
RefreshUI();
}
}
private static bool TryGetLobby(out CSteamID lobbyId)
{
//IL_0001: 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_0063: 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_006d: Unknown result type (might be due to invalid IL or missing references)
lobbyId = default(CSteamID);
if (!Hosting || _steamLobbyInstanceField == null || _lobbyIdField == null)
{
return false;
}
try
{
object value = _steamLobbyInstanceField.GetValue(null);
if (value == null)
{
return false;
}
ulong num = (ulong)_lobbyIdField.GetValue(value);
if (num == 0L)
{
return false;
}
lobbyId = new CSteamID(num);
return SteamMatchmaking.GetLobbyOwner(lobbyId) == SteamUser.GetSteamID();
}
catch (Exception ex)
{
SessionVisibilityPlugin plugin = _plugin;
if (plugin != null)
{
((BaseUnityPlugin)plugin).Logger.LogWarning((object)("Cannot resolve current Steam lobby: " + ex.Message));
}
return false;
}
}
private static bool TryReadMode(out Mode mode)
{
mode = Mode.Friends;
if (!Hosting || _hostedModeProperty == null)
{
return false;
}
StoneWardsNetworkManager instance = StoneWardsNetworkManager.Instance;
if ((Object)(object)instance == (Object)null)
{
return false;
}
try
{
int num = Convert.ToInt32(_hostedModeProperty.GetValue(instance, null));
if (num != 1 && num != 2)
{
return false;
}
mode = (Mode)num;
return true;
}
catch (Exception ex)
{
SessionVisibilityPlugin plugin = _plugin;
if (plugin != null)
{
((BaseUnityPlugin)plugin).Logger.LogWarning((object)("Cannot read lobby visibility: " + ex.Message));
}
return false;
}
}
private static bool IsGameLocked(CSteamID lobbyId)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
return string.Equals(SteamMatchmaking.GetLobbyData(lobbyId, "Joinable"), "false", StringComparison.OrdinalIgnoreCase);
}
private static bool TrySetVisibility(Mode requestedMode)
{
//IL_0069: 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_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_plugin == (Object)null)
{
return false;
}
if (!TryGetLobby(out var lobbyId))
{
((BaseUnityPlugin)_plugin).Logger.LogWarning((object)"Cannot change visibility: not the owner of an active Steam lobby.");
return false;
}
if (_setHostedModeMethod == null || _hostedModeProperty == null)
{
((BaseUnityPlugin)_plugin).Logger.LogError((object)"Game visibility state is unavailable. No change made.");
return false;
}
ELobbyType val;
switch (requestedMode)
{
case Mode.Friends:
val = (ELobbyType)1;
break;
case Mode.Public:
val = (ELobbyType)2;
break;
default:
return false;
}
try
{
if (!SteamMatchmaking.SetLobbyType(lobbyId, val))
{
((BaseUnityPlugin)_plugin).Logger.LogWarning((object)"SteamMatchmaking.SetLobbyType returned false.");
return false;
}
StoneWardsNetworkManager instance = StoneWardsNetworkManager.Instance;
if ((Object)(object)instance == (Object)null)
{
throw new InvalidOperationException("Network manager missing");
}
object obj = Enum.ToObject(_hostedModeProperty.PropertyType, (int)requestedMode);
_setHostedModeMethod.Invoke(instance, new object[1] { obj });
_plugin._lastDisplayedMode = -1;
bool flag = IsGameLocked(lobbyId);
((BaseUnityPlugin)_plugin).Logger.LogInfo((object)("Lobby visibility set to " + requestedMode.ToString() + (flag ? "; Stonewards currently blocks new joins." : "; joining rules unchanged.")));
RefreshUI();
return true;
}
catch (Exception ex)
{
((BaseUnityPlugin)_plugin).Logger.LogError((object)("Failed changing lobby visibility: " + ex));
return false;
}
}
private static void OnSessionSettingsAwake(object __instance)
{
MountVisibilityButton(__instance);
}
private static void OnSessionSettingsShown(object __instance, bool show)
{
if (show)
{
MountVisibilityButton(__instance);
RefreshUI();
}
}
private static VisualElement FindSessionHeader(Label title, VisualElement screen)
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: 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_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
VisualElement parent = ((VisualElement)title).parent;
VisualElement parent2 = ((VisualElement)title).parent;
while (parent2 != null && parent2 != screen)
{
Color backgroundColor = parent2.resolvedStyle.backgroundColor;
if (backgroundColor.a > 0.45f && backgroundColor.r > backgroundColor.g * 1.12f && backgroundColor.r > backgroundColor.b * 1.07f)
{
return parent2;
}
parent2 = parent2.parent;
}
return parent;
}
private static void MountVisibilityButton(object menu)
{
//IL_00bb: 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_00e3: 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_0107: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0302: Unknown result type (might be due to invalid IL or missing references)
//IL_0318: Unknown result type (might be due to invalid IL or missing references)
//IL_032e: Unknown result type (might be due to invalid IL or missing references)
//IL_0344: Unknown result type (might be due to invalid IL or missing references)
//IL_035a: Unknown result type (might be due to invalid IL or missing references)
//IL_0370: Unknown result type (might be due to invalid IL or missing references)
//IL_0386: Unknown result type (might be due to invalid IL or missing references)
//IL_039c: Unknown result type (might be due to invalid IL or missing references)
//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
//IL_03de: Unknown result type (might be due to invalid IL or missing references)
//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
//IL_0402: Unknown result type (might be due to invalid IL or missing references)
//IL_0418: Unknown result type (might be due to invalid IL or missing references)
//IL_042e: Unknown result type (might be due to invalid IL or missing references)
//IL_0444: Unknown result type (might be due to invalid IL or missing references)
//IL_045a: Unknown result type (might be due to invalid IL or missing references)
//IL_046d: Unknown result type (might be due to invalid IL or missing references)
//IL_0480: Unknown result type (might be due to invalid IL or missing references)
//IL_0493: Unknown result type (might be due to invalid IL or missing references)
//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0514: Unknown result type (might be due to invalid IL or missing references)
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: 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_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Expected O, but got Unknown
if ((Object)(object)_plugin == (Object)null)
{
return;
}
try
{
Component val = (Component)((menu is Component) ? menu : null);
UIDocument val2 = (((Object)(object)val == (Object)null) ? null : val.GetComponent<UIDocument>());
VisualElement val3 = (((Object)(object)val2 == (Object)null) ? null : val2.rootVisualElement);
VisualElement val4 = ((val3 == null) ? null : UQueryExtensions.Q<VisualElement>(val3, "SessionSettings", (string)null));
Label val5 = ((val4 == null) ? null : UQueryExtensions.Q<Label>(val4, "SessionTitle", (string)null));
Button val6 = ((val4 == null) ? null : UQueryExtensions.Q<Button>(val4, "SessionReturnButton", (string)null));
if (val4 == null || val5 == null || val6 == null)
{
((BaseUnityPlugin)_plugin).Logger.LogWarning((object)"Native Session title or Return button not found; visibility control unavailable.");
return;
}
VisualElement val7 = FindSessionHeader(val5, val4);
if (val7 == null || val7 == val4)
{
return;
}
val7.style.height = StyleLength.op_Implicit((StyleKeyword)2);
val7.style.minHeight = StyleLength.op_Implicit(118f);
val7.style.flexDirection = StyleEnum<FlexDirection>.op_Implicit((FlexDirection)0);
val7.style.alignItems = StyleEnum<Align>.op_Implicit((Align)2);
val7.style.justifyContent = StyleEnum<Justify>.op_Implicit((Justify)1);
val7.style.flexShrink = StyleFloat.op_Implicit(0f);
val7.style.paddingTop = StyleLength.op_Implicit(8f);
val7.style.paddingBottom = StyleLength.op_Implicit(10f);
Button val8 = UQueryExtensions.Q<Button>(val4, "StonewardsSessionVisibilityToggle", (string)null);
if (val8 == null)
{
val8 = new Button((Action)ToggleFromMenu)
{
name = "StonewardsSessionVisibilityToggle",
text = "VISIBILITY: PUBLIC"
};
foreach (string @class in ((VisualElement)val6).GetClasses())
{
((VisualElement)val8).AddToClassList(@class);
}
((CallbackEventHandler)val8).RegisterCallback<PointerEnterEvent>((EventCallback<PointerEnterEvent>)delegate
{
_buttonHovered = true;
ApplyGameButtonStyle();
}, (TrickleDown)0);
((CallbackEventHandler)val8).RegisterCallback<PointerLeaveEvent>((EventCallback<PointerLeaveEvent>)delegate
{
_buttonHovered = false;
ApplyGameButtonStyle();
}, (TrickleDown)0);
((CallbackEventHandler)val8).RegisterCallback<FocusInEvent>((EventCallback<FocusInEvent>)delegate
{
_buttonHovered = true;
ApplyGameButtonStyle();
}, (TrickleDown)0);
((CallbackEventHandler)val8).RegisterCallback<FocusOutEvent>((EventCallback<FocusOutEvent>)delegate
{
_buttonHovered = false;
ApplyGameButtonStyle();
}, (TrickleDown)0);
}
Font unityFont = ((VisualElement)val6).resolvedStyle.unityFont;
if ((Object)(object)unityFont != (Object)null)
{
((VisualElement)val8).style.unityFont = StyleFont.op_Implicit(unityFont);
}
((VisualElement)val8).style.position = StyleEnum<Position>.op_Implicit((Position)0);
((VisualElement)val8).style.alignSelf = StyleEnum<Align>.op_Implicit((Align)2);
((VisualElement)val8).style.flexGrow = StyleFloat.op_Implicit(0f);
((VisualElement)val8).style.flexShrink = StyleFloat.op_Implicit(0f);
((VisualElement)val8).style.width = StyleLength.op_Implicit(new Length(55f, (LengthUnit)1));
((VisualElement)val8).style.minWidth = StyleLength.op_Implicit(220f);
((VisualElement)val8).style.maxWidth = StyleLength.op_Implicit(350f);
((VisualElement)val8).style.height = StyleLength.op_Implicit(39f);
((VisualElement)val8).style.marginTop = StyleLength.op_Implicit(7f);
((VisualElement)val8).style.marginBottom = StyleLength.op_Implicit(0f);
((VisualElement)val8).style.marginLeft = StyleLength.op_Implicit(0f);
((VisualElement)val8).style.marginRight = StyleLength.op_Implicit(0f);
((VisualElement)val8).style.paddingLeft = StyleLength.op_Implicit(8f);
((VisualElement)val8).style.paddingRight = StyleLength.op_Implicit(8f);
((VisualElement)val8).style.fontSize = StyleLength.op_Implicit(17f);
((VisualElement)val8).style.unityFontStyleAndWeight = StyleEnum<FontStyle>.op_Implicit((FontStyle)1);
((VisualElement)val8).style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)4);
((VisualElement)val8).style.borderLeftWidth = StyleFloat.op_Implicit(0f);
((VisualElement)val8).style.borderRightWidth = StyleFloat.op_Implicit(0f);
((VisualElement)val8).style.borderTopWidth = StyleFloat.op_Implicit(0f);
((VisualElement)val8).style.borderBottomWidth = StyleFloat.op_Implicit(0f);
((VisualElement)val8).style.unitySliceLeft = StyleInt.op_Implicit(12);
((VisualElement)val8).style.unitySliceRight = StyleInt.op_Implicit(12);
((VisualElement)val8).style.unitySliceTop = StyleInt.op_Implicit(12);
((VisualElement)val8).style.unitySliceBottom = StyleInt.op_Implicit(12);
((VisualElement)val8).style.unityBackgroundImageTintColor = StyleColor.op_Implicit(Color.white);
((VisualElement)val8).style.borderTopLeftRadius = StyleLength.op_Implicit(0f);
((VisualElement)val8).style.borderTopRightRadius = StyleLength.op_Implicit(0f);
((VisualElement)val8).style.borderBottomLeftRadius = StyleLength.op_Implicit(0f);
((VisualElement)val8).style.borderBottomRightRadius = StyleLength.op_Implicit(0f);
ApplyGameButtonStyle(val8);
VisualElement val9 = (VisualElement)(object)val5;
while (val9.parent != null && val9.parent != val7)
{
val9 = val9.parent;
}
int num = val7.IndexOf(val9) + 1;
if (((VisualElement)val8).parent != val7 || val7.IndexOf((VisualElement)(object)val8) != num)
{
val7.Insert(num, (VisualElement)(object)val8);
}
if (_sessionScreen != val4)
{
_sessionLayoutExpanded = false;
}
_sessionScreen = val4;
_sessionHeader = val7;
_visibilityButton = val8;
_buttonHovered = false;
ApplyGameButtonStyle();
_plugin._lastDisplayedMode = -999;
RefreshUI();
((BaseUnityPlugin)_plugin).Logger.LogInfo((object)"Visibility toggle embedded in expanded Session title header.");
}
catch (Exception ex)
{
((BaseUnityPlugin)_plugin).Logger.LogError((object)("Could not mount Session visibility toggle: " + ex));
}
}
private static void ToggleFromMenu()
{
if (TryReadMode(out var mode))
{
TrySetVisibility((mode == Mode.Public) ? Mode.Friends : Mode.Public);
}
}
private static int StairInset(int distanceFromEdge)
{
if (distanceFromEdge < 2)
{
return 8;
}
if (distanceFromEdge < 4)
{
return 6;
}
if (distanceFromEdge < 6)
{
return 4;
}
if (distanceFromEdge < 8)
{
return 2;
}
return 0;
}
private static bool InsideStaircase(int x, int y)
{
if (x < 0 || y < 0 || x >= 32 || y >= 32)
{
return false;
}
int num = Mathf.Min(x, 31 - x);
int num2 = Mathf.Min(y, 31 - y);
if (num >= StairInset(num2))
{
return num2 >= StairInset(num);
}
return false;
}
private static Texture2D CreateButtonTexture(bool hovered)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0069: 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_006e: 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_0086: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: 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)
Texture2D val = new Texture2D(32, 32, (TextureFormat)4, false);
((Object)val).name = (hovered ? "StonewardsSessionVisibility_HoverFrame" : "StonewardsSessionVisibility_NormalFrame");
((Texture)val).filterMode = (FilterMode)0;
((Texture)val).wrapMode = (TextureWrapMode)1;
((Object)val).hideFlags = (HideFlags)61;
Color val2 = (hovered ? new Color(0.27f, 0.33f, 0.4f, 1f) : new Color(0.2f, 0.25f, 0.31f, 1f));
Color val3 = (hovered ? new Color(0.97f, 0.85f, 0.6f, 1f) : new Color(0.75f, 0.64f, 0.45f, 1f));
Color[] array = (Color[])(object)new Color[1024];
for (int i = 0; i < 32; i++)
{
for (int j = 0; j < 32; j++)
{
if (!InsideStaircase(j, i))
{
array[i * 32 + j] = Color.clear;
continue;
}
bool flag = InsideStaircase(j - 2, i) && InsideStaircase(j + 2, i) && InsideStaircase(j, i - 2) && InsideStaircase(j, i + 2);
array[i * 32 + j] = (flag ? val2 : val3);
}
}
val.SetPixels(array);
val.Apply(false, true);
return val;
}
private static void ApplyGameButtonStyle(Button button = null)
{
//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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: 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)
if (button == null)
{
button = _visibilityButton;
}
if (button != null)
{
if ((Object)(object)_normalButtonTexture == (Object)null)
{
_normalButtonTexture = CreateButtonTexture(hovered: false);
}
if ((Object)(object)_hoverButtonTexture == (Object)null)
{
_hoverButtonTexture = CreateButtonTexture(hovered: true);
}
((VisualElement)button).style.backgroundColor = StyleColor.op_Implicit(Color.clear);
((VisualElement)button).style.backgroundImage = new StyleBackground(_buttonHovered ? _hoverButtonTexture : _normalButtonTexture);
((VisualElement)button).style.color = StyleColor.op_Implicit(_buttonHovered ? new Color(1f, 0.97f, 0.83f, 1f) : new Color(0.96f, 0.94f, 0.88f, 1f));
}
}
private static void ExpandSessionLayout()
{
//IL_0093: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
if (_sessionLayoutExpanded || _sessionScreen == null || _sessionScreen.panel == null || !Hosting)
{
return;
}
VisualElement obj = UQueryExtensions.Q<VisualElement>(_sessionScreen, "unity-content-container", (string)null);
ScrollView val = null;
for (VisualElement val2 = obj; val2 != null; val2 = val2.parent)
{
val = (ScrollView)(object)((val2 is ScrollView) ? val2 : null);
if (val != null)
{
break;
}
}
float height = _sessionScreen.resolvedStyle.height;
float num = ((val == null) ? 0f : ((VisualElement)val).resolvedStyle.height);
if (!(height < 200f) && !(num < 100f))
{
_sessionScreen.style.height = StyleLength.op_Implicit(height + 82f);
_sessionScreen.style.minHeight = StyleLength.op_Implicit(height + 82f);
((VisualElement)val).style.height = StyleLength.op_Implicit(num + 82f);
((VisualElement)val).style.minHeight = StyleLength.op_Implicit(num + 82f);
_sessionLayoutExpanded = true;
SessionVisibilityPlugin plugin = _plugin;
if (plugin != null)
{
((BaseUnityPlugin)plugin).Logger.LogInfo((object)("Expanded Session popup and player viewport by " + 82f + " UI units."));
}
}
}
private static void RefreshUI()
{
//IL_003b: 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)
if (_visibilityButton == null || ((VisualElement)_visibilityButton).panel == null)
{
return;
}
Mode mode = Mode.Friends;
CSteamID lobbyId;
bool flag = TryGetLobby(out lobbyId) && TryReadMode(out mode);
((VisualElement)_visibilityButton).style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)(!flag));
if (!flag)
{
return;
}
bool flag2 = false;
try
{
flag2 = IsGameLocked(lobbyId);
}
catch (Exception)
{
}
int num = (int)mode;
if (!((Object)(object)_plugin != (Object)null) || _plugin._lastDisplayedMode != num || _plugin._lastDisplayedLocked != flag2)
{
if ((Object)(object)_plugin != (Object)null)
{
_plugin._lastDisplayedMode = num;
_plugin._lastDisplayedLocked = flag2;
}
((TextElement)_visibilityButton).text = ((mode == Mode.Public) ? "VISIBILITY: PUBLIC" : "VISIBILITY: FRIENDS");
ApplyGameButtonStyle();
((VisualElement)_visibilityButton).tooltip = (flag2 ? "The game's join lock remains active after changing visibility." : "Click to switch Friends / Public.");
}
}
private void OnDestroy()
{
if (_harmony != null)
{
_harmony.UnpatchSelf();
}
if (_plugin == this)
{
_plugin = null;
}
_sessionScreen = null;
_sessionHeader = null;
_visibilityButton = null;
_buttonHovered = false;
_sessionLayoutExpanded = false;
if ((Object)(object)_normalButtonTexture != (Object)null)
{
Object.Destroy((Object)(object)_normalButtonTexture);
}
if ((Object)(object)_hoverButtonTexture != (Object)null)
{
Object.Destroy((Object)(object)_hoverButtonTexture);
}
_normalButtonTexture = null;
_hoverButtonTexture = null;
}
}
}