using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using GameNetcodeStuff;
using HarmonyLib;
using LethalWarfare2.Modules.Model;
using Microsoft.CodeAnalysis;
using ModelReplacement;
using ModelReplacement.AvatarBodyUpdater;
using UnityEngine;
using UnityEngine.InputSystem;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("LethalWarfare2")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("LethalWarfare2")]
[assembly: AssemblyTitle("LethalWarfare2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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 LethalWarfare2.Modules
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerBPatch : PlayerControllerB
{
public static InputAction toggleKey;
public static bool switchCamera;
public static bool forceDisable;
public static bool hasCustomModel;
public static bool spectatedHasCustomModel;
public static bool displayedTip;
private static GameObject globalPrefab;
private static GameObject _postProcessing;
private static GameObject _playerHelmet;
public static GameObject PostProcessing
{
get
{
if ((Object)(object)_postProcessing == (Object)null)
{
globalPrefab = Assets.PostProcessingBundle.LoadAsset<GameObject>("Volume Global");
_postProcessing = Object.Instantiate<GameObject>(globalPrefab);
_postProcessing.SetActive(false);
}
return _postProcessing;
}
}
public static GameObject PlayerHelmet
{
get
{
if ((Object)(object)_playerHelmet == (Object)null)
{
_playerHelmet = GameObject.Find("Systems/Rendering/PlayerHUDHelmetModel/");
}
return _playerHelmet;
}
}
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void Start(ref PlayerControllerB __instance)
{
toggleKey.started += ToggleTacticalCamera;
toggleKey.Enable();
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void Update(ref PlayerControllerB __instance)
{
//IL_00c2: 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_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: 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)
switchCamera = __instance.isPlayerDead && (Object)(object)__instance.spectatedPlayerScript != (Object)null && spectatedHasCustomModel && !forceDisable;
__instance.disableLookInput = switchCamera && !__instance.quickMenuManager.isMenuOpen;
PostProcessing.SetActive(__instance.disableLookInput);
PlayerHelmet.SetActive(false);
if (switchCamera)
{
if (!displayedTip)
{
HUDManager.Instance.DisplaySpectatorTip($"Press [{Plugin.toggleKey.Value}] to switch te camera view");
displayedTip = true;
}
__instance.spectateCameraPivot.Rotate(0f, ((Component)__instance.spectatedPlayerScript.gameplayCamera).transform.localEulerAngles.y, 0f);
((Component)__instance.spectateCameraPivot).transform.localEulerAngles = new Vector3(((Component)__instance.spectateCameraPivot).transform.localEulerAngles.x, 0f, 0f);
((Component)__instance.spectateCameraPivot).transform.rotation = ((Component)__instance.spectatedPlayerScript.gameplayCamera).transform.rotation;
}
}
[HarmonyPatch("SpectateNextPlayer")]
[HarmonyPostfix]
[HarmonyPriority(200)]
private static void SpectateNextPlayer(ref PlayerControllerB __instance)
{
RaycastSpectateCameraAroundPivot(ref __instance);
}
[HarmonyPatch("RaycastSpectateCameraAroundPivot")]
[HarmonyPrefix]
private static bool RaycastSpectateCameraAroundPivot(ref PlayerControllerB __instance)
{
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//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_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
Transform boneTransform = GetBoneTransform(__instance.spectatedPlayerScript, "spine.004");
spectatedHasCustomModel = (Object)(object)boneTransform != (Object)null;
hasCustomModel = false;
if (switchCamera && spectatedHasCustomModel)
{
__instance.spectateCameraPivot.position = boneTransform.position + ((Component)__instance.spectatedPlayerScript.gameplayCamera).transform.right * Plugin.tacticalCameraOffsetX.Value + ((Component)__instance.spectatedPlayerScript.gameplayCamera).transform.up * Plugin.tacticalCameraOffsetY.Value + ((Component)__instance.spectatedPlayerScript.gameplayCamera).transform.forward * Plugin.tacticalCameraOffsetZ.Value;
((Component)__instance.playersManager.spectateCamera).transform.LookAt(__instance.spectateCameraPivot.position);
}
return !switchCamera;
}
public static Transform? GetBoneTransform(PlayerControllerB __instance, string bone)
{
if (__instance.isPlayerDead)
{
return null;
}
BodyReplacementBase val = default(BodyReplacementBase);
ModelReplacementAPI.GetPlayerModelReplacement(__instance, ref val);
if (val == null)
{
return null;
}
AvatarUpdater avatar = val.avatar;
if (avatar == null)
{
return null;
}
return avatar.GetAvatarTransformFromBoneName(bone);
}
public static void ToggleTacticalCamera(CallbackContext ctx)
{
forceDisable = !forceDisable;
}
static PlayerControllerBPatch()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: 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)
//IL_0035: Expected O, but got Unknown
KeyCode value = Plugin.toggleKey.Value;
toggleKey = new InputAction("Toggle Tactical Camera", (InputActionType)0, "<Keyboard>/" + ((object)(KeyCode)(ref value)).ToString(), (string)null, (string)null, (string)null);
switchCamera = false;
forceDisable = false;
hasCustomModel = false;
spectatedHasCustomModel = false;
displayedTip = false;
}
}
public static class PluginInfo
{
public const string GUID = "Edouard127.LethalWarfare2";
public const string NAME = "Lethal Warfare 2";
public const string VERSION = "1.2.6";
public const string WEBSITE = "https://github.com/Edouard127/LethalWarfare2";
}
[BepInPlugin("Edouard127.LethalWarfare2", "Lethal Warfare 2", "1.2.6")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public const string GUID = "Edouard127.LethalWarfare2";
public const string NAME = "Lethal Warfare 2";
public const string VERSION = "1.2.6";
public static ConfigFile config;
public static List<PluginInfo> problematicMods = new List<PluginInfo>();
private Harmony harmony = new Harmony("Edouard127.LethalWarfare2");
public static ConfigEntry<bool> disablePhysics;
public static ConfigEntry<double> disablePhysicsRange;
public static ConfigEntry<bool> tacticalCamera;
public static ConfigEntry<float> tacticalCameraOffsetX;
public static ConfigEntry<float> tacticalCameraOffsetY;
public static ConfigEntry<float> tacticalCameraOffsetZ;
public static ConfigEntry<KeyCode> toggleKey;
public void Awake()
{
config = ((BaseUnityPlugin)this).Config;
Assets.PopulateAssets();
disablePhysics = config.Bind<bool>("Lethal Warfare 2", "Disable Physics", false, "Disable physics for all players");
disablePhysicsRange = config.Bind<double>("Lethal Warfare 2", "Disable Physics Range", 100.0, "Disable physics for all players within this range");
tacticalCamera = config.Bind<bool>("Lethal Warfare 2", "Tactical Camera View", true, "Set the camera position above the spectated player's head");
tacticalCameraOffsetX = config.Bind<float>("Lethal Warfare 2", "Tactical Camera Offset X", 0.25f, "Set the camera offset on the X axis");
tacticalCameraOffsetY = config.Bind<float>("Lethal Warfare 2", "Tactical Camera Offset Y", 0.25f, "Set the camera offset on the Y axis");
tacticalCameraOffsetZ = config.Bind<float>("Lethal Warfare 2", "Tactical Camera Offset Z", 1.2f, "Set the camera offset on the Z axis");
toggleKey = config.Bind<KeyCode>("Lethal Warfare 2", "Keyboard Shortcut", (KeyCode)282, "Toggle the tactical camera view");
ModelReplacementAPI.RegisterSuitModelReplacement("Ghost Nightwar", typeof(GhostReplacement));
ModelReplacementAPI.RegisterSuitModelReplacement("Alex Keller", typeof(AlexReplacement));
ModelReplacementAPI.RegisterSuitModelReplacement("Valeria Garza", typeof(ValeriaReplacement));
harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Lethal Warfare 2 1.2.6 loaded!");
PluginCheck();
}
private void PluginCheck()
{
string[] array = new string[1] { "me.swipez.melonloader.morecompany" };
for (int i = 0; i < array.Length; i++)
{
if (IsPluginPresent(array[i], out PluginInfo plugin))
{
problematicMods.Add(plugin);
}
}
if (problematicMods.Count <= 0)
{
return;
}
((BaseUnityPlugin)this).Logger.LogWarning((object)"The following mods are known to cause issues with Lethal Warfare 2:");
foreach (PluginInfo problematicMod in problematicMods)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)$"- {problematicMod.Metadata.Name} {problematicMod.Metadata.Version}");
}
}
private static bool IsPluginPresent(string pluginName, out PluginInfo plugin)
{
return Chainloader.PluginInfos.TryGetValue(pluginName, out plugin);
}
}
public static class Assets
{
public static string modelBundleName = "mw2bundle";
public static string assetBundleName = "itembundle";
public static string postProcessingBundleName = "postprocessing";
public static AssetBundle MainModelBundle = null;
public static AssetBundle MainAssetBundle = null;
public static AssetBundle PostProcessingBundle = null;
public static string GetAssemblyName()
{
return Assembly.GetExecutingAssembly().FullName.Split(',')[0];
}
public static void PopulateAssets()
{
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + "." + modelBundleName))
{
MainModelBundle = AssetBundle.LoadFromStream(stream);
}
using (Stream stream2 = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + "." + assetBundleName))
{
MainAssetBundle = AssetBundle.LoadFromStream(stream2);
}
using Stream stream3 = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + "." + postProcessingBundleName);
PostProcessingBundle = AssetBundle.LoadFromStream(stream3);
}
public static T GetAssetFromName<T>(string name) where T : Object
{
return MainModelBundle.LoadAsset<T>(name) ?? MainAssetBundle.LoadAsset<T>(name) ?? PostProcessingBundle.LoadAsset<T>(name) ?? throw new Exception("Could not find asset " + name + "!");
}
}
}
namespace LethalWarfare2.Modules.Model
{
public class GhostReplacement : BodyReplacementBase
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.GetAssetFromName<GameObject>("GhostNightwar");
}
}
public class AlexReplacement : BodyReplacementBase
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.GetAssetFromName<GameObject>("AlexKeller");
}
}
public class ValeriaReplacement : BodyReplacementBase
{
protected override GameObject LoadAssetsAndReturnModel()
{
return Assets.GetAssetFromName<GameObject>("ValeriaGarza");
}
}
}
namespace LethalWarfare2.Modules.Items
{
internal class ProximityMine : PhysicsProp
{
public static ProximityMine LoadAssetAndReturnInstance()
{
Item assetFromName = Assets.GetAssetFromName<Item>("ProximityMine");
ProximityMine proximityMine = assetFromName.spawnPrefab.AddComponent<ProximityMine>();
((GrabbableObject)proximityMine).itemProperties = assetFromName;
return proximityMine;
}
public static TerminalNode CreateTerminalNode()
{
TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>();
obj.clearPreviousText = true;
obj.displayText = "Ping an enemy for 5 seconds when triggered";
return obj;
}
public override void ItemActivate(bool used, bool buttonDown = true)
{
//IL_001a: 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)
((GrabbableObject)this).ItemActivate(used, buttonDown);
if (buttonDown)
{
((GrabbableObject)this).playerHeldBy.DamagePlayer(20, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
}
}
}
internal class SmokeGrenade : PhysicsProp
{
private ParticleSystem smoke;
public static SmokeGrenade LoadAssetAndReturnInstance()
{
Item assetFromName = Assets.GetAssetFromName<Item>("SmokeGrenadeItem");
SmokeGrenade smokeGrenade = assetFromName.spawnPrefab.AddComponent<SmokeGrenade>();
((GrabbableObject)smokeGrenade).itemProperties = assetFromName;
return smokeGrenade;
}
public static TerminalNode CreateTerminalNode()
{
TerminalNode obj = ScriptableObject.CreateInstance<TerminalNode>();
obj.clearPreviousText = true;
obj.displayText = "Allows a player to cut line of sight with an enemy for 15 seconds";
return obj;
}
public override void ItemActivate(bool used, bool buttonDown = true)
{
//IL_001a: 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)
((GrabbableObject)this).ItemActivate(used, buttonDown);
if (buttonDown)
{
((GrabbableObject)this).playerHeldBy.DamagePlayer(20, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}