using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("OutwardSleepLonger")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OutwardSleepLonger")]
[assembly: AssemblyCopyright("Copyright © Jdbye 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SleepLonger;
[BepInPlugin("JdbyeSleepLonger", "SleepLonger", "1.1.0")]
public class SleepLongerPlugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(RestingMenu))]
public class RestingMenuPatches
{
[HarmonyPatch("StartInit")]
[HarmonyPostfix]
private static void RestingMenu_StartInit_Postfix(RestingMenu __instance)
{
//IL_00af: 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)
//IL_00ca: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: 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_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01c1: Expected O, but got Unknown
//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0301: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Expected O, but got Unknown
//IL_033b: Unknown result type (might be due to invalid IL or missing references)
//IL_034d: Unknown result type (might be due to invalid IL or missing references)
//IL_0357: Unknown result type (might be due to invalid IL or missing references)
//IL_035c: Unknown result type (might be due to invalid IL or missing references)
//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0402: Expected O, but got Unknown
//IL_0435: Unknown result type (might be due to invalid IL or missing references)
//IL_0447: Unknown result type (might be due to invalid IL or missing references)
//IL_0451: Unknown result type (might be due to invalid IL or missing references)
//IL_0456: Unknown result type (might be due to invalid IL or missing references)
//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
//IL_0600: Unknown result type (might be due to invalid IL or missing references)
//IL_060a: Unknown result type (might be due to invalid IL or missing references)
//IL_0622: Unknown result type (might be due to invalid IL or missing references)
//IL_062c: Unknown result type (might be due to invalid IL or missing references)
//IL_0644: Unknown result type (might be due to invalid IL or missing references)
//IL_064e: Unknown result type (might be due to invalid IL or missing references)
try
{
hoursAll.Remove(((Object)((Component)((UIElement)__instance).CharacterUI).gameObject).name);
Transform transform = ((Component)__instance).transform;
RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
Transform obj = ((Transform)val).Find("Content");
Transform val2 = obj.Find("lblTitle");
Transform val3 = obj.Find("DayPanorama");
Transform val4 = obj.Find("RestingActivitiesPanel");
Transform val5 = val4.Find("lblDescription");
Transform obj2 = val4.Find("RestingActivities");
RectTransform val6 = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null);
Transform val7 = obj.Find("Separator");
GameObject checkBoxTemplate = GetCheckBoxTemplate(((UIElement)__instance).CharacterUI);
val.sizeDelta = new Vector2(val.sizeDelta.x, val.sizeDelta.y + 46f);
((Transform)val6).localPosition = new Vector3(((Transform)val6).localPosition.x, ((Transform)val6).localPosition.y + 23f, ((Transform)val6).localPosition.z);
val7.localPosition = new Vector3(val7.localPosition.x, val7.localPosition.y - 23f, val7.localPosition.z);
val2.localPosition = new Vector3(val2.localPosition.x, val2.localPosition.y - 5f, val2.localPosition.z);
val5.localPosition = new Vector3(val5.localPosition.x, val5.localPosition.y + 23f, val5.localPosition.z);
foreach (Transform item in val4)
{
Transform val8 = item;
if (((Object)val8).name == "Separator")
{
val8.localPosition = new Vector3(val8.localPosition.x, val8.localPosition.y + 23f, val8.localPosition.z);
}
}
Transform val9 = val3.Find("Scroll View");
int siblingIndex = val9.GetSiblingIndex();
Transform skyline3Day = Object.Instantiate<Transform>(val9, val3);
((Object)skyline3Day).name = "ScrollView3Day";
skyline3Day.SetSiblingIndex(siblingIndex + 1);
Transform skyline7Day = Object.Instantiate<Transform>(val9, val3);
((Object)skyline7Day).name = "ScrollView7Day";
skyline7Day.SetSiblingIndex(siblingIndex + 2);
Transform val10 = skyline3Day.Find("Viewport/Content");
Transform val11 = val10.Find("Tile1");
for (int i = 3; i < 5; i++)
{
Transform obj3 = Object.Instantiate<Transform>(val11, val10);
((Object)obj3).name = $"Tile{i}";
obj3.SetAsLastSibling();
}
foreach (RectTransform item2 in val10)
{
RectTransform val12 = item2;
LayoutElement component = ((Component)val12).gameObject.GetComponent<LayoutElement>();
component.minWidth /= 3f;
((Component)val12).gameObject.GetComponent<Image>().preserveAspect = false;
val12.sizeDelta = Vector2.op_Implicit(new Vector3(val12.sizeDelta.x * (1f / 3f), val12.sizeDelta.y));
}
Transform val13 = skyline7Day.Find("Viewport/Content");
Transform val14 = val13.Find("Tile1");
((Component)val14).gameObject.GetComponent<Image>();
for (int j = 3; j < 9; j++)
{
Transform obj4 = Object.Instantiate<Transform>(val14, val13);
((Object)obj4).name = $"Tile{j}";
obj4.SetAsLastSibling();
}
foreach (RectTransform item3 in val13)
{
RectTransform val15 = item3;
LayoutElement component2 = ((Component)val15).gameObject.GetComponent<LayoutElement>();
component2.minWidth /= 7f;
((Component)val15).gameObject.GetComponent<Image>().preserveAspect = false;
val15.sizeDelta = Vector2.op_Implicit(new Vector3(val15.sizeDelta.x * (1f / 7f), val15.sizeDelta.y));
}
((Component)skyline3Day).gameObject.SetActive(false);
((Component)skyline7Day).gameObject.SetActive(false);
UIToggleButton chk1Day = CreateCheckBox(checkBoxTemplate, val4, "chkSleep1Day", "Sleep 1 Day");
UIToggleButton chk3Days = CreateCheckBox(checkBoxTemplate, val4, "chkSleep3Days", "Sleep 3 Days");
UIToggleButton chk7Days = CreateCheckBox(checkBoxTemplate, val4, "chkSleep7Days", "Sleep 7 Days");
Object.Destroy((Object)(object)((Component)((Component)chk1Day).transform.Find("Separator")).gameObject);
Object.Destroy((Object)(object)((Component)((Component)chk3Days).transform.Find("Separator")).gameObject);
Object.Destroy((Object)(object)((Component)((Component)chk7Days).transform.Find("Separator")).gameObject);
((Component)chk1Day).transform.SetAsLastSibling();
((Component)chk3Days).transform.SetAsLastSibling();
((Component)chk7Days).transform.SetAsLastSibling();
Transform transform2 = ((Component)chk1Day).transform;
RectTransform val16 = (RectTransform)(object)((transform2 is RectTransform) ? transform2 : null);
Transform transform3 = ((Component)chk3Days).transform;
RectTransform val17 = (RectTransform)(object)((transform3 is RectTransform) ? transform3 : null);
Transform transform4 = ((Component)chk7Days).transform;
RectTransform val18 = (RectTransform)(object)((transform4 is RectTransform) ? transform4 : null);
val16.sizeDelta = new Vector2(150f, 30f);
val17.sizeDelta = new Vector2(150f, 30f);
val18.sizeDelta = new Vector2(150f, 30f);
((Transform)val16).localPosition = new Vector3(-160f, -66f, ((Transform)val16).localPosition.z);
((Transform)val17).localPosition = new Vector3(0f, -66f, ((Transform)val17).localPosition.z);
((Transform)val18).localPosition = new Vector3(170f, -66f, ((Transform)val18).localPosition.z);
((UnityEvent<bool>)(object)chk1Day.onValueChanged).AddListener((UnityAction<bool>)delegate
{
if (chk1Day.isOn)
{
chk3Days.isOn = false;
chk7Days.isOn = false;
SetMaxTime(__instance, 24, forceSetRestLength: true);
}
else if (chk7Days.isOn)
{
SetMaxTime(__instance, 168);
}
else if (chk3Days.isOn)
{
SetMaxTime(__instance, 72);
}
else
{
SetMaxTime(__instance, 24);
}
});
((UnityEvent<bool>)(object)chk3Days.onValueChanged).AddListener((UnityAction<bool>)delegate
{
((Component)skyline3Day).gameObject.SetActive(chk3Days.isOn);
if (chk3Days.isOn)
{
chk1Day.isOn = false;
chk7Days.isOn = false;
SetMaxTime(__instance, 72);
}
else if (chk7Days.isOn)
{
SetMaxTime(__instance, 168);
}
else
{
SetMaxTime(__instance, 24, chk1Day.isOn);
}
});
((UnityEvent<bool>)(object)chk7Days.onValueChanged).AddListener((UnityAction<bool>)delegate
{
((Component)skyline7Day).gameObject.SetActive(chk7Days.isOn);
if (chk7Days.isOn)
{
chk1Day.isOn = false;
chk3Days.isOn = false;
SetMaxTime(__instance, 168);
}
else if (chk3Days.isOn)
{
SetMaxTime(__instance, 72);
}
else
{
SetMaxTime(__instance, 24, chk1Day.isOn);
}
});
Log.LogInfo((object)("Patched RestingMenu UI for player " + ((UIElement)__instance).CharacterUI.TargetCharacter.Name));
}
catch (Exception ex)
{
Log.LogError((object)$"Failed to patch RestingMenu UI for player {((UIElement)__instance).CharacterUI.TargetCharacter.Name} ({ex.GetType()}): {ex.Message}");
Log.LogDebug((object)("Stack trace: " + ex.StackTrace));
}
}
[HarmonyPatch("ResetMenu")]
[HarmonyPostfix]
private static void RestingMenu_ResetMenu_Postfix(RestingMenu __instance)
{
try
{
Transform obj = ((Component)__instance).transform.Find("Content/RestingActivitiesPanel");
Transform obj2 = obj.Find("chkSleep1Day");
UIToggleButton val = ((obj2 != null) ? ((Component)obj2).GetComponent<UIToggleButton>() : null);
Transform obj3 = obj.Find("chkSleep3Days");
UIToggleButton val2 = ((obj3 != null) ? ((Component)obj3).GetComponent<UIToggleButton>() : null);
Transform obj4 = obj.Find("chkSleep7Days");
UIToggleButton val3 = ((obj4 != null) ? ((Component)obj4).GetComponent<UIToggleButton>() : null);
if ((Object)(object)val != (Object)null)
{
val.isOn = false;
}
if ((Object)(object)val2 != (Object)null)
{
val2.isOn = false;
}
if ((Object)(object)val3 != (Object)null)
{
val3.isOn = false;
}
Transform obj5 = ((Component)__instance).transform.Find("Content/DayPanorama");
Transform val4 = obj5.Find("ScrollView3Day");
Transform val5 = obj5.Find("ScrollView7Day");
if (Object.op_Implicit((Object)(object)val4))
{
((Component)val4).gameObject.SetActive(false);
}
if (Object.op_Implicit((Object)(object)val5))
{
((Component)val5).gameObject.SetActive(false);
}
}
catch (Exception ex)
{
Log.LogError((object)$"ResetMenu Postfix failed for player {((UIElement)__instance).CharacterUI.TargetCharacter.Name} ({ex.GetType()}): {ex.Message}");
Log.LogDebug((object)("Stack trace: " + ex.StackTrace));
}
}
[HarmonyPatch("UpdatePanel")]
[HarmonyPrefix]
private static bool RestingMenu_UpdatePanel_Prefix(RestingMenu __instance)
{
try
{
if (hoursAll.ContainsKey(((Object)((Component)((UIElement)__instance).CharacterUI).gameObject).name))
{
UpdatePanel(__instance, hoursAll[((Object)((Component)((UIElement)__instance).CharacterUI).gameObject).name]);
return false;
}
}
catch (Exception ex)
{
Log.LogError((object)$"UpdatePanel Prefix failed for player {((UIElement)__instance).CharacterUI.TargetCharacter.Name} ({ex.GetType()}): {ex.Message}");
Log.LogDebug((object)("Stack trace: " + ex.StackTrace));
}
return true;
}
}
public const string NAME = "SleepLonger";
public const string VERSION = "1.1.0";
public const string CREATOR = "Jdbye";
public const string GUID = "JdbyeSleepLonger";
internal static ManualLogSource Log;
internal static Dictionary<string, int> hoursAll = new Dictionary<string, int>();
internal void Awake()
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"SleepLonger 1.1.0 by Jdbye loaded!");
new Harmony("JdbyeSleepLonger").PatchAll();
}
internal void Update()
{
}
internal static GameObject GetCheckBoxTemplate(CharacterUI characterUI)
{
return ((Component)((Component)characterUI).transform.Find("Canvas/GeneralPanels/Options - Panel(Clone)/Window/Panel/Content/Scroll View/Viewport/Content/General/Gameplay/chkShowHud")).gameObject;
}
internal static UIToggleButton CreateCheckBox(GameObject checkBoxTemplate, Transform parent, string name, string label)
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
GameObject obj = Object.Instantiate<GameObject>(checkBoxTemplate, parent);
obj.transform.localPosition = Vector3.zero;
obj.transform.localRotation = Quaternion.identity;
UIToggleButton component = obj.GetComponent<UIToggleButton>();
((Object)obj).name = name;
Text componentInChildren = obj.GetComponentInChildren<Text>(true);
Object.Destroy((Object)(object)((Component)componentInChildren).GetComponent<UILocalize>());
((Object)componentInChildren).name = "lblCheckBoxHeader";
component.Text = label;
((UnityEventBase)component.onValueChanged).RemoveAllListeners();
return component;
}
internal static void InitSkylineValues(RestingMenu restingMenu, int hours)
{
//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)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
hoursAll[((Object)((Component)((UIElement)restingMenu).CharacterUI).gameObject).name] = hours;
float num = hours;
if (Object.op_Implicit((Object)(object)restingMenu.m_skylineScrollRect))
{
restingMenu.m_skylineStartingToDRatio = (float)restingMenu.m_skylineStartingTime / 24f;
Rect rect = restingMenu.m_skylineScrollRect.content.rect;
float num2 = ((Rect)(ref rect)).width / (float)((Transform)restingMenu.m_skylineScrollRect.content).childCount;
rect = restingMenu.m_skylineScrollRect.viewport.rect;
float num3 = ((Rect)(ref rect)).width / num2;
float maxValue = num * num3;
if (Object.op_Implicit((Object)(object)restingMenu.m_sldLocalPlayerCursor))
{
restingMenu.m_sldLocalPlayerCursor.maxValue = maxValue;
}
if (restingMenu.m_sldOtherPlayerCursors != null)
{
for (int i = 0; i < restingMenu.m_sldOtherPlayerCursors.Length; i++)
{
if (Object.op_Implicit((Object)(object)restingMenu.m_sldOtherPlayerCursors[i]))
{
restingMenu.m_sldOtherPlayerCursors[i].maxValue = maxValue;
}
}
}
}
restingMenu.m_skylineInitialized = true;
}
internal static void RefreshSkylinePosition(RestingMenu restingMenu)
{
Transform obj = ((Component)restingMenu).transform.Find("Content/DayPanorama");
float num = EnvironmentConditions.Instance.TODRatio - restingMenu.m_skylineStartingToDRatio;
if (num < 0f)
{
num += 1f;
}
Transform val = obj.Find("ScrollView3Day");
if (Object.op_Implicit((Object)(object)val))
{
((Component)val).GetComponent<ScrollRect>().horizontalNormalizedPosition = num;
}
Transform val2 = obj.Find("ScrollView7Day");
if (Object.op_Implicit((Object)(object)val2))
{
((Component)val2).GetComponent<ScrollRect>().horizontalNormalizedPosition = num;
}
}
internal static void SetMaxTime(RestingMenu restingMenu, int hours, bool forceSetRestLength = false)
{
//IL_0130: 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_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Expected I4, but got Unknown
InitSkylineValues(restingMenu, hours);
if (hours > 24 || forceSetRestLength)
{
int num = 0;
if (CharacterManager.Instance.BaseAmbushProbability > 0)
{
float num2 = CharacterManager.Instance.BaseAmbushProbability;
int num3 = int.MaxValue;
for (int i = 0; i < CharacterManager.Instance.PlayerCharacters.Count; i++)
{
Character val = CharacterManager.Instance.Characters[CharacterManager.Instance.PlayerCharacters.Values[i]];
if ((Object)(object)val != (Object)null && Object.op_Implicit((Object)(object)val.CharacterResting.RestContainer))
{
num3 = Mathf.Min(num3, val.CharacterResting.RestContainer.AmbushReduction);
}
}
if (num3 == int.MaxValue)
{
num3 = 0;
}
else
{
num2 -= (float)num3;
}
Log.LogDebug((object)$"Ambush probability: {CharacterManager.Instance.BaseAmbushProbability} Reduction: {num3} Adjusted: {num2}");
num = ((num2 > 0f) ? (hours / 2) : 0);
}
int num4 = hours / 6;
int num5 = hours - (num + num4);
RestingActivityDisplay[] restingActivityDisplays = restingMenu.m_restingActivityDisplays;
foreach (RestingActivityDisplay val2 in restingActivityDisplays)
{
ActivityTypes type = val2.Activity.Type;
switch ((int)type)
{
case 0:
val2.m_timeSelector.ChangeValue(num4);
val2.m_timeSelector.SetValue(num4);
break;
case 4:
val2.m_timeSelector.ChangeValue(num);
val2.m_timeSelector.SetValue(num);
break;
case 3:
val2.m_timeSelector.ChangeValue(num5);
val2.m_timeSelector.SetValue(num5);
break;
default:
val2.m_timeSelector.ChangeValue(0);
val2.m_timeSelector.SetValue(0);
break;
}
}
}
else
{
RestingActivityDisplay[] restingActivityDisplays = restingMenu.m_restingActivityDisplays;
foreach (RestingActivityDisplay obj in restingActivityDisplays)
{
obj.m_timeSelector.ChangeValue(0);
obj.m_timeSelector.SetValue(0);
}
}
}
internal static void UpdatePanel(RestingMenu restingMenu, int hours)
{
//IL_0051: 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)
restingMenu.RefreshSkylinePosition();
RefreshSkylinePosition(restingMenu);
int num = 0;
bool flag = true;
bool flag2 = true;
if (Global.Lobby.PlayersInLobby.Count - 1 != restingMenu.m_otherPlayerUIDs.Count)
{
restingMenu.InitPlayerCursors();
flag = false;
flag2 = false;
}
else
{
for (int i = 0; i < restingMenu.m_otherPlayerUIDs.Count; i++)
{
Character characterFromPlayer = CharacterManager.Instance.GetCharacterFromPlayer(UID.op_Implicit(restingMenu.m_otherPlayerUIDs[i]));
if ((Object)(object)characterFromPlayer != (Object)null)
{
if (CharacterManager.Instance.RestingPlayerUIDs.Contains(UID.op_Implicit(characterFromPlayer.UID)))
{
flag2 &= characterFromPlayer.CharacterResting.DonePreparingRest;
}
else
{
flag = false;
}
restingMenu.m_sldOtherPlayerCursors[i].value = characterFromPlayer.CharacterResting.TotalRestTime;
}
else
{
flag = false;
}
}
}
for (int j = 0; j < SplitScreenManager.Instance.LocalPlayerCount; j++)
{
flag &= (Object)(object)SplitScreenManager.Instance.LocalPlayers[j].AssignedCharacter != (Object)null;
}
flag2 = flag2 && flag;
restingMenu.m_restingCanvasGroup.interactable = flag && !((UIElement)restingMenu).LocalCharacter.CharacterResting.DonePreparingRest;
if (Object.op_Implicit((Object)(object)restingMenu.m_waitingForOthers))
{
if (((Component)restingMenu.m_waitingForOthers).gameObject.activeSelf == restingMenu.m_restingCanvasGroup.interactable)
{
((Component)restingMenu.m_waitingForOthers).gameObject.SetActive(!restingMenu.m_restingCanvasGroup.interactable);
}
if (Object.op_Implicit((Object)(object)restingMenu.m_waitingText) && ((Component)restingMenu.m_waitingForOthers).gameObject.activeSelf)
{
restingMenu.m_waitingText.text = LocalizationManager.Instance.GetLoc(flag2 ? "Rest_Title_Resting" : "Sleep_Title_Waiting");
}
}
for (int k = 0; k < restingMenu.m_restingActivityDisplays.Length; k++)
{
num += restingMenu.m_restingActivityDisplays[k].AssignedTime;
}
for (int l = 0; l < restingMenu.m_restingActivityDisplays.Length; l++)
{
if ((int)restingMenu.ActiveActivities[l] != 4 || CharacterManager.Instance.BaseAmbushProbability > 0)
{
restingMenu.m_restingActivityDisplays[l].MaxValue = hours - (num - restingMenu.m_restingActivityDisplays[l].AssignedTime);
}
else
{
restingMenu.m_restingActivityDisplays[l].MaxValue = 0;
}
}
if (Object.op_Implicit((Object)(object)restingMenu.m_sldLocalPlayerCursor))
{
restingMenu.m_sldLocalPlayerCursor.value = num;
}
bool flag3 = false;
if (restingMenu.m_lastTotalRestTime != num)
{
flag3 = true;
restingMenu.m_lastTotalRestTime = num;
}
restingMenu.RefreshOverviews(flag3 && !restingMenu.m_tryRest);
}
private static Texture2D GetReadableTexture2D(Texture texture)
{
//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_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
RenderTexture temporary = RenderTexture.GetTemporary(texture.width, texture.height, 0, (RenderTextureFormat)7, (RenderTextureReadWrite)1);
Graphics.Blit(texture, temporary);
RenderTexture active = RenderTexture.active;
RenderTexture.active = temporary;
Texture2D val = new Texture2D(texture.width, texture.height);
val.ReadPixels(new Rect(0f, 0f, (float)texture.width, (float)texture.height), 0, 0);
val.Apply();
RenderTexture.active = active;
RenderTexture.ReleaseTemporary(temporary);
return val;
}
internal static Texture2D Crop(Texture2D sourceTexture, Rect cropRect)
{
//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_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Expected O, but got Unknown
RectInt val = default(RectInt);
((RectInt)(ref val))..ctor(Mathf.FloorToInt(((Rect)(ref cropRect)).x), Mathf.FloorToInt(((Rect)(ref cropRect)).y), Mathf.FloorToInt(((Rect)(ref cropRect)).width), Mathf.FloorToInt(((Rect)(ref cropRect)).height));
Color[] pixels = GetReadableTexture2D((Texture)(object)sourceTexture).GetPixels(((RectInt)(ref val)).x, ((RectInt)(ref val)).y, ((RectInt)(ref val)).width, ((RectInt)(ref val)).height);
Texture2D val2 = new Texture2D(((RectInt)(ref val)).width, ((RectInt)(ref val)).height);
val2.SetPixels(pixels);
val2.Apply();
return val2;
}
}