using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AlterTheFog")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AlterTheFog")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("94de961c-32a1-4705-bca2-ff82925ebe9f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace AlterTheFog;
[BepInPlugin("com.tinysquid.alterthefog", "alterthefog", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(CombatSettings), "SetDefault")]
private class PatchDarkFogDefault
{
public static bool Prefix(ref CombatSettings __instance)
{
__instance.aggressiveness = aggressiveness.Value;
__instance.initialLevel = initialLevel.Value;
__instance.initialGrowth = initialGrowth.Value;
__instance.initialColonize = initialColonize.Value;
__instance.maxDensity = maxDensity.Value;
__instance.growthSpeedFactor = growthSpeedFactor.Value;
__instance.powerThreatFactor = powerThreatFactor.Value;
__instance.battleThreatFactor = battleThreatFactor.Value;
__instance.battleExpFactor = battleExpFactor.Value;
return false;
}
}
[HarmonyPatch(typeof(CombatSettings), "Export")]
private class PatchDarkFogExport
{
public static bool Prefix(BinaryWriter w)
{
w.Write(0);
w.Write(aggressiveness.Value);
w.Write(initialLevel.Value);
w.Write(initialGrowth.Value);
w.Write(initialColonize.Value);
w.Write(maxDensity.Value);
w.Write(growthSpeedFactor.Value);
w.Write(powerThreatFactor.Value);
w.Write(battleThreatFactor.Value);
w.Write(battleExpFactor.Value);
return false;
}
}
public const string PLUGIN_GUID = "com.tinysquid.alterthefog";
public const string PLUGIN_NAME = "alterthefog";
public const string PLUGIN_VERSION = "1.0.0";
private static Harmony harmony;
private static ConfigEntry<float> aggressiveness;
private static ConfigEntry<float> initialLevel;
private static ConfigEntry<float> initialGrowth;
private static ConfigEntry<float> initialColonize;
private static ConfigEntry<float> maxDensity;
private static ConfigEntry<float> growthSpeedFactor;
private static ConfigEntry<float> powerThreatFactor;
private static ConfigEntry<float> battleThreatFactor;
private static ConfigEntry<float> battleExpFactor;
public void Awake()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
LoadConfig();
harmony = new Harmony("com.tinysquid.alterthefog");
ApplyPatches();
}
public void OnDestroy()
{
RevertPatches();
}
public void LoadConfig()
{
aggressiveness = ((BaseUnityPlugin)this).Config.Bind<float>("Difficulty", "aggressiveness", 1f, "Original ranges are -1 to 3");
initialLevel = ((BaseUnityPlugin)this).Config.Bind<float>("Difficulty", "initialLevel", 0f, "Original ranges are 0 to 10");
initialGrowth = ((BaseUnityPlugin)this).Config.Bind<float>("Difficulty", "initialGrowth", 1f, "Original ranges are 0 to 6");
initialColonize = ((BaseUnityPlugin)this).Config.Bind<float>("Difficulty", "initialColonize", 1f, "Original ranges are 0 to 6");
maxDensity = ((BaseUnityPlugin)this).Config.Bind<float>("Difficulty", "maxDensity", 1f, "Original ranges are 0 to 4");
growthSpeedFactor = ((BaseUnityPlugin)this).Config.Bind<float>("Difficulty", "growthSpeedFactor", 1f, "Original ranges are 0 to 4");
powerThreatFactor = ((BaseUnityPlugin)this).Config.Bind<float>("Difficulty", "powerThreatFactor", 1f, "Original ranges are 0 to 8");
battleThreatFactor = ((BaseUnityPlugin)this).Config.Bind<float>("Difficulty", "battleThreatFactor", 1f, "Original ranges are 0 to 8");
battleExpFactor = ((BaseUnityPlugin)this).Config.Bind<float>("Difficulty", "battleExpFactor", 1f, "Original ranges are 0 to 8");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded configuration values.");
}
public void ApplyPatches()
{
try
{
harmony.PatchAll(typeof(PatchDarkFogDefault));
harmony.PatchAll(typeof(PatchDarkFogExport));
((BaseUnityPlugin)this).Logger.LogInfo((object)"Patches applied!");
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Patch failed with exception: " + ex.ToString()));
}
}
public void RevertPatches()
{
harmony.UnpatchSelf();
}
}