using System;
using System.Diagnostics;
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: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("ScaleableTV")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+18865971da1ec6d961ae4356e131b15e00b57612")]
[assembly: AssemblyProduct("ScaleableTV")]
[assembly: AssemblyTitle("ScaleableTV")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 DeathWrench.ScaleableTelevision
{
public class ConfigManager
{
public static ConfigManager Instance { get; private set; }
public static ConfigEntry<float> tvScaleX { get; private set; }
public static ConfigEntry<float> tvScaleY { get; private set; }
public static ConfigEntry<float> tvScaleZ { get; private set; }
public static ConfigEntry<bool> configBiggerInteractRadius { get; internal set; }
public static ConfigEntry<float> audioSourceMinDistance { get; private set; }
public static ConfigEntry<float> audioSourceMaxDistance { get; private set; }
public static ConfigFile configFile { get; private set; }
public static void Init(ConfigFile config)
{
Instance = new ConfigManager(config);
}
private ConfigManager(ConfigFile cfg)
{
configFile = cfg;
tvScaleX = cfg.Bind<float>("Options", "TV Scale X", 1f, "X Coordinates\n Left/Right\n Make sure you put a ''f'' at the end of the number.");
tvScaleY = cfg.Bind<float>("Options", "TV Scale Y", 1f, "Y Coordinates\n Up/Down\n Make sure you put a ''f'' at the end of the number.");
tvScaleZ = cfg.Bind<float>("Options", "TV Scale Z", 1f, "Z Coordinates\n Front/Back\n Make sure you put a ''f'' at the end of the number.");
audioSourceMinDistance = cfg.Bind<float>("Options", "Audio Falloff Min Distance", 2f, "How far before TV audio starts to fall off? Set this value higher if the TV is huge and you can't hear it unless you're really close.");
audioSourceMaxDistance = cfg.Bind<float>("Options", "Audio Falloff Max Distance", 24f, "How far before you can't hear the TV anymore. Should probably keep this value higher than the minimum distance.");
configBiggerInteractRadius = cfg.Bind<bool>("Accessibility", "Bigger Interact Radius", true, "You can interact with the TV by just looking at it if you're close enough, rather than only the bottom right corner.");
}
}
[BepInPlugin("DeathWrench.ScaleableTelevision", "\u200bScaleableTelevision", "2.0.1")]
public class ScaleableTelevision : BaseUnityPlugin
{
public static class Patchez
{
[HarmonyPatch(typeof(GameObject), "TelevisionContainer")]
[HarmonyPostfix]
public static void PostFix_adjustTVScale(GameObject __instance)
{
//IL_005d: 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_015f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
//IL_030c: Unknown result type (might be due to invalid IL or missing references)
//IL_0316: Unknown result type (might be due to invalid IL or missing references)
//IL_034c: Unknown result type (might be due to invalid IL or missing references)
//IL_025b: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: Unknown result type (might be due to invalid IL or missing references)
GameObject gameObject = ((Component)__instance.gameObject.transform.parent).gameObject;
GameObject gameObject2 = GameObject.Find("TelevisionMesh").gameObject;
gameObject2.transform.localScale = new Vector3(0.01108255f * ConfigManager.tvScaleY.Value, 0.01108255f * ConfigManager.tvScaleX.Value, 0.01108255f * ConfigManager.tvScaleZ.Value);
GameObject gameObject3 = ((Component)gameObject.transform.Find("Cube")).gameObject;
GameObject gameObject4 = ((Component)gameObject.transform.Find("PlacementCollider")).gameObject;
BoxCollider component = gameObject4.GetComponent<BoxCollider>();
component.size = new Vector3(ConfigManager.tvScaleY.Value, ConfigManager.tvScaleX.Value, 0.7f);
float num = Mathf.Lerp(0f, 1536f, (ConfigManager.tvScaleX.Value - 1f) / 8191f);
float num2 = Mathf.Lerp(0f, ConfigManager.tvScaleY.Value / 2.9333f, (ConfigManager.tvScaleY.Value - 1f) / 8191f);
GameObject gameObject5 = ((Component)gameObject.transform.Find("TVAudio")).gameObject;
gameObject5.transform.localPosition = new Vector3((0f - ConfigManager.tvScaleY.Value) * 0.39f, ConfigManager.tvScaleY.Value * 0.44f, -0.42f);
AudioSource component2 = gameObject5.GetComponent<AudioSource>();
component2.minDistance = ConfigManager.audioSourceMinDistance.Value;
component2.maxDistance = ConfigManager.audioSourceMaxDistance.Value;
component.center = new Vector3(num, num2, 0.7f);
if (!ConfigManager.configBiggerInteractRadius.Value)
{
float num4;
if (ConfigManager.tvScaleX.Value <= 8f)
{
float num3 = (ConfigManager.tvScaleX.Value - 1f) / 7f;
num4 = Mathf.Lerp(0.3115522f, -3.25f, num3);
}
else
{
float num3 = Mathf.Lerp(8f, 4096f, (ConfigManager.tvScaleX.Value - 8f) / 4088f);
num4 = Mathf.Lerp(-3.25f, -1662.5f, num3);
}
gameObject3.transform.localPosition = new Vector3(num4, 0.01403493f, 0.03700018f);
gameObject3.transform.localScale = new Vector3(ConfigManager.tvScaleY.Value * 0.2601791f, ConfigManager.tvScaleY.Value * 0.405167f, ConfigManager.tvScaleZ.Value * 0.1014986f);
}
else
{
float num5 = Mathf.Lerp(0.521f, -1625.286f, (ConfigManager.tvScaleY.Value - 1f) / 4095f);
float num6 = Mathf.Lerp(0.3f, 350.3f, (ConfigManager.tvScaleX.Value - 1f) / 4095f);
gameObject3.transform.localPosition = new Vector3(num5, num6, gameObject3.transform.localPosition.z);
gameObject3.transform.localScale = new Vector3(ConfigManager.tvScaleY.Value * 1f, ConfigManager.tvScaleX.Value * 1.1f, 1f);
}
}
}
public const string PLUGIN_GUID = "DeathWrench.ScaleableTelevision";
public const string PLUGIN_NAME = "\u200bScaleableTelevision";
public const string PLUGIN_VERSION = "2.0.1";
private static GameObject? gameObject;
private void Awake()
{
ConfigManager.Init(((BaseUnityPlugin)this).Config);
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin \u200bScaleableTelevision v2.0.1 is loaded!");
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
}
private void Update()
{
//IL_00c3: 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_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_0183: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
GameObject[] array = GameObject.FindGameObjectsWithTag("InteractTrigger");
GameObject[] array2 = array;
foreach (GameObject val in array2)
{
if (((Object)val).name == "Cube" && ((Object)((Component)val.transform.parent).gameObject).name.StartsWith("TelevisionContainer"))
{
GameObject val2 = ((Component)val.transform.parent).gameObject;
GameObject val3 = ((Component)val2.transform.Find("TelevisionMesh")).gameObject;
GameObject val4 = ((Component)val2.transform.Find("TVAudio")).gameObject;
GameObject val5 = ((Component)val2.transform.Find("Cube")).gameObject;
AudioSource component = val4.GetComponent<AudioSource>();
if (!(val3.transform.localScale != new Vector3(0.01108255f * ConfigManager.tvScaleY.Value, 0.01108255f * ConfigManager.tvScaleX.Value, 0.01108255f * ConfigManager.tvScaleZ.Value)) && component.minDistance == ConfigManager.audioSourceMinDistance.Value && component.maxDistance == ConfigManager.audioSourceMaxDistance.Value && (!(val5.transform.localScale != new Vector3(ConfigManager.tvScaleY.Value * 1f, ConfigManager.tvScaleX.Value * 1.1f, 1f)) || !ConfigManager.configBiggerInteractRadius.Value) && (!(val5.transform.localScale != new Vector3(ConfigManager.tvScaleY.Value * 0.2601791f, ConfigManager.tvScaleY.Value * 0.405167f, ConfigManager.tvScaleZ.Value * 0.1014986f)) || ConfigManager.configBiggerInteractRadius.Value))
{
break;
}
Patchez.PostFix_adjustTVScale(val);
}
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}