using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("PlanetwidePlanetaryShieldGenerator")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PlanetwidePlanetaryShieldGenerator")]
[assembly: AssemblyCopyright("Copyright lltcggie 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5678B562-D4A6-488A-8229-BE42EB9AEFE3")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.1.0.0")]
namespace PlanetaryShieldGenerator;
[BepInPlugin("lltcggie.DSP.plugin.PlanetwidePlanetaryShieldGenerator", "PlanetwidePlanetaryShieldGenerator", "1.0.0")]
public class Main : BaseUnityPlugin
{
public void Awake()
{
LogManager.Logger = ((BaseUnityPlugin)this).Logger;
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
}
}
public class LogManager
{
public static ManualLogSource Logger;
}
[HarmonyPatch]
internal class PlanetaryShieldGeneratorPatches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(PlanetATField), "UpdateGeneratorMatrix")]
public static void PlanetATField_UpdateGeneratorMatrix_Postfix(PlanetATField __instance)
{
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
int generatorCount = __instance.generatorCount;
if (generatorCount <= 0)
{
return;
}
float num = 0f;
for (int i = 0; i < generatorCount; i++)
{
num = Math.Max(__instance.generatorMatrix[i].w, num);
}
__instance.generatorCount = 0;
Array.Clear(__instance.generatorMatrix, 0, 80);
double num2 = 80.0;
double num3 = __instance.planet.realRadius;
int num4 = (int)Math.Ceiling(Math.PI * num3 / (2.0 * num2));
Vector4 val = default(Vector4);
val.x = 0f;
val.y = (float)num3;
val.z = 0f;
val.w = num;
__instance.generatorMatrix[__instance.generatorCount] = val;
__instance.generatorCount++;
for (int j = 1; j <= num4; j++)
{
double num5 = (double)j * Math.PI / (double)num4;
val.x = 0f;
val.y = (float)(num3 * Math.Cos(num5));
val.z = (float)(num3 * Math.Sin(num5));
val.w = num;
__instance.generatorMatrix[__instance.generatorCount] = val;
__instance.generatorCount++;
double num6 = num3 * Math.Sin(num5);
int num7 = (int)Math.Ceiling(Math.PI * num6 * 2.0 / (2.0 * num2));
for (int k = 1; k < num7; k++)
{
double num8 = (double)k * 2.0 * Math.PI / (double)num7;
val.x = (float)(num6 * Math.Sin(num8));
val.z = (float)(num6 * Math.Cos(num8));
__instance.generatorMatrix[__instance.generatorCount] = val;
__instance.generatorCount++;
}
}
}
}