using System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SinglePlayerRevive")] [assembly: AssemblyTitle("SinglePlayerRevive")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 SinglePlayerRevive { public class SinglePlayerRevive : BaseUnityPlugin { internal static SinglePlayerRevive Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { } internal void Patch() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { } } } namespace Empress.SingleplayerRevive { [BepInPlugin("com.truckalwaysspawn.repo.solo", "TruckAlwaysSpawn.Solo", "1.0.0")] public class SingleplayerRevivePlugin : BaseUnityPlugin { public const string PluginGuid = "com.truckalwaysspawn.repo.solo"; public const string PluginName = "TruckAlwaysSpawn.Solo"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; internal static Harmony Harmony; internal static ConfigEntry CEnabled; internal static ConfigEntry CReviveDelay; internal static ConfigEntry CReviveHealth; internal static ConfigEntry CRestrictToSoloInMP; internal static bool ReviveInProgress; private void Awake() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; CEnabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "Master enable/disable."); CReviveDelay = ((BaseUnityPlugin)this).Config.Bind("General", "ReviveDelaySeconds", 2f, "Delay before reviving the player."); CReviveHealth = ((BaseUnityPlugin)this).Config.Bind("General", "ReviveHealth", 50, "Health set after revive (clamped to [1..maxHealth])."); CRestrictToSoloInMP = ((BaseUnityPlugin)this).Config.Bind("General", "RestrictToSoloInMP", true, "Only revive in MP if room PlayerCount <= 1."); Harmony = new Harmony("com.truckalwaysspawn.repo.solo"); Harmony.PatchAll(typeof(Patch_RunManager_ChangeLevel)); Log.LogInfo((object)"Singleplayer_Revive 1.0.1 loaded."); } private void OnDestroy() { Harmony harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } internal static IEnumerator ReviveRoutine() { ReviveInProgress = true; float delay = Mathf.Max(0f, CReviveDelay.Value); if (delay > 0f) { yield return (object)new WaitForSeconds(delay); } Exception caught = null; try { PlayerController pc = PlayerController.instance; PlayerAvatar avatar = (((Object)(object)pc != (Object)null) ? pc.playerAvatarScript : null); if ((Object)(object)avatar == (Object)null) { Log.LogWarning((object)"No local PlayerAvatar found. Aborting revive."); ReviveInProgress = false; yield break; } if (!avatar.isDisabled && !avatar.deadSet) { ReviveInProgress = false; yield break; } avatar.Revive(true); PlayerHealth ph = avatar.playerHealth; if ((Object)(object)ph != (Object)null) { int target = Mathf.Clamp(CReviveHealth.Value, 1, Mathf.Max(1, ph.maxHealth)); int delta = target - Mathf.Max(0, ph.health); if (delta > 0) { ph.Heal(delta, false); } } } catch (Exception ex) { caught = ex; } yield return null; ReviveInProgress = false; if (caught != null) { ManualLogSource log = Log; if (log != null) { log.LogError((object)caught); } } } } [HarmonyPatch(typeof(RunManager), "ChangeLevel")] internal static class Patch_RunManager_ChangeLevel { [HarmonyPrefix] [HarmonyPriority(600)] private static bool Prefix(RunManager __instance, bool _completedLevel, bool _levelFailed, ChangeLevelType _changeLevelType) { try { if (!SingleplayerRevivePlugin.CEnabled.Value) { return true; } if (!_levelFailed) { return true; } if (!SemiFunc.RunIsLevel()) { return true; } if (SingleplayerRevivePlugin.ReviveInProgress) { return false; } if (GameManager.Multiplayer() && SingleplayerRevivePlugin.CRestrictToSoloInMP.Value) { try { Room currentRoom = PhotonNetwork.CurrentRoom; int num = ((currentRoom != null) ? currentRoom.PlayerCount : 0); SingleplayerRevivePlugin.Log.LogDebug((object)$"Room player count = {num}"); if (num > 1) { return true; } } catch (Exception ex) { SingleplayerRevivePlugin.Log.LogWarning((object)("PlayerCount check failed: " + ex.Message)); return true; } } PlayerController instance = PlayerController.instance; PlayerAvatar val = (((Object)(object)instance != (Object)null) ? instance.playerAvatarScript : null); if ((Object)(object)val == (Object)null || !val.isDisabled) { return true; } __instance.allPlayersDead = false; ((MonoBehaviour)__instance).StartCoroutine(SingleplayerRevivePlugin.ReviveRoutine()); SingleplayerRevivePlugin.Log.LogInfo((object)"Suppressed run fail and revived local player (solo)."); return false; } catch (Exception ex2) { ManualLogSource log = SingleplayerRevivePlugin.Log; if (log != null) { log.LogError((object)ex2); } return true; } } } }