using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AlwaysPlayFinalDay.Patches;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour.HookGen;
using MyceliumNetworking;
using On;
using UnityEngine;
using Zorro.Settings;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("alexandria-p.AlwaysPlayFinalDay")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5db39137ae5a5a68527a4475c06a3d56eb29349d")]
[assembly: AssemblyProduct("AlwaysPlayFinalDay")]
[assembly: AssemblyTitle("alexandria-p.AlwaysPlayFinalDay")]
[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 AlwaysPlayFinalDay
{
[ContentWarningPlugin("alexandria-p.AlwaysPlayFinalDay", "1.0.0", false)]
[BepInPlugin("alexandria-p.AlwaysPlayFinalDay", "AlwaysPlayFinalDay", "1.0.0")]
public class FixR2Modman : BaseUnityPlugin
{
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
Logger = ((BaseUnityPlugin)this).Logger;
GameObject val = new GameObject("AlwaysPlayFinalDayPluginR2ModMan")
{
hideFlags = (HideFlags)61
};
val.AddComponent<AlwaysPlayFinalDay>();
AlwaysPlayFinalDay.Instance.SetLogger(((BaseUnityPlugin)this).Logger);
Object.DontDestroyOnLoad((Object)(object)val);
}
}
public class AlwaysPlayFinalDay : MonoBehaviour
{
[ContentWarningSetting]
public class EnableAllowCrewToWatchFootageEvenIfQuotaNotMetSetting : BoolSetting, IExposedSetting
{
public SettingCategory GetSettingCategory()
{
return (SettingCategory)4;
}
public override void ApplyValue()
{
Instance.SetPlayFinalDayEvenIfQuotaNotMet(((BoolSetting)this).Value);
}
public string GetDisplayName()
{
return "AlwaysPlayFinalDay: Allow crew to view their camera footage on final day, even if the footage won't reach quota (uses the host's game settings) \nWithout this setting, the third day ends immediately.";
}
protected override bool GetDefaultValue()
{
return true;
}
}
private const uint myceliumNetworkModId = 61813u;
public bool Debug_InitSurfaceActive;
public static AlwaysPlayFinalDay Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
public bool PlayFinalDayEvenIfQuotaNotMet { get; private set; }
public void SetLogger(ManualLogSource logger)
{
Logger = logger;
Logger.LogInfo((object)"AlwaysPlayFinalDay v1.0.0 has loaded!");
}
private void Awake()
{
Instance = this;
HookAll();
}
private void Start()
{
MyceliumNetwork.RegisterNetworkObject((object)Instance, 61813u, 0);
}
private void OnDestroy()
{
MyceliumNetwork.DeregisterNetworkObject((object)Instance, 61813u, 0);
}
internal static void HookAll()
{
SurfaceNetworkHandlerPatch.Init();
PhotonGameLobbyHandlerPatch.Init();
}
internal static void UnhookAll()
{
HookEndpointManager.RemoveAllOwnedBy((object)Assembly.GetExecutingAssembly());
}
public bool IsFinalDayAndQuotaNotMet()
{
if (SurfaceNetworkHandler.RoomStats != null && SurfaceNetworkHandler.RoomStats.IsQuotaDay)
{
return !SurfaceNetworkHandler.RoomStats.CalculateIfReachedQuota();
}
return false;
}
public void SetPlayFinalDayEvenIfQuotaNotMet(bool playFinalDayEvenIfQuotaNotMet)
{
PlayFinalDayEvenIfQuotaNotMet = playFinalDayEvenIfQuotaNotMet;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "alexandria-p.AlwaysPlayFinalDay";
public const string PLUGIN_NAME = "AlwaysPlayFinalDay";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace AlwaysPlayFinalDay.Patches
{
public class PhotonGameLobbyHandlerPatch
{
[CompilerGenerated]
private static class <>O
{
public static hook_SetCurrentObjective <0>__PhotonGameLobbyHandler_SetCurrentObjective;
}
internal static void Init()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
object obj = <>O.<0>__PhotonGameLobbyHandler_SetCurrentObjective;
if (obj == null)
{
hook_SetCurrentObjective val = PhotonGameLobbyHandler_SetCurrentObjective;
<>O.<0>__PhotonGameLobbyHandler_SetCurrentObjective = val;
obj = (object)val;
}
PhotonGameLobbyHandler.SetCurrentObjective += (hook_SetCurrentObjective)obj;
}
private static void PhotonGameLobbyHandler_SetCurrentObjective(orig_SetCurrentObjective orig, PhotonGameLobbyHandler self, Objective objective)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Expected O, but got Unknown
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
if (MyceliumNetwork.IsHost && AlwaysPlayFinalDay.Instance.PlayFinalDayEvenIfQuotaNotMet && AlwaysPlayFinalDay.Instance.IsFinalDayAndQuotaNotMet())
{
if (AlwaysPlayFinalDay.Instance.Debug_InitSurfaceActive)
{
objective = (Objective)new ExtractVideoObjective();
}
if (objective is GoToBedSuccessObjective)
{
objective = (Objective)new GoToBedFailedObjective();
}
}
orig.Invoke(self, objective);
}
}
public class SurfaceNetworkHandlerPatch
{
[CompilerGenerated]
private static class <>O
{
public static hook_InitSurface <0>__SurfaceNetworkHandler_InitSurface;
public static hook_NextDay <1>__SurfaceNetworkHandler_NextDay;
}
internal static void Init()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
object obj = <>O.<0>__SurfaceNetworkHandler_InitSurface;
if (obj == null)
{
hook_InitSurface val = SurfaceNetworkHandler_InitSurface;
<>O.<0>__SurfaceNetworkHandler_InitSurface = val;
obj = (object)val;
}
SurfaceNetworkHandler.InitSurface += (hook_InitSurface)obj;
object obj2 = <>O.<1>__SurfaceNetworkHandler_NextDay;
if (obj2 == null)
{
hook_NextDay val2 = SurfaceNetworkHandler_NextDay;
<>O.<1>__SurfaceNetworkHandler_NextDay = val2;
obj2 = (object)val2;
}
SurfaceNetworkHandler.NextDay += (hook_NextDay)obj2;
}
private static void SurfaceNetworkHandler_InitSurface(orig_InitSurface orig, SurfaceNetworkHandler self)
{
AlwaysPlayFinalDay.Instance.Debug_InitSurfaceActive = true;
orig.Invoke(self);
if (MyceliumNetwork.IsHost && AlwaysPlayFinalDay.Instance.PlayFinalDayEvenIfQuotaNotMet && AlwaysPlayFinalDay.Instance.IsFinalDayAndQuotaNotMet())
{
AlwaysPlayFinalDay.Logger.LogInfo((object)"AlwaysPlayFinalDay: spawn players, even on final day.");
if (!Player.justDied)
{
SpawnHandler.Instance.SpawnLocalPlayer((Spawns)3);
}
}
AlwaysPlayFinalDay.Instance.Debug_InitSurfaceActive = false;
}
private static void SurfaceNetworkHandler_NextDay(orig_NextDay orig, SurfaceNetworkHandler self)
{
if (MyceliumNetwork.IsHost && AlwaysPlayFinalDay.Instance.PlayFinalDayEvenIfQuotaNotMet && AlwaysPlayFinalDay.Instance.IsFinalDayAndQuotaNotMet() && AlwaysPlayFinalDay.Instance.Debug_InitSurfaceActive)
{
AlwaysPlayFinalDay.Logger.LogInfo((object)"AlwaysPlayFinalDay: Cancelled gameover, to allow players to watch their video on the final day when they didn't meet quota");
}
else
{
orig.Invoke(self);
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}