using System;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Mathematics;
using Unity.Netcode;
[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("Tomatobird.AdRevenue")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+fca4a54de2f96b2c515ff7633b1759bd549b9135")]
[assembly: AssemblyProduct("AdRevenue")]
[assembly: AssemblyTitle("Tomatobird.AdRevenue")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 AdRevenue
{
[BepInPlugin("Tomatobird.AdRevenue", "AdRevenue", "1.0.1")]
public class AdRevenue : BaseUnityPlugin
{
public static int baseCredits;
public static int multiCredits;
public static float quotaMultiplier;
public static bool displayMessage;
public static string displayTitle;
public static string displayDescription;
public static AdRevenue Instance { get; private set; }
internal static ManualLogSource Logger { get; private set; }
internal static Harmony? Harmony { get; set; }
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
baseCredits = ((BaseUnityPlugin)this).Config.Bind<int>("General", "BaseCredits", 20, "Amount of credits given.").Value;
multiCredits = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MultiCredits", 10, "Amount of credits given per each player after player 1.").Value;
quotaMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "QuotaMultiplier", 1.5f, "Multiplier for the total credits given. Set to 1 to disable.").Value;
displayMessage = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisplayMessage", true, "Display a message confirming that credits were given.").Value;
displayTitle = ((BaseUnityPlugin)this).Config.Bind<string>("General", "DisplayTitle", "Thank you!", "Title of the message box displayed after the ad.").Value;
displayDescription = ((BaseUnityPlugin)this).Config.Bind<string>("General", "DisplayDescription", "The company has paid you $bonus credits for your time.", "Description in the message box displayed after the ad. $bonus is replaced with the bonus given.").Value;
Patch();
Logger.LogInfo((object)"Tomatobird.AdRevenue v1.0.1 has loaded!");
}
internal static void Patch()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("Tomatobird.AdRevenue");
}
Logger.LogDebug((object)"Patching...");
Harmony.PatchAll();
Logger.LogDebug((object)"Finished patching!");
}
internal static void Unpatch()
{
Logger.LogDebug((object)"Unpatching...");
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogDebug((object)"Finished unpatching!");
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "Tomatobird.AdRevenue";
public const string PLUGIN_NAME = "AdRevenue";
public const string PLUGIN_VERSION = "1.0.1";
}
}
namespace AdRevenue.Patches
{
[HarmonyPatch(typeof(HUDManager))]
public class HUDManagerPatch
{
[HarmonyPatch("displayAd")]
[HarmonyPostfix]
private static void ApplyAdRevenue(HUDManager __instance)
{
int num = AdRevenue.baseCredits + AdRevenue.multiCredits * StartOfRound.Instance.connectedPlayersAmount;
if (AdRevenue.quotaMultiplier != 1f)
{
num = (int)(math.max(AdRevenue.quotaMultiplier * (float)TimeOfDay.Instance.timesFulfilledQuota, 1f) * (float)num);
}
if (((NetworkBehaviour)StartOfRound.Instance).IsHost)
{
Terminal terminalScript = __instance.terminalScript;
terminalScript.groupCredits += num;
__instance.terminalScript.SyncGroupCreditsServerRpc(__instance.terminalScript.groupCredits, __instance.terminalScript.numberOfItemsInDropship);
}
if (AdRevenue.displayMessage)
{
string text = AdRevenue.displayDescription.Replace("$bonus", num.ToString());
__instance.DisplayTip(AdRevenue.displayTitle, text, false, false, "LC_Tip1");
}
}
}
}