using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Microsoft.CodeAnalysis;
using Sons.Gameplay.TreeCutting;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SOTFCutdownTreesFaster")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SOTFCutdownTreesFaster")]
[assembly: AssemblyTitle("SOTFCutdownTreesFaster")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
}
}
}
namespace SOTFCutdownTreesFaster
{
public class Gui : MonoBehaviour
{
public static bool shallBeShown = true;
private void OnGUI()
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
if (shallBeShown)
{
GUIStyle val = new GUIStyle(GUI.skin.label);
val.fontSize = 15;
string text = "You are using the 10 minutes test version of \"" + Mod.PLUGIN_NAME + "\".";
GUI.Label(new Rect(100f, 100f, 800f, 25f), "<b>" + text + "</b>", val);
val.fontSize = 20;
text = "Go to https://dryzlers-mods.com for more information.";
GUI.Label(new Rect(100f, 125f, 800f, 40f), "<b>" + text + "</b>", val);
}
}
}
[BepInPlugin("com.dryzler.sotf.cutdowntreesfaster", "Dryzler's Cutdown Trees Faster", "1.0.3")]
public class Mod : BasePlugin
{
private class Lib
{
public static void initMod(Mod mod)
{
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Expected O, but got Unknown
instance = mod;
mod.dateTimeAwaked = DateTime.UtcNow;
mod.harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), mod.PLUGIN_ID);
try
{
X509Certificate2 serverCert = new X509Certificate2(Encoding.ASCII.GetBytes(mod.CERT));
byte[] bytes = Encoding.ASCII.GetBytes(apiKey.Value.Substring(0, 6));
string signature = apiKey.Value.Substring(6);
byte[] signature2 = (from i in Enumerable.Range(0, signature.Length / 2)
select Convert.ToByte(signature.Substring(i * 2, 2), 16)).ToArray();
mod.active = VerifySignature(bytes, signature2, serverCert);
Gui.shallBeShown = !mod.active;
}
catch (Exception ex)
{
ex.ToString();
}
ClassInjector.RegisterTypeInIl2Cpp<Gui>();
GameObject val = new GameObject("SotfBehavior");
val.AddComponent<Gui>();
((Object)val).hideFlags = (HideFlags)61;
Object.DontDestroyOnLoad((Object)val);
}
public static bool VerifySignature(byte[] data, byte[] signature, X509Certificate2 serverCert)
{
using (SHA256.Create())
{
using RSA rSA = serverCert.GetRSAPublicKey();
return rSA.VerifyData(data, signature, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1);
}
}
public static bool isDemoFinished()
{
if ((DateTime.UtcNow - instance.dateTimeAwaked).TotalMinutes >= (double)instance.MINUTES)
{
return true;
}
return false;
}
public static bool modIsActivated()
{
return instance.active;
}
}
[HarmonyPatch(typeof(TreeCutManager), "OnHit")]
private static class TreeCutManager_OnHit_Patch
{
private static bool Prefix()
{
if (Lib.isDemoFinished() && !Lib.modIsActivated() && TreeCutManager.UseOneHitFell)
{
TreeCutManager.UseOneHitFell = false;
}
return true;
}
}
private Harmony harmony;
private bool active;
private DateTime dateTimeAwaked;
private static Mod instance;
public static string PLUGIN_NAME = "Dryzler's Cutdown Trees Faster";
public static ConfigEntry<string> apiKey { get; private set; }
private string PLUGIN_ID => "com.dryzler.sotf.cutdowntreesfaster";
public string CERT => "-----BEGIN CERTIFICATE-----\r\nMIIB4DCCAYqgAwIBAgITCBVDeOE6Rg/T+QZh0AtWRyHNKjANBgkqhkiG9w0BAQsF\r\nADBFMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwY\r\nSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMB4XDTI0MDYyMDAxMzQyMloXDTQ0MDYx\r\nNTAxMzQyMlowRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAf\r\nBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDBcMA0GCSqGSIb3DQEBAQUA\r\nA0sAMEgCQQCtVEO4anldYiFp/fqwJdSKGvI/M9FFxP0Mq4DOdIVJlPoqrgq4kMlg\r\n1mHRQC5pTVLhwYLvtsdhNypzdJiWZyg3AgMBAAGjUzBRMB0GA1UdDgQWBBRHAIrw\r\n+W748xE/F55lirOOpXGC9jAfBgNVHSMEGDAWgBRHAIrw+W748xE/F55lirOOpXGC\r\n9jAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA0EAezMxc7T1cMnWcN0F\r\nzdQgU0uvNriceJuEPKhgbvMo/FG/RsEiVmN91kywZ30vNlkV8pfqaZkZDfuyd9Y8\r\nx1Pkzg==\r\n-----END CERTIFICATE-----\r\n";
private int MINUTES => 10;
public override void Load()
{
apiKey = ((BasePlugin)this).Config.Bind<string>("Dryzlers Cutdown Trees Faster", "Dryzlers-Mods-Key", "Get your mod key at https://dryzlers-mods.com", "The mod works for " + MINUTES + " minutes. After that you need a key which you enter here.");
Lib.initMod(this);
TreeCutManager.UseOneHitFell = true;
}
}
}