Decompiled source of SillyItems v0.3.0

SillyItems.dll

Decompiled 2 days ago
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 HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using Zorro.Core;

[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: AssemblyCompany("SillyItems")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SillyItems")]
[assembly: AssemblyTitle("SillyItems")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
		}
	}
}
public class ClownHorn : ItemInstanceBehaviour
{
	private OnOffEntry onOffEntry;

	private StashAbleEntry stashAbleEntry;

	public SFX_Instance sfx;

	private bool on;

	private float counter = 1f;

	public bool IsHeld => base.isHeld;

	public bool IsActive => onOffEntry.on;

	private void Update()
	{
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		counter += Time.deltaTime;
		if (counter > 0.25f && base.isHeldByMe && !Player.localPlayer.HasLockedInput() && GlobalInputHandler.CanTakeInput() && Player.localPlayer.input.clickWasPressed)
		{
			counter = 0f;
			onOffEntry.on = !onOffEntry.on;
			((ItemDataEntry)onOffEntry).SetDirty();
		}
		if (onOffEntry != null && on != onOffEntry.on)
		{
			sfx.Play(((Component)this).transform.position, false, 1f, (Transform)null);
			on = onOffEntry.on;
		}
	}

	public override void ConfigItem(ItemInstanceData data, PhotonView playerView)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		if (!data.TryGetEntry<OnOffEntry>(ref onOffEntry))
		{
			onOffEntry = new OnOffEntry
			{
				on = false
			};
			data.AddDataEntry((ItemDataEntry)(object)onOffEntry);
		}
		else
		{
			on = onOffEntry.on;
		}
	}
}
public class RubberDucky : ItemInstanceBehaviour
{
	private OnOffEntry onOffEntry;

	private StashAbleEntry stashAbleEntry;

	public SFX_Instance sfx;

	private bool on;

	private float counter = 1f;

	public bool IsHeld => base.isHeld;

	public bool IsActive => onOffEntry.on;

	private void Update()
	{
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		counter += Time.deltaTime;
		if (counter > 0.25f && base.isHeldByMe && !Player.localPlayer.HasLockedInput() && GlobalInputHandler.CanTakeInput() && Player.localPlayer.input.clickWasPressed)
		{
			counter = 0f;
			onOffEntry.on = !onOffEntry.on;
			((ItemDataEntry)onOffEntry).SetDirty();
		}
		if (onOffEntry != null && on != onOffEntry.on)
		{
			sfx.Play(((Component)this).transform.position, false, 1f, (Transform)null);
			on = onOffEntry.on;
		}
	}

	public override void ConfigItem(ItemInstanceData data, PhotonView playerView)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		if (!data.TryGetEntry<OnOffEntry>(ref onOffEntry))
		{
			onOffEntry = new OnOffEntry
			{
				on = false
			};
			data.AddDataEntry((ItemDataEntry)(object)onOffEntry);
		}
		else
		{
			on = onOffEntry.on;
		}
	}
}
public class Woops : ItemInstanceBehaviour
{
	private OnOffEntry onOffEntry;

	private StashAbleEntry stashAbleEntry;

	public SFX_Instance sfx;

	private bool on;

	private bool hitSomething;

	private float counter = 1f;

	public bool IsHeld => base.isHeld;

	public bool IsActive => onOffEntry.on;

	private void Update()
	{
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		counter += Time.deltaTime;
		if (counter > 0.25f && base.isHeldByMe && !Player.localPlayer.HasLockedInput() && GlobalInputHandler.CanTakeInput())
		{
			if (Player.localPlayer.input.clickWasPressed)
			{
				counter = 0f;
				onOffEntry.on = !onOffEntry.on;
				((ItemDataEntry)onOffEntry).SetDirty();
			}
		}
		else if (counter > 3f && hitSomething)
		{
			counter = 0f;
			hitSomething = false;
			onOffEntry.on = !onOffEntry.on;
			((ItemDataEntry)onOffEntry).SetDirty();
		}
		if (onOffEntry != null && on != onOffEntry.on)
		{
			sfx.Play(((Component)this).transform.position, false, 1f, (Transform)null);
			on = onOffEntry.on;
		}
	}

	private void OnTriggerEnter(Collider other)
	{
		if (!base.isHeldByMe && !hitSomething && (Object)(object)((Component)other).GetComponentInParent<Player>() != (Object)null)
		{
			hitSomething = true;
		}
	}

	private void OnTriggerExit(Collider other)
	{
		hitSomething = false;
	}

	public override void ConfigItem(ItemInstanceData data, PhotonView playerView)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Expected O, but got Unknown
		if (!data.TryGetEntry<OnOffEntry>(ref onOffEntry))
		{
			onOffEntry = new OnOffEntry
			{
				on = false
			};
			data.AddDataEntry((ItemDataEntry)(object)onOffEntry);
		}
		else
		{
			on = onOffEntry.on;
		}
	}
}
namespace SillyItems
{
	[BepInPlugin("arargd.bepinex.sillyitems", "sillyitems", "0.3.0")]
	public class Main : BaseUnityPlugin
	{
		public void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("arargdsillyitems");
			val.PatchAll();
		}
	}
	[HarmonyPatch(typeof(GameHandler), "Start")]
	public class LoadLater
	{
		private static void Postfix()
		{
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sillyitems");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			List<Item> list = val.LoadAllAssets<Item>().ToList();
			ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
			List<Item> list2 = ((DatabaseAsset<ItemDatabase, Item>)(object)instance).Objects.ToList();
			List<string> list3 = instance.lastLoadedPersistentIDs.ToList();
			MeshRenderer? obj2 = list2.SelectMany((Item obj) => obj.itemObject.GetComponentsInChildren<MeshRenderer>()).FirstOrDefault((Func<MeshRenderer, bool>)delegate(MeshRenderer meshRenderer)
			{
				Shader shader2 = ((Renderer)meshRenderer).sharedMaterial.shader;
				return ((shader2 != null) ? ((Object)shader2).name : null) == "World";
			});
			Shader shader = ((obj2 != null) ? ((Renderer)obj2).sharedMaterial.shader : null);
			int num = list2.Count;
			foreach (Item item in list)
			{
				MeshRenderer[] componentsInChildren = item.itemObject.GetComponentsInChildren<MeshRenderer>();
				MeshRenderer[] array = componentsInChildren;
				foreach (MeshRenderer val2 in array)
				{
					Material[] sharedMaterials = ((Renderer)val2).sharedMaterials;
					foreach (Material val3 in sharedMaterials)
					{
						if (((Object)val3.shader).name == "World")
						{
							val3.shader = shader;
						}
					}
				}
				if (num > 256)
				{
					Debug.LogError((object)"Maximum Item limit hit (256), Giving up on adding anymore Silly items! Thanks for the byte Landfall Devs!");
					break;
				}
				item.id = (byte)num;
				num++;
				list2.Add(item);
				list3.Add(item.persistentID);
			}
			((DatabaseAsset<ItemDatabase, Item>)(object)instance).Objects = list2.ToArray();
			instance.lastLoadedItems = list2;
			instance.lastLoadedPersistentIDs = list3;
			Debug.Log((object)"Loaded Silly Items, I Hope!");
		}
	}
}