using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Landfall.TABS;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Tabs Poof Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Tabs Poof Mod")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("8aad4f38-2ad4-4206-bf0b-7d28fb6d5c2e")]
[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")]
[BepInPlugin("bayturtleking.tabs.smelter", "Smelter", "1.1.1")]
public class smeltermod : BaseUnityPlugin
{
public static ConfigEntry<bool> enablemod;
public static ConfigEntry<int> shadowquality;
public static ConfigEntry<float> shadowdistance;
public static ConfigEntry<int> maxparticles;
public static ConfigEntry<float> lodbias;
public static ConfigEntry<bool> disableantialiasing;
public static ConfigEntry<bool> unlockframerate;
public static ConfigEntry<int> targetframerate;
public static ConfigEntry<float> sleepthreshold;
public static ConfigEntry<bool> reducetexturequality;
public static ConfigEntry<bool> enableunitculling;
public static ConfigEntry<float> animatorcullrange;
public static ConfigEntry<bool> enableparticleculling;
public static ConfigEntry<float> particlecullrange;
public static ConfigEntry<bool> enablecameraopt;
public static ConfigEntry<float> camerafarclip;
public static ConfigEntry<KeyCode> menukey;
public static ConfigEntry<bool> removedeadbodies;
public static smeltermod instance;
private bool showmenu;
private Rect windowrect = new Rect(20f, 20f, 280f, 340f);
private Texture2D windowbg;
private bool showadvanced;
private int selectedpreset;
private GUIStyle windowstylezzz;
private void Awake()
{
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Expected O, but got Unknown
//IL_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
instance = this;
enablemod = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Mod", true, "Master toggle. When off, Smelter forces vanilla quality settings every frame. To fully disable, disable or uninstall the mod then restart the game.");
shadowquality = ((BaseUnityPlugin)this).Config.Bind<int>("Shadows", "Shadow Quality", 2, "0 = Off, 1 = Hard Shadows Only, 2 = All Shadows.");
shadowdistance = ((BaseUnityPlugin)this).Config.Bind<float>("Shadows", "Shadow Distance", 80f, "Hidden shadow render distance.");
maxparticles = ((BaseUnityPlugin)this).Config.Bind<int>("Particles", "Max Particles", 1000, "Hidden global particle cap.");
lodbias = ((BaseUnityPlugin)this).Config.Bind<float>("LOD", "LOD Bias", 0.6f, "Hidden Level-of-Detail bias. Lower = objects lose detail sooner.");
disableantialiasing = ((BaseUnityPlugin)this).Config.Bind<bool>("Rendering", "Disable Anti-Aliasing", false, "Turns anti aliasing off.");
unlockframerate = ((BaseUnityPlugin)this).Config.Bind<bool>("Performance", "Unlock Framerate", false, "Removes the built in target framerate cap.");
targetframerate = ((BaseUnityPlugin)this).Config.Bind<int>("Performance", "Target Framerate", -1, "Framerate cap used when unlocked. -1 = uncapped.");
sleepthreshold = ((BaseUnityPlugin)this).Config.Bind<float>("Physics", "Ragdoll Sleep Threshold", 0.005f, "Hidden rigidbody sleep threshold. Higher = ragdolls settle (not sure if that's the right word) faster.");
reducetexturequality = ((BaseUnityPlugin)this).Config.Bind<bool>("Rendering", "Reduce Texture Quality", false, "Lowers texture resolution for extra performance.");
enableunitculling = ((BaseUnityPlugin)this).Config.Bind<bool>("Culling", "Enable Unit Culling", false, "Disables animators on units past the cull range.");
animatorcullrange = ((BaseUnityPlugin)this).Config.Bind<float>("Culling", "Animator Cull Range", 50f, "Distance after which unit animators are disabled.");
enableparticleculling = ((BaseUnityPlugin)this).Config.Bind<bool>("Culling", "Enable Particle Culling", false, "Stops particle systems past the cull range.");
particlecullrange = ((BaseUnityPlugin)this).Config.Bind<float>("Culling", "Particle Cull Range", 80f, "Distance after which particle systems are stopped.");
enablecameraopt = ((BaseUnityPlugin)this).Config.Bind<bool>("Culling", "Enable Camera Optimization", false, "Overrides the camera far clip plane (map renderdistance).");
camerafarclip = ((BaseUnityPlugin)this).Config.Bind<float>("Culling", "Map Render Distance", 800f, "Hidden camera far clip plane.");
menukey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Menu Key", (KeyCode)291, "Key used to open the Smelter settings panel.");
removedeadbodies = ((BaseUnityPlugin)this).Config.Bind<bool>("Performance", "Remove Dead Bodies", false, "Destroys dead bodies shortly after death. Don't use this if you have Hide the Evidence installed.");
windowbg = new Texture2D(1, 1);
windowbg.SetPixel(0, 0, new Color(0.08f, 0.08f, 0.08f, 0.92f));
windowbg.Apply();
new Harmony("bayturtleking.tabs.smelter").PatchAll();
((MonoBehaviour)this).StartCoroutine(cullingloop());
((BaseUnityPlugin)this).Logger.LogInfo((object)"Smelter loaded, hip hip hooray.");
}
private void Update()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(menukey.Value))
{
showmenu = !showmenu;
}
if (!enablemod.Value)
{
QualitySettings.shadows = (ShadowQuality)2;
QualitySettings.shadowDistance = 150f;
QualitySettings.lodBias = 1f;
QualitySettings.antiAliasing = 2;
QualitySettings.masterTextureLimit = 0;
QualitySettings.vSyncCount = 1;
Application.targetFrameRate = -1;
}
}
private void OnGUI()
{
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected O, but got Unknown
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
if (showmenu)
{
if (windowstylezzz == null)
{
windowstylezzz = new GUIStyle(GUI.skin.window);
windowstylezzz.normal.background = windowbg;
}
windowrect = GUILayout.Window(9001, windowrect, new WindowFunction(drawwindow), "Smelter", windowstylezzz, Array.Empty<GUILayoutOption>());
}
}
private void drawwindow(int id)
{
GUILayout.Label("Smelter (hidden graphics settings)", Array.Empty<GUILayoutOption>());
enablemod.Value = GUILayout.Toggle(enablemod.Value, "Enable Mod", Array.Empty<GUILayoutOption>());
GUILayout.Space(6f);
GUILayout.Label("Presets:", Array.Empty<GUILayoutOption>());
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
if (GUILayout.Button("Potato", Array.Empty<GUILayoutOption>()))
{
selectedpreset = 3;
dothepreset(selectedpreset);
}
if (GUILayout.Button("Low", Array.Empty<GUILayoutOption>()))
{
selectedpreset = 2;
dothepreset(selectedpreset);
}
if (GUILayout.Button("Balanced", Array.Empty<GUILayoutOption>()))
{
selectedpreset = 0;
dothepreset(selectedpreset);
}
GUILayout.EndHorizontal();
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
if (GUILayout.Button("High", Array.Empty<GUILayoutOption>()))
{
selectedpreset = 4;
dothepreset(selectedpreset);
}
if (GUILayout.Button("Ultra", Array.Empty<GUILayoutOption>()))
{
selectedpreset = 6;
dothepreset(selectedpreset);
}
if (GUILayout.Button("Default", Array.Empty<GUILayoutOption>()))
{
selectedpreset = 7;
dothepreset(selectedpreset);
}
GUILayout.EndHorizontal();
GUILayout.Space(6f);
showadvanced = GUILayout.Toggle(showadvanced, "Show Advanced Settings", Array.Empty<GUILayoutOption>());
if (showadvanced)
{
GUILayout.Label("Shadow Distance: " + shadowdistance.Value.ToString("F0"), Array.Empty<GUILayoutOption>());
shadowdistance.Value = GUILayout.HorizontalSlider(shadowdistance.Value, 0f, 1000f, Array.Empty<GUILayoutOption>());
GUILayout.Label("LOD Bias: " + lodbias.Value.ToString("F2"), Array.Empty<GUILayoutOption>());
lodbias.Value = GUILayout.HorizontalSlider(lodbias.Value, 0.05f, 3f, Array.Empty<GUILayoutOption>());
GUILayout.Label("Max Particles: " + maxparticles.Value, Array.Empty<GUILayoutOption>());
maxparticles.Value = (int)GUILayout.HorizontalSlider((float)maxparticles.Value, 50f, 5000f, Array.Empty<GUILayoutOption>());
GUILayout.Label("Map Render Distance: " + camerafarclip.Value.ToString("F0"), Array.Empty<GUILayoutOption>());
camerafarclip.Value = GUILayout.HorizontalSlider(camerafarclip.Value, 50f, 3000f, Array.Empty<GUILayoutOption>());
GUILayout.Label("Ragdoll Sleep Threshold: " + sleepthreshold.Value.ToString("F3"), Array.Empty<GUILayoutOption>());
sleepthreshold.Value = GUILayout.HorizontalSlider(sleepthreshold.Value, 0.001f, 0.05f, Array.Empty<GUILayoutOption>());
disableantialiasing.Value = GUILayout.Toggle(disableantialiasing.Value, "Disable Anti-Aliasing", Array.Empty<GUILayoutOption>());
reducetexturequality.Value = GUILayout.Toggle(reducetexturequality.Value, "Reduce Texture Quality", Array.Empty<GUILayoutOption>());
unlockframerate.Value = GUILayout.Toggle(unlockframerate.Value, "Unlock Framerate", Array.Empty<GUILayoutOption>());
if (unlockframerate.Value)
{
GUILayout.Label("Target Framerate: " + targetframerate.Value, Array.Empty<GUILayoutOption>());
targetframerate.Value = (int)GUILayout.HorizontalSlider((float)targetframerate.Value, -1f, 300f, Array.Empty<GUILayoutOption>());
}
enableunitculling.Value = GUILayout.Toggle(enableunitculling.Value, "Cull Distant Unit Animators", Array.Empty<GUILayoutOption>());
if (enableunitculling.Value)
{
animatorcullrange.Value = GUILayout.HorizontalSlider(animatorcullrange.Value, 5f, 500f, Array.Empty<GUILayoutOption>());
}
enableparticleculling.Value = GUILayout.Toggle(enableparticleculling.Value, "Cull Distant Particle Systems", Array.Empty<GUILayoutOption>());
if (enableparticleculling.Value)
{
particlecullrange.Value = GUILayout.HorizontalSlider(particlecullrange.Value, 5f, 500f, Array.Empty<GUILayoutOption>());
}
enablecameraopt.Value = GUILayout.Toggle(enablecameraopt.Value, "Enable Camera Optimization", Array.Empty<GUILayoutOption>());
}
GUILayout.Space(6f);
removedeadbodies.Value = GUILayout.Toggle(removedeadbodies.Value, "Remove Dead Bodies (no particle effect)", Array.Empty<GUILayoutOption>());
GUILayout.Space(10f);
if (GUILayout.Button("Apply Settings", Array.Empty<GUILayoutOption>()))
{
basicsettingspartboooooo();
}
GUI.DragWindow();
}
private void dothepreset(int preset)
{
switch (preset)
{
case 0:
shadowquality.Value = 2;
shadowdistance.Value = 80f;
lodbias.Value = 0.6f;
maxparticles.Value = 1000;
animatorcullrange.Value = 50f;
particlecullrange.Value = 80f;
camerafarclip.Value = 800f;
disableantialiasing.Value = false;
reducetexturequality.Value = false;
removedeadbodies.Value = false;
break;
case 1:
shadowquality.Value = 1;
shadowdistance.Value = 55f;
lodbias.Value = 0.4f;
maxparticles.Value = 500;
animatorcullrange.Value = 35f;
particlecullrange.Value = 60f;
camerafarclip.Value = 500f;
disableantialiasing.Value = false;
reducetexturequality.Value = false;
removedeadbodies.Value = true;
break;
case 2:
shadowquality.Value = 0;
shadowdistance.Value = 30f;
lodbias.Value = 0.3f;
maxparticles.Value = 100;
animatorcullrange.Value = 15f;
particlecullrange.Value = 20f;
camerafarclip.Value = 150f;
disableantialiasing.Value = true;
reducetexturequality.Value = true;
removedeadbodies.Value = true;
break;
case 3:
shadowquality.Value = 0;
shadowdistance.Value = 10f;
lodbias.Value = 0.1f;
maxparticles.Value = 100;
animatorcullrange.Value = 10f;
particlecullrange.Value = 20f;
camerafarclip.Value = 80f;
disableantialiasing.Value = true;
reducetexturequality.Value = true;
removedeadbodies.Value = true;
break;
case 4:
shadowquality.Value = 2;
shadowdistance.Value = 120f;
lodbias.Value = 1.2f;
maxparticles.Value = 1500;
animatorcullrange.Value = 70f;
particlecullrange.Value = 100f;
camerafarclip.Value = 1000f;
disableantialiasing.Value = false;
reducetexturequality.Value = false;
removedeadbodies.Value = false;
sleepthreshold.Value = 0.02f;
break;
case 5:
shadowquality.Value = 2;
shadowdistance.Value = 200f;
lodbias.Value = 2f;
maxparticles.Value = 3000;
animatorcullrange.Value = 100f;
particlecullrange.Value = 150f;
camerafarclip.Value = 1500f;
disableantialiasing.Value = false;
reducetexturequality.Value = false;
removedeadbodies.Value = false;
sleepthreshold.Value = 0.005f;
break;
case 6:
shadowquality.Value = 2;
shadowdistance.Value = 1000f;
lodbias.Value = 3f;
maxparticles.Value = 5000;
animatorcullrange.Value = 200f;
particlecullrange.Value = 300f;
camerafarclip.Value = 3000f;
disableantialiasing.Value = false;
reducetexturequality.Value = false;
removedeadbodies.Value = false;
sleepthreshold.Value = 0.001f;
break;
case 7:
shadowquality.Value = 2;
shadowdistance.Value = 150f;
lodbias.Value = 1f;
maxparticles.Value = 1000;
animatorcullrange.Value = 100f;
particlecullrange.Value = 100f;
camerafarclip.Value = 1000f;
disableantialiasing.Value = false;
reducetexturequality.Value = false;
removedeadbodies.Value = false;
sleepthreshold.Value = 0.005f;
break;
}
}
private void basicsettingspartboooooo()
{
switch (shadowquality.Value)
{
case 0:
QualitySettings.shadows = (ShadowQuality)0;
break;
case 1:
QualitySettings.shadows = (ShadowQuality)1;
break;
default:
QualitySettings.shadows = (ShadowQuality)2;
break;
}
QualitySettings.shadowDistance = shadowdistance.Value;
QualitySettings.lodBias = lodbias.Value;
if (disableantialiasing.Value)
{
QualitySettings.antiAliasing = 0;
}
if (reducetexturequality.Value)
{
QualitySettings.masterTextureLimit = 1;
}
if (unlockframerate.Value)
{
QualitySettings.vSyncCount = 0;
Application.targetFrameRate = ((targetframerate.Value > 0) ? targetframerate.Value : (-1));
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"Smelter -- applied new settings.");
}
private IEnumerator cullingloop()
{
while (true)
{
if (enablemod.Value)
{
Camera main = Camera.main;
if ((Object)(object)main != (Object)null)
{
if (enablecameraopt.Value)
{
main.farClipPlane = Mathf.Max(camerafarclip.Value, 50f);
}
if (enableunitculling.Value)
{
Animator[] array = Object.FindObjectsOfType<Animator>();
foreach (Animator val in array)
{
if (!((Object)(object)((Component)val).GetComponentInParent<Unit>() == (Object)null))
{
float num = Vector3.Distance(((Component)main).transform.position, ((Component)val).transform.position);
((Behaviour)val).enabled = num <= animatorcullrange.Value;
}
}
}
if (enableparticleculling.Value)
{
ParticleSystem[] array2 = Object.FindObjectsOfType<ParticleSystem>();
foreach (ParticleSystem val2 in array2)
{
if (Vector3.Distance(((Component)main).transform.position, ((Component)val2).transform.position) > particlecullrange.Value)
{
val2.Stop();
}
}
}
}
}
yield return (object)new WaitForSeconds(0.5f);
}
}
}
[HarmonyPatch(typeof(ParticleSystem), "Play", new Type[] { typeof(bool) })]
public class particlestuff
{
private static void Prefix(ParticleSystem __instance)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
if (smeltermod.enablemod.Value)
{
MainModule main = __instance.main;
((MainModule)(ref main)).maxParticles = Mathf.Min(((MainModule)(ref main)).maxParticles, smeltermod.maxparticles.Value);
}
}
}
[HarmonyPatch(typeof(Rigidbody), "WakeUp")]
public class patchrigidbodywakeup
{
private static void Prefix(Rigidbody __instance)
{
if (smeltermod.enablemod.Value)
{
__instance.sleepThreshold = smeltermod.sleepthreshold.Value;
}
}
}
[HarmonyPatch(typeof(HealthHandler), "Die", new Type[] { typeof(Unit) })]
public class patchunitdie
{
private static void Postfix(HealthHandler __instance)
{
if (smeltermod.enablemod.Value && smeltermod.removedeadbodies.Value)
{
Object.Destroy((Object)(object)((Component)((Component)__instance).transform.root).gameObject, 1.5f);
}
}
}