using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ComputerysModdingUtilities;
using FishNet.Object;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: StraftatMod(true)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MinimalViewmodelsReborn")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A remake of the original Minimal Viewmodels, updated with many new features and fixes.")]
[assembly: AssemblyFileVersion("1.1.3.0")]
[assembly: AssemblyInformationalVersion("1.1.3")]
[assembly: AssemblyProduct("kestrel.straftat.minimalviewmodels")]
[assembly: AssemblyTitle("MinimalViewmodelsReborn")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.3.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace MinimalViewmodelsReborn
{
public static class Configs
{
public static ConfigEntry<float> ViewmodelOffsetX { get; private set; }
public static ConfigEntry<float> ViewmodelOffsetY { get; private set; }
public static ConfigEntry<float> ViewmodelOffsetZ { get; private set; }
public static ConfigEntry<float> ViewmodelFOV { get; private set; }
public static ConfigEntry<bool> InvisibleViewmodels { get; private set; }
public static ConfigEntry<float> MuzzleFlashLightIntensity { get; private set; }
public static ConfigEntry<float> MuzzleFlashScale { get; private set; }
public static ConfigEntry<float> RunFovIncrease { get; private set; }
public static ConfigEntry<float> SlideFovIncrease { get; private set; }
public static ConfigEntry<float> RunSlideFovIncrease { get; private set; }
public static Vector3 ViewmodelOffset => new Vector3(ViewmodelOffsetX.Value, ViewmodelOffsetY.Value, ViewmodelOffsetZ.Value);
internal static void Init(ConfigFile config)
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Expected O, but got Unknown
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Expected O, but got Unknown
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Expected O, but got Unknown
InvisibleViewmodels = config.Bind<bool>("Viewmodels.Visibility", "Invisible Viewmodels", false, "Hides your weapon completely.");
ViewmodelFOV = config.Bind<float>("Viewmodels.Visibility", "Viewmodel FOV", 75f, "Set the FOV of the viewmodel camera.");
ViewmodelOffsetX = config.Bind<float>("Viewmodels.Offset", "Viewmodel X Offset", 0f, new ConfigDescription("Negative values will shift your held weapon left, Positive values will shift it right.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-5f, 5f), Array.Empty<object>()));
ViewmodelOffsetY = config.Bind<float>("Viewmodels.Offset", "Viewmodel Y Offset", -0.1f, new ConfigDescription("Negative values will shift your held weapon down, Positive values will shift it up.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-5f, 5f), Array.Empty<object>()));
ViewmodelOffsetZ = config.Bind<float>("Viewmodels.Offset", "Viewmodel Z Offset", 0f, new ConfigDescription("Negative values will shift your held weapon back, Positive values will shift it forward.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-5f, 5f), Array.Empty<object>()));
MuzzleFlashLightIntensity = config.Bind<float>("MuzzleFlashes.General", "Muzzle Flash Light Intensity", 1f, "A multiplier applied to the light intensity of muzzle flashes. Requires a map restart to apply.");
MuzzleFlashScale = config.Bind<float>("MuzzleFlashes.General", "Muzzle Flash Scale", 1f, "A multiplier applied to the scale of muzzle flashes. Requires a map restart to apply.");
RunFovIncrease = config.Bind<float>("DynamicFov.General", "Run Fov Increase", 15f, "When sprinting, your FOV will be increased by this amount.");
SlideFovIncrease = config.Bind<float>("DynamicFov.General", "Slide Fov Increase", 12f, "When sliding, your FOV will be increased by this amount.");
RunSlideFovIncrease = config.Bind<float>("DynamicFov.General", "Run Slide Fov Increase", 15f, "When sprinting and sliding, your FOV will be increased by this amount.");
}
}
public static class DynamicFovModifier
{
[HarmonyPatch(typeof(FirstPersonController))]
public static class FirstPersonControllerPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void ApplyOnStart(FirstPersonController __instance)
{
Apply(__instance);
}
}
public static void Apply(FirstPersonController controller)
{
if (Object.op_Implicit((Object)(object)controller))
{
controller.distToRunFov = Configs.RunFovIncrease.Value;
controller.distToSlideFov = Configs.SlideFovIncrease.Value;
controller.distToRunSlideFov = Configs.RunSlideFovIncrease.Value;
}
}
}
public static class MuzzleFlashModifier
{
[HarmonyPatch(typeof(Weapon))]
public static class WeaponPatch
{
[HarmonyPatch("Awake")]
[HarmonyPrefix]
public static void ModifyBrightness(Weapon __instance, ref float ___lightIntensity, GameObject ___muzzleFlash)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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)
string weaponName = ((Component)__instance).GetComponent<ItemBehaviour>().weaponName;
if (m_blackList.Any((string s) => s == weaponName))
{
return;
}
___lightIntensity *= Configs.MuzzleFlashLightIntensity.Value;
if (Object.op_Implicit((Object)(object)___muzzleFlash) && !m_modifiedMuzzleFlashes.Contains(___muzzleFlash))
{
ParticleSystem[] componentsInChildren = ___muzzleFlash.GetComponentsInChildren<ParticleSystem>(true);
foreach (ParticleSystem obj in componentsInChildren)
{
MainModule main = obj.main;
((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)1;
((Component)obj).gameObject.transform.localScale = Vector3.one * Configs.MuzzleFlashScale.Value;
}
m_modifiedMuzzleFlashes.Add(___muzzleFlash);
}
}
}
private static readonly string[] m_blackList = new string[2] { "phoenix", "taser" };
private static HashSet<GameObject> m_modifiedMuzzleFlashes = new HashSet<GameObject>();
public static void ClearModifiedSet()
{
m_modifiedMuzzleFlashes.Clear();
}
}
[BepInPlugin("kestrel.straftat.minimalviewmodels", "MinimalViewmodelsReborn", "1.1.3")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
public static readonly string loadBearingColonThree = ":3";
public static Plugin Instance { get; private set; }
private void Awake()
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
if (loadBearingColonThree != ":3")
{
Application.Quit();
}
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Instance = this;
Logger = ((BaseUnityPlugin)this).Logger;
Configs.Init(((BaseUnityPlugin)this).Config);
((BaseUnityPlugin)this).Config.SettingChanged += OnSettingChanged;
new Harmony("kestrel.straftat.minimalviewmodels").PatchAll();
Logger.LogInfo((object)"Hiiiiiiiiiiii :3");
}
private static void OnSettingChanged(object sender, SettingChangedEventArgs e)
{
ViewmodelModifier.ApplyTransforms();
MuzzleFlashModifier.ClearModifiedSet();
DynamicFovModifier.Apply(Settings.Instance.localPlayer);
}
}
public static class VfxPatches
{
[HarmonyPatch]
public static class SpawnBulletTrailPatch
{
[HarmonyTargetMethods]
private static IEnumerable<MethodBase> TargetMethods()
{
foreach (Type weaponType in m_weaponTypes)
{
MethodInfo method = weaponType.GetMethod("SpawnBulletTrail", BindingFlags.Instance | BindingFlags.NonPublic);
if ((object)method != null)
{
yield return method;
}
}
}
[HarmonyPrefix]
private static void FixHitPoint(Weapon __instance, ref Vector3 hitPoint, Camera ___cam, LineRenderer ___bulletTrailLocal)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: 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)
//IL_0034: 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 (((NetworkBehaviour)__instance).IsOwner)
{
hitPoint = ((Component)ViewmodelModifier.WeaponCam).transform.position + (hitPoint - ((Component)___cam).transform.position);
if (Object.op_Implicit((Object)(object)___bulletTrailLocal))
{
SetObjToLayer(((Component)___bulletTrailLocal).gameObject, m_heldLayer);
}
}
}
[HarmonyPostfix]
private static void ResetVfxLayers(Weapon __instance, LineRenderer ___bulletTrailLocal)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)__instance).IsOwner && Object.op_Implicit((Object)(object)___bulletTrailLocal))
{
SetObjToLayer(((Component)___bulletTrailLocal).gameObject, m_defaultLayer);
}
}
}
[HarmonyPatch(typeof(Weapon), "OnShoot")]
public static class WeaponPatch
{
[HarmonyPrefix]
public static void SetVfxLayers(Weapon __instance, GameObject ___ejectCaseVfx)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)__instance).IsOwner && Object.op_Implicit((Object)(object)___ejectCaseVfx))
{
SetObjToLayer(___ejectCaseVfx, m_heldLayer);
}
}
[HarmonyPostfix]
public static void ResetVfxLayers(Weapon __instance, GameObject ___ejectCaseVfx)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)__instance).IsOwner && Object.op_Implicit((Object)(object)___ejectCaseVfx))
{
SetObjToLayer(___ejectCaseVfx, m_defaultLayer);
}
}
}
[HarmonyPatch]
public static class MuzzleFlashFix
{
[HarmonyTargetMethods]
private static IEnumerable<MethodBase> TargetMethods()
{
foreach (Type weaponType in m_weaponTypes)
{
MethodInfo method = weaponType.GetMethod("ShootObserversEffect", BindingFlags.Instance | BindingFlags.NonPublic);
if ((object)method != null)
{
yield return method;
}
}
}
[HarmonyPrefix]
private static void SetVfxLayers(Weapon __instance, GameObject ___muzzleFlash)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)__instance).IsOwner && Object.op_Implicit((Object)(object)___muzzleFlash))
{
SetObjToLayer(___muzzleFlash, m_heldLayer);
}
}
[HarmonyPostfix]
private static void ResetVfxLayers(Weapon __instance, GameObject ___muzzleFlash)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)__instance).IsOwner && Object.op_Implicit((Object)(object)___muzzleFlash))
{
SetObjToLayer(___muzzleFlash, m_defaultLayer);
}
}
}
[HarmonyPatch(typeof(DualLauncher), "Update")]
public static class DualLauncherPatch
{
[HarmonyPrefix]
public static void SetVfxLayers(DualLauncher __instance, bool ___grenadeOpen, ParticleSystem ___grenadeSmoke)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (___grenadeOpen && ((NetworkBehaviour)__instance).IsOwner)
{
SetObjToLayer(((Component)___grenadeSmoke).gameObject, m_heldLayer);
}
}
[HarmonyPostfix]
public static void ResetVfxLayers(DualLauncher __instance, bool ___grenadeOpen, ParticleSystem ___grenadeSmoke)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (___grenadeOpen && ((NetworkBehaviour)__instance).IsOwner)
{
SetObjToLayer(((Component)___grenadeSmoke).gameObject, m_defaultLayer);
}
}
}
[HarmonyPatch(typeof(BeamGun))]
public static class WhatTheHellIsMuzzleFlash2
{
[HarmonyPatch("ShootObserversEffect")]
[HarmonyPrefix]
public static void SetVfxLayers(BeamGun __instance, GameObject ___muzzleFlash2)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)__instance).IsOwner && Object.op_Implicit((Object)(object)___muzzleFlash2))
{
SetObjToLayer(___muzzleFlash2, m_heldLayer);
}
}
[HarmonyPatch("ShootObserversEffect")]
[HarmonyPostfix]
public static void ResetVfxLayers(BeamGun __instance, GameObject ___muzzleFlash2)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)__instance).IsOwner && Object.op_Implicit((Object)(object)___muzzleFlash2))
{
SetObjToLayer(___muzzleFlash2, m_defaultLayer);
}
}
[HarmonyPatch("ShootObserversEffect2")]
[HarmonyPrefix]
public static void SetVfxLayers2(BeamGun __instance, GameObject ___muzzleFlash)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)__instance).IsOwner && Object.op_Implicit((Object)(object)___muzzleFlash))
{
SetObjToLayer(___muzzleFlash, m_heldLayer);
}
}
[HarmonyPatch("ShootObserversEffect2")]
[HarmonyPostfix]
public static void ResetVfxLayers2(BeamGun __instance, GameObject ___muzzleFlash)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)__instance).IsOwner && Object.op_Implicit((Object)(object)___muzzleFlash))
{
SetObjToLayer(___muzzleFlash, m_defaultLayer);
}
}
}
[HarmonyPatch(typeof(WeaponHandSpawner))]
public static class WeaponHandSpawnerPatch
{
[HarmonyPatch("HandlePlacement")]
[HarmonyPostfix]
private static void FixPlacementHologram(Transform ___previewObject)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
((Component)___previewObject.GetChild(0)).gameObject.layer = LayerMask.op_Implicit(m_defaultLayer);
}
}
private static IEnumerable<Type> m_weaponTypes = from t in AccessTools.AllTypes()
where t != typeof(Weapon) && typeof(Weapon).IsAssignableFrom(t)
select t;
private static LayerMask m_heldLayer = LayerMask.op_Implicit(LayerMask.NameToLayer("HeldWeapon"));
private static LayerMask m_defaultLayer = LayerMask.op_Implicit(LayerMask.NameToLayer("Default"));
private static void SetObjToLayer(GameObject obj, LayerMask layer)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
obj.layer = LayerMask.op_Implicit(layer);
foreach (Transform item in obj.transform)
{
((Component)item).gameObject.layer = LayerMask.op_Implicit(layer);
}
}
}
public static class ViewmodelModifier
{
[HarmonyPatch(typeof(PlayerSetup))]
public static class PlayerSetupPatch
{
[HarmonyPatch("OnStartClient")]
[HarmonyPostfix]
private static void FixCameras(PlayerSetup __instance, Camera[] ___cameras, LayerMask ___highMask)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)__instance).IsOwner)
{
___cameras[0].cullingMask = LayerMask.op_Implicit(___highMask);
WeaponCam = ___cameras[1];
((Behaviour)WeaponCam).enabled = true;
WeaponCam.farClipPlane = 100f;
if (Settings.Instance.qualitySetting < 2)
{
((Behaviour)((Component)WeaponCam).GetComponent<PostProcessLayer>()).enabled = false;
}
ApplyTransforms();
}
}
}
public static Camera WeaponCam { get; private set; }
public static void ApplyTransforms()
{
//IL_004f: 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)
if (Object.op_Implicit((Object)(object)WeaponCam))
{
((Behaviour)WeaponCam).enabled = !Configs.InvisibleViewmodels.Value;
if (!Configs.InvisibleViewmodels.Value)
{
WeaponCam.fieldOfView = Configs.ViewmodelFOV.Value;
((Component)WeaponCam).transform.localPosition = -Configs.ViewmodelOffset;
}
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "kestrel.straftat.minimalviewmodels";
public const string PLUGIN_NAME = "MinimalViewmodelsReborn";
public const string PLUGIN_VERSION = "1.1.3";
}
}