Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of JengJokes v1.0.0
JengJokes.dll
Decompiled an hour agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using LethalLib.Modules; using Microsoft.CodeAnalysis; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("JengJokes")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("JengJokes")] [assembly: AssemblyTitle("JengJokes")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 JengJokes { [HarmonyPatch(typeof(EnemyAI), "Start")] internal static class CoilHeadFacePatch { private static bool dumped; private static Material faceMat; [HarmonyPostfix] private static void Postfix(EnemyAI __instance) { //IL_0161: Unknown result type (might be due to invalid IL or missing references) if (!(__instance is SpringManAI) || !Plugin.CoilFaceEnabled.Value || (Object)(object)Plugin.CoilFaceTex == (Object)null) { return; } Transform transform = ((Component)__instance).transform; if (Plugin.DumpCoilHierarchy.Value && !dumped) { dumped = true; StringBuilder stringBuilder = new StringBuilder("Coil-head model parts:\n"); Dump(transform, 0, stringBuilder); Plugin.Log.LogInfo((object)stringBuilder.ToString()); } Transform val = null; Transform[] componentsInChildren = ((Component)transform).GetComponentsInChildren<Transform>(true); foreach (Transform val2 in componentsInChildren) { if (((Object)val2).name == "HeadTarget") { val = val2; break; } if ((Object)(object)val == (Object)null && ((Object)val2).name == "Head") { val = val2; } } if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"Couldn't find a Coil-head head part, using a fixed height instead."); } if (faceMat == null) { faceMat = Plugin.PictureMaterial(Plugin.CoilFaceTex, Plugin.CoilFaceGlows.Value); } Texture2D coilFaceTex = Plugin.CoilFaceTex; float value = Plugin.CoilFaceSize.Value; float num = value * (float)((Texture)coilFaceTex).height / (float)((Texture)coilFaceTex).width; GameObject val3 = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)val3).name = "JengJokesFace"; Object.Destroy((Object)(object)val3.GetComponent<Collider>()); val3.GetComponent<Renderer>().sharedMaterial = faceMat; val3.transform.localScale = new Vector3(value, num, 1f); val3.transform.SetParent(transform, true); bool value2 = Plugin.CoilHideHead.Value; if (value2) { Renderer[] componentsInChildren2 = ((Component)transform).GetComponentsInChildren<Renderer>(true); foreach (Renderer val4 in componentsInChildren2) { if (((Object)val4).name == "Head") { val4.enabled = false; } } } FaceFollow faceFollow = val3.AddComponent<FaceFollow>(); faceFollow.root = transform; faceFollow.head = val; faceFollow.modelHidden = value2; } private static void Dump(Transform t, int depth, StringBuilder sb) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown Renderer component = ((Component)t).GetComponent<Renderer>(); sb.Append(' ', depth * 2).Append(((Object)t).name); if ((Object)(object)component != (Object)null) { sb.Append(" [renderer: ").Append(((Object)(object)component.sharedMaterial != (Object)null) ? ((Object)component.sharedMaterial).name : "?").Append(']'); } sb.Append('\n'); foreach (Transform item in t) { Dump(item, depth + 1, sb); } } } internal class FaceFollow : MonoBehaviour { public Transform root; public Transform head; public bool modelHidden; private void LateUpdate() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0138: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)root == (Object)null) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Vector3 val = (((Object)(object)head != (Object)null) ? head.position : (root.position + root.up * 2.6f)); float y = ((Component)this).transform.lossyScale.y; Vector3 val2 = val + Vector3.up * (y / 2f - Plugin.CoilSpringOverlap.Value + Plugin.CoilFaceExtraUp.Value); Vector3 val3 = root.position + root.forward; Camera val4 = (((Object)(object)StartOfRound.Instance != (Object)null) ? StartOfRound.Instance.activeCamera : null); if (Plugin.CoilFaceFollowViewer.Value && (Object)(object)val4 != (Object)null) { val3 = ((Component)val4).transform.position; } Vector3 val5 = val2 - val3; val5.y = 0f; if (((Vector3)(ref val5)).sqrMagnitude > 0.0001f) { ((Vector3)(ref val5)).Normalize(); val2 -= val5 * Plugin.CoilFaceTowardViewer.Value; ((Component)this).transform.rotation = Quaternion.LookRotation(val5, Vector3.up); } ((Component)this).transform.position = val2; } } [HarmonyPatch(typeof(PlayerControllerB), "Update")] internal static class DebugKeys { [HarmonyPostfix] private static void Postfix(PlayerControllerB __instance) { //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.DebugHotkeys.Value || Keyboard.current == null || (Object)(object)__instance != (Object)(object)GameNetworkManager.Instance?.localPlayerController || __instance.isTypingChat || __instance.inTerminalMenu) { return; } if (((ButtonControl)Keyboard.current.f10Key).wasPressedThisFrame) { ((BaseUnityPlugin)Plugin.Instance).Config.Reload(); Tip("Config reloaded."); } bool wasPressedThisFrame = ((ButtonControl)Keyboard.current.f8Key).wasPressedThisFrame; bool wasPressedThisFrame2 = ((ButtonControl)Keyboard.current.f9Key).wasPressedThisFrame; if (!wasPressedThisFrame && !wasPressedThisFrame2) { return; } if (!NetworkManager.Singleton.IsServer) { Tip("Only the host can spawn test stuff."); return; } Transform transform = ((Component)__instance).transform; Vector3 val = transform.position + transform.forward * 2.5f; if (wasPressedThisFrame) { if ((Object)(object)PhotoScrap.Item == (Object)null) { Tip("No scrap item (missing Pictures/scrap.png)."); return; } bool isInHangarShipRoom = __instance.isInHangarShipRoom; Transform val2 = (isInHangarShipRoom ? StartOfRound.Instance.elevatorTransform : StartOfRound.Instance.propsContainer); Vector3 val3 = (isInHangarShipRoom ? (transform.position + transform.forward * 1.2f) : val) + Vector3.up * 0.5f; GameObject val4 = Object.Instantiate<GameObject>(PhotoScrap.Item.spawnPrefab, val3, Quaternion.identity, StartOfRound.Instance.propsContainer); val4.SetActive(true); GrabbableObject component = val4.GetComponent<GrabbableObject>(); val4.GetComponent<NetworkObject>().Spawn(false); component.SetScrapValue(Random.Range(24, 65)); val4.transform.SetParent(val2, true); component.isInElevator = isInHangarShipRoom; component.isInShipRoom = isInHangarShipRoom; Vector3 itemFloorPosition = component.GetItemFloorPosition(val4.transform.position); component.startFallingPosition = val4.transform.localPosition; component.targetFloorPosition = val2.InverseTransformPoint(itemFloorPosition); component.hasHitGround = false; component.fallTime = 0f; Tip("Spawned " + PhotoScrap.Item.itemName + "."); } if (!wasPressedThisFrame2) { return; } EnemyType val5 = null; SelectableLevel[] levels = StartOfRound.Instance.levels; for (int i = 0; i < levels.Length; i++) { foreach (SpawnableEnemyWithRarity enemy in levels[i].Enemies) { if ((Object)(object)enemy.enemyType?.enemyPrefab != (Object)null && (Object)(object)enemy.enemyType.enemyPrefab.GetComponent<SpringManAI>() != (Object)null) { val5 = enemy.enemyType; } } } if ((Object)(object)val5 == (Object)null) { Tip("Couldn't find the Coil-head enemy type."); return; } RoundManager.Instance.SpawnEnemyGameObject(val, transform.eulerAngles.y + 180f, -1, val5); Tip("Spawned a Coil-head. Don't blink."); } private static void Tip(string msg) { Plugin.Log.LogInfo((object)msg); HUDManager instance = HUDManager.Instance; if (instance != null) { instance.DisplayTip("JengJokes", msg, false, false, "LC_Tip1"); } } } internal static class PhotoScrap { public static Item Item; public static void Register(Texture2D tex, AudioClip useClip) { //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) float num = (float)((Texture)tex).width / (float)((Texture)tex).height; float num2 = ((num >= 1f) ? 0.5f : (0.5f * num)); float num3 = ((num >= 1f) ? (0.5f / num) : 0.5f); GameObject val = NetworkPrefabs.CreateNetworkPrefab("JengJokesPhoto"); val.tag = "PhysicsProp"; val.layer = 6; BoxCollider obj = val.AddComponent<BoxCollider>(); obj.size = new Vector3(num2 + 0.08f, num3 + 0.08f, 0.04f); ((Collider)obj).isTrigger = true; AudioSource obj2 = val.AddComponent<AudioSource>(); obj2.spatialBlend = 1f; obj2.playOnAwake = false; obj2.rolloffMode = (AudioRolloffMode)1; obj2.maxDistance = 25f; GameObject obj3 = Visual((PrimitiveType)3, val.transform, "Frame"); obj3.transform.localScale = new Vector3(num2 + 0.08f, num3 + 0.08f, 0.04f); Material val2 = Plugin.PictureMaterial(Texture2D.whiteTexture, unlit: false); val2.SetColor("_BaseColor", new Color(0.35f, 0.2f, 0.1f)); val2.color = new Color(0.35f, 0.2f, 0.1f); obj3.GetComponent<Renderer>().sharedMaterial = val2; Material sharedMaterial = Plugin.PictureMaterial(tex, unlit: false); GameObject val3 = Visual((PrimitiveType)5, val.transform, "PhotoFront"); val3.transform.localPosition = new Vector3(0f, 0f, -0.021f); val3.transform.localScale = new Vector3(num2, num3, 1f); val3.GetComponent<Renderer>().sharedMaterial = sharedMaterial; GameObject obj4 = Visual((PrimitiveType)5, val.transform, "PhotoBack"); obj4.transform.localPosition = new Vector3(0f, 0f, 0.021f); obj4.transform.localRotation = Quaternion.Euler(0f, 180f, 0f); obj4.transform.localScale = new Vector3(num2, num3, 1f); obj4.GetComponent<Renderer>().sharedMaterial = sharedMaterial; GameObject val4 = new GameObject("ScanNode") { layer = 22 }; val4.transform.SetParent(val.transform, false); BoxCollider obj5 = val4.AddComponent<BoxCollider>(); ((Collider)obj5).isTrigger = true; obj5.size = Vector3.one * 0.3f; ScanNodeProperties obj6 = val4.AddComponent<ScanNodeProperties>(); obj6.headerText = Plugin.ScrapName.Value; obj6.subText = "Value: "; obj6.maxRange = 13; obj6.minRange = 1; obj6.nodeType = 2; obj6.requiresLineOfSight = true; Item val5 = ScriptableObject.CreateInstance<Item>(); ((Object)val5).name = "JengJokesPhotoItem"; val5.itemName = Plugin.ScrapName.Value; val5.isScrap = true; val5.minValue = Plugin.ScrapMinValue.Value; val5.maxValue = Mathf.Max(Plugin.ScrapMaxValue.Value, Plugin.ScrapMinValue.Value); val5.weight = 1.08f; val5.spawnPrefab = val; val5.itemSpawnsOnGround = true; val5.canBeGrabbedBeforeGameStart = true; val5.verticalOffset = 0.03f; val5.restingRotation = new Vector3(90f, 0f, 0f); val5.rotationOffset = Vector3.zero; val5.positionOffset = Vector3.zero; val5.itemIcon = Sprite.Create(tex, new Rect(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height), new Vector2(0.5f, 0.5f)); val5.toolTips = ((!((Object)(object)useClip != (Object)null)) ? new string[0] : new string[1] { "Play sound : [LMB]" }); val5.syncUseFunction = true; val5.meshVariants = (Mesh[])(object)new Mesh[0]; val5.materialVariants = (Material[])(object)new Material[0]; PhotoProp photoProp = val.AddComponent<PhotoProp>(); ((GrabbableObject)photoProp).itemProperties = val5; ((GrabbableObject)photoProp).grabbable = true; ((GrabbableObject)photoProp).grabbableToEnemies = true; photoProp.useClip = useClip; ((GrabbableObject)photoProp).mainObjectRenderer = val3.GetComponent<MeshRenderer>(); Item = val5; Items.RegisterScrap(val5, Plugin.ScrapRarity.Value, (LevelTypes)(-1)); Plugin.Log.LogInfo((object)string.Format("Registered scrap '{0}' ({1}x{2}, sound: {3}).", val5.itemName, ((Texture)tex).width, ((Texture)tex).height, ((Object)(object)useClip != (Object)null) ? ((Object)useClip).name : "none")); } private static GameObject Visual(PrimitiveType type, Transform parent, string name) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive(type); ((Object)obj).name = name; obj.layer = 6; Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>()); obj.transform.SetParent(parent, false); return obj; } } public class PhotoProp : PhysicsProp { public AudioClip useClip; public override void LateUpdate() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) ((GrabbableObject)this).LateUpdate(); if (((GrabbableObject)this).isHeld && !((GrabbableObject)this).isPocketed && !((Object)(object)((GrabbableObject)this).playerHeldBy == (Object)null) && !((Object)(object)((GrabbableObject)this).playerHeldBy.gameplayCamera == (Object)null)) { Transform transform = ((Component)((GrabbableObject)this).playerHeldBy.gameplayCamera).transform; Vector3 value = Plugin.HoldOffset.Value; ((Component)this).transform.position = transform.position + transform.right * value.x + transform.up * value.y + transform.forward * value.z; ((Component)this).transform.rotation = Quaternion.LookRotation(transform.forward, transform.up) * Quaternion.Euler(Plugin.HoldTilt.Value); } } public override void ItemActivate(bool used, bool buttonDown = true) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) ((GrabbableObject)this).ItemActivate(used, buttonDown); if (buttonDown && !((Object)(object)useClip == (Object)null)) { AudioSource component = ((Component)this).GetComponent<AudioSource>(); component.PlayOneShot(useClip); WalkieTalkie.TransmitOneShotAudio(component, useClip, 1f); RoundManager instance = RoundManager.Instance; if (instance != null) { instance.PlayAudibleNoise(((Component)this).transform.position, 12f, 0.6f, 0, ((GrabbableObject)this).isInShipRoom, 0); } } } } [BepInPlugin("jeng.jengjokes", "JengJokes", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string GUID = "jeng.jengjokes"; public const string NAME = "JengJokes"; public const string VERSION = "1.0.0"; internal static ManualLogSource Log; internal static string PicturesDir; internal static ConfigEntry<string> ScrapName; internal static ConfigEntry<int> ScrapRarity; internal static ConfigEntry<int> ScrapMinValue; internal static ConfigEntry<int> ScrapMaxValue; internal static ConfigEntry<bool> CoilFaceEnabled; internal static ConfigEntry<bool> CoilFaceGlows; internal static ConfigEntry<bool> DumpCoilHierarchy; internal static ConfigEntry<bool> CoilHideHead; internal static ConfigEntry<bool> CoilFaceFollowViewer; internal static ConfigEntry<Vector3> HoldOffset; internal static ConfigEntry<Vector3> HoldTilt; internal static ConfigEntry<float> CoilFaceSize; internal static ConfigEntry<float> CoilFaceExtraUp; internal static ConfigEntry<float> CoilSpringOverlap; internal static ConfigEntry<float> CoilFaceTowardViewer; internal static Texture2D CoilFaceTex; internal static ConfigEntry<bool> DebugHotkeys; internal static Plugin Instance; private void Awake() { //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; DebugHotkeys = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Hotkeys", false, "Host-only test keys: F8 spawn photo, F9 spawn Coil-head, F10 reload config."); PicturesDir = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Pictures"); ScrapName = ((BaseUnityPlugin)this).Config.Bind<string>("Scrap", "Name", "Framed Photo", "Name shown when scanning or holding the item."); ScrapRarity = ((BaseUnityPlugin)this).Config.Bind<int>("Scrap", "Rarity", 40, "Spawn weight on every moon (vanilla scrap is roughly 5-90)."); ScrapMinValue = ((BaseUnityPlugin)this).Config.Bind<int>("Scrap", "MinValue", 60, "Before the game's 0.4x multiplier."); ScrapMaxValue = ((BaseUnityPlugin)this).Config.Bind<int>("Scrap", "MaxValue", 160, "Before the game's 0.4x multiplier."); CoilFaceEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("CoilHead", "Enabled", true, "Put coilhead.png on every Coil-head."); CoilFaceGlows = ((BaseUnityPlugin)this).Config.Bind<bool>("CoilHead", "FaceGlows", false, "true = face is visible in the dark (unlit)."); CoilFaceSize = ((BaseUnityPlugin)this).Config.Bind<float>("CoilHead", "FaceSize", 0.7f, "Width of the face in meters."); CoilSpringOverlap = ((BaseUnityPlugin)this).Config.Bind<float>("CoilHead", "SpringOverlap", 0.12f, "How far the bottom of the picture overlaps the top of the spring (meters)."); CoilFaceExtraUp = ((BaseUnityPlugin)this).Config.Bind<float>("CoilHead", "ExtraUp", 0f, "Nudge the picture up (+) or down (-)."); CoilFaceTowardViewer = ((BaseUnityPlugin)this).Config.Bind<float>("CoilHead", "TowardViewer", 0.25f, "Pull the picture toward whoever is looking, so the spring stays behind it."); HoldOffset = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Scrap", "HoldOffset", new Vector3(0.18f, -0.22f, 0.55f), "Where the photo sits when held, from your eyes: x = right, y = up, z = forward (meters)."); HoldTilt = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Scrap", "HoldTilt", new Vector3(-10f, -12f, 0f), "Extra tilt of the held photo in degrees (x = tip back, y = turn, z = roll)."); CoilHideHead = ((BaseUnityPlugin)this).Config.Bind<bool>("CoilHead", "HideHead", true, "Hide the Coil-head's own head so the picture replaces it (body and spring stay)."); CoilFaceFollowViewer = ((BaseUnityPlugin)this).Config.Bind<bool>("CoilHead", "FaceFollowsViewer", true, "The picture always turns to face whoever is looking at it."); DumpCoilHierarchy = ((BaseUnityPlugin)this).Config.Bind<bool>("CoilHead", "LogModelParts", true, "Write the Coil-head's part names to the log (for tuning)."); Texture2D val = LoadTexture("scrap.png"); CoilFaceTex = LoadTexture("coilhead.png"); AudioClip useClip = LoadAudio("scrap_use"); if ((Object)(object)val != (Object)null) { PhotoScrap.Register(val, useClip); } else { Log.LogWarning((object)"No Pictures/scrap.png found, skipping the scrap item."); } new Harmony("jeng.jengjokes").PatchAll(); Log.LogInfo((object)"JengJokes 1.0.0 loaded."); } internal static Texture2D LoadTexture(string file) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_002c: 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) //IL_0040: Expected O, but got Unknown string path = Path.Combine(PicturesDir, file); if (!File.Exists(path)) { return null; } Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true); ImageConversion.LoadImage(val, File.ReadAllBytes(path)); ((Texture)val).wrapMode = (TextureWrapMode)1; ((Object)val).name = Path.GetFileNameWithoutExtension(file); return val; } internal static AudioClip LoadAudio(string baseName) { //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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Invalid comparison between Unknown and I4 (string, AudioType)[] array = new(string, AudioType)[3] { (".ogg", (AudioType)14), (".wav", (AudioType)20), (".mp3", (AudioType)13) }; for (int i = 0; i < array.Length; i++) { (string, AudioType) tuple = array[i]; string item = tuple.Item1; AudioType item2 = tuple.Item2; string text = Path.Combine(PicturesDir, baseName + item); if (!File.Exists(text)) { continue; } UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip("file:///" + text.Replace('\\', '/'), item2); try { audioClip.SendWebRequest(); while (!audioClip.isDone) { } if ((int)audioClip.result != 1) { Log.LogError((object)("Couldn't load " + text + ": " + audioClip.error)); return null; } AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip); ((Object)content).name = baseName; return content; } finally { ((IDisposable)audioClip)?.Dispose(); } } return null; } internal static Material PictureMaterial(Texture2D tex, bool unlit) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) //IL_003f: 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_004f: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown Material val = new Material(Shader.Find(unlit ? "HDRP/Unlit" : "HDRP/Lit") ?? Shader.Find("Standard")); val.SetTexture("_BaseColorMap", (Texture)(object)tex); val.SetTexture("_UnlitColorMap", (Texture)(object)tex); val.SetColor("_BaseColor", Color.white); val.SetColor("_UnlitColor", Color.white); val.mainTexture = (Texture)(object)tex; return val; } } }