Decompiled source of Joint Mod v1.0.0

JointMod.dll

Decompiled 8 hours ago
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Unity.Netcode;
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("JointMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JointMod")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("78ab728a-f561-492b-a6fd-24c09f588b4f")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
public class JointItemScript : GrabbableObject
{
	private PlayerControllerB previousPlayerHeldBy;

	private bool isSmoking = false;

	private ParticleSystem smoke;

	private Vector3 normalPositionOffset = new Vector3(0.03f, 0.25f, 0.04f);

	private Vector3 smokingPositionOffset = new Vector3(0.03f, 0.2f, 0.04f);

	private Vector3 normalRotationOffset = new Vector3(115f, 20f, 0f);

	private Vector3 smokingRotationOffset = new Vector3(200f, 20f, 0f);

	private Coroutine offsetCoroutine;

	private Coroutine highCoroutine;

	private float highnessLevel = 0f;

	private void Awake()
	{
		smoke = ((Component)this).GetComponentInChildren<ParticleSystem>(true);
		if ((Object)(object)smoke == (Object)null)
		{
			Debug.LogError((object)"ParticleSystem 'Smoke' not found!");
		}
	}

	public override void ItemActivate(bool used, bool buttonDown = true)
	{
		//IL_00a4: 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_00ba: 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)
		((GrabbableObject)this).ItemActivate(used, buttonDown);
		if (!buttonDown || !((Object)(object)base.playerHeldBy != (Object)null) || !base.isHeld)
		{
			return;
		}
		isSmoking = !isSmoking;
		if (((NetworkBehaviour)this).IsOwner && (Object)(object)previousPlayerHeldBy != (Object)null)
		{
			previousPlayerHeldBy.playerBodyAnimator.SetBool("useTZPItem", isSmoking);
		}
		if (offsetCoroutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(offsetCoroutine);
		}
		offsetCoroutine = ((MonoBehaviour)this).StartCoroutine(SmoothTransition(isSmoking ? smokingPositionOffset : normalPositionOffset, isSmoking ? smokingRotationOffset : normalRotationOffset));
		if (isSmoking)
		{
			smoke.Play();
			return;
		}
		smoke.Stop();
		if (highCoroutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(highCoroutine);
			highCoroutine = null;
		}
	}

	private IEnumerator SmoothTransition(Vector3 targetPositionOffset, Vector3 targetRotationOffset)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		Vector3 initialPositionOffset = base.itemProperties.positionOffset;
		Vector3 initialRotationOffset = base.itemProperties.rotationOffset;
		float duration = 0.1f;
		float elapsedTime = 0f;
		while (elapsedTime < duration)
		{
			base.itemProperties.positionOffset = Vector3.Lerp(initialPositionOffset, targetPositionOffset, elapsedTime / duration);
			base.itemProperties.rotationOffset = Vector3.Lerp(initialRotationOffset, targetRotationOffset, elapsedTime / duration);
			elapsedTime += Time.deltaTime;
			yield return null;
		}
		base.itemProperties.positionOffset = targetPositionOffset;
		base.itemProperties.rotationOffset = targetRotationOffset;
	}

	public override void Update()
	{
		if (highnessLevel > 1f)
		{
			highnessLevel = 1f;
		}
		if (((NetworkBehaviour)this).IsOwner && (Object)(object)previousPlayerHeldBy != (Object)null && isSmoking)
		{
			highnessLevel += Time.deltaTime / 25f;
			previousPlayerHeldBy.drunkness = highnessLevel;
			previousPlayerHeldBy.increasingDrunknessThisFrame = true;
		}
		if (((NetworkBehaviour)this).IsOwner && (Object)(object)previousPlayerHeldBy != (Object)null && highnessLevel > 0f && !isSmoking)
		{
			highnessLevel = previousPlayerHeldBy.drunkness;
		}
		((GrabbableObject)this).Update();
	}

	public override void EquipItem()
	{
		((GrabbableObject)this).EquipItem();
		StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
		if ((Object)(object)base.playerHeldBy != (Object)null)
		{
			previousPlayerHeldBy = base.playerHeldBy;
		}
	}

	public override void DiscardItem()
	{
		//IL_0028: 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)
		isSmoking = false;
		if (offsetCoroutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(offsetCoroutine);
		}
		offsetCoroutine = ((MonoBehaviour)this).StartCoroutine(SmoothTransition(normalPositionOffset, normalRotationOffset));
		highnessLevel = 0f;
		if (highCoroutine != null)
		{
			((MonoBehaviour)this).StopCoroutine(highCoroutine);
			highCoroutine = null;
		}
		((GrabbableObject)this).DiscardItem();
	}

	public override void Start()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		((GrabbableObject)this).Start();
		base.itemProperties.positionOffset = normalPositionOffset;
		base.itemProperties.rotationOffset = normalRotationOffset;
	}
}
namespace JointNamespace;

[BepInPlugin("OzzyElvis.LC.JointMod", "zaza goes hard", "1.0")]
public class Plugin : BaseUnityPlugin
{
	public static Plugin instance;

	private readonly Harmony harmony = new Harmony("OzzyElvis.AIO");

	internal ManualLogSource mls;

	private void Awake()
	{
		instance = this;
		mls = ((BaseUnityPlugin)this).Logger;
		string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "joint");
		AssetBundle val = AssetBundle.LoadFromFile(text);
		string[] allAssetNames = val.GetAllAssetNames();
		Item val2 = val.LoadAsset<Item>("Assets/JointMod/Joint.asset");
		((BaseUnityPlugin)this).Logger.LogInfo((object)("Loaded prefab name: " + ((Object)val2.spawnPrefab).name));
		NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
		Utilities.FixMixerGroups(val2.spawnPrefab);
		JointItemScript jointItemScript = val2.spawnPrefab.AddComponent<JointItemScript>();
		((GrabbableObject)jointItemScript).grabbable = true;
		((GrabbableObject)jointItemScript).itemProperties = val2;
		((GrabbableObject)jointItemScript).useCooldown = 0.15f;
		TerminalNode val3 = ScriptableObject.CreateInstance<TerminalNode>();
		val3.displayText = ":3 \n\n";
		val3.clearPreviousText = true;
		Items.RegisterShopItem(val2, (TerminalNode)null, (TerminalNode)null, val3, 12);
		harmony.PatchAll(typeof(Plugin));
	}
}