using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.Json;
using System.Text.Json.Serialization;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using GameData;
using Gear;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Reflection;
using Microsoft.CodeAnalysis;
using Player;
using ReTFO.ThermalOverlay.Config;
using ReTFO.ThermalOverlay.Configurers;
using ReTFO.ThermalOverlay.Factories;
using ReTFO.ThermalOverlay.Interfaces;
using SNetwork;
using UnityEngine;
using UnityEngine.Rendering;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ThermalOverlay")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+046c9875436d9d3556e7bba72fec5b166750e47c")]
[assembly: AssemblyProduct("ThermalOverlay")]
[assembly: AssemblyTitle("ThermalOverlay")]
[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 ReTFO.ThermalOverlay
{
public class AssetBundle
{
public const string AssetBundleName = "thermaloverlay";
public static string FileOffset = Path.Combine("Assets", "ThermalOverlay");
private Shader? _thermalOverlayShader;
public static string AssetDirectory => Path.Combine(Path.GetDirectoryName(Paths.PluginPath) ?? string.Empty, FileOffset);
public static string AssetBundlePath => Path.Combine(AssetDirectory, "thermaloverlay");
public Shader? ThermalOverlayShader
{
get
{
return _thermalOverlayShader ?? (_thermalOverlayShader = this.TryLoadAsset<Shader>("Unlit_HolographicSight_ThermalOverlay.shader"));
}
set
{
_thermalOverlayShader = value ?? _thermalOverlayShader;
}
}
public T? TryLoadAsset<T>(string assetName) where T : Object
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Expected O, but got Unknown
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Expected O, but got Unknown
AssetBundle val = AssetBundle.LoadFromFile(AssetBundlePath);
bool flag = default(bool);
if ((Object)(object)val == (Object)null)
{
Plugin plugin = Plugin.TryGet();
Plugin plugin2 = plugin;
if (plugin2 != null)
{
ManualLogSource log = ((BasePlugin)plugin2).Log;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(53, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to load asset bundle ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("thermaloverlay");
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\n - Expected location: \"");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(AssetBundlePath);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\"");
}
log.LogError(val2);
}
return default(T);
}
Object val3 = (Object)(object)((val != null) ? val.LoadAsset(assetName) : null);
if (val3 == null)
{
Plugin plugin3 = Plugin.TryGet();
if (plugin3 != null)
{
ManualLogSource log2 = ((BasePlugin)plugin3).Log;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(34, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to load ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(assetName);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" from asset bundle ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("thermaloverlay");
}
log2.LogError(val2);
}
}
T val4 = ((val3 != null) ? ((Il2CppObjectBase)val3).TryCast<T>() : default(T));
if (val4 == null && val3 != null)
{
Plugin plugin4 = Plugin.TryGet();
if (plugin4 != null)
{
ManualLogSource log3 = ((BasePlugin)plugin4).Log;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(50, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to convert ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(assetName);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" to type ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(typeof(T).Name);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" because it is of type ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((MemberInfo)val3.GetIl2CppType()).Name);
}
log3.LogError(val2);
}
}
return val4;
}
public bool TryLoadAsset<T>(string assetName, [NotNullWhen(true)] out T? result) where T : Object
{
result = TryLoadAsset<T>(assetName);
return result != null;
}
public T LoadAsset<T>(string assetName) where T : Object
{
return TryLoadAsset<T>(assetName) ?? throw new NullReferenceException("Failed to load asset " + assetName);
}
}
[HarmonyPatch(typeof(PlayerBackpack))]
internal static class ItemSpawnPatcher
{
[HarmonyPatch("CheckAndCreateBackpackItem")]
[HarmonyPostfix]
internal static void OnCreate(PlayerBackpack __instance, ref BackpackItem bpItem, ItemEquippable gearItem, GearIDRange gearIDRange)
{
Plugin.Get().ApplyThermalConfig(gearItem, __instance.Owner);
}
}
[BepInPlugin("RoboRyGuy.ThermalOverlay", "ThermalOverlay", "1.0.0")]
[BepInProcess("GTFO.exe")]
public class Plugin : BasePlugin
{
public const string Name = "ThermalOverlay";
public const string Author = "RoboRyGuy";
public const string GUID = "RoboRyGuy.ThermalOverlay";
public const string Version = "1.0.0";
private static Plugin? _plugin;
protected Harmony harmony = new Harmony("RoboRyGuy.ThermalOverlay");
public const string OverlayGameObjectName = "Thermal Overlay";
public AssetBundle AssetBundle { get; private set; } = new AssetBundle();
public ConfigManager ConfigManager { get; private set; } = new ConfigManager();
public FactoryManager FactoryManager { get; private set; } = new FactoryManager();
public static Plugin Get()
{
return TryGet() ?? throw new NullReferenceException("Tried to retrieve ThermalOverlay, but it was not loaded!");
}
public static Plugin? TryGet()
{
return _plugin ?? (_plugin = ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.FirstOrDefault((KeyValuePair<string, PluginInfo> p) => p.Key == "RoboRyGuy.ThermalOverlay").Value.Instance as Plugin);
}
public static bool TryGet([NotNullWhen(true)] out Plugin? plugin)
{
plugin = TryGet();
return plugin != null;
}
public override void Load()
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
_plugin = this;
harmony.PatchAll(typeof(ItemSpawnPatcher));
harmony.PatchAll(((object)this).GetType());
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(11, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("RoboRyGuy.ThermalOverlay");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
}
public override bool Unload()
{
harmony.UnpatchSelf();
return true;
}
public void ApplyThermalConfig(ItemEquippable item, SNet_Player owner)
{
if (!item.m_gearSpawnComplete)
{
return;
}
uint checksum = item.GearIDRange.GetChecksum();
if (!ConfigManager.UserConfigs.EnableEverything && !ConfigManager.UserConfigs.EnabledGear.Contains(checksum))
{
return;
}
ThermalConfig valueOrDefault = ConfigManager.ItemConfigs.GetValueOrDefault(checksum);
ConversionContext context = new ConversionContext(this, item, valueOrDefault);
FactoryManager.RunThermalConverter(valueOrDefault?.Handler, context);
if (!ConfigManager.UserConfigs.MakeGunsCold || !owner.IsLocal)
{
return;
}
foreach (Renderer componentsInChild in ((Component)item).GetComponentsInChildren<Renderer>())
{
if (componentsInChild.sharedMaterial.HasProperty("_ShadingType"))
{
componentsInChild.sharedMaterial.SetFloat("_ShadingType", 0f);
}
}
}
}
}
namespace ReTFO.ThermalOverlay.Interfaces
{
public interface IMaterialGenerator
{
Material GenerateMaterial(string? thisName, ConversionContext context);
}
public interface IMeshGenerator
{
Mesh GenerateMesh(string? thisName, ConversionContext context);
}
public interface ISightConverter
{
bool ConvertSight(string? thisName, ConversionContext context);
}
public interface ITextureGenerator
{
Texture GenerateTexture(string? thisName, ConversionContext context);
}
public interface IThermalConverter
{
void ConvertItem(string? thisName, ConversionContext context);
}
}
namespace ReTFO.ThermalOverlay.Configurers
{
public class ThermalConverter_Standard : IThermalConverter
{
public const string Name = "Standard";
public virtual void ConvertItem(string? thisName, ConversionContext context)
{
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Expected O, but got Unknown
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Expected O, but got Unknown
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Expected O, but got Unknown
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_0260: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Expected O, but got Unknown
ItemEquippable item = context.Item;
GameObject sightPart = context.Item.GearPartHolder.SightPart;
Renderer val = ((sightPart != null) ? ((IEnumerable<Renderer>)sightPart.GetComponentsInChildren<Renderer>()).FirstOrDefault((Func<Renderer, bool>)((Renderer r) => r.sharedMaterial.HasProperty("_ReticuleA"))) : null);
bool flag = false;
bool flag3 = default(bool);
BepInExDebugLogInterpolatedStringHandler val2;
if ((Object)(object)val != (Object)null)
{
context.Renderer = val;
bool flag2 = ((Object)val.sharedMaterial.shader).name.Contains("thermal", StringComparison.OrdinalIgnoreCase);
flag = context.Plugin.FactoryManager.RunSightConverter("Standard/" + (flag2 ? "Thermal" : "NonThermal"), context);
if (flag)
{
ManualLogSource log = context.Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(39, 1, ref flag3);
if (flag3)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Successfully converted sight on item \"");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)item).name);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\"");
}
log.LogDebug(val2);
}
}
if (flag)
{
return;
}
Transform obj = ((Component)item).transform.Find("Thermal Overlay");
GameObject val3 = ((obj != null) ? ((Component)obj).gameObject : null);
if ((Object)(object)val3 != (Object)null)
{
ManualLogSource log2 = context.Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(73, 1, ref flag3);
if (flag3)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Skipping overlay creation on item \"");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)item).name);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\" due to overlay already being created");
}
log2.LogDebug(val2);
return;
}
val3 = new GameObject
{
name = "Thermal Overlay",
hideFlags = (HideFlags)52
};
MeshFilter val4 = val3.AddComponent<MeshFilter>();
val4.mesh = context.Factory.RunMeshGenerator(context.Config?.OverlayConfig.MeshGenerator, context);
Transform sightLookAlign = context.Item.SightLookAlign;
int childCount = sightLookAlign.GetChildCount();
float num = 0f;
for (int i = 0; i < childCount; i++)
{
Transform child = sightLookAlign.GetChild(i);
num = Mathf.Min(num, child.localPosition.z);
}
val3.transform.SetParent(sightLookAlign);
val3.transform.localPosition = (context.Config?.OverlayConfig.MeshOffset ?? Vector3.zero) + num * Vector3.forward;
val3.transform.localRotation = context.Config?.OverlayConfig.MeshRotation ?? Quaternion.identity;
val3.transform.localScale = context.Config?.OverlayConfig.MeshScale ?? Vector3.one;
context.Renderer = (Renderer?)(object)val3.AddComponent<MeshRenderer>();
context.Renderer.sharedMaterial = context.Factory.RunMaterialGenerator(context.Config?.MaterialConfig.Generator, context);
context.Renderer.sharedMaterial.mainTexture = context.Factory.RunTextureGenerator("Bloom", context);
context.Renderer.sharedMaterial.SetFloat("_CenterWhenUnscope", 0f);
ManualLogSource log3 = context.Log;
val2 = new BepInExDebugLogInterpolatedStringHandler(37, 1, ref flag3);
if (flag3)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Successfully added overlay to item \"");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)item).name);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\"");
}
log3.LogDebug(val2);
}
}
}
namespace ReTFO.ThermalOverlay.Factories
{
public class ConversionContext
{
public Plugin Plugin;
public ItemEquippable Item;
public Renderer? Renderer;
public ThermalConfig? Config;
public ManualLogSource Log => ((BasePlugin)Plugin).Log;
public FactoryManager Factory => Plugin.FactoryManager;
public ConversionContext(Plugin plugin, ItemEquippable item)
{
Plugin = plugin;
Item = item;
}
public ConversionContext(Plugin plugin, ItemEquippable item, ThermalConfig? config)
{
Plugin = plugin;
Item = item;
Config = config;
}
}
public class FactoryManager
{
private SortedList<string, IThermalConverter> thermalConverters = new SortedList<string, IThermalConverter>();
private int defaultThermalConverter = -1;
private SortedList<string, ISightConverter> sightConverters = new SortedList<string, ISightConverter>();
private int defaultSightConverter = -1;
private SortedList<string, IMeshGenerator> meshGenerators = new SortedList<string, IMeshGenerator>();
private int defaultMeshGenerator = -1;
private SortedList<string, IMaterialGenerator> materialGenerators = new SortedList<string, IMaterialGenerator>();
private int defaultMaterialGenerator = -1;
private SortedList<string, ITextureGenerator> TextureGenerators = new SortedList<string, ITextureGenerator>();
private int defaultTextureGenerator = -1;
public FactoryManager()
{
AddThermalConverter("Standard", new ThermalConverter_Standard(), makeDefault: true);
AddSightConverter("Standard", new SightConverter_Standard(), makeDefault: true);
AddMaterialGenerator("Standard", new MaterialGenerator_Standard(), makeDefault: true);
AddMeshGenerator("Plane", new MeshGenerator_Plane(), makeDefault: true);
AddTextureGenerator("black", new TextureGenerator_Simple(() => (Texture)(object)Texture2D.blackTexture));
AddTextureGenerator("gray", new TextureGenerator_Simple(() => (Texture)(object)Texture2D.grayTexture));
AddTextureGenerator("linearGray", new TextureGenerator_Simple(() => (Texture)(object)Texture2D.linearGrayTexture));
AddTextureGenerator("normal", new TextureGenerator_Simple(() => (Texture)(object)Texture2D.normalTexture));
AddTextureGenerator("red", new TextureGenerator_Simple(() => (Texture)(object)Texture2D.redTexture));
AddTextureGenerator("white", new TextureGenerator_Simple(() => (Texture)(object)Texture2D.whiteTexture));
AddTextureGenerator("Load", new TextureGenerator_Load());
AddTextureGenerator("Bloom", new TextureGenerator_Bloom(), makeDefault: true);
}
[return: NotNullIfNotNull("name")]
public static string? BaseName(string? name)
{
int num = name?.IndexOf('/') ?? (-1);
if (num > 0)
{
return name.Substring(0, num);
}
return name;
}
public void AddThermalConverter(string name, IThermalConverter converter, bool makeDefault = false)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
name = BaseName(name);
if (thermalConverters.ContainsKey(name))
{
Plugin plugin = Plugin.TryGet();
if (plugin != null)
{
ManualLogSource log = ((BasePlugin)plugin).Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(27, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Overwriting ThermalConvert ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
}
log.LogWarning(val);
}
}
thermalConverters[name] = converter;
if (makeDefault)
{
defaultThermalConverter = thermalConverters.IndexOfKey(name);
}
}
public IThermalConverter GetDefaultThermalConverter()
{
return thermalConverters.ElementAt(defaultThermalConverter).Value;
}
public bool TryGetThermalConverter(string? name, out IThermalConverter converter)
{
int num = ((name != null) ? thermalConverters.IndexOfKey(BaseName(name)) : (-1));
if (num >= 0)
{
converter = thermalConverters.ElementAt(num).Value;
}
else
{
converter = GetDefaultThermalConverter();
}
return num >= 0;
}
public IThermalConverter GetThermalConverter(string? name)
{
TryGetThermalConverter(name, out IThermalConverter converter);
return converter;
}
public void RunThermalConverter(string? name, ConversionContext context)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
if (!TryGetThermalConverter(name, out IThermalConverter converter) && name != null)
{
ManualLogSource log = context.Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(50, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to find thermal converter \"");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\", using default");
}
log.LogWarning(val);
}
converter.ConvertItem(name, context);
}
public void AddSightConverter(string name, ISightConverter converter, bool makeDefault = false)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
name = BaseName(name);
if (sightConverters.ContainsKey(name))
{
Plugin plugin = Plugin.TryGet();
if (plugin != null)
{
ManualLogSource log = ((BasePlugin)plugin).Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(27, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Overwriting SightConverter ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
}
log.LogWarning(val);
}
}
sightConverters[name] = converter;
if (makeDefault)
{
defaultSightConverter = sightConverters.IndexOfKey(name);
}
}
public ISightConverter GetDefaultSightConverter()
{
return sightConverters.ElementAt(defaultSightConverter).Value;
}
public bool TryGetSightConverter(string? name, out ISightConverter converter)
{
int num = ((name != null) ? sightConverters.IndexOfKey(BaseName(name)) : (-1));
if (num >= 0)
{
converter = sightConverters.ElementAt(num).Value;
}
else
{
converter = GetDefaultSightConverter();
}
return num >= 0;
}
public ISightConverter GetSightConverter(string? name)
{
TryGetSightConverter(name, out ISightConverter converter);
return converter;
}
public bool RunSightConverter(string? name, ConversionContext context)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
if (!TryGetSightConverter(name, out ISightConverter converter) && name != null)
{
ManualLogSource log = context.Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(48, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to find sight converter \"");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\", using default");
}
log.LogWarning(val);
}
return converter.ConvertSight(name, context);
}
public void AddMeshGenerator(string name, IMeshGenerator generator, bool makeDefault = false)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
name = BaseName(name);
if (meshGenerators.ContainsKey(name))
{
Plugin plugin = Plugin.TryGet();
if (plugin != null)
{
ManualLogSource log = ((BasePlugin)plugin).Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(26, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Overwriting MeshGenerator ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
}
log.LogWarning(val);
}
}
meshGenerators[name] = generator;
if (makeDefault)
{
defaultMeshGenerator = meshGenerators.IndexOfKey(name);
}
}
public IMeshGenerator GetDefaultMeshGenerator()
{
return meshGenerators.ElementAt(defaultMeshGenerator).Value;
}
public bool TryGetMeshGenerator(string? name, out IMeshGenerator converter)
{
int num = ((name != null) ? meshGenerators.IndexOfKey(BaseName(name)) : (-1));
if (num >= 0)
{
converter = meshGenerators.ElementAt(num).Value;
}
else
{
converter = GetDefaultMeshGenerator();
}
return num >= 0;
}
public IMeshGenerator GetMeshGenerator(string? name)
{
TryGetMeshGenerator(name, out IMeshGenerator converter);
return converter;
}
public Mesh RunMeshGenerator(string? name, ConversionContext context)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
if (!TryGetMeshGenerator(name, out IMeshGenerator converter) && name != null)
{
ManualLogSource log = context.Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(47, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to find mesh generator \"");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\", using default");
}
log.LogWarning(val);
}
return converter.GenerateMesh(name, context);
}
public void AddMaterialGenerator(string name, IMaterialGenerator generator, bool makeDefault = false)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
name = BaseName(name);
if (materialGenerators.ContainsKey(name))
{
Plugin plugin = Plugin.TryGet();
if (plugin != null)
{
ManualLogSource log = ((BasePlugin)plugin).Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(30, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Overwriting MaterialGenerator ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
}
log.LogWarning(val);
}
}
materialGenerators[name] = generator;
if (makeDefault)
{
defaultMaterialGenerator = materialGenerators.IndexOfKey(name);
}
}
public IMaterialGenerator GetDefaultMaterialGenerator()
{
return materialGenerators.ElementAt(defaultMaterialGenerator).Value;
}
public bool TryGetMaterialGenerator(string? name, out IMaterialGenerator converter)
{
int num = ((name != null) ? materialGenerators.IndexOfKey(BaseName(name)) : (-1));
if (num >= 0)
{
converter = materialGenerators.ElementAt(num).Value;
}
else
{
converter = GetDefaultMaterialGenerator();
}
return num >= 0;
}
public IMaterialGenerator GetMaterialGenerator(string? name)
{
TryGetMaterialGenerator(name, out IMaterialGenerator converter);
return converter;
}
public Material RunMaterialGenerator(string? name, ConversionContext context)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
if (!TryGetMaterialGenerator(name, out IMaterialGenerator converter) && name != null)
{
ManualLogSource log = context.Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(51, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to find material generator \"");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\", using default");
}
log.LogWarning(val);
}
return converter.GenerateMaterial(name, context);
}
public void AddTextureGenerator(string name, ITextureGenerator generator, bool makeDefault = false)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
name = BaseName(name);
if (TextureGenerators.ContainsKey(name))
{
Plugin plugin = Plugin.TryGet();
if (plugin != null)
{
ManualLogSource log = ((BasePlugin)plugin).Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(29, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Overwriting TextureGenerator ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
}
log.LogWarning(val);
}
}
TextureGenerators[name] = generator;
if (makeDefault)
{
defaultTextureGenerator = TextureGenerators.IndexOfKey(name);
}
}
public ITextureGenerator GetDefaultTextureGenerator()
{
return TextureGenerators.ElementAt(defaultTextureGenerator).Value;
}
public bool TryGetTextureGenerator(string? name, out ITextureGenerator converter)
{
int num = ((name != null) ? TextureGenerators.IndexOfKey(BaseName(name)) : (-1));
if (num >= 0)
{
converter = TextureGenerators.ElementAt(num).Value;
}
else
{
converter = GetDefaultTextureGenerator();
}
return num >= 0;
}
public ITextureGenerator GetTextureGenerator(string? name)
{
TryGetTextureGenerator(name, out ITextureGenerator converter);
return converter;
}
public Texture RunTextureGenerator(string? name, ConversionContext context)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
if (!TryGetTextureGenerator(name, out ITextureGenerator converter) && name != null)
{
ManualLogSource log = context.Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(50, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to find texture generator \"");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(name);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\", using default");
}
log.LogWarning(val);
}
return converter.GenerateTexture(name, context);
}
}
public class MaterialGenerator_Standard : IMaterialGenerator
{
public const string Name = "Standard";
public static readonly MaterialConfig PDWMaterialConfig = new MaterialConfig
{
Zoom = 0.25f,
ScreenIntensity = 0.1f,
HeatTex = "Load/Thremal_Gradient_FLIR.png",
HeatFalloff = 0.03f,
FogFalloff = 0.7f,
AlbedoColorFactor = 0.1f,
OcclusionHeat = 0.25f,
BodyOcclusionHeat = 1f,
DistortionTex = "Load/Scanline.png",
DistortionSpeed = 3f,
DistortionSignal = "Load/ThermalDistortionSignal.png",
DistortionSignalSpeed = 0.025f,
DistortionMin = 0.1f,
DistortionMinShadowEnemies = 0.3f,
DistortionMaxShadowEnemies = 0.9f,
DistortionSignalSpeedShadowEnemies = 0.05f,
ShadowEnemyFresnel = 50f,
ShadowEnemyHeat = 0.6f,
MainTex = "red",
FPSRenderingEnabled = true
};
public static readonly MaterialConfig PRMaterialConfig = new MaterialConfig
{
Zoom = 0.25f,
RatioAdjust = 0.89f,
ScreenIntensity = 0.152f,
HeatTex = "Load/Thremal_Gradient_EVIL.png",
HeatFalloff = 0.01f,
FogFalloff = 0.5f,
BackgroundTemp = 0f,
AmbientColorFactor = 5f,
AlbedoColorFactor = 0.5f,
AmbientTemp = 0.15f,
OcclusionHeat = 0.25f,
BodyOcclusionHeat = 1f,
DistortionTex = "Load/Scanline.png",
DistortionScale = 1f,
DistortionSpeed = 1f,
DistortionSignal = "Load/ThermalDistortionSignal.png",
DistortionSignalSpeed = 0.025f,
DistortionMin = 0.1f,
DistortionMax = 0.4f,
DistortionMinShadowEnemies = 0.3f,
DistortionMaxShadowEnemies = 0.9f,
DistortionSignalSpeedShadowEnemies = 0.05f,
ShadowEnemyFresnel = 50f,
ShadowEnemyHeat = 0.6f,
MainTex = "red",
FPSRenderingEnabled = true
};
public virtual Material GenerateMaterial(string? thisName, ConversionContext context)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Expected O, but got Unknown
Shader thermalOverlayShader = context.Plugin.AssetBundle.ThermalOverlayShader;
if ((Object)(object)thermalOverlayShader == (Object)null)
{
context.Log.LogError((object)"Failed to generate material; overlay shader failed to load");
return new Material(Shader.Find("Hidden/InternalErrorShader"));
}
Material val = new Material(thermalOverlayShader)
{
name = "ThermalOverlay - Thermal Material",
hideFlags = (HideFlags)61
};
bool flag = true;
string text = thisName?.Substring(thisName.IndexOf('/') + 1);
if (text != null && text.Length > 0 && text.Length < thisName.Length)
{
if (text == "PR")
{
flag = false;
}
else if (text != "PDW")
{
ManualLogSource log = context.Log;
bool flag2 = default(bool);
BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(86, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("MaterialGenerator_Standard does not recognize parameter \"");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\" and is treating it as \"PDW\"");
}
log.LogWarning(val2);
}
}
MaterialConfig materialConfig = ((!flag) ? PRMaterialConfig.Clone() : PDWMaterialConfig.Clone());
string value = materialConfig.HeatTex.Value;
materialConfig.HeatTex = value.Substring(0, value.Length - 4) + "_Transparent.png";
materialConfig.ApplyAllToMaterial(val, context);
val.SetFloat("_Zoom", 0f);
val.SetFloat("_OffAngleFade", 0f);
context.Config?.MaterialConfig.ApplyToMaterial(val, context);
return val;
}
public static Vector4 CalcScopeCenter(ItemEquippable item, Transform sight)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: 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_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = sight.InverseTransformPoint(item.SightLookAlign.position);
Vector4 result = default(Vector4);
result.x = val.x;
result.y = val.y;
result.z = val.z;
result.w = 1f;
return result;
}
}
public class MeshGenerator_Plane : IMeshGenerator
{
public const string Name = "Plane";
public virtual Mesh GenerateMesh(string? thisName, ConversionContext context)
{
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Expected O, but got Unknown
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
float num = 0.035f;
string text = thisName?.Substring(thisName.IndexOf('/') + 1);
if (text != null && text.Length > 0 && text.Length < thisName.Length)
{
if (float.TryParse(text, out var result))
{
num *= result;
}
else
{
ManualLogSource log = context.Log;
bool flag = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(55, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plan generator: Unrecognized parameter \"");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\" being ignored");
}
log.LogWarning(val);
}
}
Mesh val2 = new Mesh();
((Object)val2).name = "XY Plane (Generated)";
val2.vertices = Il2CppStructArray<Vector3>.op_Implicit((Vector3[])(object)new Vector3[4]
{
new Vector3(0f - num, num, 0f),
new Vector3(num, num, 0f),
new Vector3(0f - num, 0f - num, 0f),
new Vector3(num, 0f - num, 0f)
});
val2.uv = Il2CppStructArray<Vector2>.op_Implicit((Vector2[])(object)new Vector2[4]
{
new Vector2(0f, 1f),
new Vector2(1f, 1f),
new Vector2(0f, 0f),
new Vector2(1f, 0f)
});
val2.triangles = Il2CppStructArray<int>.op_Implicit(new int[6] { 0, 1, 2, 1, 3, 2 });
Mesh val3 = val2;
val3.RecalculateNormals();
val3.RecalculateTangents();
return val3;
}
}
public class SightConverter_Standard : ISightConverter
{
public const string Name = "Standard";
public virtual bool ConvertSight(string? thisName, ConversionContext context)
{
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Expected O, but got Unknown
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Expected O, but got Unknown
Shader thermalShader = context.Plugin.AssetBundle.ThermalOverlayShader;
if ((Object)(object)thermalShader == (Object)null)
{
context.Log.LogError((object)"Standard sight converter failed; failed to load thermal shader");
return false;
}
Renderer val = context.Renderer;
if ((Object)(object)val == (Object)null)
{
val = ((IEnumerable<Renderer>)context.Item.GearPartHolder.SightPart.GetComponentsInChildren<Renderer>()).First((Renderer r) => r.sharedMaterial.HasProperty("_ReticuleA"));
if ((Object)(object)val == (Object)null)
{
context.Log.LogError((object)"Sight converter failed; could not find sight!");
return false;
}
context.Renderer = val;
}
bool flag = default(bool);
if (Object.op_Implicit((Object)(object)((IEnumerable<Material>)val.sharedMaterials).FirstOrDefault((Func<Material, bool>)((Material m) => (Object)(object)m.shader == (Object)(object)thermalShader))))
{
ManualLogSource log = context.Log;
BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(73, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Skipping sight conversion on item \"");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)context.Item).name);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\" due to scope already being converted");
}
log.LogDebug(val2);
return true;
}
string text = thisName?.Substring(thisName.IndexOf('/') + 1);
bool flag2;
if (text != null && text.Length > 0 && text.Length < thisName.Length)
{
flag2 = false;
if (text == "Thermal")
{
flag2 = true;
}
else if (text != "NonThermal")
{
ManualLogSource log2 = context.Log;
BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(54, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Unrecognized parameter for SightConverter_Standard: \"");
((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("\"");
}
log2.LogWarning(val3);
}
}
else
{
flag2 = ((Object)val.sharedMaterial.shader).name.Contains("Thermal");
}
bool flag3 = ((!flag2) ? ConvertNonThermalSight(context) : ConvertThermalSight(context));
if (flag3)
{
Material val4 = ((IEnumerable<Material>)val.sharedMaterials).First();
val4.SetFloat("_CenterWhenUnscope", 1f);
val4.SetVector("_ScopeCenter", MaterialGenerator_Standard.CalcScopeCenter(context.Item, ((Component)val).transform));
context.Config?.MaterialConfig.ApplyToMaterial(val4, context);
}
return flag3;
}
public static bool ConvertThermalSight(ConversionContext context)
{
if ((Object)(object)context.Renderer == (Object)null)
{
return false;
}
context.Renderer.sharedMaterial.shader = context.Plugin.AssetBundle.ThermalOverlayShader;
context.Renderer.sharedMaterial.mainTexture = (Texture)(object)Texture2D.redTexture;
context.Renderer.sharedMaterial.SetFloat("_Zoom", Mathf.Clamp(context.Renderer.sharedMaterial.GetFloat("_Zoom") - 0.5f, 0f, 1f));
return true;
}
public static bool ConvertNonThermalSight(ConversionContext context)
{
if ((Object)(object)context.Renderer == (Object)null)
{
return false;
}
Material val = context.Plugin.FactoryManager.RunMaterialGenerator(context.Config?.MaterialGenerator, context);
Material sharedMaterial = context.Renderer.sharedMaterial;
val.mainTexture = ((sharedMaterial != null) ? sharedMaterial.mainTexture : null);
val.SetFloat("_OffAngleFade", 0f);
context.Renderer.sharedMaterials = Il2CppReferenceArray<Material>.op_Implicit(((IEnumerable<Material>)context.Renderer.sharedMaterials).Prepend(val).ToArray());
return true;
}
}
public class TextureGenerator_Bloom : ITextureGenerator
{
public const string Name = "Bloom";
public virtual Texture GenerateTexture(string? thisName, ConversionContext context)
{
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Expected O, but got Unknown
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
bool flag = true;
string[] array = thisName?.Split('/') ?? Array.Empty<string>();
if (array.Length > 1)
{
string text = array[1];
if (text == "Square")
{
flag = false;
}
else if (text != "Circle")
{
ManualLogSource log = context.Log;
bool flag2 = default(bool);
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(52, 1, ref flag2);
if (flag2)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("TextureGenerator_Bloom ignoring unknown parameter \"");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\"");
}
log.LogWarning(val);
}
}
int num = 256;
float num2 = 2f / ((float)num - 1f);
Texture2D val2 = new Texture2D(num, num, (TextureFormat)15, false);
if (flag)
{
((Object)val2).name = "Bloom - Circle";
}
else
{
((Object)val2).name = "Bloom - Square";
}
for (int i = 0; i < num; i++)
{
for (int j = 0; j < num; j++)
{
float num3 = (float)i - 0.5f * (float)(num - 1);
float num4 = (float)j - 0.5f * (float)(num - 1);
float num5 = ((!flag) ? (Mathf.Max(Mathf.Abs(num3), Mathf.Abs(num4)) * num2) : (Mathf.Sqrt(num3 * num3 + num4 * num4) * num2));
val2.SetPixel(i, j, new Color(Mathf.Clamp(1f - num5, 0f, 1f), 0f, 0f));
}
}
val2.Apply();
return (Texture)(object)val2;
}
}
public class TextureGenerator_Load : ITextureGenerator
{
public const string Name = "Load";
public static string TexturesPath = AssetBundle.AssetDirectory;
public virtual Texture GenerateTexture(string? thisName, ConversionContext context)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Expected O, but got Unknown
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Expected O, but got Unknown
string text = thisName?.Substring(thisName.IndexOf('/') + 1);
bool flag = default(bool);
BepInExErrorLogInterpolatedStringHandler val;
if (text == null || text.Length == 0 || text.Length == thisName.Length)
{
ManualLogSource log = context.Log;
val = new BepInExErrorLogInterpolatedStringHandler(70, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Texture generator failed to load file; missing parameter! Called with ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(thisName ?? "<null>");
}
log.LogError(val);
return context.Factory.RunTextureGenerator(null, context);
}
string text2 = Path.Combine(TexturesPath, text);
if (File.Exists(text2))
{
Texture2D val2 = new Texture2D(2, 2);
((Object)val2).name = text;
ImageConversion.LoadImage(val2, Il2CppStructArray<byte>.op_Implicit(File.ReadAllBytes(text2)));
val2.Apply();
return (Texture)(object)val2;
}
ManualLogSource log2 = context.Log;
val = new BepInExErrorLogInterpolatedStringHandler(84, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Texture generator failed to load file; file not found.\n - File name: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\n - Full path: ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2);
}
log2.LogError(val);
return context.Factory.RunTextureGenerator(null, context);
}
}
public class TextureGenerator_Simple : ITextureGenerator
{
private Func<Texture> Func;
public TextureGenerator_Simple(Func<Texture> func)
{
Func = func;
}
public virtual Texture GenerateTexture(string? _, ConversionContext __)
{
return Func();
}
}
}
namespace ReTFO.ThermalOverlay.Config
{
public class ConfigFile
{
public List<ConfigFileEntry> Configs = new List<ConfigFileEntry>();
}
public class ConfigFileEntry
{
public string? Name;
public uint Id;
public ThermalConfig? Config;
}
public class ConfigManager
{
private SortedList<uint, string>? _offlineGearNames;
private UserConfigs? _userConfigs;
public SortedList<uint, ThermalConfig> ItemConfigs = new SortedList<uint, ThermalConfig>();
public IReadOnlyDictionary<uint, string> OfflineGearNames
{
get
{
IReadOnlyDictionary<uint, string> offlineGearNames = _offlineGearNames;
return offlineGearNames ?? ((IEnumerable<PlayerOfflineGearDataBlock>)GameDataBlockBase<PlayerOfflineGearDataBlock>.GetAllBlocks()).Select((Func<PlayerOfflineGearDataBlock, GearIDRange>)((PlayerOfflineGearDataBlock b) => new GearIDRange(b.GearJSON))).ToDictionary((GearIDRange r) => r.GetChecksum(), (GearIDRange r) => r.PublicGearName ?? "");
}
set
{
_offlineGearNames = new SortedList<uint, string>(value.ToImmutableSortedDictionary());
}
}
public UserConfigs UserConfigs
{
get
{
return _userConfigs ?? (_userConfigs = new UserConfigs(this));
}
private set
{
_userConfigs = value;
}
}
public void LoadConfigFile(string filename)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Expected O, but got Unknown
bool flag = default(bool);
if (!File.Exists(filename))
{
ManualLogSource log = ((BasePlugin)Plugin.Get()).Log;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(25, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Config file not found: \"");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(filename);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("\"");
}
log.LogWarning(val);
return;
}
JsonSerializerOptions jsonSerializerOptions = new JsonSerializerOptions
{
AllowTrailingCommas = true,
PropertyNameCaseInsensitive = true
};
jsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
ConfigFile configFile = JsonSerializer.Deserialize<ConfigFile>(filename, jsonSerializerOptions);
if (configFile == null)
{
ManualLogSource log2 = ((BasePlugin)Plugin.Get()).Log;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(41, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Config file could not be deserialized: \"");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(filename);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\"");
}
log2.LogError(val2);
}
else
{
LoadConfigFile(configFile);
}
}
public void LoadConfigFile(ConfigFile file)
{
file.Configs.ForEach(LoadConfigEntry);
}
public void LoadConfigEntry(ConfigFileEntry entry)
{
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Expected O, but got Unknown
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected O, but got Unknown
bool flag = default(bool);
if (entry.Config != null)
{
if (ItemConfigs.ContainsKey(entry.Id))
{
ManualLogSource log = ((BasePlugin)Plugin.Get()).Log;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(42, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Overwriting thermal config for item ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(entry.Id);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" with ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(entry.Name ?? "Unnamed Config");
}
log.LogWarning(val);
}
ItemConfigs[entry.Id] = entry.Config;
}
else
{
ManualLogSource log2 = ((BasePlugin)Plugin.Get()).Log;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(41, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Skipping config ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(entry.Name ?? "Unnamed Config");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" because it is incomplete");
}
log2.LogWarning(val);
}
}
}
public struct MaterialConfig
{
public string? Generator;
[JsonIgnore]
public SortedList<string, object> Properties;
[JsonIgnore]
public List<string> Keywords;
public const string Zoom_Name = "_Zoom";
public const string RatioAdjust_Name = "_RatioAdjust";
public const string ScreenIntensity_Name = "_ScreenIntensity";
public const string OffAngleFade_Name = "_OffAngleFade";
public const string HeatTex_Name = "_HeatTex";
public const string HeatFalloff_Name = "_HeatFalloff";
public const string FogFalloff_Name = "_FogFalloff";
public const string AlphaMult_Name = "_AlphaMult";
public const string BackgroundTemp_Name = "_BackgroundTemp";
public const string AmbientColorFactor_Name = "_AmbientColorFactor";
public const string AlbedoColorFactor_Name = "_AlbedoColorFactor";
public const string AmbientTemp_Name = "_AmbientTemp";
public const string OcclusionHeat_Name = "_OcclusionHeat";
public const string BodyOcclusionHeat_Name = "_BodyOcclusionHeat";
public const string DistortionTex_Name = "_DistortionTex";
public const string DistortionScale_Name = "_DistortionScale";
public const string DistortionSpeed_Name = "_DistortionSpeed";
public const string DistortionSignal_Name = "_DistortionSignal";
public const string DistortionSignalSpeed_Name = "_DistortionSignalSpeed";
public const string DistortionMin_Name = "_DistortionMin";
public const string DistortionMax_Name = "_DistortionMax";
public const string DistortionMinShadowEnemies_Name = "_DistortionMinShadowEnemies";
public const string DistortionMaxShadowEnemies_Name = "_DistortionMaxShadowEnemies";
public const string DistortionSignalSpeedShadowEnemies_Name = "_DistortionSignalSpeedShadowEnemies";
public const string ShadowEnemyFresnel_Name = "_ShadowEnemyFresnel";
public const string ShadowEnemyHeat_Name = "_ShadowEnemyHeat";
public const string ScopeCenter_Name = "_ScopeCenter";
public const string CenterWhenUnscoped_Name = "_CenterWhenUnscope";
public const string UncenterWhenScoped_Name = "_UncenterWhenScoped";
public const string MainTex_Name = "_MainTex";
public const string ReticuleA_Name = "_ReticuleA";
public const string ReticuleB_Name = "_ReticuleB";
public const string ReticuleC_Name = "_ReticuleC";
public const string ReticuleColorA_Name = "_ReticuleColorA";
public const string ReticuleColorB_Name = "_ReticuleColorB";
public const string ReticuleColorC_Name = "_ReticuleColorC";
public const string SightDirt_Name = "_SightDirt";
public const string ProjSize1_Name = "_ProjSize1";
public const string ProjSize2_Name = "_ProjSize2";
public const string ProjSize3_Name = "_ProjSize3";
public const string FPSRenderingKeyword = "ENABLE_FPS_RENDERING";
public const string EditorRenderingKeyword = "EDITOR_RENDERING_ENABLED";
public ShaderValue<float> Zoom
{
get
{
return Get("_Zoom", 0f);
}
set
{
Set("_Zoom", value);
}
}
public ShaderValue<float> RatioAdjust
{
get
{
return Get("_RatioAdjust", 1f);
}
set
{
Set("_RatioAdjust", value);
}
}
public ShaderValue<float> ScreenIntensity
{
get
{
return Get("_ScreenIntensity", 0.2f);
}
set
{
Set("_ScreenIntensity", value);
}
}
public ShaderValue<float> OffAngleFade
{
get
{
return Get("_OffAngleFade", 0.95f);
}
set
{
Set("_OffAngleFade", value);
}
}
public ShaderValue<string> HeatTex
{
get
{
return Get("_HeatTex", "white");
}
set
{
Set("_HeatTex", value);
}
}
public ShaderValue<float> HeatFalloff
{
get
{
return Get("_HeatFalloff", 0.01f);
}
set
{
Set("_HeatFalloff", value);
}
}
public ShaderValue<float> FogFalloff
{
get
{
return Get("_FogFalloff", 0.1f);
}
set
{
Set("_FogFalloff", value);
}
}
public ShaderValue<float> AlphaMult
{
get
{
return Get("_AlphaMult", 1f);
}
set
{
Set("_AlphaMult", value);
}
}
public ShaderValue<float> BackgroundTemp
{
get
{
return Get("_BackgroundTemp", 0.05f);
}
set
{
Set("_BackgroundTemp", value);
}
}
public ShaderValue<float> AmbientColorFactor
{
get
{
return Get("_AmbientColorFactor", 5f);
}
set
{
Set("_AmbientColorFactor", value);
}
}
public ShaderValue<float> AlbedoColorFactor
{
get
{
return Get("_AlbedoColorFactor", 0.5f);
}
set
{
Set("_AlbedoColorFactor", value);
}
}
public ShaderValue<float> AmbientTemp
{
get
{
return Get("_AmbientTemp", 0.15f);
}
set
{
Set("_AmbientTemp", value);
}
}
public ShaderValue<float> OcclusionHeat
{
get
{
return Get("_OcclusionHeat", 0.5f);
}
set
{
Set("_OcclusionHeat", value);
}
}
public ShaderValue<float> BodyOcclusionHeat
{
get
{
return Get("_BodyOcclusionHeat", 2.5f);
}
set
{
Set("_BodyOcclusionHeat", value);
}
}
public ShaderValue<string> DistortionTex
{
get
{
return Get("_DistortionTex", "gray");
}
set
{
Set("_DistortionTex", value);
}
}
public ShaderValue<float> DistortionScale
{
get
{
return Get("_DistortionScale", 1f);
}
set
{
Set("_DistortionScale", value);
}
}
public ShaderValue<float> DistortionSpeed
{
get
{
return Get("_DistortionSpeed", 1f);
}
set
{
Set("_DistortionSpeed", value);
}
}
public ShaderValue<string> DistortionSignal
{
get
{
return Get("_DistortionSignal", "black");
}
set
{
Set("_DistortionSignal", value);
}
}
public ShaderValue<float> DistortionSignalSpeed
{
get
{
return Get("_DistortionSignalSpeed", 1f);
}
set
{
Set("_DistortionSignalSpeed", value);
}
}
public ShaderValue<float> DistortionMin
{
get
{
return Get("_DistortionMin", 0.01f);
}
set
{
Set("_DistortionMin", value);
}
}
public ShaderValue<float> DistortionMax
{
get
{
return Get("_DistortionMax", 0.4f);
}
set
{
Set("_DistortionMax", value);
}
}
public ShaderValue<float> DistortionMinShadowEnemies
{
get
{
return Get("_DistortionMinShadowEnemies", 0.2f);
}
set
{
Set("_DistortionMinShadowEnemies", value);
}
}
public ShaderValue<float> DistortionMaxShadowEnemies
{
get
{
return Get("_DistortionMaxShadowEnemies", 1f);
}
set
{
Set("_DistortionMaxShadowEnemies", value);
}
}
public ShaderValue<float> DistortionSignalSpeedShadowEnemies
{
get
{
return Get("_DistortionSignalSpeedShadowEnemies", 0.025f);
}
set
{
Set("_DistortionSignalSpeedShadowEnemies", value);
}
}
public ShaderValue<float> ShadowEnemyFresnel
{
get
{
return Get("_ShadowEnemyFresnel", 10f);
}
set
{
Set("_ShadowEnemyFresnel", value);
}
}
public ShaderValue<float> ShadowEnemyHeat
{
get
{
return Get("_ShadowEnemyHeat", 0.1f);
}
set
{
Set("_ShadowEnemyHeat", value);
}
}
public ShaderValue<Vector4> ScopeCenter
{
get
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
return Get<Vector4>("_ScopeCenter", new Vector4(0f, 0f, 0f, 1f));
}
set
{
Set("_ScopeCenter", value);
}
}
public ShaderValue<float> CenterWhenUnscoped
{
get
{
return Get("_CenterWhenUnscope", 1f);
}
set
{
Set("_CenterWhenUnscope", value);
}
}
public ShaderValue<float> UncenterWhenScoped
{
get
{
return Get("_UncenterWhenScoped", 0f);
}
set
{
Set("_UncenterWhenScoped", value);
}
}
public ShaderValue<string> MainTex
{
get
{
return Get("_MainTex", "red");
}
set
{
Set("_MainTex", value);
}
}
public ShaderValue<string> ReticuleA
{
get
{
return Get("_ReticuleA", "black");
}
set
{
Set("_ReticuleA", value);
}
}
public ShaderValue<string> ReticuleB
{
get
{
return Get("_ReticuleB", "black");
}
set
{
Set("_ReticuleB", value);
}
}
public ShaderValue<string> ReticuleC
{
get
{
return Get("_ReticuleC", "black");
}
set
{
Set("_ReticuleC", value);
}
}
public ShaderValue<Color> ReticuleColorA
{
get
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return Get<Color>("_ReticuleColorA", Color.white);
}
set
{
Set("_ReticuleColorA", value);
}
}
public ShaderValue<Color> ReticuleColorB
{
get
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return Get<Color>("_ReticuleColorB", Color.white);
}
set
{
Set("_ReticuleColorB", value);
}
}
public ShaderValue<Color> ReticuleColorC
{
get
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return Get<Color>("_ReticuleColorC", Color.white);
}
set
{
Set("_ReticuleColorC", value);
}
}
public ShaderValue<float> SightDirt
{
get
{
return Get("_SightDirt", 1f);
}
set
{
Set("_SightDirt", value);
}
}
public ShaderValue<float> ProjSize1
{
get
{
return Get("_ProjSize1", 1f);
}
set
{
Set("_ProjSize1", value);
}
}
public ShaderValue<float> ProjSize2
{
get
{
return Get("_ProjSize2", 1f);
}
set
{
Set("_ProjSize2", value);
}
}
public ShaderValue<float> ProjSize3
{
get
{
return Get("_ProjSize3", 1f);
}
set
{
Set("_ProjSize3", value);
}
}
public bool FPSRenderingEnabled
{
get
{
return Keywords.Contains("ENABLE_FPS_RENDERING");
}
set
{
if (value && !Keywords.Contains("ENABLE_FPS_RENDERING"))
{
Keywords.Add("ENABLE_FPS_RENDERING");
}
else if (!value)
{
Keywords.RemoveAll((string s) => s == "ENABLE_FPS_RENDERING");
}
}
}
public bool EditorRenderingEnabled
{
get
{
return Keywords.Contains("EDITOR_RENDERING_ENABLED");
}
set
{
if (value && !Keywords.Contains("EDITOR_RENDERING_ENABLED"))
{
Keywords.Add("EDITOR_RENDERING_ENABLED");
}
else if (!value)
{
Keywords.RemoveAll((string s) => s == "EDITOR_RENDERING_ENABLED");
}
}
}
public MaterialConfig()
{
Generator = null;
Properties = new SortedList<string, object>(1);
Keywords = new List<string>(1);
}
public void ApplyAllToMaterial(Material mat, ConversionContext context)
{
//IL_026c: Unknown result type (might be due to invalid IL or missing references)
//IL_0336: Unknown result type (might be due to invalid IL or missing references)
//IL_034c: Unknown result type (might be due to invalid IL or missing references)
//IL_0362: Unknown result type (might be due to invalid IL or missing references)
mat.SetFloat("_Zoom", Zoom.Value);
mat.SetFloat("_RatioAdjust", RatioAdjust.Value);
mat.SetFloat("_ScreenIntensity", ScreenIntensity.Value);
mat.SetFloat("_OffAngleFade", OffAngleFade.Value);
mat.SetTexture("_HeatTex", context.Factory.RunTextureGenerator(HeatTex.Value, context));
mat.SetFloat("_HeatFalloff", HeatFalloff.Value);
mat.SetFloat("_FogFalloff", FogFalloff.Value);
mat.SetFloat("_AlphaMult", AlphaMult.Value);
mat.SetFloat("_BackgroundTemp", BackgroundTemp.Value);
mat.SetFloat("_AmbientColorFactor", AmbientColorFactor.Value);
mat.SetFloat("_AlbedoColorFactor", AlbedoColorFactor.Value);
mat.SetFloat("_AmbientTemp", AmbientTemp.Value);
mat.SetFloat("_OcclusionHeat", OcclusionHeat.Value);
mat.SetFloat("_BodyOcclusionHeat", BodyOcclusionHeat.Value);
mat.SetTexture("_DistortionTex", context.Factory.RunTextureGenerator(DistortionTex.Value, context));
mat.SetFloat("_DistortionScale", DistortionScale.Value);
mat.SetFloat("_DistortionSpeed", DistortionSpeed.Value);
mat.SetTexture("_DistortionSignal", context.Factory.RunTextureGenerator(DistortionSignal.Value, context));
mat.SetFloat("_DistortionSignalSpeed", DistortionSignalSpeed.Value);
mat.SetFloat("_DistortionMin", DistortionMin.Value);
mat.SetFloat("_DistortionMax", DistortionMax.Value);
mat.SetFloat("_DistortionMinShadowEnemies", DistortionMinShadowEnemies.Value);
mat.SetFloat("_DistortionMaxShadowEnemies", DistortionMaxShadowEnemies.Value);
mat.SetFloat("_DistortionSignalSpeedShadowEnemies", DistortionSignalSpeedShadowEnemies.Value);
mat.SetFloat("_ShadowEnemyFresnel", ShadowEnemyFresnel.Value);
mat.SetFloat("_ShadowEnemyHeat", ShadowEnemyHeat.Value);
mat.SetVector("_ScopeCenter", ScopeCenter.Value);
mat.SetFloat("_CenterWhenUnscope", CenterWhenUnscoped.Value);
mat.SetFloat("_UncenterWhenScoped", UncenterWhenScoped.Value);
mat.SetTexture("_MainTex", context.Factory.RunTextureGenerator(MainTex.Value, context));
mat.SetTexture("_ReticuleA", context.Factory.RunTextureGenerator(ReticuleA.Value, context));
mat.SetTexture("_ReticuleB", context.Factory.RunTextureGenerator(ReticuleB.Value, context));
mat.SetTexture("_ReticuleC", context.Factory.RunTextureGenerator(ReticuleC.Value, context));
mat.SetColor("_ReticuleColorA", ReticuleColorA.Value);
mat.SetColor("_ReticuleColorB", ReticuleColorB.Value);
mat.SetColor("_ReticuleColorC", ReticuleColorC.Value);
mat.SetFloat("_SightDirt", SightDirt.Value);
mat.SetFloat("_ProjSize1", ProjSize1.Value);
mat.SetFloat("_ProjSize2", ProjSize2.Value);
mat.SetFloat("_ProjSize3", ProjSize3.Value);
foreach (string keyword in Keywords)
{
MaterialExtensions.SetKeywordEnabled(mat, keyword, true);
}
}
public void ApplyToMaterial(Material mat, ConversionContext context)
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected I4, but got Unknown
//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Expected O, but got Unknown
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Expected O, but got Unknown
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
bool flag = default(bool);
foreach (KeyValuePair<string, object> property in Properties)
{
int num = mat.shader.FindPropertyIndex(property.Key);
ShaderPropertyType propertyType = mat.shader.GetPropertyType(num);
Type typeFromHandle;
switch ((int)propertyType)
{
case 0:
{
typeFromHandle = typeof(Color);
Color? val2 = property.Value as Color?;
if (val2.HasValue)
{
mat.SetColor(num, val2.Value);
continue;
}
break;
}
case 1:
{
typeFromHandle = typeof(Vector4);
Vector4? val4 = property.Value as Vector4?;
if (val4.HasValue)
{
mat.SetVector(num, val4.Value);
continue;
}
break;
}
case 2:
case 3:
{
typeFromHandle = typeof(float);
float? num2 = property.Value as float?;
if (num2.HasValue)
{
mat.SetFloat(num, num2.Value);
continue;
}
break;
}
case 4:
typeFromHandle = typeof(string);
if (property.Value is string name)
{
Texture val3 = context.Factory.RunTextureGenerator(name, context);
mat.SetTexture(property.Key, val3);
continue;
}
break;
default:
{
ManualLogSource log = context.Log;
BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(78, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Encountered unknown shader property type ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<ShaderPropertyType>(propertyType);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" while applying to material; ignoring");
}
log.LogWarning(val);
continue;
}
}
ManualLogSource log2 = context.Log;
BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(57, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("MaterialConfig expected a ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(typeFromHandle.Name);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" for key \"");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(property.Key);
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("\", but got a ");
((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(property.Value?.GetType().Name ?? "null");
((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" instead");
}
log2.LogError(val5);
}
foreach (string keyword in Keywords)
{
MaterialExtensions.SetKeywordEnabled(mat, keyword, true);
}
}
public MaterialConfig Clone()
{
MaterialConfig result = new MaterialConfig();
result.Properties = new SortedList<string, object>(Properties);
result.Keywords = new List<string>(Keywords);
return result;
}
public static MaterialConfig FromMaterial(Material mat, bool removeDefault = true)
{
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected I4, but got Unknown
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
MaterialConfig materialConfig = new MaterialConfig();
PropertyInfo[] properties = typeof(MaterialConfig).GetProperties(BindingFlags.Instance | BindingFlags.Public);
PropertyInfo[] array = properties;
foreach (PropertyInfo propertyInfo in array)
{
string text = "_" + propertyInfo.Name;
int num = mat.shader.FindPropertyIndex(text);
if (num < 0)
{
continue;
}
ShaderPropertyType propertyType = mat.shader.GetPropertyType(num);
switch ((int)propertyType)
{
case 0:
{
Color color = mat.GetColor(text);
if (!removeDefault || !(color == ((ShaderValue<Color>)propertyInfo.GetValue(materialConfig)).Value))
{
materialConfig.Set(text, new ShaderValue<Color>(color));
}
break;
}
case 1:
{
Vector4 vector = mat.GetVector(text);
if (!removeDefault || !(vector == ((ShaderValue<Vector4>)propertyInfo.GetValue(materialConfig)).Value))
{
materialConfig.Set(text, new ShaderValue<Vector4>(vector));
}
break;
}
case 2:
case 3:
{
float @float = mat.GetFloat(text);
if (!removeDefault || @float != ((ShaderValue<float>)propertyInfo.GetValue(materialConfig)).Value)
{
materialConfig.Set(text, new ShaderValue<float>(@float));
}
break;
}
case 4:
{
Texture texture = mat.GetTexture(text);
string text2 = ((texture != null) ? ((Object)texture).name : null) ?? "null";
if (!removeDefault || !(text2 == ((ShaderValue<string>)propertyInfo.GetValue(materialConfig)).Value))
{
materialConfig.Set(text, new ShaderValue<string>(text2));
}
break;
}
}
}
materialConfig.Keywords = ((IEnumerable<string>)mat.GetShaderKeywords()).ToList();
return materialConfig;
}
public static void LogProperties(Material mat, ManualLogSource log, bool skipDefaults = true)
{
MaterialConfig materialConfig = FromMaterial(mat, skipDefaults);
log.LogDebug((object)string.Join("\n - ", Enumerable.Repeat("\nMaterial config for \"" + ((Object)mat).name + "\":", 1).Concat(materialConfig.Properties.Select<KeyValuePair<string, object>, string>((KeyValuePair<string, object> pair) => $"{pair.Key} -> {pair.Value}")).Concat(materialConfig.Keywords.Select((string keyword) => keyword + " enabled"))));
}
private ShaderValue<T> Get<T>(string key, T defaultValue)
{
ShaderValue<T> result;
if (Properties.ContainsKey(key))
{
object obj = Properties[key];
if (obj is T)
{
result = new ShaderValue<T>();
result.Value = (T)obj;
result.IsSet = true;
return result;
}
}
result = new ShaderValue<T>();
result.Value = defaultValue;
result.IsSet = false;
return result;
}
private void Set<T>(string key, ShaderValue<T> value)
{
if (value.IsSet)
{
Properties[key] = value.Value;
}
else
{
Properties.Remove(key);
}
}
}
public struct OverlayConfig
{
public string? MeshGenerator;
public Vector3 MeshOffset;
public Quaternion MeshRotation;
public Vector3 MeshScale;
public string? TextureGenerator;
public OverlayConfig()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: 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)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
MeshGenerator = null;
MeshOffset = Vector3.zero;
MeshRotation = Quaternion.identity;
MeshScale = Vector3.one;
TextureGenerator = null;
}
}
[ShaderValue_Converter]
public struct ShaderValue<T>
{
public bool IsSet;
public T Value;
public ShaderValue()
{
IsSet = false;
Value = default(T);
}
public ShaderValue(T value)
{
IsSet = true;
Value = value;
}
public static implicit operator ShaderValue<T>(T? value)
{
ShaderValue<T> result = new ShaderValue<T>();
result.IsSet = value != null;
result.Value = value;
return result;
}
}
[AttributeUsage(AttributeTargets.Struct)]
public class ShaderValue_ConverterAttribute : JsonConverterAttribute
{
public override JsonConverter? CreateConverter(Type typeToConvert)
{
Type type = typeToConvert.GetGenericArguments()[0];
Type type2 = typeof(ShaderValue_JsonConverter<>).MakeGenericType(type);
return (JsonConverter)Activator.CreateInstance(type2);
}
}
public class ShaderValue_JsonConverter<T> : JsonConverter<ShaderValue<T>>
{
private const string NonValue = "<unset>";
public override void Write(Utf8JsonWriter writer, ShaderValue<T> value, JsonSerializerOptions options)
{
if (value.IsSet)
{
JsonSerializer.Serialize(writer, value.Value, options);
}
else
{
writer.WriteStringValue("<unset>");
}
}
public override ShaderValue<T> Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
{
reader.Read();
if (reader.TokenType == JsonTokenType.String && reader.ValueTextEquals("<unset>"))
{
ShaderValue<T> result = new ShaderValue<T>();
result.IsSet = false;
return result;
}
T value = JsonSerializer.Deserialize<T>(ref reader, options);
return new ShaderValue<T>(value);
}
}
public class ThermalConfig
{
public string? Handler;
public OverlayConfig OverlayConfig = new OverlayConfig();
public string? MaterialGenerator;
public MaterialConfig MaterialConfig = new MaterialConfig();
}
public class UserConfigs
{
private readonly ConfigEntry<bool> _enableEverything;
private readonly ConfigEntry<string> _enabledGear;
private readonly ConfigEntry<bool> _makeGunsCold;
public bool EnableEverything => _enableEverything.Value;
public List<uint> EnabledGear => (from s in _enabledGear.Value.Split(',')
where s.Length > 0
select uint.Parse(s)).ToList();
public bool MakeGunsCold => _makeGunsCold.Value;
internal UserConfigs(ConfigManager manager)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
//IL_003a: Expected O, but got Unknown
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Expected O, but got Unknown
//IL_00a9: Expected O, but got Unknown
//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Expected O, but got Unknown
//IL_0104: Expected O, but got Unknown
Plugin plugin = Plugin.Get();
ConfigFile config = ((BasePlugin)plugin).Config;
_enableEverything = config.Bind<bool>(new ConfigDefinition("Conversion", "Enable Everything!"), false, new ConfigDescription("Enables all thermal configs, overriding per-item settings below", (AcceptableValueBase)null, Array.Empty<object>()));
_enabledGear = config.Bind<string>(new ConfigDefinition("Conversion", "Enabled Gear"), string.Empty, new ConfigDescription(string.Join("\n", Enumerable.Repeat("Which gear items to convert, by PlayerOfflineGear Persistent ID.\nMust be a comma-separated list of positive numbers, with no spaces.\nIDs for reference: ", 1).Concat(manager.OfflineGearNames.Select<KeyValuePair<uint, string>, string>((KeyValuePair<uint, string> p) => " - " + p.Key + " - " + p.Value))), (AcceptableValueBase)null, Array.Empty<object>()));
if (!EnableEverything && EnabledGear.Count == 0)
{
Plugin? plugin2 = Plugin.TryGet();
if (plugin2 != null)
{
((BasePlugin)plugin2).Log.LogWarning((object)"No weapons have been configured to use thermal overlays; did you forget to configure the mod?");
}
}
_makeGunsCold = config.Bind<bool>(new ConfigDefinition("Conversion", "Make Guns Cold"), true, new ConfigDescription("When thermal overlays are added to guns, they can highlight the gun they're attached to, since player weapons are considered warm. This often looks weird. This setting makes local guns cold, which prevents the issue while minimally impacting gameplay", (AcceptableValueBase)null, Array.Empty<object>()));
}
}
}