Decompiled source of Abnormal Items v1.0.0

plugins/AbnormalItems.dll

Decompiled 12 hours ago
using System;
using System.Diagnostics;
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 UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AbnormalItems")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AbnormalItems")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b0991365-76a1-4b05-b9a3-345cf2d124eb")]
[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")]
namespace AbnormalItems;

public class CustomItemProp : GrabbableObject
{
	private ItemBehaviour[] behaviours;

	public override void Start()
	{
		((GrabbableObject)this).Start();
		behaviours = ((Component)this).GetComponents<ItemBehaviour>();
		ItemBehaviour[] array = behaviours;
		foreach (ItemBehaviour itemBehaviour in array)
		{
			itemBehaviour.OnStart(this);
		}
	}

	public override void ItemActivate(bool used, bool buttonDown = true)
	{
		((GrabbableObject)this).ItemActivate(used, buttonDown);
		ItemBehaviour[] array = behaviours;
		foreach (ItemBehaviour itemBehaviour in array)
		{
			itemBehaviour.OnUse(this);
		}
	}
}
public class DamageBehaviour : ItemBehaviour
{
	public int damage = 10;

	public override void OnUse(CustomItemProp item)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)((GrabbableObject)item).playerHeldBy == (Object)null))
		{
			((GrabbableObject)item).playerHeldBy.DamagePlayer(damage, true, true, (CauseOfDeath)0, 0, false, default(Vector3));
		}
	}
}
public class DisappearBehaviour : ItemBehaviour
{
	public override void OnUse(CustomItemProp item)
	{
		if ((Object)(object)((GrabbableObject)item).playerHeldBy != (Object)null)
		{
			((GrabbableObject)item).DestroyObjectInHand(((GrabbableObject)item).playerHeldBy);
		}
	}
}
public class HealBehaviour : ItemBehaviour
{
	public int heal = 10;

	public override void OnUse(CustomItemProp item)
	{
		if (!((Object)(object)((GrabbableObject)item).playerHeldBy == (Object)null))
		{
			PlayerControllerB playerHeldBy = ((GrabbableObject)item).playerHeldBy;
			playerHeldBy.health += heal;
		}
	}
}
public abstract class ItemBehaviour : MonoBehaviour
{
	public virtual void OnStart(CustomItemProp item)
	{
	}

	public virtual void OnUse(CustomItemProp item)
	{
	}
}
public class NoisemakerBehaviour : ItemBehaviour
{
	public AudioSource noiseAudio;

	public AudioSource noiseAudioFar;

	[Space(3f)]
	public AudioClip[] noiseSFX;

	public AudioClip[] noiseSFXFar;

	[Space(3f)]
	public float noiseRange = 10f;

	public float maxLoudness = 1f;

	public float minLoudness = 1f;

	public float minPitch = 1f;

	public float maxPitch = 1f;

	public Animator triggerAnimator;

	private Random noisemakerRandom;

	public override void OnStart(CustomItemProp item)
	{
		noisemakerRandom = new Random(StartOfRound.Instance.randomMapSeed + 85);
	}

	public override void OnUse(CustomItemProp item)
	{
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null) && !((Object)(object)noiseAudio == (Object)null) && noiseSFX != null && noiseSFX.Length != 0)
		{
			int num = noisemakerRandom.Next(noiseSFX.Length);
			float num2 = (float)noisemakerRandom.Next((int)(minLoudness * 100f), (int)(maxLoudness * 100f)) / 100f;
			float pitch = (float)noisemakerRandom.Next((int)(minPitch * 100f), (int)(maxPitch * 100f)) / 100f;
			noiseAudio.pitch = pitch;
			noiseAudio.PlayOneShot(noiseSFX[num], num2);
			if ((Object)(object)noiseAudioFar != (Object)null && noiseSFXFar != null && num < noiseSFXFar.Length)
			{
				noiseAudioFar.pitch = pitch;
				noiseAudioFar.PlayOneShot(noiseSFXFar[num], num2);
			}
			if ((Object)(object)triggerAnimator != (Object)null)
			{
				triggerAnimator.SetTrigger("playAnim");
			}
			WalkieTalkie.TransmitOneShotAudio(noiseAudio, noiseSFX[num], num2);
			RoundManager.Instance.PlayAudibleNoise(((Component)item).transform.position, noiseRange, num2, 0, ((GrabbableObject)item).isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0);
			if (minLoudness >= 0.6f && (Object)(object)((GrabbableObject)item).playerHeldBy != (Object)null)
			{
				((GrabbableObject)item).playerHeldBy.timeSinceMakingLoudNoise = 0f;
			}
		}
	}
}
[BepInPlugin("Poseidon.AbnormalItems", "Abnormal Items", "1.0.0")]
public class AbnormalItems : BaseUnityPlugin
{
	private const string modGUID = "Poseidon.AbnormalItems";

	private const string modName = "Abnormal Items";

	private const string modVersion = "1.0.0";

	private readonly Harmony harmony = new Harmony("Poseidon.AbnormalItems");

	private static AbnormalItems Instance;

	internal ManualLogSource mls;

	private void Awake()
	{
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		mls = Logger.CreateLogSource("Poseidon.AbnormalItems");
		mls.LogInfo((object)"loaded abnormal items resources");
		harmony.PatchAll(typeof(AbnormalItems));
	}
}