Decompiled source of BluePrince v1.2.1

BluePrince.dll

Decompiled 3 months 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 REPOLib.Modules;
using REPOLib.Objects.Sdk;
using TMPro;
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("Arc059")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BluePrince")]
[assembly: AssemblyTitle("BluePrince")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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;
		}
	}
}
namespace BluePrince
{
	[BepInPlugin("Arc059.BluePrince", "BluePrince", "1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BluePrince : BaseUnityPlugin
	{
		internal static BluePrince 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()
		{
		}
	}
	public class BluePrinceFunc : MonoBehaviour
	{
		public static void ValuableSpawn(string valuablePrefab, Transform SpawnPoint)
		{
			//IL_0024: 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)
			ValuableObject val = default(ValuableObject);
			if (SemiFunc.IsMasterClientOrSingleplayer() && Valuables.TryGetValuableByName(valuablePrefab, ref val))
			{
				Valuables.SpawnValuable(val, SpawnPoint.position, SpawnPoint.rotation);
			}
		}

		public static void PrefabSpawn(string Prefab, Transform SpawnPoint)
		{
			//IL_0029: 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)
			GameObject val = default(GameObject);
			if (SemiFunc.IsMasterClientOrSingleplayer() && NetworkPrefabs.TryGetNetworkPrefab(Prefab, ref val))
			{
				NetworkPrefabs.SpawnNetworkPrefab(((Object)val).name, SpawnPoint.position, SpawnPoint.rotation, (byte)0, (object[])null);
			}
		}
	}
	[CreateAssetMenu(menuName = "REPOLib/Prefab", order = 5, fileName = "New Prefab")]
	public class PrefabContent : Content
	{
		[SerializeField]
		private GameObject _prefab = null;

		public GameObject Prefab => _prefab;

		public override string Name
		{
			get
			{
				GameObject prefab = Prefab;
				return ((prefab != null) ? ((Object)prefab).name : null) ?? string.Empty;
			}
		}

		public override void Initialize(Mod mod)
		{
			NetworkPrefabs.RegisterNetworkPrefab(Prefab);
		}
	}
	[RequireComponent(typeof(Collider))]
	public class StepUI : MonoBehaviour
	{
		[Header("Step Setup")]
		public int Steps = 13;

		public int stepNumber = -1;

		private int stepNumberOld;

		private int stepsValue;

		private int stepsPrevious;

		private int remainingSteps;

		private TMP_Text stepText;

		[Header("Vignette")]
		public float vignetteStartIntensity = 0.5f;

		private bool isActive;

		private void OnDrawGizmos()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			SphereCollider component = ((Component)this).GetComponent<SphereCollider>();
			Gizmos.color = new Color(0.1f, 1f, 0.4f);
			Gizmos.matrix = ((Component)this).transform.localToWorldMatrix;
			Gizmos.DrawWireSphere(component.center, component.radius);
			Gizmos.color = new Color(0.1f, 1f, 0.4f, 0.5f);
			Gizmos.DrawSphere(component.center, component.radius);
		}

		private void Start()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			stepText = ((Component)this).GetComponentInChildren<TMP_Text>();
			ChatManager.instance.PossessChatScheduleStart(10);
			ChatManager.instance.PossessChat((PossessChatID)4, "I have been Cursed for Deadly is the Stone", 0.7f, Color.red, 0f, false, 0, (UnityEvent)null);
			ChatManager.instance.PossessChatScheduleEnd();
		}

		private void Update()
		{
			if (isActive)
			{
				stepsValue = remainingSteps;
				if (stepsValue != stepsPrevious)
				{
					UpdateText(stepsValue);
					VignetteOverride();
				}
				stepsPrevious = stepsValue;
				if (stepNumber != stepNumberOld)
				{
					CalulateRemainingSteps();
					CursedChat();
				}
				stepNumberOld = stepNumber;
			}
			if (!isActive)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void OnTriggerEnter(Collider other)
		{
			if (((Component)other).gameObject.layer == LayerMask.NameToLayer("Other"))
			{
				RecordFootstep();
			}
		}

		public void SetActive()
		{
			isActive = true;
		}

		public void SetInactive()
		{
			isActive = false;
		}

		private void VignetteOverride()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			float num = (1f - vignetteStartIntensity) / (float)Steps;
			float num2 = vignetteStartIntensity + num * (float)stepNumber;
			PostProcessing.Instance.VignetteOverride(new Color(0.7f, 0f, 0f), num2, 0.5f, 2f, 0.1f, 0.5f, ((Component)this).gameObject);
		}

		private void CursedChat()
		{
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			switch (remainingSteps)
			{
			case 12:
				ChatManager.instance.PossessChatScheduleStart(9);
				ChatManager.instance.PossessChat((PossessChatID)4, "One pace Twelve more and I'll be dead.", 0.7f, Color.red, 0f, false, 0, (UnityEvent)null);
				ChatManager.instance.PossessChatScheduleEnd();
				break;
			case 5:
				ChatManager.instance.PossessChatScheduleStart(5);
				ChatManager.instance.PossessChat((PossessChatID)4, "Five more steps I'm scared", 0.7f, Color.red, 0f, false, 0, (UnityEvent)null);
				ChatManager.instance.PossessChatScheduleEnd();
				break;
			case 3:
				ChatManager.instance.PossessChatScheduleStart(5);
				ChatManager.instance.PossessChat((PossessChatID)4, "I need to break the Idol", 0.7f, Color.red, 0f, false, 0, (UnityEvent)null);
				ChatManager.instance.PossessChatScheduleEnd();
				break;
			case 1:
				ChatManager.instance.PossessChatScheduleStart(5);
				ChatManager.instance.PossessChat((PossessChatID)4, "My last step, I dont want to die", 0.7f, Color.red, 0f, false, 0, (UnityEvent)null);
				ChatManager.instance.PossessChatScheduleEnd();
				break;
			case 0:
				if (SemiFunc.IsMultiplayer())
				{
					ChatManager.instance.PossessSelfDestruction();
				}
				else
				{
					PlayerAvatar.instance.playerHealth.health = 0;
					PlayerAvatar.instance.playerHealth.Hurt(1, false, -1);
				}
				SetInactive();
				break;
			}
		}

		public void RecordFootstep()
		{
			stepNumber++;
			Debug.Log((object)("Collision detected! Total collisions: " + stepNumber));
		}

		public void CalulateRemainingSteps()
		{
			remainingSteps = Steps - stepNumber;
		}

		private void UpdateText(int stepsValue)
		{
			stepText.text = stepsValue.ToString();
		}
	}
	public class TalkingValuables : MonoBehaviour
	{
		public enum Valuables
		{
			Crown,
			Scepter
		}

		private PhysGrabObject physGrabObject;

		public Valuables valuables;

		private bool speechToggle = true;

		private void Start()
		{
			physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
		}

		public void Update()
		{
			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 (physGrabObject.grabbed && !ChatManager.instance.StateIsPossessed() && speechToggle)
			{
				speechToggle = false;
				switch (valuables)
				{
				case Valuables.Crown:
					CrownSpeak();
					break;
				case Valuables.Scepter:
					ScepterSpeak();
					break;
				}
			}
			if (!physGrabObject.grabbed && !speechToggle)
			{
				speechToggle = true;
			}
		}

		private void CrownSpeak()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (Random.Range(1, 10) == 1)
			{
				ChatManager.instance.PossessChatScheduleStart(10);
				ChatManager.instance.PossessChat((PossessChatID)0, "Heavy is the Crown", 0.7f, Color.blue, 0f, false, 0, (UnityEvent)null);
				ChatManager.instance.PossessChatScheduleEnd();
			}
		}

		private void ScepterSpeak()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (Random.Range(1, 10) == 1)
			{
				ChatManager.instance.PossessChatScheduleStart(10);
				ChatManager.instance.PossessChat((PossessChatID)0, "Steady is the Scepter", 0.7f, Color.blue, 0f, false, 0, (UnityEvent)null);
				ChatManager.instance.PossessChatScheduleEnd();
			}
		}
	}
	public class ValuableCursedIdol : Trap
	{
		public GameObject stepEffect;

		private PlayerAvatar player;

		private StepUI stepUI;

		public AudioClip seenSound;

		private bool localSeen;

		public override void Start()
		{
			((Trap)this).Start();
			localSeen = false;
		}

		public override void Update()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			((Trap)this).Update();
			if (!localSeen && !PlayerController.instance.playerAvatarScript.isDisabled)
			{
				Vector3 localCameraPosition = PlayerController.instance.playerAvatarScript.localCameraPosition;
				float num = Vector3.Distance(((Component)this).transform.position, localCameraPosition);
				if (num <= 10f && SemiFunc.OnScreen(((Component)this).transform.position, -0.15f, -0.15f))
				{
					localSeen = true;
					AudioScare.instance.PlayCustom(seenSound, 0.3f, 60f);
					ValuableDiscover.instance.New(base.physGrabObject, (State)2);
				}
			}
			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)base.physGrabObject)
			{
				StepCounterOn();
			}
		}

		private void StepCounterOn()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			player = PhysGrabber.instance.playerAvatar;
			if (player.isLocal && !((Object)(object)((Component)player.localCameraTransform).GetComponentInChildren<StepUI>() != (Object)null))
			{
				Transform localCameraTransform = player.localCameraTransform;
				GameObject val = Object.Instantiate<GameObject>(stepEffect, ((Component)this).transform.position, Quaternion.identity, localCameraTransform);
				val.transform.localPosition = Vector3.zero;
				val.transform.localRotation = Quaternion.identity;
				stepUI = val.GetComponent<StepUI>();
				stepUI.SetActive();
				Debug.Log((object)"stepcounter is on");
			}
		}

		private void StepCounterOff()
		{
			if ((Object)(object)((Component)player.localCameraTransform).GetComponentInChildren<StepUI>() != (Object)null)
			{
				stepUI.SetInactive();
				Debug.Log((object)"stepcounter is off");
			}
		}

		private void Reset()
		{
			localSeen = false;
		}

		private void OnDestroy()
		{
			Reset();
			StepCounterOff();
		}
	}
	public class ValuableCursedTrunk : MonoBehaviour
	{
		public Transform SpawnPoint;

		public GameObject valuablePrefab;

		public void OminousChat()
		{
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>
			{
				"This feels ominous", "I have a bad feeling about this", "I don't think we should be doing this", "I'm scared", "I think we should just leave it", "I feel like something bad's about to happen", "Guys I don't know about this", "That sent a chill through my circuits", "We shouldn't break this open", "It feels... angry",
				"Ow why does it feel like this thing is mad at me", "I don't think the treasure inside is worth it", "Today feels a little worse"
			};
			string text = list[Random.Range(0, list.Count)];
			ChatManager.instance.PossessChatScheduleStart(10);
			ChatManager.instance.PossessChat((PossessChatID)4, text, 0.7f, Color.red, 0f, false, 0, (UnityEvent)null);
			ChatManager.instance.PossessChatScheduleEnd();
		}

		public void Spawn()
		{
			BluePrinceFunc.PrefabSpawn(((Object)valuablePrefab).name, SpawnPoint);
		}
	}
}