using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using CSync.Extensions;
using CSync.Lib;
using LobbyCompatibility.Attributes;
using Microsoft.CodeAnalysis;
using On;
using TMPro;
using Unity.Netcode;
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: AssemblyCompany("lacrivoca.DeathQuota")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.1+7795a39c80d9fec8a4ec05c0198f3ad2ecce324a")]
[assembly: AssemblyProduct("DeathQuota")]
[assembly: AssemblyTitle("lacrivoca.DeathQuota")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.1.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 DeathQuota
{
public class ConfigMain : SyncedConfig2<ConfigMain>
{
[DataMember]
public SyncedEntry<bool> ReplaceVanilla { get; private set; }
[DataMember]
public SyncedEntry<int> BodyCost { get; private set; }
public ConfigMain(ConfigFile cfg)
: base("lacrivoca.DeathQuota")
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Expected O, but got Unknown
//IL_003b: Expected O, but got Unknown
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
//IL_0069: Expected O, but got Unknown
ConfigManager.Register<ConfigMain>((SyncedConfig2<ConfigMain>)(object)this);
ReplaceVanilla = SyncedBindingExtensions.BindSyncedEntry<bool>(cfg, new ConfigDefinition("General", "Replace Vanilla"), false, new ConfigDescription("Whether to completely replace the vanilla quota system with a 20% increase per unrecovered body or to simply add a flat amount per body.", (AcceptableValueBase)null, Array.Empty<object>()));
BodyCost = SyncedBindingExtensions.BindSyncedEntry<int>(cfg, new ConfigDefinition("General", "Body Cost"), 50, new ConfigDescription("Amount to increase the quota by per unrecovered body. Only used if Replace Vanilla is set to false.", (AcceptableValueBase)null, Array.Empty<object>()));
}
}
[BepInPlugin("lacrivoca.DeathQuota", "DeathQuota", "1.1.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency("com.sigurd.csync", "5.0.1")]
[LobbyCompatibility(/*Could not decode attribute arguments.*/)]
public class DeathQuota : BaseUnityPlugin
{
[CompilerGenerated]
private static class <>O
{
public static hook_ApplyPenalty <0>__HUDManager_ApplyPenalty;
public static hook_SetNewProfitQuota <1>__TimeOfDay_SetNewProfitQuota;
}
internal static ConfigMain Config;
public static DeathQuota Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
Config = new ConfigMain(((BaseUnityPlugin)this).Config);
Hook();
Logger.LogInfo((object)"lacrivoca.DeathQuota v1.1.1 has loaded!");
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
}
internal static void Hook()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
object obj = <>O.<0>__HUDManager_ApplyPenalty;
if (obj == null)
{
hook_ApplyPenalty val = HUDManager_ApplyPenalty;
<>O.<0>__HUDManager_ApplyPenalty = val;
obj = (object)val;
}
HUDManager.ApplyPenalty += (hook_ApplyPenalty)obj;
object obj2 = <>O.<1>__TimeOfDay_SetNewProfitQuota;
if (obj2 == null)
{
hook_SetNewProfitQuota val2 = TimeOfDay_SetNewProfitQuota;
<>O.<1>__TimeOfDay_SetNewProfitQuota = val2;
obj2 = (object)val2;
}
TimeOfDay.SetNewProfitQuota += (hook_SetNewProfitQuota)obj2;
}
private static void TimeOfDay_SetNewProfitQuota(orig_SetNewProfitQuota orig, TimeOfDay self)
{
if (!SyncedEntry<bool>.op_Implicit(Config.ReplaceVanilla))
{
orig.Invoke(self);
}
if (((NetworkBehaviour)self).IsHost)
{
self.timesFulfilledQuota++;
int num = self.quotaFulfilled - self.profitQuota;
self.timeUntilDeadline = self.totalTime * 4f;
int num2 = num / 5 + 15 * self.daysUntilDeadline;
self.SyncNewProfitQuotaClientRpc(self.profitQuota, num2, self.timesFulfilledQuota);
}
}
private static void HUDManager_ApplyPenalty(orig_ApplyPenalty orig, HUDManager self, int playersDead, int bodiesInsured)
{
if (SyncedEntry<bool>.op_Implicit(Config.ReplaceVanilla))
{
VanillaReplacement(orig, self, playersDead, bodiesInsured);
}
else
{
VanillaAddition(orig, self, playersDead, bodiesInsured);
}
}
private static void VanillaReplacement(orig_ApplyPenalty orig, HUDManager self, int playersDead, int bodiesInsured)
{
float num = 0.2f;
int num2 = TimeOfDay.Instance.profitQuota;
bodiesInsured = Mathf.Max(bodiesInsured, 0);
if (bodiesInsured == playersDead)
{
Logger.LogDebug((object)"DeathQuota: All bodies collected.");
((TMP_Text)self.statsUIElements.penaltyAddition).text = $"{playersDead} casualties: +0%\nAll bodies recovered";
((TMP_Text)self.statsUIElements.penaltyTotal).text = $"Quota Unchanged";
TimeOfDay.Instance.profitQuota = num2;
return;
}
for (int i = 0; i < playersDead - bodiesInsured; i++)
{
num2 += (int)((float)num2 * num);
}
for (int j = 0; j < bodiesInsured; j++)
{
num2 += (int)((float)num2 * (num / 2.5f));
}
((TMP_Text)self.statsUIElements.penaltyAddition).text = $"{playersDead} casualties: +{num * 100f * (float)(playersDead - bodiesInsured)}%\n({bodiesInsured} bodies recovered)";
((TMP_Text)self.statsUIElements.penaltyTotal).text = $"Quota Increased To: ${num2}";
TimeOfDay.Instance.profitQuota = num2;
}
private static void VanillaAddition(orig_ApplyPenalty orig, HUDManager self, int playersDead, int bodiesInsured)
{
float num = 0.2f;
int num2 = TimeOfDay.Instance.profitQuota;
bodiesInsured = Mathf.Max(bodiesInsured, 0);
if (bodiesInsured == playersDead)
{
Logger.LogDebug((object)"DeathQuota: All bodies collected.");
((TMP_Text)self.statsUIElements.penaltyAddition).text = string.Format("{0} casualties: -{1}%\nAll bodies recovered", playersDead, num * 100f * (float)(playersDead - bodiesInsured), bodiesInsured);
((TMP_Text)self.statsUIElements.penaltyTotal).text = $"Quota Unchanged";
TimeOfDay.Instance.profitQuota = num2;
return;
}
for (int i = 0; i < playersDead - bodiesInsured; i++)
{
num2 += SyncedEntry<int>.op_Implicit(Config.BodyCost);
}
for (int j = 0; j < bodiesInsured; j++)
{
num2 += (int)((float)SyncedEntry<int>.op_Implicit(Config.BodyCost) * num);
}
((TMP_Text)self.statsUIElements.penaltyAddition).text = $"{playersDead} casualties: -{num * 100f * (float)(playersDead - bodiesInsured)}%\n({bodiesInsured} bodies recovered)";
((TMP_Text)self.statsUIElements.penaltyTotal).text = $"Quota Increased To: ${num2}";
TimeOfDay.Instance.profitQuota = num2;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "lacrivoca.DeathQuota";
public const string PLUGIN_NAME = "DeathQuota";
public const string PLUGIN_VERSION = "1.1.1";
}
}