Decompiled source of ULTRAPISS v1.0.0

plugins\ULTRAPISS.dll

Decompiled 3 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Notiffy.API;
using Notiffy.Utils;
using PluginConfig.API;
using PluginConfig.API.Fields;
using UnityEngine;
using UnityEngine.SceneManagement;

[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("ULTRAPISS")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+fc910b8817241151efaa481cd2dc795dea548cb1")]
[assembly: AssemblyProduct("ULTRAPISS")]
[assembly: AssemblyTitle("ULTRAPISS")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
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;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 ULTRAPISS
{
	[BepInPlugin("com.github.end-4.ultrapiss", "ULTRAPISS", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource? Log;

		public static string workingPath = Assembly.GetExecutingAssembly().Location;

		public static string workingDir = Path.GetDirectoryName(workingPath);

		public const string PluginGUID = "com.github.end-4.ultrapiss";

		public const string PluginName = "ULTRAPISS";

		public const string PluginVersion = "1.0.0";

		private GameObject waterStreamObject;

		private ParticleSystem waterParticleSystem;

		private bool isFiring;

		private Material waterMaterial;

		private List<ParticleCollisionEvent> collisionEvents = new List<ParticleCollisionEvent>();

		public PluginConfigurator config;

		public KeyCodeField PissKey;

		public ColorField PissColor;

		public FloatSliderField PissOpacity;

		public FloatField PissForce;

		public FloatField PissDensity;

		public FloatField PissAngle;

		private BoolField RemindInstructions;

		private int collisionTickCounter;

		private Material? pissDecalMaterial;

		public Color PissColorValue => new Color(PissColor.value.r, PissColor.value.g, PissColor.value.b, PissOpacity.value);

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			CreateConfig();
			CreateWaterParticleSystem();
			CreatePissDecal();
			SceneManager.sceneLoaded += IssueInstructionsIfNeeded;
			Log.LogInfo((object)"THE WORLD IS YOUR CANVAS. SO TAKE UP YOUR BRUSH. AND PAINT. THE WORLD.  Y E L L O W .");
		}

		private void IssueInstructionsIfNeeded(Scene _, LoadSceneMode __)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (RemindInstructions.value)
			{
				RemindInstructions.value = false;
				KeyCode value = PissKey.value;
				NotificationSystem.NotifySend("<color=#d7a000>ULTRAPISS</color> instructions", "To pee, press [<color=#ff8000>" + ((object)(KeyCode)(ref value)).ToString() + "</color>]. Many parameters such as piss strength can be adjusted in <color=#55c7f6>Options > Plugin Config > ULTRAPISS</color>", (Sprite)null, "", (Urgency)1, "NotifySend", 0u, (Dictionary<string, string>)null, -1);
			}
		}

		private void Update()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)MonoSingleton<GunControl>.Instance == (Object)null))
			{
				if ((Object)(object)waterStreamObject == (Object)null || (Object)(object)waterParticleSystem == (Object)null || (Object)(object)waterMaterial == (Object)null)
				{
					CreateWaterParticleSystem();
				}
				if (Input.GetKey(PissKey.value))
				{
					StartShooting();
				}
				else
				{
					StopShooting();
				}
			}
		}

		private void UpdatePissColor()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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_0014: 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)
			MainModule main = waterParticleSystem.main;
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(PissColorValue);
			if ((Object)(object)pissDecalMaterial != (Object)null)
			{
				pissDecalMaterial.color = PissColorValue;
			}
		}

		private void UpdatePissColor(Color _)
		{
			UpdatePissColor();
		}

		private void UpdatePissColor(float _, Tuple<float, float> __)
		{
			UpdatePissColor();
		}

		private void UpdatePissForce()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			MainModule main = waterParticleSystem.main;
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(PissForce.value);
		}

		private void UpdatePissForce(float _)
		{
			UpdatePissForce();
		}

		private void UpdatePissDensity()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			EmissionModule emission = waterParticleSystem.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(PissDensity.value);
		}

		private void UpdatePissDensity(float _)
		{
			UpdatePissDensity();
		}

		private void CreateConfig()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Expected O, but got Unknown
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Expected O, but got Unknown
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Expected O, but got Unknown
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			config = PluginConfigurator.Create("ULTRAPISS", "com.github.end-4.ultrapiss");
			string text = Path.Combine(workingDir, "icon.png");
			if (File.Exists(text))
			{
				config.SetIconWithURL(text);
			}
			PissKey = new KeyCodeField(config.rootPanel, "Piss key", "pissKey", (KeyCode)112);
			PissColor = new ColorField(config.rootPanel, "Piss color", "pissColor", new Color(0.8745098f, 0.654902f, 11f / 85f));
			PissColor.postValueChangeEvent += new PostColorValueChangeEvent(UpdatePissColor);
			PissOpacity = new FloatSliderField(config.rootPanel, "Piss opacity", "pissOpacity", new Tuple<float, float>(0f, 1f), 0.9f);
			PissOpacity.postValueChangeEvent += new PostFloatSliderValueChangeEvent(UpdatePissColor);
			PissForce = new FloatField(config.rootPanel, "Piss force", "pissForce", 30f);
			PissForce.postValueChangeEvent += new PostFloatValueChangeEvent(UpdatePissForce);
			PissDensity = new FloatField(config.rootPanel, "Piss density", "pissDensity", 300f);
			PissDensity.postValueChangeEvent += new PostFloatValueChangeEvent(UpdatePissDensity);
			PissAngle = new FloatField(config.rootPanel, "Piss angle", "pissAngle", -48f);
			RemindInstructions = new BoolField(config.rootPanel, "Show instructions on startup", "remindInstructions", true);
		}

		private Texture2D CreateCircleTexture(int size)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_00eb: 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_00be: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
			float num = (float)size / 2f;
			float num2 = (float)size / 2f;
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(PissColor.value.r, PissColor.value.g, PissColor.value.b, 0f);
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num3 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), new Vector2(num, num));
					if (num3 <= num2)
					{
						float num4 = Mathf.Clamp01((num2 - num3) / 1.8f);
						val.SetPixel(j, i, new Color(PissColor.value.r, PissColor.value.g, PissColor.value.b, num4));
					}
					else
					{
						val.SetPixel(j, i, val2);
					}
				}
			}
			val.Apply();
			return val;
		}

		private void CreatePissDecal()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("UI/Default");
			Log.LogInfo((object)val);
			if ((Object)(object)val != (Object)null)
			{
				pissDecalMaterial = new Material(val);
				pissDecalMaterial.mainTexture = (Texture)(object)Img2Sprite.LoadTexture(Path.Combine(workingDir, "assets/stain.png"));
				pissDecalMaterial.color = PissColorValue;
			}
		}

		private void CreateWaterParticleSystem()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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)
			//IL_0114: 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_013f: 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_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Expected O, but got Unknown
			if ((Object)(object)waterStreamObject != (Object)null)
			{
				Object.Destroy((Object)(object)waterStreamObject);
			}
			waterStreamObject = new GameObject("ULTRAPISS_Particles");
			Object.DontDestroyOnLoad((Object)(object)waterStreamObject);
			Rigidbody obj = waterStreamObject.AddComponent<Rigidbody>();
			obj.isKinematic = true;
			obj.useGravity = false;
			waterParticleSystem = waterStreamObject.AddComponent<ParticleSystem>();
			MainModule main = waterParticleSystem.main;
			((MainModule)(ref main)).duration = 1f;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0.6f);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.25f);
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(4.5f);
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(PissColorValue);
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).maxParticles = 5000;
			UpdatePissForce();
			CollisionModule collision = waterParticleSystem.collision;
			((CollisionModule)(ref collision)).enabled = true;
			((CollisionModule)(ref collision)).type = (ParticleSystemCollisionType)1;
			int num = LayerMask.NameToLayer("Player");
			((CollisionModule)(ref collision)).collidesWith = LayerMask.op_Implicit(~(1 << num));
			((CollisionModule)(ref collision)).maxCollisionShapes = 10;
			((CollisionModule)(ref collision)).bounce = MinMaxCurve.op_Implicit(0f);
			((CollisionModule)(ref collision)).dampen = MinMaxCurve.op_Implicit(1f);
			((CollisionModule)(ref collision)).lifetimeLoss = MinMaxCurve.op_Implicit(1f);
			((CollisionModule)(ref collision)).sendCollisionMessages = true;
			EmissionModule emission = waterParticleSystem.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(300f);
			((EmissionModule)(ref emission)).enabled = false;
			ShapeModule shape = waterParticleSystem.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
			((ShapeModule)(ref shape)).angle = 1.5f;
			((ShapeModule)(ref shape)).radius = 0.03f;
			Shader val = Shader.Find("Sprites/Default");
			if ((Object)(object)val != (Object)null)
			{
				waterMaterial = new Material(val);
				waterMaterial.mainTexture = (Texture)(object)CreateCircleTexture(64);
			}
			ParticleSystemRenderer component = waterStreamObject.GetComponent<ParticleSystemRenderer>();
			if ((Object)(object)component != (Object)null && (Object)(object)waterMaterial != (Object)null)
			{
				((Renderer)component).material = waterMaterial;
			}
			waterStreamObject.AddComponent<ParticleCollisionListener>().OnCollisionAction = HandleParticleImpact;
		}

		private void HandleParticleImpact(GameObject other)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			if (other.CompareTag("Player") || (Object)(object)MonoSingleton<BloodsplatterManager>.Instance == (Object)null)
			{
				return;
			}
			int num = ParticlePhysicsExtensions.GetCollisionEvents(waterParticleSystem, other, collisionEvents);
			Bloodsplatter val2 = default(Bloodsplatter);
			Collider val3 = default(Collider);
			MeshRenderer val4 = default(MeshRenderer);
			for (int i = 0; i < num; i++)
			{
				collisionTickCounter++;
				if (collisionTickCounter % 10 != 0)
				{
					continue;
				}
				ParticleCollisionEvent val = collisionEvents[i];
				Vector3 intersection = ((ParticleCollisionEvent)(ref val)).intersection;
				val = collisionEvents[i];
				Vector3 normal = ((ParticleCollisionEvent)(ref val)).normal;
				Quaternion rotation = Quaternion.LookRotation(normal);
				GameObject gore = MonoSingleton<BloodsplatterManager>.Instance.GetGore((GoreType)5, false, false, false, (EnemyIdentifier)null, false);
				if ((Object)(object)gore != (Object)null)
				{
					gore.SetActive(true);
					gore.transform.position = intersection;
					gore.transform.rotation = rotation;
					if (gore.TryGetComponent<Bloodsplatter>(ref val2) && (Object)(object)val2.part != (Object)null)
					{
						MainModule main = val2.part.main;
						((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(1f, 0.9f, 0f, 1f));
					}
					GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5);
					if (obj.TryGetComponent<Collider>(ref val3))
					{
						Object.Destroy((Object)(object)val3);
					}
					if (obj.TryGetComponent<MeshRenderer>(ref val4) && (Object)(object)pissDecalMaterial != (Object)null)
					{
						((Renderer)val4).material = pissDecalMaterial;
					}
					obj.transform.position = intersection + normal * 0.015f;
					obj.transform.rotation = rotation;
					obj.transform.SetParent(other.transform, true);
					float num2 = Random.Range(0.2f, 3f);
					obj.transform.localScale = new Vector3(num2, num2, 1f);
					Object.Destroy((Object)(object)obj, 25f);
				}
			}
		}

		private void StartShooting()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)MonoSingleton<NewMovement>.Instance == (Object)null) && !((Object)(object)MonoSingleton<CameraController>.Instance == (Object)null) && !((Object)(object)waterStreamObject == (Object)null))
			{
				Transform transform = ((Component)MonoSingleton<NewMovement>.Instance).transform;
				Transform transform2 = ((Component)MonoSingleton<CameraController>.Instance).transform;
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(0f, -0.5f, 0.8f);
				waterStreamObject.transform.position = transform.TransformPoint(val);
				waterStreamObject.transform.rotation = transform2.rotation;
				waterStreamObject.transform.Rotate(Vector3.right, PissAngle.value, (Space)1);
				if (!isFiring)
				{
					isFiring = true;
					EmissionModule emission = waterParticleSystem.emission;
					((EmissionModule)(ref emission)).enabled = true;
					waterParticleSystem.Play();
				}
			}
		}

		private void StopShooting()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (isFiring)
			{
				isFiring = false;
				if (!((Object)(object)waterParticleSystem == (Object)null))
				{
					EmissionModule emission = waterParticleSystem.emission;
					((EmissionModule)(ref emission)).enabled = false;
					waterParticleSystem.Stop();
				}
			}
		}
	}
	public class ParticleCollisionListener : MonoBehaviour
	{
		public Action<GameObject>? OnCollisionAction;

		private void OnParticleCollision(GameObject other)
		{
			OnCollisionAction?.Invoke(other);
		}
	}
}