using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Extras;
using LethalLib.Modules;
using LethalSettings.UI;
using LethalSettings.UI.Components;
using Microsoft.CodeAnalysis;
using MoreCompany.Cosmetics;
using UnityEngine;
using UnityEngine.Rendering;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("MirrorDecor")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A mod for Lethal Company that adds a working mirror decoration that you can buy for your ship!")]
[assembly: AssemblyFileVersion("1.1.6.0")]
[assembly: AssemblyInformationalVersion("1.1.6")]
[assembly: AssemblyProduct("MirrorDecor")]
[assembly: AssemblyTitle("MirrorDecor")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.6.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.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;
}
}
[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 MirrorDecor
{
public class Config
{
public static ConfigEntry<bool> mirrorEnabled;
public static ConfigEntry<int> mirrorPrice;
public static ConfigEntry<bool> alwaysAvailable;
public static ConfigEntry<int> resolution;
public static void Load()
{
mirrorEnabled = Plugin.config.Bind<bool>("Mirror", "MirrorEnabled", true, "Will you be able to purchase the mirror?");
mirrorPrice = Plugin.config.Bind<int>("Mirror", "MirrorPrice", 100, "What will be the price of the mirror?");
alwaysAvailable = Plugin.config.Bind<bool>("Mirror", "AlwaysAvailable", true, "Is the mirror always available to purchase from the store?");
resolution = Plugin.config.Bind<int>("Mirror", "MirrorResolution", 512, "What is the resolution/quality of the mirror image? (ex. 2000 = 2000x2000 pixels)");
}
}
public class CustomUnlockable
{
public string name = "";
public string unlockablePath = "";
public string infoPath = "";
public Action<UnlockableItem> unlockableAction = delegate
{
};
public bool enabled = true;
public int unlockCost = -1;
public CustomUnlockable(string name, string unlockablePath, string infoPath, Action<UnlockableItem> action = null, int unlockCost = -1)
{
this.name = name;
this.unlockablePath = unlockablePath;
this.infoPath = infoPath;
if (action != null)
{
unlockableAction = action;
}
this.unlockCost = unlockCost;
}
public static CustomUnlockable Add(string name, string unlockablePath, string infoPath = null, Action<UnlockableItem> action = null, int unlockCost = -1, bool enabled = true)
{
return new CustomUnlockable(name, unlockablePath, infoPath, action, unlockCost)
{
enabled = enabled
};
}
}
public class MirrorScript : MonoBehaviour
{
}
[HarmonyPatch(typeof(PlayerControllerB), "SpawnPlayerAnimation")]
internal class PlayerPatch
{
private static void Postfix(ref PlayerControllerB __instance)
{
if ((Object)(object)__instance == (Object)(object)GameNetworkManager.Instance.localPlayerController)
{
PlayerControllerB obj = __instance;
((Component)__instance).GetComponentInChildren<LODGroup>().enabled = false;
((Renderer)obj.thisPlayerModel).shadowCastingMode = (ShadowCastingMode)1;
((Component)obj.localVisor).GetComponentInChildren<Renderer>().shadowCastingMode = (ShadowCastingMode)0;
((Renderer)obj.thisPlayerModelLOD1).shadowCastingMode = (ShadowCastingMode)3;
((Renderer)obj.thisPlayerModelLOD2).enabled = false;
((Component)obj.thisPlayerModel).gameObject.layer = 23;
((Component)obj.thisPlayerModelArms).gameObject.layer = 5;
}
}
}
[BepInPlugin("quackandcheese.mirrordecor", "MirrorDecor", "1.3.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("Lethal Company.exe")]
public class Plugin : BaseUnityPlugin
{
public class OnUpdateResolutionEventArgs : EventArgs
{
public int res;
public OnUpdateResolutionEventArgs(int res)
{
this.res = res;
}
}
public const string ModGUID = "quackandcheese.mirrordecor";
public const string ModName = "MirrorDecor";
public const string ModVersion = "1.3.2";
public const int MirrorCameraCullingMask = 565909343;
public static AssetBundle Bundle;
public static ConfigFile config;
public static ManualLogSource logger;
public static List<CustomUnlockable> customUnlockables;
public const int MirrorMinRes = 8;
public const int MirrorMaxRes = 1024;
public static event EventHandler<OnUpdateResolutionEventArgs> OnUpdateResolution;
private void Awake()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
Bundle = QuickLoadAssetBundle("mirror.assets");
logger = ((BaseUnityPlugin)this).Logger;
config = ((BaseUnityPlugin)this).Config;
new Harmony("quackandcheese.mirrordecor").PatchAll();
Config.Load();
RegisterItems();
if (Chainloader.PluginInfos.ContainsKey("com.willis.lc.lethalsettings"))
{
AddSetting();
}
UpdateMirrorRes(Config.resolution.Value);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MirrorDecor is loaded!");
}
[MethodImpl(MethodImplOptions.NoInlining)]
private void AddSetting()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Expected O, but got Unknown
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
//IL_004a: 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_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: 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_0093: 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_00ad: Expected O, but got Unknown
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Expected O, but got Unknown
ModSettingsConfig val = new ModSettingsConfig();
val.Name = "MirrorDecor";
val.Id = "quackandcheese.mirrordecor";
val.Version = "1.3.2";
val.Description = "Adds a working mirror decoration that you can buy for your ship!";
MenuComponent[] array = new MenuComponent[2];
HorizontalComponent val2 = new HorizontalComponent();
val2.Children = (MenuComponent[])(object)new MenuComponent[1] { (MenuComponent)new SliderComponent
{
Value = Config.resolution.Value,
MinValue = 8f,
MaxValue = 1024f,
Text = "Mirror Resolution",
OnValueChanged = delegate(SliderComponent self, float value)
{
UpdateMirrorRes((int)value);
},
WholeNumbers = true,
OnInitialize = delegate
{
UpdateMirrorRes(Config.resolution.Value);
}
} };
array[0] = (MenuComponent)val2;
array[1] = (MenuComponent)new LabelComponent
{
Text = "The resolution/quality of the mirror image. Reduce size for better framerate."
};
val.MenuComponents = (MenuComponent[])(object)array;
ModMenu.RegisterMod(val, true, true);
}
private void UpdateMirrorRes(int res)
{
int num = Mathf.Clamp(res, 8, 1024);
Resize(Bundle.LoadAsset<RenderTexture>("Assets/Mirror/Materials/Mirror.renderTexture"), num, num);
Config.resolution.Value = num;
}
private void RegisterItems()
{
customUnlockables = new List<CustomUnlockable> { CustomUnlockable.Add("Mirror", "Assets/Mirror/Unlockables/Mirror/Mirror.asset", "Assets/Mirror/Unlockables/Mirror/MirrorInfo.asset", null, Config.mirrorPrice.Value, Config.mirrorEnabled.Value) };
Bundle.LoadAsset<UnlockableItemDef>("Assets/Mirror/Unlockables/Mirror/Mirror.asset").unlockable.alwaysInStock = Config.alwaysAvailable.Value;
foreach (CustomUnlockable customUnlockable in customUnlockables)
{
if (customUnlockable.enabled)
{
UnlockableItem unlockable = Bundle.LoadAsset<UnlockableItemDef>(customUnlockable.unlockablePath).unlockable;
if ((Object)(object)unlockable.prefabObject != (Object)null)
{
NetworkPrefabs.RegisterNetworkPrefab(unlockable.prefabObject);
}
TerminalNode val = null;
if (customUnlockable.infoPath != null)
{
val = Bundle.LoadAsset<TerminalNode>(customUnlockable.infoPath);
}
Unlockables.RegisterUnlockable(unlockable, (StoreType)2, (TerminalNode)null, (TerminalNode)null, val, customUnlockable.unlockCost);
}
}
}
public static T FindAsset<T>(string name) where T : Object
{
return Resources.FindObjectsOfTypeAll<T>().ToList().Find((T x) => ((Object)x).name == name);
}
public static AssetBundle QuickLoadAssetBundle(string assetBundleName)
{
return AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), assetBundleName));
}
public static void Resize(RenderTexture renderTexture, int width, int height)
{
if (Object.op_Implicit((Object)(object)renderTexture))
{
renderTexture.Release();
((Texture)renderTexture).width = width;
((Texture)renderTexture).height = height;
}
}
public void sendModInfo()
{
foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
{
if (pluginInfo.Value.Metadata.GUID.Contains("ModSync"))
{
try
{
List<string> list = new List<string> { "quackandcheese", "MirrorDecor" };
((Component)pluginInfo.Value.Instance).BroadcastMessage("getModInfo", (object)list, (SendMessageOptions)1);
break;
}
catch (Exception)
{
logger.LogInfo((object)"Failed to send info to ModSync, go yell at Minx");
break;
}
}
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "MirrorDecor";
public const string PLUGIN_NAME = "MirrorDecor";
public const string PLUGIN_VERSION = "1.1.6";
}
}
namespace MirrorDecor.Compatibility
{
[HarmonyPatch(typeof(HUDManager), "AddPlayerChatMessageClientRpc")]
internal class CosmeticPatch
{
private static void Postfix()
{
if (Chainloader.PluginInfos.ContainsKey("me.swipez.melonloader.morecompany"))
{
MoreCompanyPatch();
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static void MoreCompanyPatch()
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
CosmeticApplication val = Object.FindObjectOfType<CosmeticApplication>();
if (CosmeticRegistry.locallySelectedCosmetics.Count <= 0 || val.spawnedCosmetics.Count > 0)
{
return;
}
foreach (string locallySelectedCosmetic in CosmeticRegistry.locallySelectedCosmetics)
{
val.ApplyCosmetic(locallySelectedCosmetic, true);
}
foreach (CosmeticInstance spawnedCosmetic in val.spawnedCosmetics)
{
Transform transform = ((Component)spawnedCosmetic).transform;
transform.localScale *= 0.38f;
SetAllChildrenLayer(((Component)spawnedCosmetic).transform, 23);
}
}
private static void SetAllChildrenLayer(Transform transform, string layerName)
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Expected O, but got Unknown
int layer = LayerMask.NameToLayer(layerName);
((Component)transform).gameObject.layer = layer;
foreach (Transform item in transform)
{
SetAllChildrenLayer(item, layerName);
}
}
private static void SetAllChildrenLayer(Transform transform, int layer)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
((Component)transform).gameObject.layer = layer;
foreach (Transform item in transform)
{
SetAllChildrenLayer(item, layer);
}
}
}
}