using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ComputerysModdingUtilities;
using DG.Tweening;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityStandardAssets.Water;
using VLB;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("DorsthTweaks")]
[assembly: AssemblyDescription("STRAFTAT: hitmarker, HUD and outline colors, reduced UI animations, no rain, static textures and playlist tweaks.")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: StraftatMod(true)]
[assembly: AssemblyVersion("1.0.1.0")]
namespace DorsthTweaks;
[BepInPlugin("dorsth.straftat.dorsthtweaks", "DorsthTweaks", "1.0.1")]
public sealed class DorsthTweaksPlugin : BaseUnityPlugin
{
public const string Guid = "dorsth.straftat.dorsthtweaks";
public const string Name = "DorsthTweaks";
public const string Version = "1.0.1";
internal static ManualLogSource Log;
internal static Harmony Harmony;
internal static ConfigEntry<bool> HideHitmarkers;
internal static ColorSetting BodyshotColor;
internal static ColorSetting HeadshotColor;
internal static ConfigEntry<bool> HideFps;
internal static ConfigEntry<bool> HidePing;
internal static ConfigEntry<bool> HideNearMissVignette;
internal static ColorSetting MinimalHudColor;
internal static ColorSetting WeaponHighlightColor;
internal static ColorSetting PromptColor;
internal static ConfigEntry<bool> ReduceUIAnimations;
internal static ConfigEntry<bool> DisableRain;
internal static ConfigEntry<bool> StaticTextures;
internal static ConfigEntry<bool> HideDefaultPlaylists;
private static bool _errorLogged;
private void Awake()
{
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: 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_0232: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Log.LogMessage((object)"Dorsth was here");
HideHitmarkers = ((BaseUnityPlugin)this).Config.Bind<bool>("Hitmarkers", "Hide Hitmarkers", false, "Hides hitmarkers.");
BodyshotColor = new ColorSetting(((BaseUnityPlugin)this).Config, "Hitmarkers", "Bodyshot Color", new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), "Color of bodyshot hitmarkers.");
HeadshotColor = new ColorSetting(((BaseUnityPlugin)this).Config, "Hitmarkers", "Headshot Color", new Color32(byte.MaxValue, (byte)0, (byte)0, byte.MaxValue), "Color of headshot hitmarkers.");
HideFps = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "Hide FPS", false, "Hides the FPS counter.");
HidePing = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "Hide Ping", false, "Hides the ping counter.");
MinimalHudColor = new ColorSetting(((BaseUnityPlugin)this).Config, "HUD", "Minimal HUD Color", new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue), "Color of the minimal HUD text (health, ammo, FPS and ping).");
HideNearMissVignette = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "Hide Near Miss Vignette", false, "Hides the dark screen edges that flash when shots land near you.");
WeaponHighlightColor = new ColorSetting(((BaseUnityPlugin)this).Config, "Interaction", "Weapon Highlight Color", new Color32(byte.MaxValue, (byte)209, (byte)109, byte.MaxValue), "Color of the outline on weapons you look at.");
PromptColor = new ColorSetting(((BaseUnityPlugin)this).Config, "Interaction", "Interaction Prompt Color", new Color32(byte.MaxValue, (byte)141, (byte)0, byte.MaxValue), "Color of interaction prompts like \"pistol [f]\".");
ReduceUIAnimations = ((BaseUnityPlugin)this).Config.Bind<bool>("UI", "Reduce UI Animations", false, "Turns off animations in the menus and HUD. Slightly improves performance.");
DisableRain = ((BaseUnityPlugin)this).Config.Bind<bool>("World", "Disable Rain", false, "Removes rain from maps. Big FPS boost on rainy maps.");
StaticTextures = ((BaseUnityPlugin)this).Config.Bind<bool>("World", "Static Textures", false, "Freezes animated textures, water, sky and light beams in maps and turns off water reflections. Big FPS boost on maps with water.");
HideDefaultPlaylists = ((BaseUnityPlugin)this).Config.Bind<bool>("Playlists", "Hide Default Playlists", false, "Removes the game's default playlists. Your own playlists are kept.");
Harmony = new Harmony("dorsth.straftat.dorsthtweaks");
Install("hitmarkers", Hitmarkers.Install);
Install("FPS/ping", Stats.Install);
Install("HUD and prompt colors", TextColors.Install);
Install("weapon highlight", WeaponHighlight.Install);
Install("near miss vignette", NearMiss.Install);
Install("reduce UI animations", StaticUI.Install);
Install("rain and static textures", World.Install);
Install("playlists", Playlists.Install);
GameHook.RefreshAll();
if (GameHook.Missing.Count > 0)
{
Log.LogWarning((object)("Not in this game version, skipped: " + string.Join(", ", GameHook.Missing.ToArray())));
}
}
private static void Install(string feature, Action install)
{
try
{
install();
}
catch (Exception ex)
{
Log.LogWarning((object)(feature + " is off: it doesn't fit this game version. (" + ex.Message + ")"));
}
}
internal static void LogErrorOnce(Exception e)
{
if (!_errorLogged)
{
_errorLogged = true;
Log.LogError((object)("Error (further errors are not logged): " + e));
}
}
internal static void OnChange(ConfigEntry<bool> setting, Action apply)
{
setting.SettingChanged += delegate
{
GameHook.RefreshAll();
try
{
apply();
}
catch (Exception e)
{
LogErrorOnce(e);
}
};
}
internal static MethodInfo Target(Type type, string name)
{
MethodInfo methodInfo = AccessTools.Method(type, name, (Type[])null, (Type[])null);
if (methodInfo == null)
{
throw new MissingMethodException(type.Name, name);
}
return methodInfo;
}
internal static HarmonyMethod Patch(Type type, string name)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Expected O, but got Unknown
return new HarmonyMethod(Target(type, name));
}
}
internal sealed class ColorSetting
{
private readonly ConfigEntry<Color> _entry;
private readonly Color32 _default;
internal Color Color { get; private set; }
internal bool IsDefault { get; private set; }
internal event Action Changed;
internal ColorSetting(ConfigFile config, string section, string key, Color32 defaultValue, string description)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: 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)
_default = defaultValue;
_entry = config.Bind<Color>(section, key, Color32.op_Implicit(defaultValue), description);
Read();
_entry.SettingChanged += delegate
{
Read();
Action action = this.Changed;
if (action == null)
{
return;
}
try
{
action();
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
};
}
private void Read()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: 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_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
Color = _entry.Value;
Color32 val = Color32.op_Implicit(Color);
IsDefault = val.r == _default.r && val.g == _default.g && val.b == _default.b && val.a == _default.a;
}
internal Color Like(Color original)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: 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_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
float num = Mathf.Max(1f, Mathf.Max(original.r, Mathf.Max(original.g, original.b)));
Color color = Color;
return new Color(color.r * num, color.g * num, color.b * num, color.a * original.a);
}
}
internal sealed class GameHook
{
private static readonly List<GameHook> All = new List<GameHook>();
internal static readonly List<string> Missing = new List<string>();
private readonly MethodBase _target;
private readonly HarmonyMethod _prefix;
private readonly HarmonyMethod _postfix;
private readonly Func<bool> _needed;
private bool _on;
private GameHook(MethodBase target, HarmonyMethod prefix, HarmonyMethod postfix, Func<bool> needed)
{
_target = target;
_prefix = prefix;
_postfix = postfix;
_needed = needed;
}
internal static void Add(Type type, string method, Type[] args, Type patches, string prefix, string postfix, Func<bool> needed)
{
MethodInfo methodInfo = ((args == null) ? AccessTools.Method(type, method, (Type[])null, (Type[])null) : AccessTools.Method(type, method, args, (Type[])null));
if (methodInfo == null)
{
Missing.Add(type.Name + "." + method);
}
else
{
All.Add(new GameHook(methodInfo, (prefix == null) ? null : DorsthTweaksPlugin.Patch(patches, prefix), (postfix == null) ? null : DorsthTweaksPlugin.Patch(patches, postfix), needed));
}
}
internal static void RefreshAll()
{
foreach (GameHook item in All)
{
item.Refresh();
}
}
private void Refresh()
{
bool flag = _needed();
if (flag == _on)
{
return;
}
try
{
if (flag)
{
DorsthTweaksPlugin.Harmony.Patch(_target, _prefix, _postfix, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
else
{
if (_prefix != null)
{
DorsthTweaksPlugin.Harmony.Unpatch(_target, _prefix.method);
}
if (_postfix != null)
{
DorsthTweaksPlugin.Harmony.Unpatch(_target, _postfix.method);
}
}
_on = flag;
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
}
}
internal static class Scenes
{
internal const string MainMenu = "MainMenu";
internal static bool IsMenu(Scene scene)
{
string name = ((Scene)(ref scene)).name;
if (!(name == "MainMenu"))
{
return name == "DontDestroyOnLoad";
}
return true;
}
internal static bool InMainMenu()
{
PauseManager instance = PauseManager.Instance;
if ((Object)(object)instance != (Object)null)
{
return instance.inMainMenu;
}
return false;
}
internal static Object[] FindAll(Type type)
{
return Object.FindObjectsOfType(type, true);
}
internal static void PruneGone<TKey, TValue>(Dictionary<TKey, TValue> saved) where TKey : Object
{
List<TKey> list = new List<TKey>();
foreach (TKey key in saved.Keys)
{
if ((Object)(object)key == (Object)null)
{
list.Add(key);
}
}
foreach (TKey item in list)
{
saved.Remove(item);
}
}
}
internal static class Hitmarkers
{
private struct Marker
{
public Graphic Graphic;
public bool Head;
}
private static readonly List<Marker> Waiting = new List<Marker>();
private static bool _listening;
internal static void Install()
{
MethodInfo methodInfo = AccessTools.Method(typeof(ShortcutExtensions), "DOPunchScale", new Type[5]
{
typeof(Transform),
typeof(Vector3),
typeof(float),
typeof(int),
typeof(float)
}, (Type[])null);
if (methodInfo == null)
{
throw new MissingMethodException("ShortcutExtensions", "DOPunchScale");
}
DorsthTweaksPlugin.Harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, DorsthTweaksPlugin.Patch(typeof(Hitmarkers), "PunchPostfix"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
internal static bool IsHitmarker(Transform t)
{
if ((Object)(object)t == (Object)null)
{
return false;
}
PauseManager instance = PauseManager.Instance;
if ((Object)(object)instance != (Object)null)
{
return (Object)(object)t.parent == (Object)(object)((Component)instance).transform;
}
return false;
}
private static void PunchPostfix(Transform target, Vector3 punch, object __result)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Expected O, but got Unknown
try
{
if (!IsHitmarker(target))
{
return;
}
if (DorsthTweaksPlugin.HideHitmarkers.Value)
{
Tween val = (Tween)((__result is Tween) ? __result : null);
if (val != null)
{
TweenExtensions.Kill(val, false);
}
((Component)target).gameObject.SetActive(false);
return;
}
bool flag = punch.x > 2f;
if ((flag ? DorsthTweaksPlugin.HeadshotColor : DorsthTweaksPlugin.BodyshotColor).IsDefault)
{
return;
}
Graphic component = ((Component)target).GetComponent<Graphic>();
if (!((Object)(object)component == (Object)null))
{
Waiting.Add(new Marker
{
Graphic = component,
Head = flag
});
if (!_listening)
{
Canvas.preWillRenderCanvases += new WillRenderCanvases(Paint);
_listening = true;
}
}
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
}
private static void Paint()
{
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
try
{
foreach (Marker item in Waiting)
{
if (!((Object)(object)item.Graphic == (Object)null))
{
Color color = (item.Head ? DorsthTweaksPlugin.HeadshotColor : DorsthTweaksPlugin.BodyshotColor).Color;
item.Graphic.color = new Color(color.r, color.g, color.b, color.a * item.Graphic.color.a);
}
}
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
finally
{
Waiting.Clear();
Canvas.preWillRenderCanvases -= new WillRenderCanvases(Paint);
_listening = false;
}
}
}
internal static class Stats
{
private static readonly List<HUD> Counters = new List<HUD>();
private static readonly HashSet<Behaviour> Hidden = new HashSet<Behaviour>();
private static FieldRef<HUD, bool> _fps;
private static FieldRef<HUD, bool> _ping;
internal static void Install()
{
_fps = AccessTools.FieldRefAccess<HUD, bool>("fpsDisplay");
_ping = AccessTools.FieldRefAccess<HUD, bool>("pingDisplay");
DorsthTweaksPlugin.Harmony.Patch((MethodBase)DorsthTweaksPlugin.Target(typeof(HUD), "Awake"), (HarmonyMethod)null, DorsthTweaksPlugin.Patch(typeof(Stats), "HudAwakePostfix"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
DorsthTweaksPlugin.HideFps.SettingChanged += delegate
{
ApplyAll();
};
DorsthTweaksPlugin.HidePing.SettingChanged += delegate
{
ApplyAll();
};
}
private static void HudAwakePostfix(HUD __instance)
{
try
{
if (_fps.Invoke(__instance) || _ping.Invoke(__instance))
{
Counters.RemoveAll((HUD c) => (Object)(object)c == (Object)null);
Hidden.RemoveWhere((Behaviour b) => (Object)(object)b == (Object)null);
Counters.Add(__instance);
Apply(__instance);
}
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
}
internal static void ApplyAll()
{
try
{
Counters.RemoveAll((HUD c) => (Object)(object)c == (Object)null);
foreach (HUD counter in Counters)
{
Apply(counter);
}
PauseManager instance = PauseManager.Instance;
if (!((Object)(object)instance == (Object)null))
{
Show((Behaviour)(object)instance.minimalFpsText, !DorsthTweaksPlugin.HideFps.Value);
Show((Behaviour)(object)instance.minimalPingText, !DorsthTweaksPlugin.HidePing.Value);
}
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
}
private static void Apply(HUD counter)
{
bool show = !(_fps.Invoke(counter) ? DorsthTweaksPlugin.HideFps.Value : DorsthTweaksPlugin.HidePing.Value);
Show((Behaviour)(object)((Component)counter).GetComponent<Graphic>(), show);
Show((Behaviour)(object)counter, show);
Transform parent = ((Component)counter).transform.parent;
if (!((Object)(object)parent == (Object)null) && parent.childCount == 2)
{
Transform val = (((Object)(object)parent.GetChild(0) == (Object)(object)((Component)counter).transform) ? parent.GetChild(1) : parent.GetChild(0));
if (val.childCount == 0 && !((Object)(object)((Component)val).GetComponent<HUD>() != (Object)null))
{
Show((Behaviour)(object)((Component)val).GetComponent<Graphic>(), show);
}
}
}
private static void Show(Behaviour part, bool show)
{
if ((Object)(object)part == (Object)null)
{
return;
}
if (!show)
{
if (part.enabled && Hidden.Add(part))
{
part.enabled = false;
}
}
else if (Hidden.Remove(part))
{
part.enabled = true;
}
}
}
internal static class TextColors
{
private static readonly Dictionary<TMP_Text, Color> Originals = new Dictionary<TMP_Text, Color>();
private static readonly Dictionary<TMP_Text, Material> GameMaterials = new Dictionary<TMP_Text, Material>();
private static readonly Dictionary<TMP_Text, Material> Copies = new Dictionary<TMP_Text, Material>();
internal static void Install()
{
DorsthTweaksPlugin.Harmony.Patch((MethodBase)DorsthTweaksPlugin.Target(typeof(PauseManager), "Awake"), (HarmonyMethod)null, DorsthTweaksPlugin.Patch(typeof(TextColors), "PauseManagerPostfix"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
DorsthTweaksPlugin.MinimalHudColor.Changed += ApplyHud;
DorsthTweaksPlugin.PromptColor.Changed += ApplyPrompts;
}
private static void PauseManagerPostfix(PauseManager __instance)
{
if (!((Object)(object)PauseManager.Instance != (Object)(object)__instance))
{
ApplyHud();
ApplyPrompts();
Stats.ApplyAll();
}
}
private static void ApplyHud()
{
try
{
PauseManager instance = PauseManager.Instance;
if ((Object)(object)instance == (Object)null)
{
return;
}
HashSet<TMP_Text> hashSet = new HashSet<TMP_Text>();
if ((Object)(object)instance.minimalistUi != (Object)null)
{
hashSet.UnionWith(instance.minimalistUi.GetComponentsInChildren<TMP_Text>(true));
}
TMP_Text[] array = (TMP_Text[])(object)new TMP_Text[7]
{
(TMP_Text)instance.minimalistHealthText,
(TMP_Text)instance.minimalFpsText,
(TMP_Text)instance.minimalPingText,
(TMP_Text)instance.rightGunAmmo,
(TMP_Text)instance.leftGunAmmo,
(TMP_Text)instance.rightGunAmmoReload,
(TMP_Text)instance.leftGunAmmoReload
};
foreach (TMP_Text val in array)
{
if ((Object)(object)val != (Object)null)
{
hashSet.Add(val);
}
}
foreach (TMP_Text item in hashSet)
{
Apply(item, DorsthTweaksPlugin.MinimalHudColor);
}
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
}
private static void ApplyPrompts()
{
try
{
PauseManager instance = PauseManager.Instance;
if (!((Object)(object)instance == (Object)null))
{
ApplyGlow((TMP_Text)(object)instance.grabPopup, DorsthTweaksPlugin.PromptColor);
ApplyGlow((TMP_Text)(object)instance.interactPopup, DorsthTweaksPlugin.PromptColor);
}
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
}
private static void ApplyGlow(TMP_Text text, ColorSetting setting)
{
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Expected O, but got Unknown
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)text == (Object)null)
{
return;
}
Material value;
bool flag = GameMaterials.TryGetValue(text, out value);
if (!flag)
{
value = text.fontSharedMaterial;
}
if ((Object)(object)value == (Object)null || !value.HasProperty(ShaderUtilities.ID_OutlineColor) || value.GetFloat(ShaderUtilities.ID_OutlineWidth) <= 0f)
{
Apply(text, setting);
return;
}
if (setting.IsDefault)
{
if (flag)
{
Material val = Copies[text];
text.fontSharedMaterial = value;
GameMaterials.Remove(text);
Copies.Remove(text);
if ((Object)(object)val != (Object)null)
{
Object.Destroy((Object)(object)val);
}
}
return;
}
if (!Copies.TryGetValue(text, out var value2) || (Object)(object)value2 == (Object)null)
{
value2 = new Material(value)
{
name = ((Object)value).name + " (DorsthTweaks)"
};
GameMaterials[text] = value;
Copies[text] = value2;
}
value2.SetColor(ShaderUtilities.ID_OutlineColor, setting.Like(value.GetColor(ShaderUtilities.ID_OutlineColor)));
if ((Object)(object)text.fontSharedMaterial != (Object)(object)value2)
{
text.fontSharedMaterial = value2;
}
}
private static void Apply(TMP_Text text, ColorSetting setting)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: 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_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)text == (Object)null)
{
return;
}
Color value;
bool flag = Originals.TryGetValue(text, out value);
if (setting.IsDefault)
{
if (flag)
{
((Graphic)text).color = value;
}
return;
}
if (!flag)
{
value = (Originals[text] = ((Graphic)text).color);
}
Color color2 = setting.Color;
((Graphic)text).color = new Color(color2.r, color2.g, color2.b, color2.a * value.a);
}
}
internal static class WeaponHighlight
{
private static readonly Dictionary<Material, Color> Originals = new Dictionary<Material, Color>();
private static FieldRef<ItemBehaviour, List<Material>> _materials;
private static int _outlineColor;
internal static void Install()
{
//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_003f: Expected O, but got Unknown
_materials = AccessTools.FieldRefAccess<ItemBehaviour, List<Material>>("hoveredObjectMat");
_outlineColor = Shader.PropertyToID("_Color_Outline");
HarmonyMethod val = new HarmonyMethod(DorsthTweaksPlugin.Target(typeof(WeaponHighlight), "FocusPostfix"))
{
priority = 0
};
DorsthTweaksPlugin.Harmony.Patch((MethodBase)DorsthTweaksPlugin.Target(typeof(ItemBehaviour), "OnFocus"), (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
SceneManager.sceneLoaded += delegate
{
Scenes.PruneGone<Material, Color>(Originals);
};
}
private static void FocusPostfix(ItemBehaviour __instance)
{
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
try
{
ColorSetting weaponHighlightColor = DorsthTweaksPlugin.WeaponHighlightColor;
if (weaponHighlightColor.IsDefault && Originals.Count == 0)
{
return;
}
List<Material> list = _materials.Invoke(__instance);
if (list == null)
{
return;
}
foreach (Material item in list)
{
if ((Object)(object)item == (Object)null)
{
continue;
}
if (!Originals.TryGetValue(item, out var value))
{
if (weaponHighlightColor.IsDefault || !item.HasProperty(_outlineColor))
{
continue;
}
value = (Originals[item] = item.GetColor(_outlineColor));
}
else if (weaponHighlightColor.IsDefault)
{
item.SetColor(_outlineColor, value);
Originals.Remove(item);
continue;
}
item.SetColor(_outlineColor, weaponHighlightColor.Like(value));
}
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
}
}
internal static class NearMiss
{
internal static void Install()
{
DorsthTweaksPlugin.Harmony.Patch((MethodBase)DorsthTweaksPlugin.Target(typeof(CameraEffect), "TrigSup"), DorsthTweaksPlugin.Patch(typeof(NearMiss), "VignettePrefix"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
private static bool VignettePrefix()
{
return !DorsthTweaksPlugin.HideNearMissVignette.Value;
}
}
internal static class StaticUI
{
private struct ParticleState
{
public bool Emission;
public bool Playing;
}
private struct NewTween
{
public Tween Tween;
public object Target;
}
private static readonly Func<bool> On = () => DorsthTweaksPlugin.ReduceUIAnimations.Value;
private static FieldRef<HUD, TMP_Text> _hudText;
private static FieldRef<HUD, PauseManager> _hudPause;
private static FieldRef<HUD, bool> _ammoRight;
private static FieldRef<HUD, bool> _ammoLeft;
private static FieldRef<HealthTween, TMP_Text> _healthText;
private static FieldRef<HealthTween, Color> _firstColor;
private static FieldRef<HealthTween, Color> _lastColor;
private static FieldRef<HUDTween, Transform> _hudUp;
private static FieldRef<HUDTween, Transform> _hudDown;
private static FieldRef<HUDTween, bool> _slidIn;
private static FieldRef<HUDTween, ClientInstance> _client;
private static int _healthShownBy;
private static int _healthShown = int.MinValue;
private static FieldRef<ButtonSizeTween, Vector3> _restScale;
private static FieldRef<ButtonSizeTween, bool> _scaleTextOnly;
private static FieldRef<ButtonSizeTween, bool> _scaleParent;
private static FieldRef<ButtonSizeTween, TextMeshProUGUI> _scaledText;
private static FieldRef<ModelButtonTween, Vector3> _modelRest;
private static FieldRef<ScaleTweenLoop, bool> _loopOnStart;
private static FieldRef<AlphaYoyo, TextMeshProUGUI> _yoyoText;
private static FieldRef<AlphaYoyo, Color> _yoyoColor;
private static FieldRef<AboubiPreviewLobby, bool> _runningIn;
private static MethodInfo _loopStart;
private static readonly Dictionary<Selectable, float> Fades = new Dictionary<Selectable, float>();
private static readonly Dictionary<Toggle, ToggleTransition> ToggleFades = new Dictionary<Toggle, ToggleTransition>();
private static readonly Dictionary<Selectable, float> ListFades = new Dictionary<Selectable, float>();
private static readonly Dictionary<TMP_InputField, float> Carets = new Dictionary<TMP_InputField, float>();
private static readonly Dictionary<ParticleSystem, ParticleState> Particles = new Dictionary<ParticleSystem, ParticleState>();
private static readonly HashSet<ScaleTweenLoop> StoppedLoops = new HashSet<ScaleTweenLoop>();
private static readonly List<NewTween> NewTweens = new List<NewTween>();
private static bool _finishing;
internal static void Install()
{
_hudText = AccessTools.FieldRefAccess<HUD, TMP_Text>("text");
_hudPause = AccessTools.FieldRefAccess<HUD, PauseManager>("pauseManager");
_ammoRight = AccessTools.FieldRefAccess<HUD, bool>("ammoRight");
_ammoLeft = AccessTools.FieldRefAccess<HUD, bool>("ammoLeft");
_healthText = AccessTools.FieldRefAccess<HealthTween, TMP_Text>("text");
_firstColor = AccessTools.FieldRefAccess<HealthTween, Color>("firstColor");
_lastColor = AccessTools.FieldRefAccess<HealthTween, Color>("lastColor");
_hudUp = AccessTools.FieldRefAccess<HUDTween, Transform>("hudUp");
_hudDown = AccessTools.FieldRefAccess<HUDTween, Transform>("hudDown");
_slidIn = AccessTools.FieldRefAccess<HUDTween, bool>("trigger");
_client = AccessTools.FieldRefAccess<HUDTween, ClientInstance>("clientScript");
_restScale = AccessTools.FieldRefAccess<ButtonSizeTween, Vector3>("initScale");
_scaleTextOnly = AccessTools.FieldRefAccess<ButtonSizeTween, bool>("scaleTextOnly");
_scaleParent = AccessTools.FieldRefAccess<ButtonSizeTween, bool>("parentScale");
_scaledText = AccessTools.FieldRefAccess<ButtonSizeTween, TextMeshProUGUI>("textChild");
_modelRest = AccessTools.FieldRefAccess<ModelButtonTween, Vector3>("initialPosition");
_loopOnStart = AccessTools.FieldRefAccess<ScaleTweenLoop, bool>("loopOnStart");
_yoyoText = AccessTools.FieldRefAccess<AlphaYoyo, TextMeshProUGUI>("text");
_yoyoColor = AccessTools.FieldRefAccess<AlphaYoyo, Color>("initialColor");
_runningIn = AccessTools.FieldRefAccess<AboubiPreviewLobby, bool>("isRunning");
_loopStart = DorsthTweaksPlugin.Target(typeof(ScaleTweenLoop), "Start");
Type typeFromHandle = typeof(StaticUI);
GameHook.Add(typeof(HUD), "Update", null, typeFromHandle, "AmmoPrefix", null, On);
GameHook.Add(typeof(HealthTween), "Update", null, typeFromHandle, "HeartbeatPrefix", null, On);
GameHook.Add(typeof(HealthTween), "ChangeState", null, typeFromHandle, "HealthChangePrefix", null, On);
GameHook.Add(typeof(HUDTween), "Update", null, typeFromHandle, "SlideInPrefix", null, On);
GameHook.Add(typeof(HUDTween), "MoveUp", null, typeFromHandle, "MoveUpPrefix", null, On);
string[] array = new string[4] { "OnPointerEnter", "OnPointerExit", "OnSelect", "OnDeselect" };
foreach (string method in array)
{
GameHook.Add(typeof(ButtonSizeTween), method, null, typeFromHandle, null, "StayPostfix", On);
}
array = new string[4] { "Hover", "Leave", "Press", "Release" };
foreach (string method2 in array)
{
GameHook.Add(typeof(ModelButtonTween), method2, null, typeFromHandle, "Skip", null, On);
}
GameHook.Add(typeof(ScaleTweenLoop), "Start", null, typeFromHandle, "LoopStartPrefix", null, On);
GameHook.Add(typeof(ScaleTweenLoop), "TempTween", null, typeFromHandle, "Skip", null, On);
GameHook.Add(typeof(AlphaYoyo), "Update", null, typeFromHandle, "Skip", null, On);
GameHook.Add(typeof(AboubiPreview), "Update", null, typeFromHandle, "Skip", null, On);
GameHook.Add(typeof(AboubiPreviewLobby), "Update", null, typeFromHandle, null, "LobbyPostfix", On);
GameHook.Add(typeof(MenuAnimation), "Update", null, typeFromHandle, "Skip", null, On);
GameHook.Add(typeof(Rotate), "Update", null, typeFromHandle, "SkipInMenu", null, On);
array = new string[3] { "ChangeState", "SetEnabled", "SetDisabled" };
foreach (string method3 in array)
{
GameHook.Add(typeof(MenuHUDTween), method3, null, typeFromHandle, null, "FinishPostfix", On);
}
array = new string[2] { "ChangeState", "ChooseState" };
foreach (string method4 in array)
{
GameHook.Add(typeof(MoveUIObject), method4, null, typeFromHandle, null, "FinishPostfix", On);
}
GameHook.Add(typeof(Selectable), "OnEnable", null, typeFromHandle, null, "SelectableEnablePostfix", On);
Type typeFromHandle2 = typeof(ShortcutExtensions);
GameHook.Add(typeFromHandle2, "DOMove", new Type[4]
{
typeof(Transform),
typeof(Vector3),
typeof(float),
typeof(bool)
}, typeFromHandle, null, "TweenPostfix", On);
GameHook.Add(typeFromHandle2, "DOLocalMove", new Type[4]
{
typeof(Transform),
typeof(Vector3),
typeof(float),
typeof(bool)
}, typeFromHandle, null, "TweenPostfix", On);
GameHook.Add(typeFromHandle2, "DOScale", new Type[3]
{
typeof(Transform),
typeof(Vector3),
typeof(float)
}, typeFromHandle, null, "TweenPostfix", On);
GameHook.Add(typeFromHandle2, "DOScale", new Type[3]
{
typeof(Transform),
typeof(float),
typeof(float)
}, typeFromHandle, null, "TweenPostfix", On);
GameHook.Add(typeFromHandle2, "DOPunchScale", new Type[5]
{
typeof(Transform),
typeof(Vector3),
typeof(float),
typeof(int),
typeof(float)
}, typeFromHandle, null, "TweenPostfix", On);
GameHook.Add(typeof(DOTweenModuleUI), "DOColor", new Type[3]
{
typeof(Image),
typeof(Color),
typeof(float)
}, typeFromHandle, null, "ImageTweenPostfix", On);
DorsthTweaksPlugin.OnChange(DorsthTweaksPlugin.ReduceUIAnimations, Apply);
SceneManager.sceneLoaded += OnSceneLoaded;
}
private static void Apply()
{
if (On())
{
Still();
}
else
{
Restore();
}
}
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
if (!On() || ((Scene)(ref scene)).name != "MainMenu")
{
return;
}
try
{
Still();
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
}
private static bool InMenu(Component c)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)c != (Object)null)
{
return Scenes.IsMenu(c.gameObject.scene);
}
return false;
}
private static bool InMainMenuScene(Component c)
{
//IL_000f: 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)
if ((Object)(object)c != (Object)null)
{
Scene scene = c.gameObject.scene;
return ((Scene)(ref scene)).name == "MainMenu";
}
return false;
}
private static void Still()
{
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Expected O, but got Unknown
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Expected O, but got Unknown
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Expected O, but got Unknown
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Expected O, but got Unknown
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Expected O, but got Unknown
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
//IL_023c: Expected O, but got Unknown
//IL_029e: Unknown result type (might be due to invalid IL or missing references)
//IL_02a5: Expected O, but got Unknown
//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
Stills.Prune();
Scenes.PruneGone<Selectable, float>(Fades);
Scenes.PruneGone<Toggle, ToggleTransition>(ToggleFades);
Scenes.PruneGone<Selectable, float>(ListFades);
Scenes.PruneGone<TMP_InputField, float>(Carets);
Scenes.PruneGone<ParticleSystem, ParticleState>(Particles);
StoppedLoops.RemoveWhere((ScaleTweenLoop loop) => (Object)(object)loop == (Object)null);
Object[] array = Scenes.FindAll(typeof(Selectable));
for (int num = 0; num < array.Length; num++)
{
Selectable val = (Selectable)array[num];
if (InMenu((Component)(object)val))
{
StillSelectable(val);
}
}
array = Scenes.FindAll(typeof(ParticleSystem));
for (int num = 0; num < array.Length; num++)
{
ParticleSystem val2 = (ParticleSystem)array[num];
if (InMainMenuScene((Component)(object)val2))
{
StillParticles(val2);
}
}
array = Scenes.FindAll(typeof(Renderer));
for (int num = 0; num < array.Length; num++)
{
Renderer val3 = (Renderer)array[num];
if (!(val3 is ParticleSystemRenderer) && InMainMenuScene((Component)(object)val3))
{
Material[] sharedMaterials = val3.sharedMaterials;
for (int num2 = 0; num2 < sharedMaterials.Length; num2++)
{
Stills.Freeze(sharedMaterials[num2], 1);
}
}
}
array = Scenes.FindAll(typeof(Graphic));
for (int num = 0; num < array.Length; num++)
{
Graphic val4 = (Graphic)array[num];
if (!(val4 is TMP_Text) && !(val4 is TMP_SubMeshUI) && InMenu((Component)(object)val4))
{
Stills.Freeze(val4.material, 1);
}
}
World.StillSky();
array = Scenes.FindAll(typeof(ButtonSizeTween));
for (int num = 0; num < array.Length; num++)
{
ButtonSizeTween val5 = (ButtonSizeTween)array[num];
if (((Behaviour)val5).isActiveAndEnabled)
{
Stay(val5);
}
}
array = Scenes.FindAll(typeof(ModelButtonTween));
for (int num = 0; num < array.Length; num++)
{
ModelButtonTween val6 = (ModelButtonTween)array[num];
Vector3 val7 = _modelRest.Invoke(val6);
if (!(val7 == Vector3.zero))
{
ShortcutExtensions.DOKill((Component)(object)((Component)val6).transform, false);
((Component)val6).transform.localPosition = val7;
}
}
array = Scenes.FindAll(typeof(ScaleTweenLoop));
for (int num = 0; num < array.Length; num++)
{
ScaleTweenLoop val8 = (ScaleTweenLoop)array[num];
Transform transform = ((Component)val8).transform;
if (DOTween.IsTweening((object)transform, false))
{
ShortcutExtensions.DORewind((Component)(object)transform, true);
ShortcutExtensions.DOKill((Component)(object)transform, false);
if (_loopOnStart.Invoke(val8))
{
StoppedLoops.Add(val8);
}
}
}
array = Scenes.FindAll(typeof(AlphaYoyo));
for (int num = 0; num < array.Length; num++)
{
AlphaYoyo val9 = (AlphaYoyo)array[num];
TextMeshProUGUI val10 = _yoyoText.Invoke(val9);
if ((Object)(object)val10 != (Object)null)
{
((Graphic)val10).color = _yoyoColor.Invoke(val9);
}
}
}
private static void SelectableEnablePostfix(Selectable __instance)
{
try
{
if (InMenu((Component)(object)__instance))
{
StillSelectable(__instance);
}
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
}
private static void StillSelectable(Selectable s)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
ColorBlock colors = s.colors;
if (((ColorBlock)(ref colors)).fadeDuration > 0f && !Fades.ContainsKey(s))
{
Fades[s] = ((ColorBlock)(ref colors)).fadeDuration;
((ColorBlock)(ref colors)).fadeDuration = 0f;
s.colors = colors;
}
Toggle val = (Toggle)(object)((s is Toggle) ? s : null);
if ((Object)(object)val != (Object)null && (int)val.toggleTransition != 0 && !ToggleFades.ContainsKey(val))
{
ToggleFades[val] = val.toggleTransition;
val.toggleTransition = (ToggleTransition)0;
}
Dropdown val2 = (Dropdown)(object)((s is Dropdown) ? s : null);
if ((Object)(object)val2 != (Object)null && val2.alphaFadeSpeed > 0f && !ListFades.ContainsKey(s))
{
ListFades[s] = val2.alphaFadeSpeed;
val2.alphaFadeSpeed = 0f;
}
TMP_Dropdown val3 = (TMP_Dropdown)(object)((s is TMP_Dropdown) ? s : null);
if ((Object)(object)val3 != (Object)null && val3.alphaFadeSpeed > 0f && !ListFades.ContainsKey(s))
{
ListFades[s] = val3.alphaFadeSpeed;
val3.alphaFadeSpeed = 0f;
}
TMP_InputField val4 = (TMP_InputField)(object)((s is TMP_InputField) ? s : null);
if ((Object)(object)val4 != (Object)null && val4.caretBlinkRate > 0f && !Carets.ContainsKey(val4))
{
Carets[val4] = val4.caretBlinkRate;
val4.caretBlinkRate = 0f;
}
}
private static void StillParticles(ParticleSystem ps)
{
//IL_000f: 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)
if (!Particles.ContainsKey(ps))
{
EmissionModule emission = ps.emission;
Particles[ps] = new ParticleState
{
Emission = ((EmissionModule)(ref emission)).enabled,
Playing = ps.isPlaying
};
((EmissionModule)(ref emission)).enabled = false;
ps.Stop(false, (ParticleSystemStopBehavior)0);
}
}
private static void Restore()
{
//IL_002b: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
foreach (KeyValuePair<Selectable, float> fade in Fades)
{
if (!((Object)(object)fade.Key == (Object)null))
{
ColorBlock colors = fade.Key.colors;
((ColorBlock)(ref colors)).fadeDuration = fade.Value;
fade.Key.colors = colors;
}
}
Fades.Clear();
foreach (KeyValuePair<Toggle, ToggleTransition> toggleFade in ToggleFades)
{
if ((Object)(object)toggleFade.Key != (Object)null)
{
toggleFade.Key.toggleTransition = toggleFade.Value;
}
}
ToggleFades.Clear();
foreach (KeyValuePair<Selectable, float> listFade in ListFades)
{
Selectable key = listFade.Key;
Dropdown val = (Dropdown)(object)((key is Dropdown) ? key : null);
if ((Object)(object)val != (Object)null)
{
val.alphaFadeSpeed = listFade.Value;
}
Selectable key2 = listFade.Key;
TMP_Dropdown val2 = (TMP_Dropdown)(object)((key2 is TMP_Dropdown) ? key2 : null);
if ((Object)(object)val2 != (Object)null)
{
val2.alphaFadeSpeed = listFade.Value;
}
}
ListFades.Clear();
foreach (KeyValuePair<TMP_InputField, float> caret in Carets)
{
if ((Object)(object)caret.Key != (Object)null)
{
caret.Key.caretBlinkRate = caret.Value;
}
}
Carets.Clear();
foreach (KeyValuePair<ParticleSystem, ParticleState> particle in Particles)
{
ParticleSystem key3 = particle.Key;
if (!((Object)(object)key3 == (Object)null))
{
EmissionModule emission = key3.emission;
((EmissionModule)(ref emission)).enabled = particle.Value.Emission;
if (particle.Value.Playing)
{
key3.Play(false);
}
}
}
Particles.Clear();
Stills.Release(1);
foreach (ScaleTweenLoop stoppedLoop in StoppedLoops)
{
if ((Object)(object)stoppedLoop != (Object)null && ((Behaviour)stoppedLoop).isActiveAndEnabled && !DOTween.IsTweening((object)((Component)stoppedLoop).transform, false))
{
_loopStart.Invoke(stoppedLoop, null);
}
}
StoppedLoops.Clear();
}
private static bool Skip()
{
return false;
}
private static bool SkipInMenu()
{
return !Scenes.InMainMenu();
}
private static void StayPostfix(ButtonSizeTween __instance)
{
try
{
Stay(__instance);
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
}
private static void Stay(ButtonSizeTween b)
{
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
Transform val2;
if (_scaleTextOnly.Invoke(b))
{
TextMeshProUGUI val = _scaledText.Invoke(b);
val2 = (((Object)(object)val != (Object)null) ? ((TMP_Text)val).transform : null);
}
else
{
val2 = (_scaleParent.Invoke(b) ? ((Component)b).transform.parent : ((Component)b).transform);
}
Vector3 val3 = _restScale.Invoke(b);
if (!((Object)(object)val2 == (Object)null) && !(val3 == Vector3.zero) && !(val2.localScale == Vector3.zero))
{
ShortcutExtensions.DOKill((Component)(object)val2, false);
val2.localScale = val3;
}
}
private static void LobbyPostfix(AboubiPreviewLobby __instance)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
if (!_runningIn.Invoke(__instance))
{
((Component)__instance).transform.forward = -Vector3.forward;
}
}
private static bool LoopStartPrefix(ScaleTweenLoop __instance)
{
if (_loopOnStart.Invoke(__instance))
{
StoppedLoops.Add(__instance);
}
return false;
}
private static void FinishPostfix(MonoBehaviour __instance)
{
try
{
ShortcutExtensions.DOComplete((Component)(object)((Component)__instance).transform, false);
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
}
private static void TweenPostfix(Transform target, object __result)
{
try
{
if (target is RectTransform && !Hitmarkers.IsHitmarker(target))
{
Queue((Tween)((__result is Tween) ? __result : null), target);
}
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
}
private static void ImageTweenPostfix(Image target, object __result)
{
try
{
Queue((Tween)((__result is Tween) ? __result : null), target);
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
}
private static void Queue(Tween tween, object target)
{
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
if (tween != null)
{
NewTweens.Add(new NewTween
{
Tween = tween,
Target = target
});
if (!_finishing)
{
Canvas.preWillRenderCanvases += new WillRenderCanvases(FinishTweens);
_finishing = true;
}
}
}
private static void FinishTweens()
{
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Expected O, but got Unknown
try
{
for (int i = 0; i < NewTweens.Count && i < 1000; i++)
{
Tween tween = NewTweens[i].Tween;
if (TweenExtensions.IsActive(tween) && tween.target == NewTweens[i].Target)
{
if (TweenExtensions.Loops(tween) == -1)
{
TweenExtensions.Rewind(tween, true);
TweenExtensions.Kill(tween, false);
}
else
{
TweenExtensions.Complete(tween, true);
}
}
}
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
finally
{
NewTweens.Clear();
Canvas.preWillRenderCanvases -= new WillRenderCanvases(FinishTweens);
_finishing = false;
}
}
private static bool AmmoPrefix(HUD __instance)
{
try
{
bool flag = _ammoRight.Invoke(__instance);
bool flag2 = _ammoLeft.Invoke(__instance);
if (!flag && !flag2)
{
return true;
}
PauseManager val = _hudPause.Invoke(__instance);
TMP_Text val2 = _hudText.Invoke(__instance);
if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
{
return true;
}
if (flag)
{
val2.text = ((TMP_Text)val.rightGunAmmo).text;
}
if (flag2)
{
val2.text = ((TMP_Text)val.leftGunAmmo).text;
}
return false;
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
return true;
}
}
private static bool HeartbeatPrefix(HealthTween __instance)
{
try
{
TMP_Text val = _healthText.Invoke(__instance);
if ((Object)(object)val == (Object)null)
{
return true;
}
int num = (int)Mathf.Ceil(__instance.health / 4f * 100f);
int instanceID = ((Object)__instance).GetInstanceID();
if (num != _healthShown || instanceID != _healthShownBy)
{
val.text = num.ToString(CultureInfo.InvariantCulture);
_healthShown = num;
_healthShownBy = instanceID;
}
return false;
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
return true;
}
}
private static bool HealthChangePrefix(HealthTween __instance)
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
try
{
TMP_Text val = _healthText.Invoke(__instance);
if ((Object)(object)val == (Object)null)
{
return true;
}
ShortcutExtensions.DOKill((Component)(object)((Component)__instance).transform, false);
((Component)__instance).transform.localScale = Vector3.one;
Color val2 = (((Graphic)val).color = Color.Lerp(_firstColor.Invoke(__instance), _lastColor.Invoke(__instance), 1f - __instance.health / 4f));
val.fontSharedMaterial.SetColor(ShaderUtilities.ID_GlowColor, val2);
val.outlineColor = Color32.op_Implicit(val2);
_healthShown = int.MinValue;
return false;
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
return true;
}
}
private static bool SlideInPrefix(HUDTween __instance)
{
try
{
ClientInstance val = _client.Invoke(__instance);
if ((Object)(object)val != (Object)null && val.nonSteamworksTransport)
{
Snap(__instance);
}
if (!_slidIn.Invoke(__instance) && (Object)(object)PauseManager.Instance != (Object)null && PauseManager.Instance.onStartRoundScreen)
{
_slidIn.Invoke(__instance) = true;
Snap(__instance);
}
return false;
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
return true;
}
}
private static bool MoveUpPrefix(HUDTween __instance)
{
try
{
Snap(__instance);
return false;
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
return true;
}
}
private static void Snap(HUDTween tween)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
Transform[] array = (Transform[])(object)new Transform[2]
{
_hudUp.Invoke(tween),
_hudDown.Invoke(tween)
};
foreach (Transform val in array)
{
if (!((Object)(object)val == (Object)null))
{
ShortcutExtensions.DOKill((Component)(object)val, false);
val.localPosition = Vector3.zero;
}
}
}
}
internal static class World
{
private struct BeamNoise
{
public bool UseGlobal;
public Vector3 Local;
}
private struct RainState
{
public bool Emission;
public bool Drawn;
public bool Playing;
}
private static readonly Func<bool> Textures = () => DorsthTweaksPlugin.StaticTextures.Value;
private static readonly Dictionary<Water, WaterMode> WaterModes = new Dictionary<Water, WaterMode>();
private static readonly List<PlanarReflection> Reflections = new List<PlanarReflection>();
private static readonly Dictionary<VolumetricLightBeam, BeamNoise> Beams = new Dictionary<VolumetricLightBeam, BeamNoise>();
private static readonly Dictionary<ParticleSystem, RainState> RainParticles = new Dictionary<ParticleSystem, RainState>();
private static readonly List<AudioSource> RainSounds = new List<AudioSource>();
internal static void Install()
{
Type typeFromHandle = typeof(World);
GameHook.Add(typeof(Water), "Update", null, typeFromHandle, "Skip", null, Textures);
GameHook.Add(typeof(WaterBasic), "Update", null, typeFromHandle, "Skip", null, Textures);
GameHook.Add(typeof(PlanarReflection), "WaterTileBeingRendered", null, typeFromHandle, "Skip", null, Textures);
GameHook.Add(typeof(Wobble), "Update", null, typeFromHandle, "Skip", null, Textures);
GameHook.Add(typeof(DF_SkyRotation), "Update", null, typeFromHandle, "SkyPrefix", null, () => DorsthTweaksPlugin.StaticTextures.Value || DorsthTweaksPlugin.ReduceUIAnimations.Value);
DorsthTweaksPlugin.OnChange(DorsthTweaksPlugin.StaticTextures, ApplyTextures);
DorsthTweaksPlugin.OnChange(DorsthTweaksPlugin.DisableRain, ApplyRain);
SceneManager.sceneLoaded += OnSceneLoaded;
SceneManager.activeSceneChanged += delegate(Scene previous, Scene now)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if (!((Scene)(ref now)).IsValid() || !((Scene)(ref now)).isLoaded)
{
return;
}
try
{
Stills.Release((!Scenes.IsMenu(now)) ? 1 : 2);
StillSky();
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
};
}
private static bool Skip()
{
return false;
}
internal static void StillSky()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).IsValid() && ((Scene)(ref activeScene)).isLoaded)
{
bool flag = Scenes.IsMenu(activeScene);
if (flag ? DorsthTweaksPlugin.ReduceUIAnimations.Value : Textures())
{
Stills.Freeze(RenderSettings.skybox, flag ? 1 : 2);
}
}
}
private static bool SkyPrefix()
{
return !(Scenes.InMainMenu() ? DorsthTweaksPlugin.ReduceUIAnimations.Value : DorsthTweaksPlugin.StaticTextures.Value);
}
private static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
try
{
if (!Scenes.IsMenu(scene))
{
if (DorsthTweaksPlugin.DisableRain.Value)
{
RemoveRain(scene);
}
if (Textures())
{
StillTextures(scene);
}
}
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
}
private static void ApplyTextures()
{
if (Textures())
{
StillTextures(null);
}
else
{
RestoreTextures();
}
}
private static bool InMap(Component c, Scene? only)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)c == (Object)null)
{
return false;
}
Scene scene = c.gameObject.scene;
if (!Scenes.IsMenu(scene))
{
if (only.HasValue)
{
return scene == only.Value;
}
return true;
}
return false;
}
private static void StillTextures(Scene? only)
{
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Expected O, but got Unknown
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Expected O, but got Unknown
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_016d: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Expected O, but got Unknown
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
Stills.Prune();
Scenes.PruneGone<Water, WaterMode>(WaterModes);
Scenes.PruneGone<VolumetricLightBeam, BeamNoise>(Beams);
Reflections.RemoveAll((PlanarReflection p) => (Object)(object)p == (Object)null);
Object[] array = Scenes.FindAll(typeof(Renderer));
for (int num = 0; num < array.Length; num++)
{
Renderer val = (Renderer)array[num];
if (!(val is ParticleSystemRenderer) && InMap((Component)(object)val, only))
{
Material[] sharedMaterials = val.sharedMaterials;
for (int num2 = 0; num2 < sharedMaterials.Length; num2++)
{
Stills.Freeze(sharedMaterials[num2], 2);
}
}
}
StillSky();
array = Scenes.FindAll(typeof(Water));
for (int num = 0; num < array.Length; num++)
{
Water val2 = (Water)array[num];
if (InMap((Component)(object)val2, only) && !WaterModes.ContainsKey(val2) && (int)val2.waterMode != 0)
{
WaterModes[val2] = val2.waterMode;
val2.waterMode = (WaterMode)0;
}
}
array = Scenes.FindAll(typeof(PlanarReflection));
for (int num = 0; num < array.Length; num++)
{
PlanarReflection val3 = (PlanarReflection)array[num];
if (InMap((Component)(object)val3, only) && ((Behaviour)val3).enabled)
{
((Behaviour)val3).enabled = false;
Reflections.Add(val3);
}
}
array = Scenes.FindAll(typeof(VolumetricLightBeam));
for (int num = 0; num < array.Length; num++)
{
VolumetricLightBeam val4 = (VolumetricLightBeam)array[num];
if (InMap((Component)(object)val4, only) && !Beams.ContainsKey(val4) && (int)val4.noiseMode != 0)
{
Beams[val4] = new BeamNoise
{
UseGlobal = val4.noiseVelocityUseGlobal,
Local = val4.noiseVelocityLocal
};
val4.noiseVelocityUseGlobal = false;
val4.noiseVelocityLocal = Vector3.zero;
val4.UpdateAfterManualPropertyChange();
}
}
}
private static void RestoreTextures()
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
Stills.Release(2);
foreach (KeyValuePair<Water, WaterMode> waterMode in WaterModes)
{
if ((Object)(object)waterMode.Key != (Object)null)
{
waterMode.Key.waterMode = waterMode.Value;
}
}
WaterModes.Clear();
foreach (PlanarReflection reflection in Reflections)
{
if ((Object)(object)reflection != (Object)null)
{
((Behaviour)reflection).enabled = true;
}
}
Reflections.Clear();
foreach (KeyValuePair<VolumetricLightBeam, BeamNoise> beam in Beams)
{
VolumetricLightBeam key = beam.Key;
if (!((Object)(object)key == (Object)null))
{
key.noiseVelocityUseGlobal = beam.Value.UseGlobal;
key.noiseVelocityLocal = beam.Value.Local;
key.UpdateAfterManualPropertyChange();
}
}
Beams.Clear();
}
private static void ApplyRain()
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
if (DorsthTweaksPlugin.DisableRain.Value)
{
RemoveRain(null);
return;
}
foreach (KeyValuePair<ParticleSystem, RainState> rainParticle in RainParticles)
{
ParticleSystem key = rainParticle.Key;
if (!((Object)(object)key == (Object)null))
{
EmissionModule emission = key.emission;
((EmissionModule)(ref emission)).enabled = rainParticle.Value.Emission;
ParticleSystemRenderer component = ((Component)key).GetComponent<ParticleSystemRenderer>();
if ((Object)(object)component != (Object)null)
{
((Renderer)component).enabled = rainParticle.Value.Drawn;
}
if (rainParticle.Value.Playing)
{
key.Play(false);
}
}
}
RainParticles.Clear();
foreach (AudioSource rainSound in RainSounds)
{
if ((Object)(object)rainSound != (Object)null)
{
((Behaviour)rainSound).enabled = true;
}
}
RainSounds.Clear();
}
private static void RemoveRain(Scene? only)
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Expected O, but got Unknown
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
Scenes.PruneGone<ParticleSystem, RainState>(RainParticles);
RainSounds.RemoveAll((AudioSource a) => (Object)(object)a == (Object)null);
Object[] array = Scenes.FindAll(typeof(ParticleSystem));
for (int num = 0; num < array.Length; num++)
{
ParticleSystem val = (ParticleSystem)array[num];
if (InMap((Component)(object)val, only) && !RainParticles.ContainsKey(val) && RainNamed((Component)(object)val))
{
EmissionModule emission = val.emission;
ParticleSystemRenderer component = ((Component)val).GetComponent<ParticleSystemRenderer>();
RainParticles[val] = new RainState
{
Emission = ((EmissionModule)(ref emission)).enabled,
Drawn = ((Object)(object)component != (Object)null && ((Renderer)component).enabled),
Playing = val.isPlaying
};
((EmissionModule)(ref emission)).enabled = false;
if ((Object)(object)component != (Object)null)
{
((Renderer)component).enabled = false;
}
val.Stop(false, (ParticleSystemStopBehavior)0);
}
}
array = Scenes.FindAll(typeof(AudioSource));
for (int num = 0; num < array.Length; num++)
{
AudioSource val2 = (AudioSource)array[num];
if (InMap((Component)(object)val2, only) && ((Behaviour)val2).enabled && (RainNamed((Component)(object)val2) || (val2.loop && (Object)(object)val2.clip != (Object)null && IsRainName(((Object)val2.clip).name))))
{
((Behaviour)val2).enabled = false;
RainSounds.Add(val2);
}
}
}
private static bool RainNamed(Component c)
{
if (IsRainName(((Object)c).name))
{
return true;
}
Transform parent = c.transform.parent;
if ((Object)(object)parent != (Object)null)
{
return IsRainName(((Object)parent).name);
}
return false;
}
private static bool IsRainName(string name)
{
if (string.IsNullOrEmpty(name))
{
return false;
}
string text = name.ToLowerInvariant();
if (text.Contains("pluie") || text.Contains("drizzle") || text.Contains("precipitation"))
{
return true;
}
for (int num = text.IndexOf("rain", StringComparison.Ordinal); num >= 0; num = text.IndexOf("rain", num + 1, StringComparison.Ordinal))
{
if ((num == 0 || !char.IsLetter(name[num - 1]) || (name[num] == 'R' && name[num + 1] == 'a')) && string.CompareOrdinal(text, num, "rainbow", 0, 7) != 0)
{
return true;
}
}
return false;
}
}
internal static class Stills
{
private struct Saved
{
public int Id;
public bool Vector;
public Vector4 Value;
}
private sealed class Frozen
{
public int Owners;
public Saved[] Values;
}
internal const int Menu = 1;
internal const int Maps = 2;
private static readonly Saved[] NoProps = new Saved[0];
private static readonly Dictionary<Shader, Saved[]> SpeedProps = new Dictionary<Shader, Saved[]>();
private static readonly Dictionary<Material, Frozen> FrozenMaterials = new Dictionary<Material, Frozen>();
internal static void Freeze(Material m, int owner)
{
//IL_00f4: 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_009a: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)m == (Object)null)
{
return;
}
if (FrozenMaterials.TryGetValue(m, out var value))
{
value.Owners |= owner;
return;
}
Saved[] array = PropsOf(m.shader);
if (array.Length == 0)
{
return;
}
List<Saved> list = new List<Saved>(array.Length);
Saved[] array2 = array;
for (int i = 0; i < array2.Length; i++)
{
Saved saved = array2[i];
if (m.HasProperty(saved.Id))
{
if (saved.Vector)
{
list.Add(new Saved
{
Id = saved.Id,
Vector = true,
Value = m.GetVector(saved.Id)
});
m.SetVector(saved.Id, Vector4.zero);
}
else
{
list.Add(new Saved
{
Id = saved.Id,
Value = new Vector4(m.GetFloat(saved.Id), 0f, 0f, 0f)
});
m.SetFloat(saved.Id, 0f);
}
}
}
if (list.Count > 0)
{
FrozenMaterials[m] = new Frozen
{
Owners = owner,
Values = list.ToArray()
};
}
}
internal static void Release(int owner)
{
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
List<Material> list = new List<Material>();
foreach (KeyValuePair<Material, Frozen> frozenMaterial in FrozenMaterials)
{
frozenMaterial.Value.Owners &= ~owner;
if (frozenMaterial.Value.Owners != 0)
{
continue;
}
list.Add(frozenMaterial.Key);
Material key = frozenMaterial.Key;
if ((Object)(object)key == (Object)null)
{
continue;
}
Saved[] values = frozenMaterial.Value.Values;
for (int i = 0; i < values.Length; i++)
{
Saved saved = values[i];
if (saved.Vector)
{
key.SetVector(saved.Id, saved.Value);
}
else
{
key.SetFloat(saved.Id, saved.Value.x);
}
}
}
foreach (Material item in list)
{
FrozenMaterials.Remove(item);
}
}
internal static void Prune()
{
Scenes.PruneGone<Material, Frozen>(FrozenMaterials);
}
private static Saved[] PropsOf(Shader shader)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Invalid comparison between Unknown and I4
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Invalid comparison between Unknown and I4
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Invalid comparison between Unknown and I4
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Invalid comparison between Unknown and I4
if ((Object)(object)shader == (Object)null)
{
return NoProps;
}
if (SpeedProps.TryGetValue(shader, out var value))
{
return value;
}
List<Saved> list = new List<Saved>();
int propertyCount = shader.GetPropertyCount();
for (int i = 0; i < propertyCount; i++)
{
ShaderPropertyType propertyType = shader.GetPropertyType(i);
if (((int)propertyType == 2 || (int)propertyType == 3 || (int)propertyType == 1) && IsSpeedName(shader.GetPropertyName(i)))
{
list.Add(new Saved
{
Id = shader.GetPropertyNameId(i),
Vector = ((int)propertyType == 1)
});
}
}
value = ((list.Count == 0) ? NoProps : list.ToArray());
SpeedProps[shader] = value;
return value;
}
private static bool IsSpeedName(string name)
{
string text = name.ToLowerInvariant();
if (!text.Contains("speed") && !text.Contains("scroll") && !text.Contains("panner") && !text.Contains("panning") && !text.Contains("fps") && !text.Contains("framerate") && !text.Contains("frame_rate") && !text.Contains("timescale"))
{
return text == "_bumpdirection";
}
return true;
}
}
internal static class Playlists
{
private static MethodInfo _addPresets;
private static FieldRef<MapsManager, TextMeshProUGUI> _activeLabel;
private static bool _gettingDefaults;
private static bool _waitingForMenu;
internal static void Install()
{
_addPresets = DorsthTweaksPlugin.Target(typeof(MapsManager), "AddPresetPlaylists");
_activeLabel = AccessTools.FieldRefAccess<MapsManager, TextMeshProUGUI>("activePlaylistText");
Harmony harmony = DorsthTweaksPlugin.Harmony;
harmony.Patch((MethodBase)_addPresets, DorsthTweaksPlugin.Patch(typeof(Playlists), "AddPresetsPrefix"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
harmony.Patch((MethodBase)DorsthTweaksPlugin.Target(typeof(MapsManager), "LoadState"), (HarmonyMethod)null, DorsthTweaksPlugin.Patch(typeof(Playlists), "LoadStatePostfix"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
DorsthTweaksPlugin.HideDefaultPlaylists.SettingChanged += delegate
{
SettingChanged();
};
}
private static bool AddPresetsPrefix(MapsManager __instance)
{
if (_gettingDefaults || !DorsthTweaksPlugin.HideDefaultPlaylists.Value)
{
return true;
}
try
{
KeepOne(__instance);
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
return false;
}
private static void LoadStatePostfix(MapsManager __instance)
{
try
{
if (DorsthTweaksPlugin.HideDefaultPlaylists.Value)
{
Clean(__instance, live: false);
}
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
}
private static void SettingChanged()
{
try
{
if ((Object)(object)MapsManager.Instance == (Object)null)
{
return;
}
if ((Object)(object)PauseManager.Instance != (Object)null && !PauseManager.Instance.inMainMenu)
{
if (!_waitingForMenu)
{
_waitingForMenu = true;
SceneManager.sceneLoaded += BackInMenu;
}
}
else
{
Apply(MapsManager.Instance);
}
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
}
private static void BackInMenu(Scene scene, LoadSceneMode mode)
{
if (((Scene)(ref scene)).name != "MainMenu")
{
return;
}
SceneManager.sceneLoaded -= BackInMenu;
_waitingForMenu = false;
try
{
if ((Object)(object)MapsManager.Instance != (Object)null)
{
Apply(MapsManager.Instance);
}
}
catch (Exception e)
{
DorsthTweaksPlugin.LogErrorOnce(e);
}
}
private static void Apply(MapsManager maps)
{
if (DorsthTweaksPlugin.HideDefaultPlaylists.Value)
{
Clean(maps, live: true);
return;
}
_addPresets.Invoke(maps, null);
maps.UpdatePlaylists(false);
}
private static void KeepOne(MapsManager maps)
{
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
if (maps.Playlists.Count == 0)
{
maps.Playlists.Add(new Playlist("Playlist n°1", new string[0], false));
}
}
private static Dictionary<string, string[]> GameDefaults(MapsManager maps)
{
List<Playlist> playlists = maps.Playlists;
List<Playlist> list = (maps.Playlists = new List<Playlist>());
_gettingDefaults = true;
try
{
_addPresets.Invoke(maps, null);
}
finally
{
_gettingDefaults = false;
maps.Playlists = playlists;
}
Dictionary<string, string[]> dictionary = new Dictionary<string, string[]>();
foreach (Playlist item in list)
{
if (item != null && item.Name != null && !dictionary.ContainsKey(item.Name))
{
dictionary[item.Name] = item.Maps;
}
}
return dictionary;
}
private static void Clean(MapsManager maps, bool live)
{
List<Playlist> playlists = maps.Playlists;
Dictionary<string, string[]> dictionary = GameDefaults(maps);
int selectedPlaylistIndex = maps.selectedPlaylistIndex;
int activePlaylistIndex = maps.activePlaylistIndex;
bool flag = selectedPlaylistIndex < 0 || selectedPlaylistIndex >= playlists.Count;
List<Playlist> list = new List<Playlist>(playlists.Count);
int num = -1;
int num2 = 0;
bool flag2 = false;
for (int i = 0; i < playlists.Count; i++)
{
Playlist val = playlists[i];
if (val != null && val.Name != null && dictionary.TryGetValue(val.Name, out var value))
{
flag2 = true;
if (i == selectedPlaylistIndex)
{
flag = true;
}
if (SameMaps(val.Maps, value))
{
continue;
}
val.Name = FreeName(playlists, val.Name + " (edited)");
}
if (i == activePlaylistIndex)
{
num = list.Count;
}
if (i == selectedPlaylistIndex)
{
num2 = list.Count;
}
list.Add(val);
}
if (flag2)
{
playlists.Clear();
playlists.AddRange(list);
KeepOne(maps);
maps.selectedPlaylistIndex = num2;
maps.activePlaylistIndex = num;
TextMeshProUGUI val2 = _activeLabel.Invoke(maps);
if ((Object)(object)val2 != (Object)null)
{
((TMP_Text)val2).text = ((num < 0) ? "all maps" : playlists[num].Name);
}
if (live)
{
maps.UpdatePlaylists(false);
}
if (flag)
{
maps.PopulateMapsFromPlayList(num2);
((TMP_Text)maps.currentPlaylistText).text = playlists[num2].Name;
}
}
}
private static bool SameMaps(string[] a, string[] b)
{
return new HashSet<string>(a ?? new string[0]).SetEquals(b ?? new string[0]);
}
private static string FreeName(List<Playlist> list, string wanted)
{
string name = wanted;
int num = 2;
while (list.Exists((Playlist p) => p != null && p.Name == name))
{
name = wanted + " " + num;
num++;
}
return name;
}
}