Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of SelfRevive v1.1.1
SelfRevive.dll
Decompiled 2 years agousing System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using OPJosMod_ContentWarning.SelfRevive.Patches; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("OPJosMod-ContentWarning")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OPJosMod-ContentWarning")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("6ffa103f-a7db-440a-9db8-7d56cff399f8")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace OPJosMod_ContentWarning { public class CustomText { private Camera mainCamera; private GameObject textDisplayObject; private TextMesh textMesh; private float startDisplay; private float DisplayTime = -1f; private bool hasStarted = false; public void Start() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown mainCamera = Camera.main; startDisplay = Time.time; textDisplayObject = GameObject.Find("TextDisplay"); if ((Object)(object)textDisplayObject == (Object)null) { textDisplayObject = new GameObject("TextDisplay"); } textMesh = textDisplayObject.GetComponent<TextMesh>(); if ((Object)(object)textMesh == (Object)null) { textMesh = textDisplayObject.AddComponent<TextMesh>(); } hasStarted = true; } public void Update() { //IL_005d: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) if (hasStarted) { if ((Object)(object)mainCamera != (Object)null && Time.time - startDisplay < DisplayTime) { textDisplayObject.gameObject.SetActive(true); Vector3 position = ((Component)mainCamera).transform.position + ((Component)mainCamera).transform.forward * 2f; position.y -= 0.5f; textDisplayObject.transform.position = position; Quaternion rotation = Quaternion.LookRotation(textDisplayObject.transform.position - ((Component)mainCamera).transform.position); textDisplayObject.transform.rotation = rotation; } else { textDisplayObject.gameObject.SetActive(false); } } } public void DisplayText(string text, float displayTime) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_0101: Unknown result type (might be due to invalid IL or missing references) startDisplay = Time.time; DisplayTime = displayTime; textMesh.text = text; textMesh.fontSize = 24; textMesh.characterSize = 0.1f; textMesh.color = Color.white; textDisplayObject.transform.position = new Vector3(0f, 1f, 0f); if ((Object)(object)mainCamera != (Object)null) { Vector3 position = ((Component)mainCamera).transform.position + ((Component)mainCamera).transform.forward * 2f; textDisplayObject.transform.position = position; Quaternion rotation = Quaternion.LookRotation(textDisplayObject.transform.position - ((Component)mainCamera).transform.position); textDisplayObject.transform.rotation = rotation; } } } } namespace OPJosMod_ContentWarning.SelfRevive { [BepInPlugin("OpJosMod.SelfRevive", "SelfRevive", "1.1.0")] public class OpJosMod : BaseUnityPlugin { private const string modGUID = "OpJosMod.SelfRevive"; private const string modName = "SelfRevive"; private const string modVersion = "1.1.0"; private readonly Harmony harmony = new Harmony("OpJosMod.SelfRevive"); private static OpJosMod Instance; internal ManualLogSource mls; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("OpJosMod.SelfRevive"); mls.LogInfo((object)"mod has started!"); PlayerPatch.SetLogSource(mls); harmony.PatchAll(); } } } namespace OPJosMod_ContentWarning.SelfRevive.Patches { [HarmonyPatch(typeof(Player))] public static class PlayerPatch { private static ManualLogSource mls; private static bool AutoRevive = true; private static PlayerRagdoll localPLayer; private static MethodInfo ragdollMethod; private static bool isRagdoll; private static float lastCalled = Time.time; private static float timeDied = Time.time; private static CustomText customText = new CustomText(); public static void SetLogSource(ManualLogSource logSource) { mls = logSource; } [HarmonyPatch("Update")] [HarmonyPostfix] private static void patchUpdate(Player __instance) { if (__instance.IsLocal && Input.GetKeyDown((KeyCode)107)) { __instance.Die(); } if (__instance.IsLocal && Input.GetKeyDown((KeyCode)108)) { if (AutoRevive) { mls.LogMessage((object)"auto revive off"); customText.DisplayText("auto revive OFF", 3f); AutoRevive = false; if (isRagdoll) { __instance.Die(); } } else { mls.LogMessage((object)"auto revive on"); customText.DisplayText("auto revive ON", 3f); AutoRevive = true; } } if (isRagdoll && Time.time - timeDied > 3f) { isRagdoll = false; } else if (isRagdoll && Time.time - lastCalled > 0.25f) { lastCalled = Time.time; ragdollMethod.Invoke(localPLayer, new object[1] { 1f }); } customText.Update(); } [HarmonyPatch("Start")] [HarmonyPostfix] private static void patchStart(Player __instance) { if (__instance.IsLocal) { customText.Start(); } } [HarmonyPatch("Awake")] [HarmonyPostfix] private static void patchAwake(Player __instance) { if (__instance.IsLocal) { localPLayer = ((Component)__instance).gameObject.GetComponent<PlayerRagdoll>(); ragdollMethod = ((object)localPLayer).GetType().GetMethod("CallFall", BindingFlags.Instance | BindingFlags.NonPublic); } } [HarmonyPatch("Die")] [HarmonyPrefix] private static bool patchDie(Player __instance) { if (AutoRevive && __instance.IsLocal) { isRagdoll = true; lastCalled = Time.time; timeDied = Time.time; __instance.data.health = 10f; __instance.data.remainingOxygen = __instance.data.maxOxygen / 2f; return false; } return true; } } }