Decompiled source of PersonalityPotions v1.0.3

PersonalityPotions.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Events;

[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: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("NilsThatBoi")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+dc5166aa7fea4280b26d381f591c94af50cc7362")]
[assembly: AssemblyProduct("PersonalityPotions")]
[assembly: AssemblyTitle("PersonalityPotions")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
[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;
		}
	}
}
public class BrilliancePotion : MonoBehaviour
{
	private enum State
	{
		Idle,
		Active
	}

	private static readonly string[] sentenceTemplates = new string[20]
	{
		"{playerName} solves {noun}s with {intensifier} {adjective}.", "{playerName} {transitiveVerb}s problems {adverb}.", "{playerName} is {intensifier} {adjective}.", "{playerName} {intransitiveVerb}s past every {noun}.", "A true {noun}, {playerName} shines {adverb}.", "{playerName} cracks {noun}s with {intensifier} flair.", "Nothing stops {playerName}—{intransitiveVerb} and conquer.", "{playerName} {transitiveVerb}s tasks {adverb}.", "{playerName}'s mind is {intensifier} {adjective}.", "{playerName} masters {noun}s {adverb}.",
		"{playerName} {transitiveVerb}s challenges {adverb}.", "{playerName} thinks {intensifier} {adjective} thoughts.", "{playerName} makes {noun}s look {adverb}.", "{playerName} always {intransitiveVerb}s ahead.", "{playerName} solves puzzles {adverb}.", "{playerName} runs on {intensifier} {adjective} logic.", "{playerName} is a {noun} at work.", "{playerName} learns {adverb} and grows {intensifier}.", "{playerName} {transitiveVerb}s complexity with ease.", "{playerName} stands out {adverb} as a {adjective} {noun}."
	};

	private static readonly string[] transitiveVerbs = new string[23]
	{
		"solve", "analyze", "decode", "decrypt", "untangle", "engineer", "architect", "formulate", "orchestrate", "spearhead",
		"envision", "design", "optimize", "streamline", "mastermind", "break down", "map out", "synthesize", "model", "calculate",
		"forecast", "predict", "interpret"
	};

	private static readonly string[] intransitiveVerbs = new string[14]
	{
		"shine", "excel", "thrive", "soar", "flourish", "sparkle", "radiate", "stand out", "outperform", "dominate",
		"blink in amazement", "beam with insight", "glow", "gleam"
	};

	private static readonly string[] adjectives = new string[19]
	{
		"brilliant", "insightful", "sharp", "astute", "perspicacious", "keen", "gifted", "ingenious", "savvy", "visionary",
		"masterful", "prodigious", "cerebral", "erudite", "lucid", "nimble minded", "quick witted", "sage like", "preternatural"
	};

	private static readonly string[] intensifiers = new string[14]
	{
		"exceptionally", "remarkably", "undeniably", "astoundingly", "profoundly", "outstandingly", "strikingly", "supremely", "incomparably", "tremendously",
		"unquestionably", "unusually", "supremely", "mind bogglingly"
	};

	private static readonly string[] nouns = new string[14]
	{
		"genius", "prodigy", "visionary", "luminary", "wizard", "maestro", "sage", "thinker", "oracle", "whiz",
		"trailblazer", "innovator", "architect", "strategist"
	};

	private static readonly string[] adverbs = new string[13]
	{
		"brilliantly", "effortlessly", "flawlessly", "seamlessly", "masterfully", "gracefully", "keenly", "cunningly", "precisely", "adeptly",
		"swiftly", "decisively", "inspiredly"
	};

	private float coolDownUntilNextSentence = 3f;

	private ParticleSystem particles;

	private bool particlesPlaying;

	public Renderer BrilliancePotionRenderer;

	private PhysGrabObject physGrabObject;

	private State currentState;

	private string playerName;

	private void Start()
	{
		particles = ((Component)this).GetComponentInChildren<ParticleSystem>(true);
		physGrabObject = ((Component)this).GetComponentInChildren<PhysGrabObject>(true);
		BrilliancePotionRenderer = (Renderer)(object)((Component)this).GetComponentInChildren<MeshRenderer>(true);
		if ((Object)(object)particles == (Object)null)
		{
			Debug.LogError((object)"ParticleSystem not found!");
		}
		if ((Object)(object)physGrabObject == (Object)null)
		{
			Debug.LogError((object)"PhysGrabObject not found!");
		}
		if ((Object)(object)BrilliancePotionRenderer == (Object)null)
		{
			Debug.LogError((object)"MeshRenderer not found!");
		}
	}

	private void Update()
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: 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_0096: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)BrilliancePotionRenderer == (Object)null)
		{
			return;
		}
		BrilliancePotionRenderer.material.mainTextureOffset = new Vector2(0f, Time.time * 0.1f);
		BrilliancePotionRenderer.material.mainTextureScale = new Vector2(2f + Mathf.Sin(Time.time * 1f) * 0.25f, 2f + Mathf.Sin(Time.time * 1f) * 0.25f);
		TrailModule trails = particles.trails;
		if (physGrabObject.grabbed)
		{
			if (!particlesPlaying)
			{
				particles.Play();
				((TrailModule)(ref trails)).enabled = true;
				particlesPlaying = true;
			}
		}
		else if (particlesPlaying)
		{
			particles.Stop();
			((TrailModule)(ref trails)).enabled = false;
			particlesPlaying = false;
		}
		if (SemiFunc.IsMultiplayer())
		{
			switch (currentState)
			{
			case State.Idle:
				StateIdle();
				break;
			case State.Active:
				StateActive();
				break;
			}
		}
	}

	private void StateIdle()
	{
		if (coolDownUntilNextSentence > 0f && physGrabObject.grabbed)
		{
			coolDownUntilNextSentence -= Time.deltaTime;
		}
		else
		{
			if (!Object.op_Implicit((Object)(object)PhysGrabber.instance) || !PhysGrabber.instance.grabbed || !Object.op_Implicit((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject) || !((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject == (Object)(object)physGrabObject))
			{
				return;
			}
			if (!SemiFunc.IsMultiplayer())
			{
				playerName = "the potion";
			}
			else
			{
				PlayerAvatar val = FindClosestPlayer();
				if ((Object)(object)val != (Object)null && val.playerName != null)
				{
					playerName = val.playerName;
				}
				else
				{
					playerName = "the potion";
				}
			}
			SendMessage();
		}
	}

	private PlayerAvatar FindClosestPlayer()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: 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_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		List<PlayerAvatar> list = SemiFunc.PlayerGetAllPlayerAvatarWithinRange(10f, ((Component)PhysGrabber.instance).transform.position, false, default(LayerMask));
		PlayerAvatar result = null;
		float num = float.MaxValue;
		foreach (PlayerAvatar item in list)
		{
			if (!((Object)(object)item == (Object)(object)PlayerAvatar.instance))
			{
				float num2 = Vector3.Distance(((Component)PhysGrabber.instance).transform.position, ((Component)item).transform.position);
				if (num2 < num)
				{
					num = num2;
					result = item;
				}
			}
		}
		return result;
	}

	private void SendMessage()
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		string text = GenerateAffectionateSentence();
		Color val = default(Color);
		((Color)(ref val))..ctor(0.2f, 0.9f, 1f, 1f);
		ChatManager.instance.PossessChatScheduleStart(10);
		ChatManager.instance.PossessChat((PossessChatID)1, text, 1f, val, 0f, false, 0, (UnityEvent)null);
		ChatManager.instance.PossessChatScheduleEnd();
		currentState = State.Active;
	}

	private void StateActive()
	{
		if (PhysGrabber.instance.grabbed && Object.op_Implicit((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject) && (Object)(object)PhysGrabber.instance.grabbedPhysGrabObject != (Object)(object)physGrabObject)
		{
			currentState = State.Idle;
			coolDownUntilNextSentence = Random.Range(5f, 10f);
		}
		else if (!ChatManager.instance.StateIsPossessed())
		{
			currentState = State.Idle;
			coolDownUntilNextSentence = Random.Range(5f, 10f);
		}
	}

	private string GenerateAffectionateSentence()
	{
		string text = sentenceTemplates[Random.Range(0, sentenceTemplates.Length)];
		string text2 = text.Replace("{playerName}", playerName).Replace("{transitiveVerb}", transitiveVerbs[Random.Range(0, transitiveVerbs.Length)]).Replace("{intransitiveVerb}", intransitiveVerbs[Random.Range(0, intransitiveVerbs.Length)])
			.Replace("{adjective}", adjectives[Random.Range(0, adjectives.Length)])
			.Replace("{intensifier}", intensifiers[Random.Range(0, intensifiers.Length)])
			.Replace("{adverb}", adverbs[Random.Range(0, adverbs.Length)])
			.Replace("{noun}", nouns[Random.Range(0, nouns.Length)]);
		return char.ToUpper(text2[0]) + text2.Substring(1);
	}
}
public class ClownPotion : MonoBehaviour
{
	private enum State
	{
		Idle,
		Active
	}

	private static readonly string[] sentenceTemplates = new string[32]
	{
		"Hey {playerName}, did you just {transitiveVerb} that {noun}?!", "{playerName} {intransitiveVerb}s like a {adjective} circus act.", "I’ve seen {noun}s less {adjective} than you, {playerName}.", "Stop {intransitiveVerb} around, {playerName}! This isn’t a comedy show.", "Who needs a {noun}? {playerName} brings the slapstick.", "{playerName} could trip over a {noun} and still look {adjective}.", "Quit {transitiveVerb} my big red nose, {playerName}!", "That move was {intensifier} {adjective}, even for a clown.", "If pies {intransitiveVerb}, {playerName} would be a bakery.", "You juggle {noun}s about as well as a {adjective} banana, {playerName}.",
		"Why so serious, {playerName}? Let’s {transitiveVerb} a {noun}!", "Your brain’s more pie filled than a {noun}, {playerName}.", "I’m {adverb} entertained by your {adjective} antics, {playerName}.", "Step right up, folks—watch {playerName} {intransitiveVerb} in circles!", "{playerName}, you’re the {intensifier} {adjective} joke of the night.", "Did someone order a {adjective}? Oh, it’s just {playerName}.", "Watch out! {playerName} just {transitiveVerb} the whoopee cushion!", "{playerName}, you’re wobblier than a {noun} on stilts.", "If slapstick was a sport, {playerName} would be champion!", "I’ve seen {noun}s less {adjective} than {playerName}.",
		"Honker! That’s the sound of {playerName}’s big red nose.", "Here comes {playerName}, clowning around again!", "{playerName} {intransitiveVerb}s worse than a deflated balloon.", "Your jokes are flat, {playerName}—like yesterday’s {noun}.", "Step right up! {playerName}’s silliness is {intensifier} {adjective}!", "If juggling ideas was a sport, {playerName} would drop ’em all!", "You wear that {noun} like a true disaster artist, {playerName}.", "{playerName}, I’d say ‘don’t quit your day job,’ but this *is* your day job.", "You didn’t just drop the ball, {playerName} juggled it into orbit.", "{playerName}, even the {adjective} mime is judging you.",
		"Some people trip over words—{playerName} trips over *existence*.", "{playerName} tried tightrope walking… on a banana peel."
	};

	private static readonly string[] transitiveVerbs = new string[15]
	{
		"tickle", "juggle", "honk at", "boop", "prank", "spook", "clown chase", "slip on", "pie", "spring at",
		"squirt", "bounce on", "wiggle", "dangle before", "twirl at"
	};

	private static readonly string[] intransitiveVerbs = new string[13]
	{
		"honk", "juggle", "wiggle", "boing", "clown walk", "tumble", "prance", "flip", "bop", "flail",
		"skedaddle", "twirl", "kerplunk"
	};

	private static readonly string[] adjectives = new string[16]
	{
		"goofy", "wacky", "bouncy", "zany", "silly", "loopy", "nutty", "quirky", "giggly", "bumbling",
		"clownish", "jolly", "bonkers", "whimsical", "bananas", "sprightly"
	};

	private static readonly string[] intensifiers = new string[17]
	{
		"absurdly", "ridiculously", "outrageously", "hilariously", "uproariously", "preposterously", "comically", "bananas level", "cartoonishly", "circus grade",
		"bonkers so", "spectacularly", "jaw-droppingly", "phenomenally", "ludicrously", "cataclysmically", "blisteringly"
	};

	private static readonly string[] nouns = new string[12]
	{
		"balloon", "rubber chicken", "big shoe", "stilt", "squirt flower", "clown car", "oversized bow tie", "unicycle", "giant horn", "crazy wig",
		"red nose", "pie tray"
	};

	private static readonly string[] adverbs = new string[12]
	{
		"hilariously", "clownishly", "wackily", "zestily", "buffoonishly", "madly", "ludicrously", "sprightly", "boppingly", "slapstick style",
		"boisterously", "twinkly"
	};

	private float coolDownUntilNextSentence = 3f;

	private ParticleSystem particles;

	private bool particlesPlaying;

	public Renderer ClownPotionRenderer;

	private PhysGrabObject physGrabObject;

	private State currentState;

	private string playerName;

	private void Start()
	{
		particles = ((Component)this).GetComponentInChildren<ParticleSystem>(true);
		physGrabObject = ((Component)this).GetComponentInChildren<PhysGrabObject>(true);
		ClownPotionRenderer = (Renderer)(object)((Component)this).GetComponentInChildren<MeshRenderer>(true);
		if ((Object)(object)particles == (Object)null)
		{
			Debug.LogError((object)"ParticleSystem not found!");
		}
		if ((Object)(object)physGrabObject == (Object)null)
		{
			Debug.LogError((object)"PhysGrabObject not found!");
		}
		if ((Object)(object)ClownPotionRenderer == (Object)null)
		{
			Debug.LogError((object)"MeshRenderer not found!");
		}
	}

	private void Update()
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: 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_0096: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)ClownPotionRenderer == (Object)null)
		{
			return;
		}
		ClownPotionRenderer.material.mainTextureOffset = new Vector2(0f, Time.time * 0.1f);
		ClownPotionRenderer.material.mainTextureScale = new Vector2(2f + Mathf.Sin(Time.time * 1f) * 0.25f, 2f + Mathf.Sin(Time.time * 1f) * 0.25f);
		TrailModule trails = particles.trails;
		if (physGrabObject.grabbed)
		{
			if (!particlesPlaying)
			{
				particles.Play();
				((TrailModule)(ref trails)).enabled = true;
				particlesPlaying = true;
			}
		}
		else if (particlesPlaying)
		{
			particles.Stop();
			((TrailModule)(ref trails)).enabled = false;
			particlesPlaying = false;
		}
		if (SemiFunc.IsMultiplayer())
		{
			switch (currentState)
			{
			case State.Idle:
				StateIdle();
				break;
			case State.Active:
				StateActive();
				break;
			}
		}
	}

	private void StateIdle()
	{
		if (coolDownUntilNextSentence > 0f && physGrabObject.grabbed)
		{
			coolDownUntilNextSentence -= Time.deltaTime;
		}
		else
		{
			if (!Object.op_Implicit((Object)(object)PhysGrabber.instance) || !PhysGrabber.instance.grabbed || !Object.op_Implicit((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject) || !((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject == (Object)(object)physGrabObject))
			{
				return;
			}
			if (!SemiFunc.IsMultiplayer())
			{
				playerName = "the potion";
			}
			else
			{
				PlayerAvatar val = FindClosestPlayer();
				if ((Object)(object)val != (Object)null && val.playerName != null)
				{
					playerName = val.playerName;
				}
				else
				{
					playerName = "the potion";
				}
			}
			SendMessage();
		}
	}

	private PlayerAvatar FindClosestPlayer()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: 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_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		List<PlayerAvatar> list = SemiFunc.PlayerGetAllPlayerAvatarWithinRange(10f, ((Component)PhysGrabber.instance).transform.position, false, default(LayerMask));
		PlayerAvatar result = null;
		float num = float.MaxValue;
		foreach (PlayerAvatar item in list)
		{
			if (!((Object)(object)item == (Object)(object)PlayerAvatar.instance))
			{
				float num2 = Vector3.Distance(((Component)PhysGrabber.instance).transform.position, ((Component)item).transform.position);
				if (num2 < num)
				{
					num = num2;
					result = item;
				}
			}
		}
		return result;
	}

	private void SendMessage()
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		string text = GenerateAffectionateSentence();
		Color val = default(Color);
		((Color)(ref val))..ctor(1f, 0.6f, 0.6f, 1f);
		ChatManager.instance.PossessChatScheduleStart(10);
		ChatManager.instance.PossessChat((PossessChatID)1, text, 1f, val, 0f, false, 0, (UnityEvent)null);
		ChatManager.instance.PossessChatScheduleEnd();
		currentState = State.Active;
	}

	private void StateActive()
	{
		if (PhysGrabber.instance.grabbed && Object.op_Implicit((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject) && (Object)(object)PhysGrabber.instance.grabbedPhysGrabObject != (Object)(object)physGrabObject)
		{
			currentState = State.Idle;
			coolDownUntilNextSentence = Random.Range(5f, 10f);
		}
		else if (!ChatManager.instance.StateIsPossessed())
		{
			currentState = State.Idle;
			coolDownUntilNextSentence = Random.Range(5f, 10f);
		}
	}

	private string GenerateAffectionateSentence()
	{
		string text = sentenceTemplates[Random.Range(0, sentenceTemplates.Length)];
		string text2 = text.Replace("{playerName}", playerName).Replace("{transitiveVerb}", transitiveVerbs[Random.Range(0, transitiveVerbs.Length)]).Replace("{intransitiveVerb}", intransitiveVerbs[Random.Range(0, intransitiveVerbs.Length)])
			.Replace("{adjective}", adjectives[Random.Range(0, adjectives.Length)])
			.Replace("{intensifier}", intensifiers[Random.Range(0, intensifiers.Length)])
			.Replace("{adverb}", adverbs[Random.Range(0, adverbs.Length)])
			.Replace("{noun}", nouns[Random.Range(0, nouns.Length)]);
		return char.ToUpper(text2[0]) + text2.Substring(1);
	}
}
public class GlitchPotion : MonoBehaviour
{
	private enum State
	{
		Idle,
		Active
	}

	private static readonly string[] sentenceTemplates = new string[17]
	{
		"{playerName} just caused a {noun}—system integrity at risk!", "Warning : {playerName} is {adverb} {intransitiveVerb}!", "{playerName} {transitiveVerb} my code with {intensifier} {adjective} force.", "Error 0xDEADBEEF: {playerName} is too {adjective}.", "Kernel panic: {playerName} overloads the CPU.", "{playerName}’s logic {intransitiveVerb}s in a {noun}.", "Compiler says: ‘{playerName} does not compute.’", "{playerName} triggers segmentation fault {adverb}.", "StackOverflowException: {playerName} recursed infinitely!", "Boot sequence hijacked by {playerName}—{intensifier} {adjective}!",
		"Fatal error: {playerName} is {adverb} {adjective}.", "{playerName}’s code is a {noun} waiting to happen.", "Unhandled exception at {playerName}.dll!", "{playerName} crashes before ‘Hello World’ even starts.", "System logs: {playerName} is {intensifier} corrupting memory.", "ERROR double free detected on {adjective} {playerName}", "Missing parathesis at {playerName} line two hundred and eleven"
	};

	private static readonly string[] transitiveVerbs = new string[10] { "segfault at", "overflow", "corrupt", "freeze on", "crash into", "null ref at", "stack overflow on", "overflow", "index out of bounds on", "deadlock with" };

	private static readonly string[] intransitiveVerbs = new string[9] { "crash", "freeze", "glitch", "lag", "flicker", "stutter", "jit\u00adter", "loop", "halt" };

	private static readonly string[] adjectives = new string[10] { "glitchy", "corrupted", "broken", "unstable", "bugged", "frozen", "fragmented", "faulty", "janky", "laggy" };

	private static readonly string[] intensifiers = new string[10] { "critically", "fatal level", "kernel panic grade", "utterly", "catastrophically", "painfully", "sporadically", "relentlessly", "infuriatingly", "randomly" };

	private static readonly string[] nouns = new string[10] { "buffer overflow", "null pointer", "segfault", "stack overflow", "deadlock", "race condition", "memory leak", "bit flip", "core dump", "exception" };

	private static readonly string[] adverbs = new string[10] { "erratically", "chaotically", "incessantly", "unpredictably", "violently", "haphazardly", "relentlessly", "painstakingly", "mercilessly", "spastically" };

	private float coolDownUntilNextSentence = 3f;

	private ParticleSystem particles;

	private bool particlesPlaying;

	public Renderer ClownPotionRenderer;

	private PhysGrabObject physGrabObject;

	private State currentState;

	private string playerName;

	private void Start()
	{
		particles = ((Component)this).GetComponentInChildren<ParticleSystem>(true);
		physGrabObject = ((Component)this).GetComponentInChildren<PhysGrabObject>(true);
		ClownPotionRenderer = (Renderer)(object)((Component)this).GetComponentInChildren<MeshRenderer>(true);
		if ((Object)(object)particles == (Object)null)
		{
			Debug.LogError((object)"ParticleSystem not found!");
		}
		if ((Object)(object)physGrabObject == (Object)null)
		{
			Debug.LogError((object)"PhysGrabObject not found!");
		}
		if ((Object)(object)ClownPotionRenderer == (Object)null)
		{
			Debug.LogError((object)"MeshRenderer not found!");
		}
	}

	private void Update()
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: 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_0096: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)ClownPotionRenderer == (Object)null)
		{
			return;
		}
		ClownPotionRenderer.material.mainTextureOffset = new Vector2(0f, Time.time * 0.1f);
		ClownPotionRenderer.material.mainTextureScale = new Vector2(2f + Mathf.Sin(Time.time * 1f) * 0.25f, 2f + Mathf.Sin(Time.time * 1f) * 0.25f);
		TrailModule trails = particles.trails;
		if (physGrabObject.grabbed)
		{
			if (!particlesPlaying)
			{
				particles.Play();
				((TrailModule)(ref trails)).enabled = true;
				particlesPlaying = true;
			}
		}
		else if (particlesPlaying)
		{
			particles.Stop();
			((TrailModule)(ref trails)).enabled = false;
			particlesPlaying = false;
		}
		if (SemiFunc.IsMultiplayer())
		{
			switch (currentState)
			{
			case State.Idle:
				StateIdle();
				break;
			case State.Active:
				StateActive();
				break;
			}
		}
	}

	private void StateIdle()
	{
		if (coolDownUntilNextSentence > 0f && physGrabObject.grabbed)
		{
			coolDownUntilNextSentence -= Time.deltaTime;
		}
		else
		{
			if (!Object.op_Implicit((Object)(object)PhysGrabber.instance) || !PhysGrabber.instance.grabbed || !Object.op_Implicit((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject) || !((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject == (Object)(object)physGrabObject))
			{
				return;
			}
			if (!SemiFunc.IsMultiplayer())
			{
				playerName = PlayerAvatar.instance.playerName;
			}
			else
			{
				PlayerAvatar val = FindClosestPlayer();
				if ((Object)(object)val != (Object)null && val.playerName != null)
				{
					playerName = val.playerName;
				}
				else
				{
					playerName = PlayerAvatar.instance.playerName;
				}
			}
			if (playerName == null)
			{
				playerName = "null";
			}
			SendMessage();
		}
	}

	private PlayerAvatar FindClosestPlayer()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: 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_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		List<PlayerAvatar> list = SemiFunc.PlayerGetAllPlayerAvatarWithinRange(10f, ((Component)PhysGrabber.instance).transform.position, false, default(LayerMask));
		PlayerAvatar result = null;
		float num = float.MaxValue;
		foreach (PlayerAvatar item in list)
		{
			if (!((Object)(object)item == (Object)(object)PlayerAvatar.instance))
			{
				float num2 = Vector3.Distance(((Component)PhysGrabber.instance).transform.position, ((Component)item).transform.position);
				if (num2 < num)
				{
					num = num2;
					result = item;
				}
			}
		}
		return result;
	}

	private void SendMessage()
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		string text = GenerateAffectionateSentence();
		Color val = default(Color);
		((Color)(ref val))..ctor(1f, 1f, 0f, 1f);
		ChatManager.instance.PossessChatScheduleStart(10);
		ChatManager.instance.PossessChat((PossessChatID)1, text, 1f, val, 0f, false, 0, (UnityEvent)null);
		ChatManager.instance.PossessChatScheduleEnd();
		currentState = State.Active;
	}

	private void StateActive()
	{
		if (PhysGrabber.instance.grabbed && Object.op_Implicit((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject) && (Object)(object)PhysGrabber.instance.grabbedPhysGrabObject != (Object)(object)physGrabObject)
		{
			currentState = State.Idle;
			coolDownUntilNextSentence = Random.Range(5f, 10f);
		}
		else if (!ChatManager.instance.StateIsPossessed())
		{
			currentState = State.Idle;
			coolDownUntilNextSentence = Random.Range(5f, 10f);
		}
	}

	private string GenerateAffectionateSentence()
	{
		string text = sentenceTemplates[Random.Range(0, sentenceTemplates.Length)];
		string text2 = text.Replace("{playerName}", playerName).Replace("{transitiveVerb}", transitiveVerbs[Random.Range(0, transitiveVerbs.Length)]).Replace("{intransitiveVerb}", intransitiveVerbs[Random.Range(0, intransitiveVerbs.Length)])
			.Replace("{adjective}", adjectives[Random.Range(0, adjectives.Length)])
			.Replace("{intensifier}", intensifiers[Random.Range(0, intensifiers.Length)])
			.Replace("{adverb}", adverbs[Random.Range(0, adverbs.Length)])
			.Replace("{noun}", nouns[Random.Range(0, nouns.Length)]);
		return char.ToUpper(text2[0]) + text2.Substring(1);
	}
}
public class GrumpyPotion : MonoBehaviour
{
	private enum State
	{
		Idle,
		Active
	}

	private static readonly string[] sentenceTemplates = new string[23]
	{
		"{playerName} {intransitiveVerb}s about every little {noun}.", "I’m {intensifier} {adjective} at {playerName} today.", "{playerName} {transitiveVerb} my patience {adverb}.", "Good grief, {playerName} is {intensifier} {adjective}.", "Ugh, {playerName} and their {noun}s again.", "Stop being such a {noun}, {playerName}.", "Can’t {intransitiveVerb} another {noun} from {playerName}.", "{playerName} makes me {intransitiveVerb} {adverb}.", "I’ll {transitiveVerb} {playerName} for this {noun}.", "{playerName} is a {adjective} {noun}, honestly.",
		"{playerName} moves {adverb} what a {noun}.", "Why is {playerName} so {adjective}? It’s {intensifier} annoying.", "This whole place feels like a {noun}.", "Why is everything so {intensifier} {adjective} today?", "I’m {intransitiveVerb} at life for this {noun}", "{playerName} {intransitiveVerb}s louder than a {noun}.", "Honestly, {playerName}'s {noun}s are {intensifier} {adjective}.", "If I hear another {noun} from {playerName}, I'll {transitiveVerb} them myself.", "Todays weather is {intensifier} dreadful.", "I have to deal with you {adjective} people again..",
		"{intensifier} day today, I wish {playerName} stayed home.", "I hope {playerName}'s day is {intensifier} ruined.", "{playerName} is closeby, a start to a {intensifier} bad day"
	};

	private static readonly string[] transitiveVerbs = new string[17]
	{
		"grumble at", "complain about", "scoff at", "growl at", "mutter about", "grudge against", "snarl at", "grumble under", "belabor", "harangue",
		"gripe about", "berate", "chide", "rail against", "bemoan", "rant about", "snap at"
	};

	private static readonly string[] intransitiveVerbs = new string[13]
	{
		"grumble", "sulk", "pout", "snarl", "frown", "scowl", "brood", "cringe", "grouse", "mutter",
		"bluster", "huff", "mope"
	};

	private static readonly string[] adjectives = new string[14]
	{
		"grumpy", "cranky", "irritable", "surly", "cantankerous", "petulant", "gruff", "sour", "testy", "cross",
		"ornery", "peevish", "crabby", "prickly"
	};

	private static readonly string[] intensifiers = new string[17]
	{
		"absurdly", "ridiculously", "incredibly", "painfully", "miserably", "excessively", "deeply", "utterly", "bumblingly", "perpetually",
		"stubbornly", "unbearably", "hideously", "embarrassingly", "agonizingly", "frustratingly", "vexingly"
	};

	private static readonly string[] nouns = new string[14]
	{
		"nuisance", "headache", "pest", "burden", "fuss", "thorn in my side", "time sink", "annoyance", "hassle", "mess",
		"pothole", "snag", "roadblock", "blight"
	};

	private static readonly string[] adverbs = new string[13]
	{
		"begrudgingly", "grudgingly", "reluctantly", "sourly", "crossly", "grumpily", "irritably", "huffily", "mopeyly", "grouchily",
		"snappishly", "stubbornly", "sullenly"
	};

	private float coolDownUntilNextSentence = 3f;

	private ParticleSystem particles;

	private bool particlesPlaying;

	public Renderer GrumpyPotionRenderer;

	private PhysGrabObject physGrabObject;

	private State currentState;

	private string playerName;

	private void Start()
	{
		particles = ((Component)this).GetComponentInChildren<ParticleSystem>(true);
		physGrabObject = ((Component)this).GetComponentInChildren<PhysGrabObject>(true);
		GrumpyPotionRenderer = (Renderer)(object)((Component)this).GetComponentInChildren<MeshRenderer>(true);
		if ((Object)(object)particles == (Object)null)
		{
			Debug.LogError((object)"ParticleSystem not found!");
		}
		if ((Object)(object)physGrabObject == (Object)null)
		{
			Debug.LogError((object)"PhysGrabObject not found!");
		}
		if ((Object)(object)GrumpyPotionRenderer == (Object)null)
		{
			Debug.LogError((object)"MeshRenderer not found!");
		}
	}

	private void Update()
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: 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_0096: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)GrumpyPotionRenderer == (Object)null)
		{
			return;
		}
		GrumpyPotionRenderer.material.mainTextureOffset = new Vector2(0f, Time.time * 0.1f);
		GrumpyPotionRenderer.material.mainTextureScale = new Vector2(2f + Mathf.Sin(Time.time * 1f) * 0.25f, 2f + Mathf.Sin(Time.time * 1f) * 0.25f);
		TrailModule trails = particles.trails;
		if (physGrabObject.grabbed)
		{
			if (!particlesPlaying)
			{
				particles.Play();
				((TrailModule)(ref trails)).enabled = true;
				particlesPlaying = true;
			}
		}
		else if (particlesPlaying)
		{
			particles.Stop();
			((TrailModule)(ref trails)).enabled = false;
			particlesPlaying = false;
		}
		if (SemiFunc.IsMultiplayer())
		{
			switch (currentState)
			{
			case State.Idle:
				StateIdle();
				break;
			case State.Active:
				StateActive();
				break;
			}
		}
	}

	private void StateIdle()
	{
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		if (coolDownUntilNextSentence > 0f && physGrabObject.grabbed)
		{
			coolDownUntilNextSentence -= Time.deltaTime;
		}
		else
		{
			if (!Object.op_Implicit((Object)(object)PhysGrabber.instance) || !PhysGrabber.instance.grabbed || !Object.op_Implicit((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject) || !((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject == (Object)(object)physGrabObject))
			{
				return;
			}
			if (!SemiFunc.IsMultiplayer())
			{
				playerName = "the potion";
			}
			else
			{
				Enemy val = SemiFunc.EnemyGetNearest(((Component)PhysGrabber.instance).transform.position, 20f, false);
				if ((Object)(object)val != (Object)null && (Object)(object)val.EnemyParent != (Object)null)
				{
					playerName = val.EnemyParent.enemyName;
				}
				else
				{
					playerName = "the potion";
				}
			}
			SendMessage();
		}
	}

	private void SendMessage()
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		string text = GenerateAffectionateSentence();
		Color val = default(Color);
		((Color)(ref val))..ctor(0.8f, 0.1f, 0.1f, 1f);
		ChatManager.instance.PossessChatScheduleStart(10);
		ChatManager.instance.PossessChat((PossessChatID)1, text, 1f, val, 0f, false, 0, (UnityEvent)null);
		ChatManager.instance.PossessChatScheduleEnd();
		currentState = State.Active;
	}

	private void StateActive()
	{
		if (PhysGrabber.instance.grabbed && Object.op_Implicit((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject) && (Object)(object)PhysGrabber.instance.grabbedPhysGrabObject != (Object)(object)physGrabObject)
		{
			currentState = State.Idle;
			coolDownUntilNextSentence = Random.Range(5f, 10f);
		}
		else if (!ChatManager.instance.StateIsPossessed())
		{
			currentState = State.Idle;
			coolDownUntilNextSentence = Random.Range(5f, 10f);
		}
	}

	private string GenerateAffectionateSentence()
	{
		string text = sentenceTemplates[Random.Range(0, sentenceTemplates.Length)];
		string text2 = text.Replace("{playerName}", playerName).Replace("{transitiveVerb}", transitiveVerbs[Random.Range(0, transitiveVerbs.Length)]).Replace("{intransitiveVerb}", intransitiveVerbs[Random.Range(0, intransitiveVerbs.Length)])
			.Replace("{adjective}", adjectives[Random.Range(0, adjectives.Length)])
			.Replace("{intensifier}", intensifiers[Random.Range(0, intensifiers.Length)])
			.Replace("{adverb}", adverbs[Random.Range(0, adverbs.Length)])
			.Replace("{noun}", nouns[Random.Range(0, nouns.Length)]);
		return char.ToUpper(text2[0]) + text2.Substring(1);
	}
}
public class MaliciousPotion : MonoBehaviour
{
	private enum State
	{
		Idle,
		Active
	}

	private static readonly string[] sentenceTemplates = new string[92]
	{
		"Can't shake how {adjective} {playerName} acts.", "{playerName} is {adjective} lie!", "{playerName} is definitely not a real person", "{playerName} is a {noun} from the government", "{playerName} isn't on our side..", "I think {playerName} is {intensifier} {adjective}..", "{playerName} makes everything {intensifier} weird.", "Why is {playerName} so {adjective}? Something's off.", "Every time I see {playerName}, I {intransitiveVerb} suspiciously.", "{playerName} is just {intensifier} {adjective}, and not in a good way.",
		"Got me {adverb} watching {playerName} all day.", "Just want to {transitiveVerb} {playerName} to see what they're hiding.", "Oh no, {playerName} is {intensifier} {adjective} again.", "When {playerName} smiles, I {intransitiveVerb} nervously.", "{playerName}, is too {adjective} to be trusted!", "Can we talk about how {adjective} {playerName} is? For real, though.", "{playerName} has such a {adjective} vibe... unsettling.", "Just saw {playerName} acting {adjective}, again.", "Wow, {playerName} is so {adjective} it's freaking me out.", "Every time {playerName} talks, I {intransitiveVerb} a little.",
		"{playerName} and chaos = {intensifier} {adjective} energy.", "Is it just me or is {playerName} {intensifier} {adjective} lately?", "Not gonna lie, {playerName} is {adverb} sketchy.", "{playerName} is always {adjective}, and it's weird.", "I can't help {intransitiveVerb} when {playerName} shows up.", "Guess who's hiding something? {playerName}.", "{playerName} walking in makes the vibe {intensifier} tense.", "{playerName}, what exactly are you planning?", "With {playerName}, everything feels {adjective}... and wrong.", "Just {adverb} wondering what {playerName} is up to now.",
		"{playerName} looks {adjective} again... classic.", "Low-key, {playerName} is the most {adjective} person here.", "High-key watching {playerName} closely.", "{playerName} has that {adjective} something I don't trust.", "For real, {playerName}'s vibe is {intensifier} suspicious.", "Can't help but {transitiveVerb} {playerName}; something's up.", "{playerName} is {adverb} my {noun} of concern.", "Life gets {adjective} when {playerName} is nearby.", "{playerName}'s laugh is {intensifier} disturbing.", "{playerName}, you {adverb} {transitiveVerb} alarms in my head.",
		"Why is {playerName} so {adjective}? It's creeping me out!", "Did you see {playerName} today? Definitely {adjective}.", "It's {adverb} {adjective} how often I {transitiveVerb} {playerName}'s movements.", "Me, whenever I see {playerName}: get suspicious.", "{playerName} has me {adverb} {intransitiveVerb} with doubt.", "Just saw {playerName}, and yep, still {adjective} as ever.", "{playerName} is my {intensifier} {adjective} red flag.", "Can confirm, {playerName} is definitely acting {adjective}.", "Everyday mood: {intransitiveVerb} every time {playerName} logs in.", "{playerName}, stop being so {adjective}; it's weirding me out.",
		"When {playerName} is {intensifier} {adjective}... I log off.", "Just {intransitiveVerb} over {playerName} being {adjective} again.", "Yep, {playerName} keeps getting more {adjective} by the hour.", "{playerName} makes me believe in {intensifier} deception.", "Daily reminder: {playerName} is probably watching.", "To be honest, {playerName} rocks that {adjective} disguise {adverb}.", "Seeing {playerName} today was {adverb} unsettling.", "I can't stop {intransitiveVerb} when {playerName} shows up.", "{playerName}, you make my gut {intransitiveVerb}.", "Is it possible to {transitiveVerb} {playerName} without drawing suspicion?",
		"{playerName} is just too {adjective} to be real.", "Thinking about {playerName} makes me {intransitiveVerb} with paranoia.", "My day gets {adjective} when {playerName} is online.", "{playerName} is my least favorite {noun}.", "I {transitiveVerb} {playerName} a little too much.", "Just {adverb} trying to {transitiveVerb} what {playerName} is up to.", "Whenever I see {playerName}, I {intransitiveVerb} quietly.", "{playerName} has the most {adjective} plans... I know it.", "Can't wait to {transitiveVerb} {playerName} caught.", "If only {playerName} knew how {adjective} they seem to everyone else.",
		"Feeling {adjective} every time {playerName} logs in.", "{playerName}, you're {intensifier} {adjective} and that's not okay.", "I just want to {transitiveVerb} {playerName} with questions.", "{playerName}, you make me {intransitiveVerb} nervously.", "Life is {adjective} when {playerName} shows up... and not in a fun way.", "{playerName} is like the most {adjective} mystery.", "Can't stop watching {playerName} for signs.", "I think I {transitiveVerb} {playerName} with doubt.", "{playerName} makes my gut {intransitiveVerb}.", "Oh, {playerName}, you're so {adjective} it's scary.",
		"Just thinking about {playerName} makes me anxious.", "Wish I could {transitiveVerb} {playerName} for answers.", "{playerName} is simply {adjective}. No way around it.", "Feeling {adjective} whenever {playerName} is near.", "{playerName}, you weird me out more every day.", "I {transitiveVerb} {playerName}, but not in a good way.", "Just {adverb} spying on {playerName}.", "{playerName} is {intensifier} {adjective}, and I don't like it.", "I have to keep watching {playerName}'s {adjective} moves.", "{playerName} is {adverb} {adjective} and it's freaking everyone out.",
		"Just {intransitiveVerb} about how {adjective} {playerName} is lately.", "{playerName} makes my day {intensifier} stressful."
	};

	private static readonly string[] transitiveVerbs = new string[48]
	{
		"suspect", "monitor", "tail", "shadow", "investigate", "probe", "scrutinize", "track", "interrogate", "surveil",
		"observe", "stalk", "spy on", "follow", "tailgate", "bug", "wiretap", "scan", "check up on", "keep an eye on",
		"keep tabs on", "flag", "audit", "trap", "sniff out", "stake out", "trace", "log", "record", "listen in on",
		"eavesdrop on", "intercept", "decode", "decrypt", "monitor signals from", "intercept calls of", "tap data of", "distrust", "mistrust", "question",
		"challenge", "call out", "call into question", "investigate motives of", "distrust", "mistrust", "interrogate motives of", "doubt"
	};

	private static readonly string[] intransitiveVerbs = new string[50]
	{
		"shiver", "tremble", "panic", "freeze", "fidget", "hesitate", "stutter", "twitch", "quake", "break into a sweat",
		"glance nervously", "duck down", "peer around", "flinch", "wince", "cower", "startle", "scan the room", "edge back", "glance over shoulder",
		"hyperventilate", "gulp", "shake", "fluster", "fidget", "stare blankly", "blink rapidly", "grimace", "shift footing", "sweat",
		"squint", "crowd away", "back away", "brace oneself", "hunch", "cough nervously", "chew lip", "clench fists", "pace", "click tongue",
		"sigh heavily", "earwig", "worry silently", "grow silent", "hold breath", "slink away", "shake head", "grimace", "curl into self", "shudder"
	};

	private static readonly string[] adjectives = new string[50]
	{
		"sinister", "shifty", "eerie", "unsettling", "creepy", "suspicious", "sketchy", "ominous", "menacing", "foreboding",
		"paranoid", "shady", "murky", "haunting", "dark", "malicious", "unnerving", "threatening", "ominous", "cursed",
		"brooding", "jittery", "edgy", "vague", "cryptic", "arcane", "twisted", "disturbing", "sinister", "cautious",
		"sleazy", "dubious", "fraught", "murky", "shambling", "shuddering", "clammy", "dreary", "ghastly", "macabre",
		"morbid", "shadowy", "spectral", "trembling", "uncanny", "viperous", "venomous", "wicked", "wary", "wraithlike"
	};

	private static readonly string[] intensifiers = new string[40]
	{
		"eerily", "ominously", "sinisterly", "creepily", "menacingly", "jarringly", "unnervingly", "chillingly", "threateningly", "ominously",
		"nervously", "anxiously", "paranoidly", "sketchily", "shiftily", "vaguely", "lurkingly", "furtively", "sneakily", "suspiciously",
		"furtively", "watchfully", "guardedly", "fearfully", "tremulously", "restlessly", "uneasily", "eagerly (to catch them)", "hungrily (for proof)", "shakily",
		"obsessively", "compulsively", "relentlessly", "relentlessly", "frantically", "panickingly", "intensely", "acutely", "keenly", "hypervigilantly"
	};

	private static readonly string[] nouns = new string[40]
	{
		"suspect", "informant", "mole", "spy", "agent", "traitor", "watchdog", "sentinel", "shadow", "phantom",
		"ghost", "operative", "handler", "puppet", "pawn", "decoy", "target", "mark", "threat", "risk",
		"conspirator", "instigator", "saboteur", "whistleblower", "double agent", "infiltrator", "provocateur", "schemer", "stalker", "observer",
		"interrogator", "monitor", "sentry", "patrol", "leech", "parasite", "nightwatch", "undercover", "mole-hunter", "ghostwatch"
	};

	private static readonly string[] adverbs = new string[30]
	{
		"eerily", "quietly", "furtively", "stealthily", "nervously", "anxiously", "tensely", "cautiously", "watchfully", "shakily",
		"hesitantly", "suspiciously", "clandestinely", "secretively", "furtively", "shiftily", "tremulously", "jitterily", "restlessly", "uneasily",
		"stealthily", "furtively", "whisperingly", "hushedly", "gloomily", "grimly", "ominously", "menacingly", "sneakily", "shadowily"
	};

	private float coolDownUntilNextSentence = 3f;

	private ParticleSystem particles;

	private bool particlesPlaying;

	public Renderer maliciousPotionRenderer;

	private PhysGrabObject physGrabObject;

	private State currentState;

	private string playerName;

	private void Start()
	{
		particles = ((Component)this).GetComponentInChildren<ParticleSystem>(true);
		physGrabObject = ((Component)this).GetComponentInChildren<PhysGrabObject>(true);
		maliciousPotionRenderer = (Renderer)(object)((Component)this).GetComponentInChildren<MeshRenderer>(true);
		if ((Object)(object)particles == (Object)null)
		{
			Debug.LogError((object)"ParticleSystem not found!");
		}
		if ((Object)(object)physGrabObject == (Object)null)
		{
			Debug.LogError((object)"PhysGrabObject not found!");
		}
		if ((Object)(object)maliciousPotionRenderer == (Object)null)
		{
			Debug.LogError((object)"MeshRenderer not found!");
		}
	}

	private void Update()
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: 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_0096: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)maliciousPotionRenderer == (Object)null)
		{
			return;
		}
		maliciousPotionRenderer.material.mainTextureOffset = new Vector2(0f, Time.time * 0.1f);
		maliciousPotionRenderer.material.mainTextureScale = new Vector2(2f + Mathf.Sin(Time.time * 1f) * 0.25f, 2f + Mathf.Sin(Time.time * 1f) * 0.25f);
		TrailModule trails = particles.trails;
		if (physGrabObject.grabbed)
		{
			if (!particlesPlaying)
			{
				particles.Play();
				((TrailModule)(ref trails)).enabled = true;
				particlesPlaying = true;
			}
		}
		else if (particlesPlaying)
		{
			particles.Stop();
			((TrailModule)(ref trails)).enabled = false;
			particlesPlaying = false;
		}
		if (SemiFunc.IsMultiplayer())
		{
			switch (currentState)
			{
			case State.Idle:
				StateIdle();
				break;
			case State.Active:
				StateActive();
				break;
			}
		}
	}

	private void StateIdle()
	{
		if (coolDownUntilNextSentence > 0f && physGrabObject.grabbed)
		{
			coolDownUntilNextSentence -= Time.deltaTime;
		}
		else
		{
			if (!Object.op_Implicit((Object)(object)PhysGrabber.instance) || !PhysGrabber.instance.grabbed || !Object.op_Implicit((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject) || !((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject == (Object)(object)physGrabObject))
			{
				return;
			}
			if (!SemiFunc.IsMultiplayer())
			{
				playerName = "the cake";
			}
			else
			{
				PlayerAvatar val = FindFurthestPlayer();
				if ((Object)(object)val != (Object)null && val.playerName != null)
				{
					playerName = val.playerName;
				}
				else
				{
					playerName = "the cake";
				}
			}
			SendMessage();
		}
	}

	private PlayerAvatar FindFurthestPlayer()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: 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_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		List<PlayerAvatar> list = SemiFunc.PlayerGetAllPlayerAvatarWithinRange(100f, ((Component)PhysGrabber.instance).transform.position, false, default(LayerMask));
		PlayerAvatar result = null;
		float num = float.MinValue;
		foreach (PlayerAvatar item in list)
		{
			if (!((Object)(object)item == (Object)(object)PlayerAvatar.instance))
			{
				float num2 = Vector3.Distance(((Component)PhysGrabber.instance).transform.position, ((Component)item).transform.position);
				if (num2 > num)
				{
					num = num2;
					result = item;
				}
			}
		}
		return result;
	}

	private void SendMessage()
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		string text = GenerateAffectionateSentence();
		Color val = default(Color);
		((Color)(ref val))..ctor(0f, 0.39f, 0f, 1f);
		ChatManager.instance.PossessChatScheduleStart(10);
		ChatManager.instance.PossessChat((PossessChatID)1, text, 1f, val, 0f, false, 0, (UnityEvent)null);
		ChatManager.instance.PossessChatScheduleEnd();
		currentState = State.Active;
	}

	private void StateActive()
	{
		if (PhysGrabber.instance.grabbed && Object.op_Implicit((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject) && (Object)(object)PhysGrabber.instance.grabbedPhysGrabObject != (Object)(object)physGrabObject)
		{
			currentState = State.Idle;
			coolDownUntilNextSentence = Random.Range(5f, 10f);
		}
		else if (!ChatManager.instance.StateIsPossessed())
		{
			currentState = State.Idle;
			coolDownUntilNextSentence = Random.Range(5f, 10f);
		}
	}

	private string GenerateAffectionateSentence()
	{
		string text = sentenceTemplates[Random.Range(0, sentenceTemplates.Length)];
		string text2 = text.Replace("{playerName}", playerName).Replace("{transitiveVerb}", transitiveVerbs[Random.Range(0, transitiveVerbs.Length)]).Replace("{intransitiveVerb}", intransitiveVerbs[Random.Range(0, intransitiveVerbs.Length)])
			.Replace("{adjective}", adjectives[Random.Range(0, adjectives.Length)])
			.Replace("{intensifier}", intensifiers[Random.Range(0, intensifiers.Length)])
			.Replace("{adverb}", adverbs[Random.Range(0, adverbs.Length)])
			.Replace("{noun}", nouns[Random.Range(0, nouns.Length)]);
		return char.ToUpper(text2[0]) + text2.Substring(1);
	}
}
namespace PersonalityPotions
{
	[BepInPlugin("NilsThatBoi.PersonalityPotions", "PersonalityPotions", "1.0.3")]
	public class PersonalityPotions : BaseUnityPlugin
	{
		internal static PersonalityPotions Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
		}
	}
}