

using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Hardcore;
using Hardcore.Helpers;
using Hardcore.Patches;
using HarmonyLib;
using Il2CppFishNet;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.ItemFramework;
using Il2CppScheduleOne.Persistence;
using Il2CppScheduleOne.PlayerScripts;
using Il2CppScheduleOne.UI;
using Il2CppScheduleOne.UI.MainMenu;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppTMPro;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using S1API.Internal.Abstraction;
using S1API.Saveables;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(global::Hardcore.Hardcore), "Hardcore", "1.0.0", "k073l", null)]
[assembly: MelonColor(1, 255, 0, 0)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("Hardcore-IL2CPP")]
[assembly: AssemblyConfiguration("Release IL2CPP")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+bead19bfee33487deb72cf5e424a015fea248be8")]
[assembly: AssemblyProduct("Hardcore-IL2CPP")]
[assembly: AssemblyTitle("Hardcore-IL2CPP")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace Hardcore
{
public class HardcoreData
{
public bool HardcoreMode;
public string Version = "1.0.0";
public bool Died;
public string Reason = "";
}
public class HardcoreSave : Saveable
{
[SaveableField("hardcore_mode")]
public HardcoreData HardcoreModeData = new HardcoreData();
public static HardcoreSave Instance { get; } = new HardcoreSave();
protected override void OnSaved()
{
Melon<Hardcore>.Logger.Msg("Game Saved!");
Melon<Hardcore>.Logger.Msg($"Hardcore Mode is: {HardcoreModeData.HardcoreMode}");
}
protected override void OnLoaded()
{
Melon<Hardcore>.Logger.Msg("Game Loaded!");
Melon<Hardcore>.Logger.Msg($"Hardcore Mode is: {HardcoreModeData.HardcoreMode}");
}
}
public static class BuildInfo
{
public const string Name = "Hardcore";
public const string Description = "Adds a Hardcore mode to the game";
public const string Author = "k073l";
public const string Version = "1.0.0";
}
public class Hardcore : MelonMod
{
[CompilerGenerated]
private sealed class <CheckHardcore>d__11 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CheckHardcore>d__11(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
_logger.Msg("Hardcore mode is " + (HardcoreSave.Instance.HardcoreModeData.HardcoreMode ? "enabled" : "disabled"));
DeathScreenPatch.AddDeathUIInfo();
if (HardcoreSave.Instance.HardcoreModeData.Died)
{
PlayerCameraPatch.FreeCamPlayerInvisible();
}
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static Instance _logger;
private static Texture2D _heartTexture2D;
private static MelonPreferences_Category _category;
private static MelonPreferences_Entry<bool> _showHeartHUD;
private static MelonPreferences_Entry<int> _heartHUDsize;
private static MelonPreferences_Entry<int> _heartHUDXOffset;
private static MelonPreferences_Entry<int> _heartHUDYOffset;
public override void OnInitializeMelon()
{
_logger = ((MelonBase)this).LoggerInstance;
_logger.Msg("Hardcore initialized");
_category = MelonPreferences.CreateCategory("Hardcore");
_showHeartHUD = _category.CreateEntry<bool>("ShowHeartHUD", true, "Show Heart HUD", "Show a heart icon in the HUD when in Hardcore mode", false, false, (ValueValidator)null, (string)null);
_heartHUDsize = _category.CreateEntry<int>("HeartHUDSize", 32, "Heart HUD Size", "Size of the heart icon in the HUD", false, false, (ValueValidator)null, (string)null);
_heartHUDXOffset = _category.CreateEntry<int>("HeartHUDXOffset", 5, "Heart HUD Position (horizontal)", "Horizontal offset from the right side of the screen (in px)", false, false, (ValueValidator)null, (string)null);
_heartHUDYOffset = _category.CreateEntry<int>("HeartHUDYOffset", 5, "Heart HUD Position (vertical)", "Vertical offset from the top of the screen (in px)", false, false, (ValueValidator)null, (string)null);
ModSaveableRegistry.Register((Saveable)(object)HardcoreSave.Instance, (string)null);
LoadEmbeddedImage();
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
_logger.Debug("Scene loaded: " + sceneName);
if (!(sceneName == "Menu"))
{
if (sceneName == "Main")
{
_logger.Debug("Main scene loaded, waiting for player");
MelonCoroutines.Start(Utils.WaitForPlayer(CheckHardcore()));
}
}
else
{
HardcoreSave.Instance.HardcoreModeData = new HardcoreData();
}
}
private void LoadEmbeddedImage()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
Assembly executingAssembly = Assembly.GetExecutingAssembly();
using Stream stream = executingAssembly.GetManifestResourceStream("Hardcore.assets.heart.png");
if (stream == null)
{
_logger.Error("Embedded image not found!");
return;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
_heartTexture2D = new Texture2D(2, 2);
if (!ImageConversion.LoadImage(_heartTexture2D, Il2CppStructArray<byte>.op_Implicit(array)))
{
_logger.Error("Failed to load image data into Texture2D.");
}
}
public override void OnGUI()
{
//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_0095: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (!(((Scene)(ref activeScene)).name != "Main") && !((Object)(object)_heartTexture2D == (Object)null) && HardcoreSave.Instance.HardcoreModeData.HardcoreMode && _showHeartHUD.Value)
{
float num = _heartHUDsize.Value;
float num2 = (float)Screen.width - num - (float)_heartHUDXOffset.Value;
float num3 = _heartHUDYOffset.Value;
GUI.DrawTexture(new Rect(num2, num3, num, num), (Texture)(object)_heartTexture2D);
}
}
[IteratorStateMachine(typeof(<CheckHardcore>d__11))]
private static IEnumerator CheckHardcore()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CheckHardcore>d__11(0);
}
}
}
namespace Hardcore.Patches
{
[HarmonyPatch(typeof(DeathScreen))]
public class DeathScreenPatch
{
[HarmonyPatch("Open")]
[HarmonyPostfix]
public static void SaveDeath(DeathScreen __instance)
{
if (HardcoreSave.Instance.HardcoreModeData.HardcoreMode)
{
Melon<Hardcore>.Logger.Msg("Player has died in Hardcore.");
if (!string.IsNullOrEmpty(HardcoreSave.Instance.HardcoreModeData.Reason))
{
Melon<Hardcore>.Logger.Msg("Death Reason: " + HardcoreSave.Instance.HardcoreModeData.Reason);
}
HardcoreSave.Instance.HardcoreModeData.Died = true;
Singleton<SaveManager>.Instance.Save();
}
}
public static void AddDeathUIInfo()
{
if (HardcoreSave.Instance.HardcoreModeData.HardcoreMode)
{
Transform val = ((Component)Singleton<DeathScreen>.Instance).transform.Find("Container");
Transform val2 = val.Find("Title");
Transform button = val.Find("Respawn");
Transform button2 = val.Find("Load");
EditButton(button);
EditButton(button2);
}
}
public static void EditButton(Transform button)
{
Button component = ((Component)button).GetComponent<Button>();
if ((Object)(object)component != (Object)null)
{
((UnityEventBase)component.onClick).RemoveAllListeners();
((UnityEvent)component.onClick).AddListener(UnityAction.op_Implicit((Action)GhostMode));
}
TextMeshProUGUI componentInChildren = ((Component)button).GetComponentInChildren<TextMeshProUGUI>();
if ((Object)(object)componentInChildren != (Object)null)
{
((TMP_Text)componentInChildren).text = "Become a Ghost";
}
}
public static void GhostMode()
{
Singleton<DeathScreen>.Instance.Close();
PlayerSingleton<PlayerCamera>.Instance.LockMouse();
PlayerCameraPatch.FreeCamPlayerInvisible();
}
}
[HarmonyPatch(typeof(PlayerCamera))]
public class PlayerCameraPatch
{
[HarmonyPatch("Exit")]
[HarmonyPostfix]
public static void FreecamJailPost()
{
if (HardcoreSave.Instance.HardcoreModeData.HardcoreMode && HardcoreSave.Instance.HardcoreModeData.Died)
{
FreeCamPlayerInvisible();
if (Singleton<PauseMenu>.Instance.IsPaused)
{
Singleton<PauseMenu>.Instance.Resume();
}
else
{
Singleton<PauseMenu>.Instance.Pause();
}
}
}
public static void FreeCamPlayerInvisible()
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
PlayerSingleton<PlayerCamera>.Instance.FreeCamEnabled = true;
((Behaviour)Singleton<HUD>.Instance.canvas).enabled = false;
PlayerSingleton<PlayerMovement>.Instance.canMove = false;
Player.Local.SetVisibleToLocalPlayer(false);
PlayerSingleton<PlayerCamera>.Instance.OverrideTransform(((Component)PlayerSingleton<PlayerCamera>.Instance).transform.position, ((Component)PlayerSingleton<PlayerCamera>.Instance).transform.rotation, 0f, false);
PlayerSingleton<PlayerCamera>.Instance.AddActiveUIElement(((Object)PlayerSingleton<PlayerCamera>.Instance).name);
}
}
[HarmonyPatch(typeof(SetupScreen))]
public class SetupScreenPatch
{
public static Toggle hardcoreToggle;
public static TextMeshProUGUI hardcoreToggleLabel;
public static GameObject hardcoreToggleContainer;
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void AddHardcoreToggle(SetupScreen __instance)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: 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_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Expected O, but got Unknown
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: 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_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Expected O, but got Unknown
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_0350: Unknown result type (might be due to invalid IL or missing references)
//IL_0309: 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_04f7: 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_0434: Unknown result type (might be due to invalid IL or missing references)
//IL_0479: Unknown result type (might be due to invalid IL or missing references)
//IL_0488: Unknown result type (might be due to invalid IL or missing references)
//IL_0497: 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_04b5: Unknown result type (might be due to invalid IL or missing references)
//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
//IL_05ab: Expected O, but got Unknown
//IL_05d7: Unknown result type (might be due to invalid IL or missing references)
//IL_05ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0605: Unknown result type (might be due to invalid IL or missing references)
//IL_061c: Unknown result type (might be due to invalid IL or missing references)
//IL_0633: Unknown result type (might be due to invalid IL or missing references)
//IL_0698: Unknown result type (might be due to invalid IL or missing references)
//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
//IL_06fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0702: Unknown result type (might be due to invalid IL or missing references)
//IL_0706: Unknown result type (might be due to invalid IL or missing references)
//IL_070d: Unknown result type (might be due to invalid IL or missing references)
//IL_071a: Unknown result type (might be due to invalid IL or missing references)
Transform transform = ((Component)__instance).transform;
Transform val = transform.Find("SkipIntro");
Transform val2 = transform.Find("Confirm");
if ((Object)(object)val == (Object)null)
{
Melon<Hardcore>.Logger.Error("SkipIntro not found!");
return;
}
Toggle component = ((Component)val).GetComponent<Toggle>();
TextMeshProUGUI componentInChildren = ((Component)val).GetComponentInChildren<TextMeshProUGUI>();
hardcoreToggleContainer = new GameObject("HardcoreMode");
hardcoreToggleContainer.transform.SetParent(transform);
hardcoreToggleContainer.transform.localScale = Vector3.one;
RectTransform val3 = hardcoreToggleContainer.AddComponent<RectTransform>();
RectTransform component2 = ((Component)val).GetComponent<RectTransform>();
val3.anchorMin = new Vector2(0.5f, 0.5f);
val3.anchorMax = new Vector2(0.5f, 0.5f);
val3.pivot = new Vector2(0.5f, 0.5f);
val3.sizeDelta = component2.sizeDelta;
val3.anchoredPosition = new Vector2(0f, component2.anchoredPosition.y - component2.sizeDelta.y - 30f);
RectTransform component3 = ((Component)val2).GetComponent<RectTransform>();
component3.anchoredPosition = new Vector2(component3.anchoredPosition.x, component3.anchoredPosition.y - 35f);
GameObject val4 = new GameObject("Toggle");
val4.transform.SetParent(hardcoreToggleContainer.transform);
RectTransform val5 = val4.AddComponent<RectTransform>();
val5.anchorMin = new Vector2(0.5f, 0.5f);
val5.anchorMax = new Vector2(0.5f, 0.5f);
val5.pivot = new Vector2(0.5f, 0.5f);
val5.anchoredPosition = new Vector2(-48f, 0f);
val5.sizeDelta = new Vector2(25f, 25f);
Image val6 = val4.AddComponent<Image>();
hardcoreToggle = val4.AddComponent<Toggle>();
((Selectable)hardcoreToggle).targetGraphic = (Graphic)(object)val6;
hardcoreToggle.isOn = false;
GameObject val7 = new GameObject("Checkmark");
val7.transform.SetParent(val4.transform);
RectTransform val8 = val7.AddComponent<RectTransform>();
Image val9 = val7.AddComponent<Image>();
hardcoreToggle.graphic = (Graphic)(object)val9;
((Selectable)hardcoreToggle).transition = ((Selectable)component).transition;
((Selectable)hardcoreToggle).colors = ((Selectable)component).colors;
((Selectable)hardcoreToggle).spriteState = ((Selectable)component).spriteState;
((Selectable)hardcoreToggle).animationTriggers = ((Selectable)component).animationTriggers;
Image val10 = null;
Graphic targetGraphic = ((Selectable)component).targetGraphic;
Image val11 = (Image)(object)((targetGraphic is Image) ? targetGraphic : null);
if (val11 != null)
{
val10 = val11;
}
else if ((Object)(object)((Selectable)component).targetGraphic != (Object)null)
{
val10 = ((Component)((Selectable)component).targetGraphic).GetComponent<Image>();
}
if ((Object)(object)val10 != (Object)null)
{
val6.sprite = val10.sprite;
val6.type = val10.type;
((Graphic)val6).color = ((Graphic)val10).color;
((Graphic)val6).material = ((Graphic)val10).material;
((Graphic)val6).raycastTarget = ((Graphic)val10).raycastTarget;
}
else
{
val6.type = (Type)1;
((Graphic)val6).color = Color.gray;
((Graphic)val6).raycastTarget = true;
if ((Object)(object)((Selectable)component).targetGraphic != (Object)null)
{
((Graphic)val6).material = ((Selectable)component).targetGraphic.material;
((Graphic)val6).raycastTarget = ((Selectable)component).targetGraphic.raycastTarget;
}
Melon<Hardcore>.Logger.Warning("Using fallback background configuration");
}
Image val12 = null;
Graphic graphic = component.graphic;
Image val13 = (Image)(object)((graphic is Image) ? graphic : null);
if (val13 != null)
{
val12 = val13;
}
else if ((Object)(object)component.graphic != (Object)null)
{
val12 = ((Component)component.graphic).GetComponent<Image>();
}
if ((Object)(object)val12 != (Object)null)
{
val9.sprite = val12.sprite;
val9.type = val12.type;
((Graphic)val9).color = new Color(14f / 15f, 0.29411766f, 0.16862746f);
((Graphic)val9).material = ((Graphic)val12).material;
((Graphic)val9).raycastTarget = ((Graphic)val12).raycastTarget;
RectTransform component4 = ((Component)val12).GetComponent<RectTransform>();
if ((Object)(object)component4 != (Object)null)
{
val8.anchorMin = component4.anchorMin;
val8.anchorMax = component4.anchorMax;
val8.pivot = component4.pivot;
val8.anchoredPosition = component4.anchoredPosition;
val8.sizeDelta = component4.sizeDelta;
val8.offsetMin = component4.offsetMin;
val8.offsetMax = component4.offsetMax;
}
}
else
{
((Graphic)val9).color = new Color(14f / 15f, 0.29411766f, 0.16862746f);
val9.type = (Type)0;
if ((Object)(object)component.graphic != (Object)null)
{
((Graphic)val9).material = component.graphic.material;
((Graphic)val9).raycastTarget = component.graphic.raycastTarget;
}
Il2CppArrayBase<Sprite> source = Resources.FindObjectsOfTypeAll<Sprite>();
Sprite val14 = ((IEnumerable<Sprite>)source).FirstOrDefault((Func<Sprite, bool>)((Sprite s) => ((Object)s).name.ToLower().Contains("check") || ((Object)s).name.ToLower().Contains("tick") || ((Object)s).name.ToLower().Contains("mark")));
if ((Object)(object)val14 != (Object)null)
{
val9.sprite = val14;
}
Melon<Hardcore>.Logger.Warning("Using fallback checkmark configuration");
}
GameObject val15 = new GameObject("Label");
val15.transform.SetParent(hardcoreToggleContainer.transform);
RectTransform val16 = val15.AddComponent<RectTransform>();
val16.anchorMin = new Vector2(0.5f, 0.5f);
val16.anchorMax = new Vector2(0.5f, 0.5f);
val16.pivot = new Vector2(0f, 0.5f);
val16.anchoredPosition = new Vector2(-30f, 0f);
val16.sizeDelta = new Vector2(200f, 20f);
hardcoreToggleLabel = val15.AddComponent<TextMeshProUGUI>();
((TMP_Text)hardcoreToggleLabel).text = "Hardcore Mode";
((TMP_Text)hardcoreToggleLabel).font = ((TMP_Text)componentInChildren).font;
((TMP_Text)hardcoreToggleLabel).fontSize = ((TMP_Text)componentInChildren).fontSize * 1.25f;
((Graphic)hardcoreToggleLabel).color = new Color(44f / 51f, 4f / 51f, 0.23529412f);
((TMP_Text)hardcoreToggleLabel).alignment = ((TMP_Text)componentInChildren).alignment;
((TMP_Text)hardcoreToggleLabel).fontStyle = ((TMP_Text)componentInChildren).fontStyle;
((TMP_Text)hardcoreToggleLabel).lineSpacing = ((TMP_Text)componentInChildren).lineSpacing;
((Selectable)hardcoreToggle).interactable = true;
Transform val17 = transform.Find("Background");
RectTransform component5 = ((Component)val17).GetComponent<RectTransform>();
Vector2 sizeDelta = component5.sizeDelta;
component5.sizeDelta = new Vector2(sizeDelta.x, sizeDelta.y + 65f);
Melon<Hardcore>.Logger.Msg("Hardcore toggle created successfully!");
}
[HarmonyPatch("StartGame")]
[HarmonyPostfix]
public static void ApplyHardcoreSetting(SetupScreen __instance)
{
HardcoreSave.Instance.HardcoreModeData.HardcoreMode = hardcoreToggle.isOn;
}
}
}
namespace Hardcore.Helpers
{
public static class MelonLoggerExtensions
{
public static void Debug(this Instance logger, string message, bool stacktrace = true)
{
}
private static string GetLoggerName(Instance logger)
{
return typeof(Instance).GetField("Name", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(logger) as string;
}
private static void InvokeNativeMsg(Color namesectionColor, Color textColor, string nameSection, string message)
{
typeof(MelonLogger).GetMethod("NativeMsg", BindingFlags.Static | BindingFlags.NonPublic)?.Invoke(null, new object[5]
{
namesectionColor,
textColor,
nameSection,
message ?? "null",
false
});
}
private static string GetCallerInfo()
{
StackTrace stackTrace = new StackTrace();
for (int i = 2; i < stackTrace.FrameCount; i++)
{
StackFrame frame = stackTrace.GetFrame(i);
MethodBase method = frame.GetMethod();
if (!(method?.DeclaringType == null))
{
return method.DeclaringType.FullName + "." + method.Name;
}
}
return "unknown";
}
}
public static class Il2CppListExtensions
{
public static IEnumerable<T> AsEnumerable<T>(this List<T> list)
{
return list ?? new List<T>();
}
public static List<T> ToIl2CppList<T>(this IEnumerable<T> source)
{
List<T> val = new List<T>();
foreach (T item in source)
{
val.Add(item);
}
return val;
}
public static List<T> ConvertToList<T>(List<T> il2CppList)
{
List<T> list = new List<T>();
T[] collection = Il2CppArrayBase<T>.op_Implicit(il2CppList.ToArray());
list.AddRange(collection);
return list;
}
public static IEnumerable<T> AsEnumerable<T>(this List<T> list)
{
IEnumerable<T> result;
if (list != null)
{
result = ((IEnumerable<T>)list._items).Take(list._size);
}
else
{
IEnumerable<T> enumerable = Array.Empty<T>();
result = enumerable;
}
return result;
}
}
public static class Utils
{
[CompilerGenerated]
private sealed class <WaitForNetwork>d__6 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public IEnumerator routine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNetwork>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (!InstanceFinder.IsServer && !InstanceFinder.IsClient)
{
<>2__current = null;
<>1__state = 1;
return true;
}
MelonCoroutines.Start(routine);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForNetworkSingleton>d__8<T> : IEnumerator<object>, IEnumerator, IDisposable where T : notnull, NetworkSingleton<T>
{
private int <>1__state;
private object <>2__current;
public IEnumerator coroutine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNetworkSingleton>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
goto IL_0044;
case 1:
<>1__state = -1;
goto IL_0044;
case 2:
{
<>1__state = -1;
return false;
}
IL_0044:
if (!NetworkSingleton<T>.InstanceExists)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<>2__current = coroutine;
<>1__state = 2;
return true;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForNotNull>d__7 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public object obj;
public float timeout;
public Action onTimeout;
public Action onFinish;
private float <startTime>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNotNull>d__7(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<startTime>5__1 = Time.time;
break;
case 1:
<>1__state = -1;
break;
}
if (obj == null)
{
if (!float.IsNaN(timeout) && Time.time - <startTime>5__1 > timeout)
{
onTimeout?.Invoke();
return false;
}
<>2__current = null;
<>1__state = 1;
return true;
}
onFinish?.Invoke();
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForPlayer>d__5 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public IEnumerator routine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForPlayer>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if ((Object)(object)Player.Local == (Object)null || (Object)(object)((Component)Player.Local).gameObject == (Object)null)
{
<>2__current = null;
<>1__state = 1;
return true;
}
MelonCoroutines.Start(routine);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static readonly Instance Logger = new Instance("Hardcore-Utils");
public static T FindObjectByName<T>(string objectName) where T : Object
{
try
{
foreach (T item in Resources.FindObjectsOfTypeAll<T>())
{
if (((Object)item).name != objectName)
{
continue;
}
Logger.Debug($"Found {typeof(T).Name} '{objectName}' directly in loaded objects");
return item;
}
return default(T);
}
catch (Exception ex)
{
Logger.Error($"Error finding {typeof(T).Name} '{objectName}': {ex.Message}");
return default(T);
}
}
public static List<T> GetAllComponentsInChildrenRecursive<T>(GameObject obj) where T : Component
{
List<T> list = new List<T>();
if ((Object)(object)obj == (Object)null)
{
return list;
}
T[] array = Il2CppArrayBase<T>.op_Implicit(obj.GetComponents<T>());
if (array.Length != 0)
{
list.AddRange(array);
}
for (int i = 0; i < obj.transform.childCount; i++)
{
Transform child = obj.transform.GetChild(i);
list.AddRange(GetAllComponentsInChildrenRecursive<T>(((Component)child).gameObject));
}
return list;
}
public static bool Is<T>(object obj, out T result) where T : Object
{
Object val = (Object)((obj is Object) ? obj : null);
if (val != null)
{
Type val2 = Il2CppType.Of<T>();
Type il2CppType = val.GetIl2CppType();
if (val2.IsAssignableFrom(il2CppType))
{
result = ((Il2CppObjectBase)val).TryCast<T>();
return result != null;
}
}
result = default(T);
return false;
}
public static List<StorableItemDefinition> GetAllStorableItemDefinitions()
{
List<ItemRegister> list = Il2CppListExtensions.ConvertToList<ItemRegister>(Singleton<Registry>.Instance.ItemRegistry);
List<StorableItemDefinition> list2 = new List<StorableItemDefinition>();
foreach (ItemRegister item in list)
{
if (Utils.Is<StorableItemDefinition>((object)item.Definition, out StorableItemDefinition result))
{
list2.Add(result);
}
else
{
Logger.Warning("Definition " + ((object)item.Definition)?.GetType().FullName + " is not a StorableItemDefinition");
}
}
return list2.ToList();
}
[IteratorStateMachine(typeof(<WaitForPlayer>d__5))]
public static IEnumerator WaitForPlayer(IEnumerator routine)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForPlayer>d__5(0)
{
routine = routine
};
}
[IteratorStateMachine(typeof(<WaitForNetwork>d__6))]
public static IEnumerator WaitForNetwork(IEnumerator routine)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNetwork>d__6(0)
{
routine = routine
};
}
[IteratorStateMachine(typeof(<WaitForNotNull>d__7))]
public static IEnumerator WaitForNotNull(object? obj, float timeout = float.NaN, Action onTimeout = null, Action onFinish = null)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNotNull>d__7(0)
{
obj = obj,
timeout = timeout,
onTimeout = onTimeout,
onFinish = onFinish
};
}
[IteratorStateMachine(typeof(<WaitForNetworkSingleton>d__8<>))]
public static IEnumerator WaitForNetworkSingleton<T>(IEnumerator coroutine) where T : NetworkSingleton<T>
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNetworkSingleton>d__8<T>(0)
{
coroutine = coroutine
};
}
}
}using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using FishNet;
using Hardcore;
using Hardcore.Helpers;
using Hardcore.Patches;
using HarmonyLib;
using MelonLoader;
using MelonLoader.Preferences;
using Microsoft.CodeAnalysis;
using S1API.Internal.Abstraction;
using S1API.Saveables;
using ScheduleOne;
using ScheduleOne.DevUtilities;
using ScheduleOne.ItemFramework;
using ScheduleOne.Persistence;
using ScheduleOne.PlayerScripts;
using ScheduleOne.UI;
using ScheduleOne.UI.MainMenu;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(global::Hardcore.Hardcore), "Hardcore", "1.0.0", "k073l", null)]
[assembly: MelonColor(1, 255, 0, 0)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Hardcore-Mono")]
[assembly: AssemblyConfiguration("Release Mono")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+58d2af4bb65b9d140f39e7a6e10086edba77961f")]
[assembly: AssemblyProduct("Hardcore-Mono")]
[assembly: AssemblyTitle("Hardcore-Mono")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace Hardcore
{
public class HardcoreData
{
public bool HardcoreMode;
public string Version = "1.0.0";
public bool Died;
public string Reason = "";
}
public class HardcoreSave : Saveable
{
[SaveableField("hardcore_mode")]
public HardcoreData HardcoreModeData = new HardcoreData();
public static HardcoreSave Instance { get; } = new HardcoreSave();
protected override void OnSaved()
{
Melon<Hardcore>.Logger.Msg("Game Saved!");
Melon<Hardcore>.Logger.Msg($"Hardcore Mode is: {HardcoreModeData.HardcoreMode}");
}
protected override void OnLoaded()
{
Melon<Hardcore>.Logger.Msg("Game Loaded!");
Melon<Hardcore>.Logger.Msg($"Hardcore Mode is: {HardcoreModeData.HardcoreMode}");
}
}
public static class BuildInfo
{
public const string Name = "Hardcore";
public const string Description = "Adds a Hardcore mode to the game";
public const string Author = "k073l";
public const string Version = "1.0.0";
}
public class Hardcore : MelonMod
{
[CompilerGenerated]
private sealed class <CheckHardcore>d__11 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CheckHardcore>d__11(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(1f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
_logger.Msg("Hardcore mode is " + (HardcoreSave.Instance.HardcoreModeData.HardcoreMode ? "enabled" : "disabled"));
DeathScreenPatch.AddDeathUIInfo();
if (HardcoreSave.Instance.HardcoreModeData.Died)
{
PlayerCameraPatch.FreeCamPlayerInvisible();
}
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static Instance _logger;
private static Texture2D _heartTexture2D;
private static MelonPreferences_Category _category;
private static MelonPreferences_Entry<bool> _showHeartHUD;
private static MelonPreferences_Entry<int> _heartHUDsize;
private static MelonPreferences_Entry<int> _heartHUDXOffset;
private static MelonPreferences_Entry<int> _heartHUDYOffset;
public override void OnInitializeMelon()
{
_logger = ((MelonBase)this).LoggerInstance;
_logger.Msg("Hardcore initialized");
_category = MelonPreferences.CreateCategory("Hardcore");
_showHeartHUD = _category.CreateEntry<bool>("ShowHeartHUD", true, "Show Heart HUD", "Show a heart icon in the HUD when in Hardcore mode", false, false, (ValueValidator)null, (string)null);
_heartHUDsize = _category.CreateEntry<int>("HeartHUDSize", 32, "Heart HUD Size", "Size of the heart icon in the HUD", false, false, (ValueValidator)null, (string)null);
_heartHUDXOffset = _category.CreateEntry<int>("HeartHUDXOffset", 5, "Heart HUD Position (horizontal)", "Horizontal offset from the right side of the screen (in px)", false, false, (ValueValidator)null, (string)null);
_heartHUDYOffset = _category.CreateEntry<int>("HeartHUDYOffset", 5, "Heart HUD Position (vertical)", "Vertical offset from the top of the screen (in px)", false, false, (ValueValidator)null, (string)null);
ModSaveableRegistry.Register((Saveable)(object)HardcoreSave.Instance, (string)null);
LoadEmbeddedImage();
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
_logger.Debug("Scene loaded: " + sceneName);
if (!(sceneName == "Menu"))
{
if (sceneName == "Main")
{
_logger.Debug("Main scene loaded, waiting for player");
MelonCoroutines.Start(Utils.WaitForPlayer(CheckHardcore()));
}
}
else
{
HardcoreSave.Instance.HardcoreModeData = new HardcoreData();
}
}
private void LoadEmbeddedImage()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
Assembly executingAssembly = Assembly.GetExecutingAssembly();
using Stream stream = executingAssembly.GetManifestResourceStream("Hardcore.assets.heart.png");
if (stream == null)
{
_logger.Error("Embedded image not found!");
return;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
_heartTexture2D = new Texture2D(2, 2);
if (!ImageConversion.LoadImage(_heartTexture2D, array))
{
_logger.Error("Failed to load image data into Texture2D.");
}
}
public override void OnGUI()
{
//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_0095: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (!(((Scene)(ref activeScene)).name != "Main") && !((Object)(object)_heartTexture2D == (Object)null) && HardcoreSave.Instance.HardcoreModeData.HardcoreMode && _showHeartHUD.Value)
{
float num = _heartHUDsize.Value;
float num2 = (float)Screen.width - num - (float)_heartHUDXOffset.Value;
float num3 = _heartHUDYOffset.Value;
GUI.DrawTexture(new Rect(num2, num3, num, num), (Texture)(object)_heartTexture2D);
}
}
[IteratorStateMachine(typeof(<CheckHardcore>d__11))]
private static IEnumerator CheckHardcore()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CheckHardcore>d__11(0);
}
}
}
namespace Hardcore.Patches
{
[HarmonyPatch(typeof(DeathScreen))]
public class DeathScreenPatch
{
[CompilerGenerated]
private static class <>O
{
public static UnityAction <0>__GhostMode;
}
[HarmonyPatch("Open")]
[HarmonyPostfix]
public static void SaveDeath(DeathScreen __instance)
{
if (HardcoreSave.Instance.HardcoreModeData.HardcoreMode)
{
Melon<Hardcore>.Logger.Msg("Player has died in Hardcore.");
if (!string.IsNullOrEmpty(HardcoreSave.Instance.HardcoreModeData.Reason))
{
Melon<Hardcore>.Logger.Msg("Death Reason: " + HardcoreSave.Instance.HardcoreModeData.Reason);
}
HardcoreSave.Instance.HardcoreModeData.Died = true;
Singleton<SaveManager>.Instance.Save();
}
}
public static void AddDeathUIInfo()
{
if (HardcoreSave.Instance.HardcoreModeData.HardcoreMode)
{
Transform val = ((Component)Singleton<DeathScreen>.Instance).transform.Find("Container");
Transform val2 = val.Find("Title");
Transform button = val.Find("Respawn");
Transform button2 = val.Find("Load");
EditButton(button);
EditButton(button2);
}
}
public static void EditButton(Transform button)
{
//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_0041: Expected O, but got Unknown
Button component = ((Component)button).GetComponent<Button>();
if ((Object)(object)component != (Object)null)
{
((UnityEventBase)component.onClick).RemoveAllListeners();
ButtonClickedEvent onClick = component.onClick;
object obj = <>O.<0>__GhostMode;
if (obj == null)
{
UnityAction val = GhostMode;
<>O.<0>__GhostMode = val;
obj = (object)val;
}
((UnityEvent)onClick).AddListener((UnityAction)obj);
}
TextMeshProUGUI componentInChildren = ((Component)button).GetComponentInChildren<TextMeshProUGUI>();
if ((Object)(object)componentInChildren != (Object)null)
{
((TMP_Text)componentInChildren).text = "Become a Ghost";
}
}
public static void GhostMode()
{
Singleton<DeathScreen>.Instance.Close();
PlayerSingleton<PlayerCamera>.Instance.LockMouse();
PlayerCameraPatch.FreeCamPlayerInvisible();
}
}
[HarmonyPatch(typeof(PlayerCamera))]
public class PlayerCameraPatch
{
[HarmonyPatch("Exit")]
[HarmonyPostfix]
public static void FreecamJailPost()
{
if (HardcoreSave.Instance.HardcoreModeData.HardcoreMode && HardcoreSave.Instance.HardcoreModeData.Died)
{
FreeCamPlayerInvisible();
if (Singleton<PauseMenu>.Instance.IsPaused)
{
Singleton<PauseMenu>.Instance.Resume();
}
else
{
Singleton<PauseMenu>.Instance.Pause();
}
}
}
public static void FreeCamPlayerInvisible()
{
//IL_0044: 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)
PlayerSingleton<PlayerCamera>.Instance.FreeCamEnabled = true;
((Behaviour)Singleton<HUD>.Instance.canvas).enabled = false;
PlayerSingleton<PlayerMovement>.Instance.canMove = false;
Player.Local.SetVisibleToLocalPlayer(false);
PlayerSingleton<PlayerCamera>.Instance.OverrideTransform(((Component)PlayerSingleton<PlayerCamera>.Instance).transform.position, ((Component)PlayerSingleton<PlayerCamera>.Instance).transform.rotation, 0f, false);
PlayerSingleton<PlayerCamera>.Instance.AddActiveUIElement(((Object)PlayerSingleton<PlayerCamera>.Instance).name);
}
}
[HarmonyPatch(typeof(SetupScreen))]
public class SetupScreenPatch
{
public static Toggle hardcoreToggle;
public static TextMeshProUGUI hardcoreToggleLabel;
public static GameObject hardcoreToggleContainer;
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void AddHardcoreToggle(SetupScreen __instance)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: 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_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_015f: Expected O, but got Unknown
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: 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_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_022c: Expected O, but got Unknown
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_0275: Unknown result type (might be due to invalid IL or missing references)
//IL_0286: Unknown result type (might be due to invalid IL or missing references)
//IL_034f: Unknown result type (might be due to invalid IL or missing references)
//IL_0308: Unknown result type (might be due to invalid IL or missing references)
//IL_0317: Unknown result type (might be due to invalid IL or missing references)
//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0417: Unknown result type (might be due to invalid IL or missing references)
//IL_0433: Unknown result type (might be due to invalid IL or missing references)
//IL_0478: Unknown result type (might be due to invalid IL or missing references)
//IL_0487: Unknown result type (might be due to invalid IL or missing references)
//IL_0496: Unknown result type (might be due to invalid IL or missing references)
//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
//IL_04c3: 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_05a3: Unknown result type (might be due to invalid IL or missing references)
//IL_05aa: Expected O, but got Unknown
//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0604: Unknown result type (might be due to invalid IL or missing references)
//IL_061b: Unknown result type (might be due to invalid IL or missing references)
//IL_0632: Unknown result type (might be due to invalid IL or missing references)
//IL_0697: Unknown result type (might be due to invalid IL or missing references)
//IL_06a9: Unknown result type (might be due to invalid IL or missing references)
//IL_06bb: Unknown result type (might be due to invalid IL or missing references)
//IL_06fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0701: Unknown result type (might be due to invalid IL or missing references)
//IL_0705: Unknown result type (might be due to invalid IL or missing references)
//IL_070c: Unknown result type (might be due to invalid IL or missing references)
//IL_0719: Unknown result type (might be due to invalid IL or missing references)
Transform transform = ((Component)__instance).transform;
Transform val = transform.Find("SkipIntro");
Transform val2 = transform.Find("Confirm");
if ((Object)(object)val == (Object)null)
{
Melon<Hardcore>.Logger.Error("SkipIntro not found!");
return;
}
Toggle component = ((Component)val).GetComponent<Toggle>();
TextMeshProUGUI componentInChildren = ((Component)val).GetComponentInChildren<TextMeshProUGUI>();
hardcoreToggleContainer = new GameObject("HardcoreMode");
hardcoreToggleContainer.transform.SetParent(transform);
hardcoreToggleContainer.transform.localScale = Vector3.one;
RectTransform val3 = hardcoreToggleContainer.AddComponent<RectTransform>();
RectTransform component2 = ((Component)val).GetComponent<RectTransform>();
val3.anchorMin = new Vector2(0.5f, 0.5f);
val3.anchorMax = new Vector2(0.5f, 0.5f);
val3.pivot = new Vector2(0.5f, 0.5f);
val3.sizeDelta = component2.sizeDelta;
val3.anchoredPosition = new Vector2(0f, component2.anchoredPosition.y - component2.sizeDelta.y - 30f);
RectTransform component3 = ((Component)val2).GetComponent<RectTransform>();
component3.anchoredPosition = new Vector2(component3.anchoredPosition.x, component3.anchoredPosition.y - 35f);
GameObject val4 = new GameObject("Toggle");
val4.transform.SetParent(hardcoreToggleContainer.transform);
RectTransform val5 = val4.AddComponent<RectTransform>();
val5.anchorMin = new Vector2(0.5f, 0.5f);
val5.anchorMax = new Vector2(0.5f, 0.5f);
val5.pivot = new Vector2(0.5f, 0.5f);
val5.anchoredPosition = new Vector2(-48f, 0f);
val5.sizeDelta = new Vector2(25f, 25f);
Image val6 = val4.AddComponent<Image>();
hardcoreToggle = val4.AddComponent<Toggle>();
((Selectable)hardcoreToggle).targetGraphic = (Graphic)(object)val6;
hardcoreToggle.isOn = false;
GameObject val7 = new GameObject("Checkmark");
val7.transform.SetParent(val4.transform);
RectTransform val8 = val7.AddComponent<RectTransform>();
Image val9 = val7.AddComponent<Image>();
hardcoreToggle.graphic = (Graphic)(object)val9;
((Selectable)hardcoreToggle).transition = ((Selectable)component).transition;
((Selectable)hardcoreToggle).colors = ((Selectable)component).colors;
((Selectable)hardcoreToggle).spriteState = ((Selectable)component).spriteState;
((Selectable)hardcoreToggle).animationTriggers = ((Selectable)component).animationTriggers;
Image val10 = null;
Graphic targetGraphic = ((Selectable)component).targetGraphic;
Image val11 = (Image)(object)((targetGraphic is Image) ? targetGraphic : null);
if (val11 != null)
{
val10 = val11;
}
else if ((Object)(object)((Selectable)component).targetGraphic != (Object)null)
{
val10 = ((Component)((Selectable)component).targetGraphic).GetComponent<Image>();
}
if ((Object)(object)val10 != (Object)null)
{
val6.sprite = val10.sprite;
val6.type = val10.type;
((Graphic)val6).color = ((Graphic)val10).color;
((Graphic)val6).material = ((Graphic)val10).material;
((Graphic)val6).raycastTarget = ((Graphic)val10).raycastTarget;
}
else
{
val6.type = (Type)1;
((Graphic)val6).color = Color.gray;
((Graphic)val6).raycastTarget = true;
if ((Object)(object)((Selectable)component).targetGraphic != (Object)null)
{
((Graphic)val6).material = ((Selectable)component).targetGraphic.material;
((Graphic)val6).raycastTarget = ((Selectable)component).targetGraphic.raycastTarget;
}
Melon<Hardcore>.Logger.Warning("Using fallback background configuration");
}
Image val12 = null;
Graphic graphic = component.graphic;
Image val13 = (Image)(object)((graphic is Image) ? graphic : null);
if (val13 != null)
{
val12 = val13;
}
else if ((Object)(object)component.graphic != (Object)null)
{
val12 = ((Component)component.graphic).GetComponent<Image>();
}
if ((Object)(object)val12 != (Object)null)
{
val9.sprite = val12.sprite;
val9.type = val12.type;
((Graphic)val9).color = new Color(14f / 15f, 0.29411766f, 0.16862746f);
((Graphic)val9).material = ((Graphic)val12).material;
((Graphic)val9).raycastTarget = ((Graphic)val12).raycastTarget;
RectTransform component4 = ((Component)val12).GetComponent<RectTransform>();
if ((Object)(object)component4 != (Object)null)
{
val8.anchorMin = component4.anchorMin;
val8.anchorMax = component4.anchorMax;
val8.pivot = component4.pivot;
val8.anchoredPosition = component4.anchoredPosition;
val8.sizeDelta = component4.sizeDelta;
val8.offsetMin = component4.offsetMin;
val8.offsetMax = component4.offsetMax;
}
}
else
{
((Graphic)val9).color = new Color(14f / 15f, 0.29411766f, 0.16862746f);
val9.type = (Type)0;
if ((Object)(object)component.graphic != (Object)null)
{
((Graphic)val9).material = component.graphic.material;
((Graphic)val9).raycastTarget = component.graphic.raycastTarget;
}
Sprite[] source = Resources.FindObjectsOfTypeAll<Sprite>();
Sprite val14 = ((IEnumerable<Sprite>)source).FirstOrDefault((Func<Sprite, bool>)((Sprite s) => ((Object)s).name.ToLower().Contains("check") || ((Object)s).name.ToLower().Contains("tick") || ((Object)s).name.ToLower().Contains("mark")));
if ((Object)(object)val14 != (Object)null)
{
val9.sprite = val14;
}
Melon<Hardcore>.Logger.Warning("Using fallback checkmark configuration");
}
GameObject val15 = new GameObject("Label");
val15.transform.SetParent(hardcoreToggleContainer.transform);
RectTransform val16 = val15.AddComponent<RectTransform>();
val16.anchorMin = new Vector2(0.5f, 0.5f);
val16.anchorMax = new Vector2(0.5f, 0.5f);
val16.pivot = new Vector2(0f, 0.5f);
val16.anchoredPosition = new Vector2(-30f, 0f);
val16.sizeDelta = new Vector2(200f, 20f);
hardcoreToggleLabel = val15.AddComponent<TextMeshProUGUI>();
((TMP_Text)hardcoreToggleLabel).text = "Hardcore Mode";
((TMP_Text)hardcoreToggleLabel).font = ((TMP_Text)componentInChildren).font;
((TMP_Text)hardcoreToggleLabel).fontSize = ((TMP_Text)componentInChildren).fontSize * 1.25f;
((Graphic)hardcoreToggleLabel).color = new Color(44f / 51f, 4f / 51f, 0.23529412f);
((TMP_Text)hardcoreToggleLabel).alignment = ((TMP_Text)componentInChildren).alignment;
((TMP_Text)hardcoreToggleLabel).fontStyle = ((TMP_Text)componentInChildren).fontStyle;
((TMP_Text)hardcoreToggleLabel).lineSpacing = ((TMP_Text)componentInChildren).lineSpacing;
((Selectable)hardcoreToggle).interactable = true;
Transform val17 = transform.Find("Background");
RectTransform component5 = ((Component)val17).GetComponent<RectTransform>();
Vector2 sizeDelta = component5.sizeDelta;
component5.sizeDelta = new Vector2(sizeDelta.x, sizeDelta.y + 65f);
Melon<Hardcore>.Logger.Msg("Hardcore toggle created successfully!");
}
[HarmonyPatch("StartGame")]
[HarmonyPostfix]
public static void ApplyHardcoreSetting(SetupScreen __instance)
{
HardcoreSave.Instance.HardcoreModeData.HardcoreMode = hardcoreToggle.isOn;
}
}
}
namespace Hardcore.Helpers
{
public static class MelonLoggerExtensions
{
public static void Debug(this Instance logger, string message, bool stacktrace = true)
{
}
private static string GetLoggerName(Instance logger)
{
return typeof(Instance).GetField("Name", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(logger) as string;
}
private static void InvokeNativeMsg(Color namesectionColor, Color textColor, string nameSection, string message)
{
typeof(MelonLogger).GetMethod("NativeMsg", BindingFlags.Static | BindingFlags.NonPublic)?.Invoke(null, new object[5]
{
namesectionColor,
textColor,
nameSection,
message ?? "null",
false
});
}
private static string GetCallerInfo()
{
StackTrace stackTrace = new StackTrace();
for (int i = 2; i < stackTrace.FrameCount; i++)
{
StackFrame frame = stackTrace.GetFrame(i);
MethodBase method = frame.GetMethod();
if (!(method?.DeclaringType == null))
{
return method.DeclaringType.FullName + "." + method.Name;
}
}
return "unknown";
}
}
public static class Il2CppListExtensions
{
public static IEnumerable<T> AsEnumerable<T>(this List<T> list)
{
return list ?? new List<T>();
}
}
public static class Utils
{
[CompilerGenerated]
private sealed class <WaitForNetwork>d__6 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public IEnumerator routine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNetwork>d__6(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (!InstanceFinder.IsServer && !InstanceFinder.IsClient)
{
<>2__current = null;
<>1__state = 1;
return true;
}
MelonCoroutines.Start(routine);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForNetworkSingleton>d__8<T> : IEnumerator<object>, IEnumerator, IDisposable where T : notnull, NetworkSingleton<T>
{
private int <>1__state;
private object <>2__current;
public IEnumerator coroutine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNetworkSingleton>d__8(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
goto IL_0044;
case 1:
<>1__state = -1;
goto IL_0044;
case 2:
{
<>1__state = -1;
return false;
}
IL_0044:
if (!NetworkSingleton<T>.InstanceExists)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<>2__current = coroutine;
<>1__state = 2;
return true;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForNotNull>d__7 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public object obj;
public float timeout;
public Action onTimeout;
public Action onFinish;
private float <startTime>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForNotNull>d__7(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<startTime>5__1 = Time.time;
break;
case 1:
<>1__state = -1;
break;
}
if (obj == null)
{
if (!float.IsNaN(timeout) && Time.time - <startTime>5__1 > timeout)
{
onTimeout?.Invoke();
return false;
}
<>2__current = null;
<>1__state = 1;
return true;
}
onFinish?.Invoke();
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <WaitForPlayer>d__5 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public IEnumerator routine;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitForPlayer>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if ((Object)(object)Player.Local == (Object)null || (Object)(object)((Component)Player.Local).gameObject == (Object)null)
{
<>2__current = null;
<>1__state = 1;
return true;
}
MelonCoroutines.Start(routine);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static readonly Instance Logger = new Instance("Hardcore-Utils");
public static T FindObjectByName<T>(string objectName) where T : Object
{
try
{
T[] array = Resources.FindObjectsOfTypeAll<T>();
foreach (T val in array)
{
if (!(((Object)val).name != objectName))
{
Logger.Debug("Found " + typeof(T).Name + " '" + objectName + "' directly in loaded objects");
return val;
}
}
return default(T);
}
catch (Exception ex)
{
Logger.Error("Error finding " + typeof(T).Name + " '" + objectName + "': " + ex.Message);
return default(T);
}
}
public static List<T> GetAllComponentsInChildrenRecursive<T>(GameObject obj) where T : Component
{
List<T> list = new List<T>();
if ((Object)(object)obj == (Object)null)
{
return list;
}
T[] components = obj.GetComponents<T>();
if (components.Length != 0)
{
list.AddRange(components);
}
for (int i = 0; i < obj.transform.childCount; i++)
{
Transform child = obj.transform.GetChild(i);
list.AddRange(GetAllComponentsInChildrenRecursive<T>(((Component)child).gameObject));
}
return list;
}
public static bool Is<T>(object obj, out T result) where T : class
{
if (obj is T val)
{
result = val;
return true;
}
result = null;
return false;
}
public static List<StorableItemDefinition> GetAllStorableItemDefinitions()
{
List<ItemRegister> list = Singleton<Registry>.Instance.ItemRegistry.ToList();
List<StorableItemDefinition> list2 = new List<StorableItemDefinition>();
foreach (ItemRegister item in list)
{
if (Is<StorableItemDefinition>(item.Definition, out var result))
{
list2.Add(result);
}
else
{
Logger.Warning("Definition " + ((object)item.Definition)?.GetType().FullName + " is not a StorableItemDefinition");
}
}
return list2.ToList();
}
[IteratorStateMachine(typeof(<WaitForPlayer>d__5))]
public static IEnumerator WaitForPlayer(IEnumerator routine)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForPlayer>d__5(0)
{
routine = routine
};
}
[IteratorStateMachine(typeof(<WaitForNetwork>d__6))]
public static IEnumerator WaitForNetwork(IEnumerator routine)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNetwork>d__6(0)
{
routine = routine
};
}
[IteratorStateMachine(typeof(<WaitForNotNull>d__7))]
public static IEnumerator WaitForNotNull(object? obj, float timeout = float.NaN, Action onTimeout = null, Action onFinish = null)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNotNull>d__7(0)
{
obj = obj,
timeout = timeout,
onTimeout = onTimeout,
onFinish = onFinish
};
}
[IteratorStateMachine(typeof(<WaitForNetworkSingleton>d__8<>))]
public static IEnumerator WaitForNetworkSingleton<T>(IEnumerator coroutine) where T : NetworkSingleton<T>
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitForNetworkSingleton>d__8<T>(0)
{
coroutine = coroutine
};
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}