Decompiled source of NoNailsRequired v1.0.2

PutUpPaintings.dll

Decompiled 4 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("PutUpPaintings")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PutUpPaintings")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("86b5c81d-6cd5-403d-ba89-f68862e964f6")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
public class PaintingObject : PhysicsProp
{
	public bool isUp = false;

	public bool hitRay = false;

	public static LayerMask layer = LayerMask.op_Implicit(LayerMask.GetMask(new string[3] { "Default", "Room", "Colliders" }));

	public static Vector3 upPos;

	public static Vector3 upRot;

	public static Vector3 downPos = new Vector3(-0.3f, 0.07f, -0.6f);

	public static Vector3 downRot = new Vector3(0f, 100f, 90f);

	public static Vector3 downRest = new Vector3(-90f, 0f, 180f);

	public float time = 0f;

	private const float speed = 2f;

	public override void Start()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: 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_0023: Unknown result type (might be due to invalid IL or missing references)
		((GrabbableObject)this).Start();
		upPos = ((GrabbableObject)this).itemProperties.positionOffset;
		upRot = ((GrabbableObject)this).itemProperties.rotationOffset;
	}

	public override void ItemActivate(bool used, bool buttonDown = true)
	{
		((GrabbableObject)this).ItemActivate(used, buttonDown);
		isUp = !isUp;
		HUDManager.Instance.ChangeControlTip(1, ((GrabbableObject)this).itemProperties.toolTips[0], false);
	}

	public override void SetControlTipsForItem()
	{
		string text = (isUp ? "Stand Down : [LMB]" : "Put Down : [LMB]");
		HUDManager.Instance.ChangeControlTip(1, text, false);
	}

	public override void DiscardItem()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: 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_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: 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_0086: 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)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
		((GrabbableObject)this).DiscardItem();
		if (isUp)
		{
			Ray val = default(Ray);
			((Ray)(ref val))..ctor(((Component)this).transform.position - ((Component)this).transform.right * 0.2f, ((Component)this).transform.right);
			RaycastHit val2 = default(RaycastHit);
			if (hitRay = Physics.Raycast(val, ref val2, 1f, LayerMask.op_Implicit(layer)))
			{
				((GrabbableObject)this).startFallingPosition = ((Component)this).transform.parent.InverseTransformPoint(((RaycastHit)(ref val2)).point) + ((RaycastHit)(ref val2)).normal * 0.05f;
				((GrabbableObject)this).targetFloorPosition = ((GrabbableObject)this).startFallingPosition;
				Quaternion val3 = Quaternion.LookRotation(-((RaycastHit)(ref val2)).normal);
				((GrabbableObject)this).floorYRot = (int)((Quaternion)(ref val3)).eulerAngles.y;
			}
		}
	}

	public override void LateUpdate()
	{
		//IL_001e: 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_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_007b: 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_0081: 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_0091: 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_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: 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)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)((GrabbableObject)this).radarIcon != (Object)null)
		{
			((GrabbableObject)this).radarIcon.position = ((Component)this).transform.position;
		}
		time = Mathf.MoveTowards(time, (float)isUp.GetHashCode(), Time.deltaTime * 2f);
		if ((Object)(object)((GrabbableObject)this).parentObject != (Object)null)
		{
			Vector3 val = Vector3.Lerp(upRot, downRot, time);
			Vector3 val2 = Vector3.Lerp(upPos, downPos, time);
			((Component)this).transform.rotation = ((GrabbableObject)this).parentObject.rotation;
			((Component)this).transform.Rotate(val);
			((Component)this).transform.position = ((GrabbableObject)this).parentObject.position;
			Vector3 val3 = val2;
			val3 = ((GrabbableObject)this).parentObject.rotation * val3;
			Transform transform = ((Component)this).transform;
			transform.position += val3;
		}
		else
		{
			((Component)this).transform.rotation = Quaternion.Euler((isUp && hitRay) ? downRest.x : ((GrabbableObject)this).itemProperties.restingRotation.x, (float)(((GrabbableObject)this).floorYRot + ((GrabbableObject)this).itemProperties.floorYOffset) + 90f, (isUp && hitRay) ? downRest.z : ((GrabbableObject)this).itemProperties.restingRotation.z);
		}
	}
}
[BepInPlugin("Mellowdy.Paintings", "Paintings", "1.0.1")]
public class LC_PutUpPaintings : BaseUnityPlugin
{
	private const string modGUID = "Mellowdy.Paintings";

	private const string modName = "Paintings";

	private const string modVersion = "1.0.1";

	public static ManualLogSource mls;

	private static LC_PutUpPaintings instance;

	private readonly Harmony harmony = new Harmony("Mellowdy.Paintings");

	public const bool debug = false;

	public static bool doneOnce;

	private void Awake()
	{
		if ((Object)(object)instance == (Object)null)
		{
			instance = this;
		}
		mls = Logger.CreateLogSource("Mellowdy.Paintings");
		harmony.PatchAll();
		harmony.PatchAll(typeof(LC_PutUpPaintings));
		mls.LogInfo((object)"Paintings has been loaded");
	}

	[HarmonyPatch(typeof(StartOfRound), "Awake")]
	[HarmonyPostfix]
	public static void ReplacePainting(AllItemsList ___allItemsList)
	{
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		if (doneOnce)
		{
			return;
		}
		Item val = null;
		string text = "Painting";
		bool flag = false;
		Item[] array = ___allItemsList.itemsList.ToArray();
		foreach (Item val2 in array)
		{
			bool flag2 = false;
			if (val2.itemName == text)
			{
				val = val2;
				break;
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			mls.LogWarning((object)"Could not find painting item among items");
			return;
		}
		GameObject spawnPrefab = val.spawnPrefab;
		PhysicsProp component = spawnPrefab.GetComponent<PhysicsProp>();
		PaintingObject paintingObject = spawnPrefab.AddComponent<PaintingObject>();
		((Object)paintingObject).name = ((Object)component).name;
		((GrabbableObject)paintingObject).itemProperties = val;
		((GrabbableObject)paintingObject).radarIcon = ((GrabbableObject)component).radarIcon;
		((GrabbableObject)paintingObject).grabbable = ((GrabbableObject)component).grabbable;
		((GrabbableObject)paintingObject).grabbableToEnemies = ((GrabbableObject)component).grabbableToEnemies;
		((GrabbableObject)paintingObject).originalScale = ((GrabbableObject)component).originalScale;
		((GrabbableObject)paintingObject).mainObjectRenderer = ((GrabbableObject)component).mainObjectRenderer;
		val.toolTips = new string[1] { "Stand Up : [LMB]" };
		Object.Destroy((Object)(object)component);
		((GrabbableObject)paintingObject).useCooldown = 0.2f;
		((GrabbableObject)paintingObject).itemProperties.syncDiscardFunction = true;
		doneOnce = true;
	}
}