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.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("PortalTurrets")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A mod that replaces the in game turrets with the ones from Portal.")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2")] [assembly: AssemblyProduct("PortalTurrets")] [assembly: AssemblyTitle("PortalTurrets")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.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 PortalTurrets { [BepInPlugin("walterman.plugins.portalturrets", "PortalTurrets", "1.0.2")] [BepInProcess("Lethal Company.exe")] public class PortalTurretBase : BaseUnityPlugin { private const string MOD_GUID = "walterman.plugins.portalturrets"; private const string MOD_NAME = "PortalTurrets"; private const string MOD_VERSION = "1.0.2"; private ConfigEntry configShowLaser; private GameObject portalTurretPrefab; public static PortalTurretBase Instance { get; private set; } private void Awake() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin walterman.plugins.portalturrets is loaded!"); if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"More than one PortalTurretBase instance"); } Instance = this; BindConfig(); Harmony val = new Harmony("walterman.plugins.portalturrets"); val.PatchAll(); string path = "turretasset"; string filePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), path); LoadAssetBundle(filePath); } private void LoadAssetBundle(string filePath) { AssetBundle val = AssetBundle.LoadFromFile(filePath); if ((Object)(object)val != (Object)null) { GameObject val2 = val.LoadAsset("PortalTurret"); val.Unload(false); portalTurretPrefab = val2; } else { ((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load asset bundle from " + filePath)); } } private void BindConfig() { configShowLaser = ((BaseUnityPlugin)this).Config.Bind("General", "ShowLaser", true, "Whether or not turrets show the laser from their eye"); } public bool GetShowLaser() { return configShowLaser.Value; } public Transform GetPortalTurretPrefab() { return portalTurretPrefab.transform; } public void Log(string message) { ((BaseUnityPlugin)this).Logger.LogInfo((object)(message ?? "")); } public void LogError(string message) { ((BaseUnityPlugin)this).Logger.LogError((object)(message ?? "")); } } public static class PluginInfo { public const string PLUGIN_GUID = "PortalTurrets"; public const string PLUGIN_NAME = "PortalTurrets"; public const string PLUGIN_VERSION = "1.0.2"; } } namespace PortalTurrets.Patches { [HarmonyPatch(typeof(Turret))] internal class TurretPatch { private static PortalTurretBase pluginBase = PortalTurretBase.Instance; private static Dictionary turretDictionary = new Dictionary(); [HarmonyPrefix] [HarmonyPatch("Start")] private static void TurretPatchStart(Turret __instance, ref Transform ___centerPoint, ref float ___rotationRange, ref Animator ___turretAnimator, ref ParticleSystem ___bulletParticles) { //IL_001b: 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_0039: 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_0041: 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_004d: Unknown result type (might be due to invalid IL or missing references) Transform parent = ((Component)__instance).transform.parent; Transform meshContainer = parent.Find("MeshContainer"); Vector3 val = ___centerPoint.position - new Vector3(0f, 1.4968f, 0f); Quaternion rotation = ___centerPoint.rotation; Transform val2 = Object.Instantiate(pluginBase.GetPortalTurretPrefab(), val, rotation, parent); ((Object)val2).name = "PortalTurret"; ___turretAnimator = ((Component)val2).GetComponentInChildren(); ___bulletParticles = ((Component)val2).GetComponentInChildren(); bool showLaser = pluginBase.GetShowLaser(); ((Component)val2.GetChild(2)).gameObject.SetActive(showLaser); DisableMeshRenderers(meshContainer); turretDictionary[__instance] = val2; } [HarmonyPostfix] [HarmonyPatch("Update")] private static void TurretPatchUpdate(Turret __instance, ref Animator ___turretAnimator, ref Transform ___turretRod) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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) if (turretDictionary.TryGetValue(__instance, out var value)) { ((Component)((Component)value).GetComponentInChildren()).transform.rotation = ___turretRod.rotation; Transform child = value.GetChild(2); UpdateLaserPosition(((Component)child).GetComponent(), child, ___turretRod.rotation); if (___turretAnimator.GetInteger("TurretMode") == 0) { Quaternion rotation = value.GetChild(0).rotation; Quaternion rotation2 = value.rotation; float num = Mathf.Clamp01(4f * Time.deltaTime); value.GetChild(0).rotation = Quaternion.Lerp(rotation, rotation2, num); } else { value.GetChild(0).rotation = ___turretRod.rotation; } } } private static void DisableMeshRenderers(Transform meshContainer) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown foreach (Transform item in ((Component)meshContainer).transform) { Transform val = item; MeshRenderer component = ((Component)val).GetComponent(); if ((Object)(object)component != (Object)null && !((Object)val).name.Contains("Plane")) { ((Renderer)component).enabled = false; } DisableMeshRenderers(((Component)val).transform); } } private static void UpdateLaserPosition(LineRenderer laser, Transform startPoint, Quaternion rodRotation) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) startPoint.rotation = rodRotation; laser.SetPosition(0, startPoint.position); RaycastHit val = default(RaycastHit); if (Physics.Raycast(startPoint.position, startPoint.forward, ref val)) { laser.SetPosition(1, ((RaycastHit)(ref val)).point); } else { laser.SetPosition(1, startPoint.position + startPoint.forward * 100f); } } } }