using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using EntityStates.Events;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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("LocalizedStorms")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LocalizedStorms")]
[assembly: AssemblyTitle("LocalizedStorms")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace LocalizedStorms
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("acanthi.LocalizedStorms", "LocalizedStorms", "1.0.0")]
public class LocalizedStorms : BaseUnityPlugin
{
[HarmonyPatch(typeof(Storm), "OnEnter")]
public class Storm_OnEnter_Patcher
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Expected O, but got Unknown
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Expected O, but got Unknown
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
MethodInfo methodInfo = AccessTools.Method(typeof(LocalizedStorms), "GetStormText", (Type[])null, (Type[])null);
FieldInfo fieldInfo = AccessTools.Field(typeof(Storm), "stormLevel");
for (int i = 0; i < list.Count; i++)
{
if (list[i].opcode == OpCodes.Ldstr && list[i].operand.ToString().Contains("ermmmm..... storm"))
{
list.RemoveRange(i, 5);
list.InsertRange(i, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[3]
{
new CodeInstruction(OpCodes.Ldarg_0, (object)null),
new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo),
new CodeInstruction(OpCodes.Call, (object)methodInfo)
});
break;
}
}
return list.AsEnumerable();
}
}
[HarmonyPatch(typeof(Storm), "FixedUpdate")]
public class Storm_FixedUpdate_Patcher
{
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
MethodInfo methodInfo = AccessTools.Method(typeof(LocalizedStorms), "GoodbyeStorm", (Type[])null, (Type[])null);
for (int i = 0; i < list.Count; i++)
{
if (list[i].opcode == OpCodes.Ldstr && list[i].operand.ToString().Contains("ermmmm..... bye"))
{
Debug.Log((object)"erm bye patched!");
list.RemoveAt(i);
list.InsertRange(i, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[1]
{
new CodeInstruction(OpCodes.Call, (object)methodInfo)
});
break;
}
}
return list.AsEnumerable();
}
}
public const string PluginGUID = "acanthi.LocalizedStorms";
public const string PluginAuthor = "acanthi";
public const string PluginName = "LocalizedStorms";
public const string PluginVersion = "1.0.0";
public void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony val = new Harmony("acanthi.LocalizedStorms");
val.PatchAll();
}
public static string GetStormText(int stormLevel)
{
return stormLevel switch
{
1 => "A storm is approaching...",
2 => "The wind howls in the air...",
3 => "The rains pierce the planet...",
4 => "Static fills the air...",
5 => "Thunder surrounds the teleporter...",
_ => "Thunder surrounds the teleporter...",
};
}
public static string GoodbyeStorm()
{
return "The clouds begin to clear...";
}
}
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}
}