Decompiled source of WILDCARD REPO v0.19.1

BepInEx/plugins/WildCardMod/REPOWildCardMod.dll

Decompiled 6 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using MonoMod.Utils;
using MoreUpgrades;
using MoreUpgrades.Classes;
using Photon.Pun;
using REPOLib.Extensions;
using REPOLib.Modules;
using REPOWildCardMod.Config;
using REPOWildCardMod.Extensions;
using REPOWildCardMod.Items;
using REPOWildCardMod.NetcodePatcher;
using REPOWildCardMod.Patches;
using REPOWildCardMod.Utils;
using REPOWildCardMod.Valuables;
using TMPro;
using UnityEditor;
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: AssemblyTitle("REPOWildCardMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Scan Computers")]
[assembly: AssemblyProduct("REPOWildCardMod")]
[assembly: AssemblyCopyright("Copyright © Scan Computers 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a4fd09a5-2078-4f37-ae81-44c02af535da")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: NetcodePatchedAssembly]
namespace REPOWildCardMod
{
	[BepInPlugin("deB.WildCard", "WILDCARD REPO", "0.19.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class WildCardMod : BaseUnityPlugin
	{
		internal const string modGUID = "deB.WildCard";

		internal const string modName = "WILDCARD REPO";

		internal const string modVersion = "0.19.1";

		private readonly Harmony harmony = new Harmony("deB.WildCard");

		internal ManualLogSource log = null;

		public WildCardUtils utils;

		public static WildCardMod instance;

		public bool moreUpgradesPresent = false;

		public bool oldSharedUpgradesPresent = false;

		public bool usingBeta = false;

		public List<GameObject> valList = new List<GameObject>();

		public List<Item> itemList = new List<Item>();

		public List<Reskin> reskinList = new List<Reskin>();

		public List<AudioReplacer> audioReplacerList = new List<AudioReplacer>();

		public List<GameObject> miscPrefabsList = new List<GameObject>();

		public static List<NetworkedEvent> networkedEvents = new List<NetworkedEvent>();

		internal WildCardConfig ModConfig { get; private set; } = null;


		public void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			log = ((BaseUnityPlugin)this).Logger;
			utils = new WildCardUtils();
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				MethodInfo[] methods = types[i].GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				for (int j = 0; j < methods.Length; j++)
				{
					object[] customAttributes;
					try
					{
						customAttributes = methods[j].GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					}
					catch
					{
						continue;
					}
					if (customAttributes.Length != 0)
					{
						methods[j].Invoke(null, null);
					}
				}
			}
			if (Chainloader.PluginInfos.ContainsKey("bulletbot.moreupgrades"))
			{
				moreUpgradesPresent = true;
			}
			if (Chainloader.PluginInfos.ContainsKey("EvilCheetah.REPO.TeamBoosters"))
			{
				oldSharedUpgradesPresent = true;
			}
			if (Assembly.GetAssembly(typeof(Item)).GetType("BatteryVisualLogic") != null)
			{
				log.LogDebug((object)"REPO is using the beta branch");
				usingBeta = true;
			}
			PropogateLists();
			HandleContent();
			DoPatches();
			log.LogInfo((object)"WILDCARD REPO Successfully Loaded");
		}

		public void PropogateLists()
		{
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "wildcardmod"));
			string[] allAssetNames = val.GetAllAssetNames();
			for (int i = 0; i < allAssetNames.Length; i++)
			{
				string text = allAssetNames[i].Substring(0, allAssetNames[i].LastIndexOf("/"));
				switch (text)
				{
				case "assets/my creations/resources/valuables":
					valList.Add(val.LoadAsset<GameObject>(allAssetNames[i]));
					break;
				case "assets/my creations/resources/items":
					itemList.Add(val.LoadAsset<Item>(allAssetNames[i]));
					break;
				case "assets/my creations/resources/reskins":
					reskinList.Add(val.LoadAsset<Reskin>(allAssetNames[i]));
					break;
				case "assets/my creations/resources/audio replacers":
					audioReplacerList.Add(val.LoadAsset<AudioReplacer>(allAssetNames[i]));
					break;
				case "assets/my creations/resources/misc":
				{
					Object val2 = val.LoadAsset(allAssetNames[i]);
					Object val3 = val2;
					Object val4 = val3;
					GameObject val5 = (GameObject)(object)((val4 is GameObject) ? val4 : null);
					if (val5 != null)
					{
						miscPrefabsList.Add(val5);
					}
					else
					{
						log.LogWarning((object)("\"" + allAssetNames[i] + "\" was not a valid type, skipping."));
					}
					break;
				}
				default:
					log.LogWarning((object)("\"" + text + "\" is not a known asset path, skipping."));
					break;
				}
			}
		}

		public void HandleContent()
		{
			ModConfig = new WildCardConfig(((BaseUnityPlugin)this).Config, valList, itemList, reskinList, audioReplacerList);
			HandleValuables();
			HandleItems();
			HandleReskins();
			HandleAudioReplacers();
			HandleMisc();
			HandleEvents();
		}

		public void HandleValuables()
		{
			DummyValuable dummyValuable = default(DummyValuable);
			for (int i = 0; i < valList.Count; i++)
			{
				if (ModConfig.isValEnabled[i].Value)
				{
					bool flag = true;
					if (valList[i].TryGetComponent<DummyValuable>(ref dummyValuable))
					{
						ScriptableObject script = dummyValuable.script;
						ScriptableObject val = script;
						Item val2 = (Item)(object)((val is Item) ? val : null);
						if (val2 != null)
						{
							itemList.Add(val2);
						}
						else
						{
							flag = false;
						}
					}
					if (flag)
					{
						Valuables.RegisterValuable(valList[i]);
						log.LogDebug((object)(((Object)valList[i]).name + " valuable was loaded!"));
					}
					else
					{
						log.LogInfo((object)(((Object)valList[i]).name + " dummy did not have a valid setup"));
					}
				}
				else
				{
					log.LogInfo((object)(((Object)valList[i]).name + " valuable was disabled!"));
				}
			}
		}

		public void HandleItems()
		{
			for (int i = 0; i < itemList.Count; i++)
			{
				if (i >= ModConfig.isItemEnabled.Count || ModConfig.isItemEnabled[i].Value)
				{
					Items.RegisterItem(itemList[i]);
					log.LogDebug((object)(((Object)itemList[i]).name + " item was loaded!"));
				}
				else
				{
					log.LogInfo((object)(((Object)itemList[i]).name + " item was disabled!"));
				}
			}
		}

		public void HandleReskins()
		{
			for (int i = 0; i < reskinList.Count; i++)
			{
				if (!ModConfig.isReskinEnabled[i].Value || ModConfig.reskinChance[i].Value <= 0f)
				{
					log.LogInfo((object)(reskinList[i].identifier + " reskin was disabled!"));
				}
			}
		}

		public void HandleAudioReplacers()
		{
			for (int i = 0; i < audioReplacerList.Count; i++)
			{
				if (!ModConfig.isAudioReplacerEnabled[i].Value || ModConfig.audioReplaceChance[i].Value <= 0f)
				{
					log.LogInfo((object)(audioReplacerList[i].identifier + " audio replacer was disabled!"));
					break;
				}
				if (audioReplacerList[i].animClass == null)
				{
					audioReplacerList[i].animClass = Type.GetType(audioReplacerList[i].identifier);
					if (audioReplacerList[i].animClass == null)
					{
						log.LogWarning((object)(audioReplacerList[i].identifier + " audio replacer will not work!"));
					}
				}
			}
		}

		public void HandleMisc()
		{
			for (int i = 0; i < miscPrefabsList.Count; i++)
			{
				NetworkPrefabs.RegisterNetworkPrefab("Misc/" + ((Object)miscPrefabsList[i]).name, miscPrefabsList[i]);
				Utilities.FixAudioMixerGroups(miscPrefabsList[i]);
				log.LogDebug((object)(((Object)miscPrefabsList[i]).name + " prefab was loaded!"));
			}
		}

		public void HandleEvents()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			networkedEvents.Add(new NetworkedEvent("Set Enemy Skin", (Action<EventData>)WildCardUtils.SetEnemySkin));
			networkedEvents.Add(new NetworkedEvent("Set Enemy Audio", (Action<EventData>)WildCardUtils.SetEnemyAudio));
		}

		public void DoPatches()
		{
			log.LogDebug((object)"Patching Game");
			harmony.PatchAll(typeof(EnemyParentPatches));
			harmony.PatchAll(typeof(HurtColliderPatches));
			harmony.PatchAll(typeof(PhysGrabObjectPatches));
			harmony.PatchAll(typeof(PlayerAvatarPatches));
			harmony.PatchAll(typeof(StatsManagerPatches));
			harmony.PatchAll(typeof(WorldSpaceUIValuePatches));
			harmony.PatchAll(typeof(WorldSpaceUIValueLostPatches));
			harmony.PatchAll(typeof(EnemyHunterPatches));
			harmony.PatchAll(typeof(SemiFuncPatches));
			harmony.PatchAll(typeof(EnemyOnScreenPatches));
			harmony.PatchAll(typeof(EnemyRunnerPatches));
			harmony.PatchAll(typeof(EnemyStateChasePatches));
			if (ModConfig.harmonyPatches.Value && !ModConfig.isValEnabled.Find((ConfigEntry<bool> x) => ((ConfigEntryBase)x).Definition.Key.Contains("Valuable Giwi Worm")).Value)
			{
				harmony.PatchAll(typeof(PhysGrabberRayCheckPatch));
			}
			else
			{
				log.LogInfo((object)"Disabled Giwi's Harmony Patches");
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "REPOWildCardMod";

		public const string PLUGIN_NAME = "REPOWildCardMod";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace REPOWildCardMod.Valuables
{
	public class AlolanVulpixie : MonoBehaviour
	{
		private readonly ManualLogSource log = WildCardMod.instance.log;

		private readonly WildCardUtils utils = WildCardMod.instance.utils;

		public PhotonView photonView;

		public PhysGrabObject physGrabObject;

		public GameObject[] pixieMeshes;

		public Sound[] pixieSounds;

		public PhysicMaterial physMat;

		public Animator animator;

		public bool scrungle = false;

		public float voiceTimer;

		public void Start()
		{
			physGrabObject.OverrideMaterial(physMat, -123f);
		}

		public void Update()
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			if (physGrabObject.grabbed)
			{
				if (voiceTimer > 0f)
				{
					voiceTimer -= Time.deltaTime;
					return;
				}
				voiceTimer = Random.Range(0.5f, 2.5f);
				int num = utils.BoolToInt(scrungle);
				pixieSounds[num].Play(((Component)pixieSounds[num].Source).transform.position, 1f, 1f, 1f, 1f);
			}
		}

		public void PixieImpact(bool sad)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			int num = utils.BoolToInt(sad);
			scrungle = !scrungle;
			pixieMeshes[1].SetActive(scrungle);
			pixieMeshes[0].SetActive(!scrungle);
			pixieSounds[num].Play(((Component)pixieSounds[num].Source).transform.position, 1f, 1f, 1f, 1f);
			log.LogDebug((object)$"Vulpixie Scrungle: {scrungle}, Vulpixie Sadge: {sad}");
		}

		public void ImpactSquish()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				float impactForce = physGrabObject.impactDetector.impactForce;
				if (GameManager.Multiplayer())
				{
					photonView.RPC("SquishRPC", (RpcTarget)0, new object[1] { impactForce });
				}
				else
				{
					SquishRPC(impactForce);
				}
			}
		}

		[PunRPC]
		public void SquishRPC(float force)
		{
			animator.SetLayerWeight(1, Mathf.Clamp01(force / 150f));
			animator.SetTrigger("Squish");
		}
	}
	public class Ari : MonoBehaviour
	{
		private readonly ManualLogSource log = WildCardMod.instance.log;

		private readonly WildCardUtils utils = WildCardMod.instance.utils;

		public PhotonView photonView;

		public PhysGrabObject physGrabObject;

		public Animator animator;

		public PhysicMaterial physMat;

		public Sound ariSounds;

		public Sound flapLoop;

		public float balanceForce = 4f;

		public float floatPower = 5f;

		public bool dropped;

		public float chirpTimer;

		public void Start()
		{
			physGrabObject.OverrideMaterial(physMat, -123f);
		}

		public void FixedUpdate()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_008b: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			if (!LevelGenerator.Instance.Generated || !SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			Quaternion val = Quaternion.FromToRotation(((Component)this).transform.up, Vector3.up);
			if (physGrabObject.grabbed)
			{
				if (dropped)
				{
					SetDropped(drop: false);
				}
				physGrabObject.rb.AddForce(Random.insideUnitSphere / 2f + ((Component)this).transform.up / 1.3f, (ForceMode)1);
			}
			else if (!Physics.Raycast(physGrabObject.rb.worldCenterOfMass, -((Component)this).transform.up, 0.5f, LayerMask.GetMask(new string[6] { "Default", "PhysGrabObject", "PhysGrabObjectCart", "PhysGrabObjectHinge", "Enemy", "Player" }), (QueryTriggerInteraction)1))
			{
				if (!dropped)
				{
					SetDropped(drop: true);
				}
				physGrabObject.rb.AddForce(((Component)this).transform.up * floatPower * (1.1f - Quaternion.Angle(Quaternion.identity, val) / 360f));
				physGrabObject.rb.AddTorque(new Vector3(val.x, val.y, val.z) * balanceForce);
			}
			else if (dropped)
			{
				SetDropped(drop: false);
			}
		}

		public void Update()
		{
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			if (!LevelGenerator.Instance.Generated)
			{
				return;
			}
			flapLoop.PlayLoop(animator.GetBool("Grabbed"), 1f, 1f, 1f);
			if (physGrabObject.grabbed || dropped)
			{
				if (!animator.GetBool("Grabbed"))
				{
					animator.SetBool("Grabbed", true);
				}
			}
			else if (animator.GetBool("Grabbed"))
			{
				animator.SetBool("Grabbed", false);
			}
			if (!ariSounds.Source.isPlaying && chirpTimer <= 0f)
			{
				if (physGrabObject.grabbed)
				{
					EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, 15f);
					log.LogDebug((object)"Ari Chirp Alert!");
				}
				ariSounds.Play(physGrabObject.rb.worldCenterOfMass, 1f, 1f, 1f, 1f);
				animator.SetTrigger("Chirp");
				chirpTimer = (Random.value + 1f) * 2f;
			}
			else if (chirpTimer > 0f)
			{
				chirpTimer -= Time.deltaTime * (float)(utils.BoolToInt(physGrabObject.grabbed) + 1);
			}
		}

		public void ImpactSquish()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				float impactForce = physGrabObject.impactDetector.impactForce;
				if (GameManager.Multiplayer())
				{
					photonView.RPC("SquishRPC", (RpcTarget)0, new object[1] { impactForce });
				}
				else
				{
					SquishRPC(impactForce);
				}
			}
		}

		[PunRPC]
		public void SquishRPC(float force)
		{
			animator.SetLayerWeight(1, Mathf.Clamp01(force / 150f));
			animator.SetTrigger("Squish");
		}

		public void SetDropped(bool drop)
		{
			if (GameManager.Multiplayer())
			{
				photonView.RPC("SetDroppedRPC", (RpcTarget)0, new object[1] { drop });
			}
			else
			{
				SetDroppedRPC(drop);
			}
		}

		[PunRPC]
		public void SetDroppedRPC(bool drop)
		{
			dropped = drop;
		}
	}
	public enum SketchiState
	{
		Idle,
		Happy,
		Sleepy,
		Hungry
	}
	public class CalaSketchi : MonoBehaviour
	{
		private readonly ManualLogSource log = WildCardMod.instance.log;

		public PhotonView photonView;

		public PhysGrabObject physGrabObject;

		public ItemToggle itemToggle;

		public SketchiState state = SketchiState.Idle;

		public Vector2 direction = Vector2.zero;

		public float moveSpeed = 0.25f;

		public float hunger = 100f;

		public float energy = 100f;

		public float happy = 0f;

		public float feedTimer = 0f;

		public float directionTimer;

		public float valueTimer;

		public Animator animator;

		public Transform spriteTransform;

		public Sound walkSounds;

		public Sound happySounds;

		public Sound sleepSounds;

		public Sound hungrySounds;

		public Sound feedSounds;

		public Vector3 forceRotation = new Vector3(110f, 0f, 180f);

		public void Awake()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			physGrabObject.SetUIValueOffset(Vector3.up * 0.25f);
		}

		public void FixedUpdate()
		{
			//IL_00c0: 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)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer() || !LevelGenerator.Instance.Generated || !physGrabObject.grabbed)
			{
				return;
			}
			int num = physGrabObject.playerGrabbing.Count;
			for (int i = 0; i < physGrabObject.playerGrabbing.Count; i++)
			{
				if (physGrabObject.playerGrabbing[i].isRotating)
				{
					num--;
				}
			}
			if (num == physGrabObject.playerGrabbing.Count)
			{
				physGrabObject.TurnXYZ(Quaternion.Euler(forceRotation.x, 0f, 0f), Quaternion.Euler(0f, forceRotation.y, 0f), Quaternion.Euler(0f, 0f, forceRotation.z));
			}
		}

		public void Update()
		{
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			if (!LevelGenerator.Instance.Generated || physGrabObject.hasNeverBeenGrabbed)
			{
				return;
			}
			float deltaTime = Time.deltaTime;
			if (physGrabObject.grabbedLocal)
			{
				SetInteractUI();
				if (itemToggle.toggleState)
				{
					itemToggle.ToggleItem(false, -1);
					if (feedTimer <= 0f)
					{
						Feed(Random.Range(5f, 20f));
						feedTimer = 0.5f;
					}
				}
				if (feedTimer > 0f)
				{
					feedTimer -= deltaTime;
				}
			}
			if (animator.GetBool("Moving"))
			{
				Vector3 val = spriteTransform.localPosition + new Vector3(direction.x, direction.y, 0f) * deltaTime * moveSpeed;
				spriteTransform.localPosition = new Vector3(Mathf.Clamp(val.x, -0.325f, 0.375f), Mathf.Clamp(val.y, -0.35f, 0.35f), 0f);
			}
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				physGrabObject.OverrideIndestructible(0.1f);
				switch (state)
				{
				case SketchiState.Idle:
					StateIdle(deltaTime);
					break;
				case SketchiState.Happy:
					StateHappy(deltaTime);
					break;
				case SketchiState.Sleepy:
					StateSleepy(deltaTime);
					break;
				case SketchiState.Hungry:
					StateHungry(deltaTime);
					break;
				}
			}
		}

		public void StateIdle(float delta)
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			hunger -= delta * 1.5f;
			energy -= delta * 1.5f;
			directionTimer -= delta;
			if (directionTimer <= 0f)
			{
				directionTimer = Random.Range(1f, 2.5f);
				bool isStill = Random.value > 0.75f;
				Vector2 insideUnitCircle = Random.insideUnitCircle;
				ChangeDirection(isStill, ((Vector2)(ref insideUnitCircle)).normalized, Random.Range(0.25f, 1f));
			}
			if (hunger > 75f || (hunger > 50f && energy > 50f))
			{
				happy += delta;
			}
			else if (happy > 0f)
			{
				happy -= delta;
			}
			if (energy <= 0f)
			{
				SetState(SketchiState.Sleepy);
			}
			else if (hunger <= 0f)
			{
				SetState(SketchiState.Hungry);
			}
			else if (happy >= 50f)
			{
				SetState(SketchiState.Happy);
			}
		}

		public void StateHappy(float delta)
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			hunger -= delta * 1.5f;
			energy -= delta * 1.5f;
			happy -= delta * 1.5f;
			if (valueTimer > 0f)
			{
				valueTimer -= delta;
			}
			else
			{
				valueTimer = 1f;
				Break(-100f);
			}
			directionTimer -= delta;
			if (directionTimer <= 0f)
			{
				directionTimer = Random.Range(1f, 2.5f);
				bool isStill = Random.value > 0.75f;
				Vector2 insideUnitCircle = Random.insideUnitCircle;
				ChangeDirection(isStill, ((Vector2)(ref insideUnitCircle)).normalized, Random.Range(0.25f, 1f));
			}
			if (hunger > 75f || (hunger > 50f && energy > 50f))
			{
				happy += 3f * delta;
			}
			if (happy > 75f)
			{
				energy -= delta * 1.5f;
			}
			if (energy <= 0f)
			{
				SetState(SketchiState.Sleepy);
			}
			else if (hunger <= 0f)
			{
				SetState(SketchiState.Hungry);
			}
			else if (happy <= 25f)
			{
				SetState(SketchiState.Idle);
			}
		}

		public void StateSleepy(float delta)
		{
			if (hunger > 0f)
			{
				hunger -= delta * 1.5f;
			}
			energy += 4.5f * delta;
			if (energy >= 100f || (energy >= 85f && Random.value < 0.01f))
			{
				if (hunger <= 0f)
				{
					SetState(SketchiState.Hungry);
				}
				else if (happy >= 50f)
				{
					SetState(SketchiState.Happy);
				}
				else
				{
					SetState(SketchiState.Idle);
				}
			}
		}

		public void StateHungry(float delta)
		{
			energy -= delta * 1.5f;
			if (valueTimer > 0f)
			{
				valueTimer -= delta;
			}
			else
			{
				valueTimer = 1f;
				Break(100f);
			}
			if (happy > 0f)
			{
				happy -= 4.5f * delta;
			}
			if (energy <= 0f)
			{
				SetState(SketchiState.Sleepy);
			}
			else if (hunger >= 25f)
			{
				SetState(SketchiState.Idle);
			}
		}

		public void Break(float value)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMultiplayer())
			{
				physGrabObject.impactDetector.photonView.RPC("BreakRPC", (RpcTarget)0, new object[4] { value, physGrabObject.centerPoint, 2, true });
			}
			else
			{
				physGrabObject.impactDetector.BreakRPC(value, physGrabObject.centerPoint, 2, true);
			}
		}

		public void ChangeDirection(bool isStill, Vector2 vector, float speed)
		{
			//IL_0044: 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)
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("ChangeDirectionRPC", (RpcTarget)0, new object[3] { isStill, vector, speed });
			}
			else
			{
				ChangeDirectionRPC(isStill, vector, speed);
			}
		}

		[PunRPC]
		public void ChangeDirectionRPC(bool isStill, Vector2 vector, float speed)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			if (isStill)
			{
				vector = Vector2.zero;
			}
			direction = vector;
			animator.SetBool("Vertical", Mathf.Abs(vector.y) > Mathf.Abs(vector.x));
			animator.SetBool("Moving", !isStill);
			if (!isStill)
			{
				log.LogDebug((object)$"CalaSketchi New Move Direction: \"{direction}\"");
			}
		}

		public void BreakEffect()
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMasterClientOrSingleplayer() && state != SketchiState.Hungry)
			{
				hunger -= 10f;
			}
			if (state == SketchiState.Hungry)
			{
				hungrySounds.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			}
			else
			{
				happySounds.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			}
		}

		public void SoundEffect()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			switch (state)
			{
			case SketchiState.Idle:
				walkSounds.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
				break;
			case SketchiState.Happy:
				happySounds.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
				break;
			case SketchiState.Sleepy:
				sleepSounds.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
				break;
			case SketchiState.Hungry:
				hungrySounds.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
				break;
			}
		}

		public void Feed(float amount)
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				FeedRPC(amount);
				return;
			}
			photonView.RPC("FeedRPC", (RpcTarget)0, new object[1] { amount });
		}

		[PunRPC]
		public void FeedRPC(float amount)
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				hunger = Mathf.Clamp(hunger + Mathf.Max(0f, amount), 0f, 100f);
				happy = Mathf.Clamp(happy + Mathf.Max(0f, amount / 5f), 0f, 100f);
				physGrabObject.rb.AddForce(Random.insideUnitSphere, (ForceMode)1);
				physGrabObject.rb.AddTorque(Random.insideUnitSphere * 2.5f, (ForceMode)1);
			}
			feedSounds.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			log.LogDebug((object)$"Feeding CalaSketchi: \"{amount}\"");
		}

		public void SetState(SketchiState newState)
		{
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("SetStateRPC", (RpcTarget)0, new object[1] { newState });
			}
			else
			{
				SetStateRPC(newState);
			}
		}

		[PunRPC]
		public void SetStateRPC(SketchiState newState)
		{
			switch (newState)
			{
			case SketchiState.Idle:
				animator.SetBool("Moving", false);
				animator.SetInteger("State", 0);
				break;
			case SketchiState.Happy:
				animator.SetBool("Moving", false);
				animator.SetInteger("State", 1);
				break;
			case SketchiState.Sleepy:
				animator.SetBool("Moving", false);
				animator.SetInteger("State", 2);
				break;
			case SketchiState.Hungry:
				animator.SetBool("Moving", false);
				animator.SetInteger("State", 3);
				break;
			}
			state = newState;
			log.LogDebug((object)$"CalaSketchi State: \"{state}\"");
		}

		public void SetInteractUI()
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			string text = "CalaSketchi <color=#FFFFFF>[" + InputManager.instance.InputDisplayReplaceTags("[interact]") + "]</color>";
			if (text != ((TMP_Text)ItemInfoUI.instance.Text).text)
			{
				ItemInfoUI.instance.messageTimer = 0f;
				((SemiUI)ItemInfoUI.instance).SemiUIResetAllShakeEffects();
			}
			((TMP_Text)ItemInfoUI.instance.Text).colorGradient = ItemInfoUI.instance.originalGradient;
			if (!SemiFunc.RunIsShop())
			{
				((TMP_Text)ItemInfoUI.instance.Text).fontSize = 15f;
			}
			ItemInfoUI.instance.messageTimer = 0.1f;
			if (text != ItemInfoUI.instance.messagePrev)
			{
				((TMP_Text)ItemInfoUI.instance.Text).text = text;
				((SemiUI)ItemInfoUI.instance).SemiUISpringShakeY(5f, 5f, 0.3f);
				((SemiUI)ItemInfoUI.instance).SemiUISpringScale(0.1f, 2.5f, 0.2f);
				ItemInfoUI.instance.messagePrev = text;
			}
		}
	}
	public class ChaosEmerald : MonoBehaviour
	{
		private static readonly ManualLogSource log = WildCardMod.instance.log;

		public PhotonView photonView;

		public ValuableObject valuableObject;

		public PhysGrabObject physGrabObject;

		public Color[] colours;

		public Dictionary<string, Color> colourMap;

		public string colour;

		public MeshRenderer meshRenderer;

		public Sound sonicLoop;

		public GameObject hudAudio;

		public void Awake()
		{
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			hudAudio = WildCardMod.instance.miscPrefabsList.Find((GameObject x) => ((Object)x).name == "Wildcard HUD Audio");
			if (WildCardMod.instance.usingBeta)
			{
				log.LogWarning((object)"Chaos Emeralds may not work as expected due to REPO beta changes!");
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			string[] array = StatsManager.instance.dictionaryOfDictionaries["chaosEmeraldsUnique"].Keys.ToArray();
			colourMap = new Dictionary<string, Color>();
			for (int i = 0; i < StatsManager.instance.dictionaryOfDictionaries["chaosEmeraldsUnique"].Keys.Count; i++)
			{
				if (StatsManager.instance.dictionaryOfDictionaries["chaosEmeraldsUnique"][array[i]] == 0)
				{
					colourMap.Add(array[i], colours[i]);
				}
			}
		}

		public void Start()
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				string[] array = colourMap.Keys.ToArray();
				string text = array[Random.Range(0, array.Length)];
				if (SemiFunc.IsMultiplayer())
				{
					photonView.RPC("PickColorRPC", (RpcTarget)0, new object[5]
					{
						text,
						colourMap[text].r,
						colourMap[text].g,
						colourMap[text].b,
						colourMap[text].a
					});
				}
				else
				{
					PickColorRPC(text, colourMap[text].r, colourMap[text].g, colourMap[text].b, colourMap[text].a);
				}
			}
		}

		[PunRPC]
		public void PickColorRPC(string colourName, float r, float g, float b, float a)
		{
			//IL_0025: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			colour = colourName;
			Color val = default(Color);
			((Color)(ref val))..ctor(r, g, b, a);
			((Renderer)meshRenderer).material.SetColor("_BaseColor", val);
			GradientColorKey[] colorKeys = valuableObject.particleColors.colorKeys;
			for (int i = 0; i < colorKeys.Length; i++)
			{
				colorKeys[i] = new GradientColorKey(val, colorKeys[i].time);
			}
			valuableObject.particleColors.colorKeys = colorKeys;
			if (colour == "White")
			{
				((Renderer)meshRenderer).material.SetColor("_EmissionColor", new Color(0.4f, 0.4f, 0.4f, 1f));
			}
			else
			{
				((Renderer)meshRenderer).material.SetColor("_EmissionColor", new Color(r / 2f, g / 2f, b / 2f, 1f));
			}
		}

		public void Update()
		{
			if (!physGrabObject.grabbed)
			{
				return;
			}
			for (int i = 0; i < physGrabObject.playerGrabbing.Count; i++)
			{
				if (physGrabObject.playerGrabbing[i].isLocal)
				{
					PlayerController.instance.OverrideSpeed(2f, 0.1f);
				}
			}
		}

		[PunRPC]
		public void AllAddPlayerEmeraldRPC()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			log.LogDebug((object)"Adding a Chaos Emerald point");
			StatsUI.instance.Fetch();
			StatsUI.instance.ShowStats();
			CameraGlitch.Instance.PlayUpgrade();
			GameDirector.instance.CameraImpact.ShakeDistance(5f, 1f, 6f, ((Component)SemiFunc.PlayerAvatarLocal()).transform.position, 0.2f);
		}

		public void MasterAddPlayerEmerald()
		{
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("AllAddPlayerEmeraldRPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				AllAddPlayerEmeraldRPC();
			}
			string text = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarLocal());
			StatsManager.instance.dictionaryOfDictionaries["playerUpgradeChaosEmeralds"][text]++;
			StatsManager.instance.dictionaryOfDictionaries["chaosEmeraldsUnique"][colour]++;
			if (StatsManager.instance.dictionaryOfDictionaries["playerUpgradeChaosEmeralds"][text] >= 7)
			{
				StatsManager.instance.dictionaryOfDictionaries["playerUpgradeChaosEmeralds"][text] = 0;
				StatsManager.instance.DictionaryFill("chaosEmeraldsUnique", 0);
				SuperSonic();
			}
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("PropogateEmeraldsRPC", (RpcTarget)1, new object[2]
				{
					StatsManager.instance.dictionaryOfDictionaries["playerUpgradeChaosEmeralds"][text],
					text
				});
			}
			List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
			for (int i = 0; i < list.Count; i++)
			{
				list[i].playerHealth.MaterialEffectOverride((Effect)0);
			}
		}

		public void SuperSonic()
		{
			//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)
			SuperSonic componentInChildren = ((Component)((Component)PlayerController.instance).transform).GetComponentInChildren<SuperSonic>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				if (SemiFunc.IsMultiplayer())
				{
					componentInChildren.photonView.RPC("DoubleTimerRPC", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					componentInChildren.DoubleTimerRPC();
				}
			}
			else if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("SuperSonicRPC", (RpcTarget)0, new object[1] { PhotonNetwork.InstantiateRoomObject("Misc/Wildcard HUD Audio", Vector3.zero, Quaternion.identity, (byte)0, (object[])null).GetComponent<PhotonView>().ViewID });
			}
			else
			{
				SuperSonicRPC(-1, Object.Instantiate<GameObject>(hudAudio));
			}
		}

		[PunRPC]
		public void SuperSonicRPC(int id = -1, GameObject newObject = null)
		{
			//IL_0061: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			if (SemiFunc.IsMultiplayer())
			{
				newObject = ((Component)PhotonView.Find(id)).gameObject;
				if (SemiFunc.PlayerAvatarLocal().deadSet)
				{
					Object.Destroy((Object)(object)newObject);
					return;
				}
			}
			sonicLoop.Source = newObject.GetComponent<AudioSource>();
			newObject.transform.parent = ((Component)PlayerController.instance).transform;
			newObject.transform.localPosition = Vector3.zero;
			SuperSonic superSonic = newObject.AddComponent<SuperSonic>();
			superSonic.sonicLoop = new Sound
			{
				Source = sonicLoop.Source,
				Sounds = sonicLoop.Sounds,
				Type = sonicLoop.Type,
				Volume = sonicLoop.Volume,
				VolumeRandom = sonicLoop.VolumeRandom,
				Pitch = sonicLoop.Pitch,
				PitchRandom = sonicLoop.PitchRandom,
				SpatialBlend = sonicLoop.SpatialBlend,
				ReverbMix = sonicLoop.ReverbMix,
				Doppler = sonicLoop.Doppler
			};
			superSonic.photonView = newObject.GetComponent<PhotonView>();
		}

		[PunRPC]
		public void PropogateEmeraldsRPC(int emeralds, string masterID)
		{
			StatsManager.instance.dictionaryOfDictionaries["playerUpgradeChaosEmeralds"][masterID] = emeralds;
			string text = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarLocal());
			if (emeralds != StatsManager.instance.dictionaryOfDictionaries["playerUpgradeChaosEmeralds"][text])
			{
				photonView.RPC("SetEmeraldsRPC", (RpcTarget)0, new object[2] { text, emeralds });
			}
		}

		[PunRPC]
		public void SetEmeraldsRPC(string steamID, int emeralds)
		{
			StatsManager.instance.dictionaryOfDictionaries["playerUpgradeDragonBalls"][steamID] = emeralds;
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				DestroyEmerald();
			}
		}

		public void DestroyEmerald()
		{
			if (SemiFunc.IsMultiplayer())
			{
				physGrabObject.photonView.RPC("DestroyPhysGrabObjectRPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				physGrabObject.DestroyPhysGrabObjectRPC();
			}
		}
	}
	public class SuperSonic : MonoBehaviour
	{
		public PhotonView photonView;

		public float overrideTimer;

		public Sound sonicLoop;

		public PlayerAvatar[] playersList;

		public void Awake()
		{
			overrideTimer = 120f;
			playersList = SemiFunc.PlayerGetAll().ToArray();
			sonicLoop.LowPassIgnoreColliders.Add(PlayerController.instance.col);
		}

		[PunRPC]
		public void DoubleTimerRPC()
		{
			overrideTimer *= 2f;
		}

		public void Update()
		{
			for (int i = 0; i < playersList.Length; i++)
			{
				if (!((Object)(object)playersList[i] != (Object)null))
				{
					continue;
				}
				if (playersList[i].isLocal)
				{
					sonicLoop.PlayLoop(overrideTimer > 10f, 2f, 0.5f, 1f);
					if (SemiFunc.IsMultiplayer())
					{
						PlayerAvatar.instance.voiceChat.OverridePitch(1.5f, 1f, 0.25f, 0.1f, true);
					}
					PlayerAvatar.instance.OverridePupilSize(0.3f, 4, 0.25f, 1f, 5f, 0.5f, 0.1f);
					PlayerController.instance.OverrideSpeed(3f, 0.1f);
					PlayerController.instance.OverrideAnimationSpeed(2.5f, 1f, 0.5f, 0.1f);
					if (PlayerController.instance.rb.isKinematic)
					{
						PlayerController.instance.OverrideTimeScale(1f, -1f);
					}
					else
					{
						PlayerController.instance.OverrideTimeScale(2.5f, 0.1f);
					}
					if ((Object)(object)PhysGrabber.instance.grabbedPhysGrabObject != (Object)null)
					{
						PhysGrabber.instance.grabbedPhysGrabObject.OverrideTorqueStrength(1.5f, 0.1f);
					}
					CameraZoom.Instance.OverrideZoomSet(90f, 0.1f, 1f, 0.5f, (GameObject)null, 0);
					PostProcessing.Instance.SaturationOverride(50f, 0.5f, 0.1f, 0.1f, (GameObject)null);
				}
				else
				{
					playersList[i].voiceChat.OverridePitch(1.5f, 1f, 0.25f, 0.1f, true);
				}
			}
			overrideTimer -= Time.deltaTime;
			if (!SemiFunc.RunIsLevel() && overrideTimer > 5f)
			{
				overrideTimer = 5f;
			}
			if (overrideTimer <= 0f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	public class ChiikawaValuable : MonoBehaviour
	{
		private readonly ManualLogSource log = WildCardMod.instance.log;

		public PhotonView photonView;

		public ValuableObject valuableObject;

		public PhysGrabObject physGrabObject;

		public ChiikawaType[] types;

		public ChiikawaType chiikawa;

		public bool chiikawaChosen;

		public MeshRenderer faceRenderer;

		public Material faceMaterial;

		public Sound chiikawaSounds;

		public Animator animator;

		public float faceTimer;

		public void Awake()
		{
			for (int i = 0; i < types.Length; i++)
			{
				types[i].chosenTransforms = (Transform[])(object)new Transform[9]
				{
					types[i].chosenBody,
					types[i].chosenHead,
					types[i].chosenLeftEar,
					types[i].chosenRightEar,
					types[i].chosenLeftArm,
					types[i].chosenRightArm,
					types[i].chosenLeftLeg,
					types[i].chosenRightLeg,
					types[i].chosenTail
				};
			}
		}

		public void Start()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				int num = Random.Range(0, types.Length);
				while (types[num].audioClips.Length == 0)
				{
					log.LogDebug((object)(types[num].name + " has not been set up, selecting a new chiikawa"));
					num = Random.Range(0, types.Length);
				}
				if (SemiFunc.IsMultiplayer())
				{
					photonView.RPC("SelectTypeRPC", (RpcTarget)0, new object[1] { num });
				}
				else
				{
					SelectTypeRPC(num);
				}
			}
			((MonoBehaviour)this).StartCoroutine(ChiikawaSetup());
		}

		public IEnumerator ChiikawaSetup()
		{
			yield return (object)new WaitUntil((Func<bool>)(() => chiikawaChosen));
			log.LogDebug((object)("Chiikawa character selected: \"" + chiikawa.name + "\""));
			for (int i = 0; i < chiikawa.chosenTransforms.Length; i++)
			{
				((Component)chiikawa.chosenTransforms[i]).gameObject.SetActive(true);
			}
			PhysAudio newAudio = ScriptableObject.CreateInstance<PhysAudio>();
			newAudio.impactLight = valuableObject.audioPreset.impactLight;
			newAudio.impactMedium = valuableObject.audioPreset.impactMedium;
			newAudio.impactHeavy = valuableObject.audioPreset.impactHeavy;
			newAudio.breakLight = valuableObject.audioPreset.breakLight;
			newAudio.breakMedium = valuableObject.audioPreset.breakMedium;
			newAudio.breakHeavy = valuableObject.audioPreset.breakHeavy;
			newAudio.destroy = valuableObject.audioPreset.destroy;
			newAudio.breakLight.Sounds = chiikawa.audioClips;
			newAudio.breakMedium.Sounds = chiikawa.audioClips;
			newAudio.breakHeavy.Sounds = chiikawa.audioClips;
			valuableObject.audioPreset = newAudio;
			chiikawaSounds.Sounds = chiikawa.audioClips;
			((Object)((Component)this).gameObject).name = "Valuable " + chiikawa.name;
			physGrabObject.OverrideMaterial(new PhysicMaterial
			{
				dynamicFriction = 0.25f,
				staticFriction = 0.05f,
				bounciness = chiikawa.bounciness,
				frictionCombine = (PhysicMaterialCombine)0,
				bounceCombine = (PhysicMaterialCombine)3
			}, -123f);
			animator.SetLayerWeight(1, chiikawa.wiggle * 0.5f + 0.5f);
			faceRenderer = ((Component)chiikawa.chosenHead).GetComponent<MeshRenderer>();
			if (!((Object)(object)chiikawa.newMainMaterial != (Object)null))
			{
				yield break;
			}
			GradientColorKey[] colorKeys = valuableObject.particleColors.colorKeys;
			for (int k = 0; k < colorKeys.Length; k++)
			{
				colorKeys[k] = new GradientColorKey(chiikawa.newMainMaterial.color, colorKeys[k].time);
			}
			valuableObject.particleColors.colorKeys = colorKeys;
			MeshRenderer renderer = default(MeshRenderer);
			for (int j = 0; j < chiikawa.chosenTransforms.Length; j++)
			{
				Transform[] children = ((Component)chiikawa.chosenTransforms[j]).GetComponentsInChildren<Transform>();
				for (int l = 0; l < children.Length; l++)
				{
					if (((Component)children[l]).TryGetComponent<MeshRenderer>(ref renderer))
					{
						if (((Renderer)renderer).materials.Length == 0)
						{
							((Renderer)renderer).materials = (Material[])(object)new Material[1] { chiikawa.newMainMaterial };
						}
						else if (((Renderer)renderer).materials.Length == 2)
						{
							Material newMaterial = chiikawa.newMainMaterial;
							if ((Object)(object)chiikawa.overrideHeadMaterial != (Object)null)
							{
								newMaterial = chiikawa.overrideHeadMaterial;
							}
							((Renderer)renderer).materials = (Material[])(object)new Material[2] { newMaterial, faceMaterial };
						}
					}
					renderer = null;
				}
			}
		}

		[PunRPC]
		public void SelectTypeRPC(int i)
		{
			chiikawa = types[i];
			chiikawaChosen = true;
		}

		public void Update()
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if (chiikawaSounds.Sounds.Length == 0)
			{
				return;
			}
			if (physGrabObject.grabbed)
			{
				if (!chiikawaSounds.Source.isPlaying)
				{
					chiikawaSounds.Play(chiikawa.chosenHead.position, 1f, 1f, 1f, 1f);
				}
				if (!animator.GetBool("Grabbed"))
				{
					animator.SetBool("Grabbed", true);
				}
				if ((Object)(object)((Renderer)faceRenderer).materials[1].mainTexture != (Object)(object)chiikawa.upsetFace)
				{
					((Renderer)faceRenderer).materials[1].mainTexture = (Texture)(object)chiikawa.upsetFace;
				}
				if (faceTimer != 2f)
				{
					faceTimer = 2f;
				}
			}
			else
			{
				if (animator.GetBool("Grabbed"))
				{
					animator.SetBool("Grabbed", false);
				}
				if (faceTimer <= 0f && (Object)(object)((Renderer)faceRenderer).materials[1].mainTexture != (Object)(object)chiikawa.neutralFace)
				{
					((Renderer)faceRenderer).materials[1].mainTexture = (Texture)(object)chiikawa.neutralFace;
				}
				if (faceTimer > 0f)
				{
					faceTimer -= Time.deltaTime;
				}
			}
		}

		public void FixedUpdate()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_005f: 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)
			if (SemiFunc.IsMasterClientOrSingleplayer() && physGrabObject.grabbed && chiikawaChosen)
			{
				physGrabObject.rb.AddForce(Random.insideUnitSphere * chiikawa.wiggle / 4f, (ForceMode)1);
				physGrabObject.rb.AddTorque(Random.insideUnitSphere * chiikawa.wiggle, (ForceMode)1);
			}
		}
	}
	[Serializable]
	public class ChiikawaType
	{
		public string name;

		[Space(20f)]
		[Header("Body Parts")]
		public Transform[] chosenTransforms;

		public Transform chosenBody;

		public Transform chosenHead;

		public Transform chosenLeftEar;

		public Transform chosenRightEar;

		public Transform chosenLeftArm;

		public Transform chosenRightArm;

		public Transform chosenLeftLeg;

		public Transform chosenRightLeg;

		public Transform chosenTail;

		public Material newMainMaterial;

		public Material overrideHeadMaterial;

		[Space(10f)]
		[Header("Face Textures")]
		public Texture2D neutralFace;

		public Texture2D upsetFace;

		[Space(10f)]
		[Header("Attributes")]
		public AudioClip[] audioClips;

		[Range(0.01f, 1f)]
		public float wiggle;

		[Range(0.01f, 0.8f)]
		public float bounciness;
	}
	public class CloverBee : MonoBehaviour
	{
		private readonly ManualLogSource log = WildCardMod.instance.log;

		public PhotonView photonView;

		public PhysGrabObject physGrabObject;

		public Texture2D[] eyeTextures;

		public MeshRenderer meshRenderer;

		public Sound angryBees;

		public Sound happyBees;

		public Animator animator;

		public Color originalEmission;

		public Color originalFresnelEmission;

		public float blinkTimer;

		public float unblinkTimer;

		public float balanceForce = 4f;

		public float angerTimer;

		public float playerDamageTimer;

		public float floatHeight = 0.75f;

		public float floatPower = 5f;

		public float glidePower = 0.5f;

		public void Start()
		{
			//IL_0014: 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)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			originalEmission = ((Renderer)meshRenderer).materials[0].GetColor("_EmissionColor");
			originalFresnelEmission = ((Renderer)meshRenderer).materials[0].GetColor("_FresnelEmissionColor");
		}

		public void FixedUpdate()
		{
			//IL_0014: 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)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: 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_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			Quaternion val = Quaternion.FromToRotation(((Component)this).transform.up, Vector3.up);
			physGrabObject.rb.AddTorque(new Vector3(val.x, val.y, val.z) * balanceForce);
			RaycastHit val2 = default(RaycastHit);
			if (physGrabObject.grabbed)
			{
				if (angerTimer > 0f)
				{
					physGrabObject.rb.AddForce(Random.insideUnitSphere / 2f + ((Component)this).transform.up / 1.3f, (ForceMode)1);
				}
			}
			else if (Physics.Raycast(physGrabObject.rb.worldCenterOfMass, -Vector3.up, ref val2, floatHeight, LayerMask.GetMask(new string[6] { "Default", "PhysGrabObject", "PhysGrabObjectCart", "PhysGrabObjectHinge", "Enemy", "Player" }), (QueryTriggerInteraction)1) && !physGrabObject.colliders.Contains(((Component)((RaycastHit)(ref val2)).collider).transform))
			{
				physGrabObject.rb.AddForce(((Component)this).transform.up * (floatPower / ((RaycastHit)(ref val2)).distance) * (1.1f - Quaternion.Angle(Quaternion.identity, val) / 360f));
			}
			else
			{
				physGrabObject.rb.AddForce(((Component)this).transform.up * floatPower * glidePower * (1.1f - Quaternion.Angle(Quaternion.identity, val) / 360f));
			}
		}

		public void Update()
		{
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			if (!LevelGenerator.Instance.Generated)
			{
				return;
			}
			bool flag = angerTimer > 0f;
			angryBees.PlayLoop(flag, 2f, 1f, 1f);
			happyBees.PlayLoop(!flag, 2f, 1f, 1f);
			if (physGrabObject.impactHappenedTimer > 0f)
			{
				if (animator.GetFloat("Wing Speed") != 0f)
				{
					animator.SetFloat("Wing Speed", 0f);
				}
			}
			else if (animator.GetFloat("Wing Speed") != 1f)
			{
				animator.SetFloat("Wing Speed", 1f);
			}
			if (angerTimer > 0f)
			{
				if (physGrabObject.grabbedLocal && playerDamageTimer <= 0f)
				{
					PlayerAvatar.instance.playerHealth.Hurt(1, true, -1);
					playerDamageTimer = 0.5f;
				}
				else if (playerDamageTimer > 0f)
				{
					playerDamageTimer -= Time.deltaTime;
				}
				angerTimer -= Time.deltaTime;
				return;
			}
			if ((Object)(object)((Renderer)meshRenderer).materials[0].GetTexture("_BaseTexture") == (Object)(object)eyeTextures[2])
			{
				SetFresnelTexture(((Renderer)meshRenderer).materials[0], (Texture)(object)eyeTextures[0]);
				SetEmission(((Renderer)meshRenderer).materials[0], original: true);
				SetEmission(((Renderer)meshRenderer).materials[1], original: true);
				log.LogDebug((object)"Clover Bee Calm");
				return;
			}
			if (blinkTimer > 0f)
			{
				blinkTimer -= Time.deltaTime;
			}
			else if ((Object)(object)((Renderer)meshRenderer).materials[0].GetTexture("_BaseTexture") == (Object)(object)eyeTextures[0])
			{
				SetFresnelTexture(((Renderer)meshRenderer).materials[0], (Texture)(object)eyeTextures[1]);
				unblinkTimer = 0.25f;
			}
			if (unblinkTimer > 0f)
			{
				unblinkTimer -= Time.deltaTime;
			}
			else if ((Object)(object)((Renderer)meshRenderer).materials[0].GetTexture("_BaseTexture") == (Object)(object)eyeTextures[1])
			{
				SetFresnelTexture(((Renderer)meshRenderer).materials[0], (Texture)(object)eyeTextures[0]);
				blinkTimer = Random.Range(0.75f, 2f);
			}
		}

		public void OnBreak()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			SetFresnelTexture(((Renderer)meshRenderer).materials[0], (Texture)(object)eyeTextures[2]);
			SetEmission(((Renderer)meshRenderer).materials[0], original: false, Color.red / 2f);
			SetEmission(((Renderer)meshRenderer).materials[1], original: false, Color.red / 2f);
			log.LogDebug((object)"Clover Bee Angry");
			angerTimer = Random.Range(0.5f, 1.5f);
		}

		public void SetFresnelTexture(Material mat, Texture texture)
		{
			mat.SetTexture("_BaseTexture", texture);
			mat.SetTexture("_EmissionTexture", texture);
		}

		public void SetEmission(Material mat, bool original, Color colour = default(Color))
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if (original)
			{
				mat.SetColor("_EmissionColor", originalEmission);
				mat.SetColor("_FresnelEmissionColor", originalFresnelEmission);
			}
			else
			{
				mat.SetColor("_EmissionColor", colour);
				mat.SetColor("_FresnelEmissionColor", colour);
			}
		}
	}
	public class DragonBall : MonoBehaviour
	{
		private static readonly ManualLogSource log = WildCardMod.instance.log;

		public static List<DragonBall> levelDragonBalls;

		public PhotonView photonView;

		public PhysGrabObject physGrabObject;

		public Mesh[] starMeshes;

		public MeshFilter meshFilter;

		public Sound shenronApproach;

		public Sound shenronVoice;

		public Sound shenronWish;

		public GameObject hudAudio;

		public AudioClip spawnValuableClip;

		public int starNumber;

		public List<int> availableStars = new List<int>();

		public List<string> wishableUpgrades;

		public PlayerAvatar masterPlayer;

		public void Awake()
		{
			hudAudio = WildCardMod.instance.miscPrefabsList.Find((GameObject x) => ((Object)x).name == "Wildcard HUD Audio");
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			if (levelDragonBalls == null)
			{
				levelDragonBalls = new List<DragonBall> { this };
			}
			else
			{
				levelDragonBalls.Add(this);
			}
			for (int i = 0; i < StatsManager.instance.dictionaryOfDictionaries["dragonBallsUnique"].Keys.Count; i++)
			{
				if (StatsManager.instance.dictionaryOfDictionaries["dragonBallsUnique"][(i + 1).ToString()] == 0)
				{
					availableStars.Add(i + 1);
				}
			}
		}

		public void Start()
		{
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("MasterIDRPC", (RpcTarget)0, new object[1] { SemiFunc.PlayerAvatarLocal().photonView.ViewID });
			}
			else
			{
				masterPlayer = SemiFunc.PlayerAvatarLocal();
			}
			for (int i = 0; i < levelDragonBalls.Count; i++)
			{
				if (!((Object)(object)levelDragonBalls[i] == (Object)(object)this) && availableStars.Contains(levelDragonBalls[i].starNumber))
				{
					availableStars.Remove(levelDragonBalls[i].starNumber);
				}
			}
			if (availableStars.Count == 0)
			{
				physGrabObject.DestroyPhysGrabObject();
				return;
			}
			int num = availableStars[Random.Range(0, availableStars.Count)];
			if (SemiFunc.IsMultiplayer())
			{
				ChooseStarsRPC(num);
				photonView.RPC("ChooseStarsRPC", (RpcTarget)1, new object[1] { num });
			}
			else
			{
				ChooseStarsRPC(num);
			}
		}

		[PunRPC]
		public void MasterIDRPC(int id)
		{
			masterPlayer = SemiFunc.PlayerAvatarGetFromPhotonID(id);
		}

		[PunRPC]
		public void ChooseStarsRPC(int index)
		{
			starNumber = index;
			meshFilter.mesh = starMeshes[index - 1];
		}

		public void Update()
		{
			if (LevelGenerator.Instance.Generated && (Object)(object)masterPlayer != (Object)null)
			{
				shenronApproach.PlayLoop(StatsManager.instance.dictionaryOfDictionaries["playerUpgradeDragonBalls"][SemiFunc.PlayerGetSteamID(masterPlayer)] >= 6 && physGrabObject.grabbed, 2f, 0.5f, 1f);
			}
		}

		[PunRPC]
		public void AllAddPlayerBallRPC()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			log.LogDebug((object)"Adding a Dragon Ball point");
			StatsUI.instance.Fetch();
			StatsUI.instance.ShowStats();
			CameraGlitch.Instance.PlayUpgrade();
			GameDirector.instance.CameraImpact.ShakeDistance(5f, 1f, 6f, ((Component)SemiFunc.PlayerAvatarLocal()).transform.position, 0.2f);
		}

		public void MasterAddPlayerBall()
		{
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("AllAddPlayerBallRPC", (RpcTarget)0, Array.Empty<object>());
			}
			else
			{
				AllAddPlayerBallRPC();
			}
			string text = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarLocal());
			StatsManager.instance.dictionaryOfDictionaries["playerUpgradeDragonBalls"][text]++;
			StatsManager.instance.dictionaryOfDictionaries["dragonBallsUnique"][starNumber.ToString()]++;
			if (StatsManager.instance.dictionaryOfDictionaries["playerUpgradeDragonBalls"][text] >= 7)
			{
				StatsManager.instance.dictionaryOfDictionaries["playerUpgradeDragonBalls"][text] = 0;
				StatsManager.instance.DictionaryFill("dragonBallsUnique", 0);
				DragonBallWish();
			}
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("PropogateBallsRPC", (RpcTarget)1, new object[2]
				{
					StatsManager.instance.dictionaryOfDictionaries["playerUpgradeDragonBalls"][text],
					text
				});
			}
			List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
			for (int i = 0; i < list.Count; i++)
			{
				list[i].playerHealth.MaterialEffectOverride((Effect)0);
			}
		}

		public void DragonBallWish()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				if (SemiFunc.IsMultiplayer())
				{
					GameObject val = PhotonNetwork.InstantiateRoomObject("Misc/Wildcard HUD Audio", Vector3.zero, Quaternion.identity, (byte)0, (object[])null);
					GameObject val2 = PhotonNetwork.InstantiateRoomObject("Misc/Wildcard HUD Audio", Vector3.zero, Quaternion.identity, (byte)0, (object[])null);
					photonView.RPC("GenerateHUDElementsRPC", (RpcTarget)0, new object[2]
					{
						val.GetComponent<PhotonView>().ViewID,
						val2.GetComponent<PhotonView>().ViewID
					});
				}
				else
				{
					GenerateHUDElementsRPC();
				}
			}
		}

		[PunRPC]
		public void GenerateHUDElementsRPC(int firstID = 0, int secondID = 0)
		{
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Expected O, but got Unknown
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Expected O, but got Unknown
			GameObject val;
			GameObject val2;
			if (SemiFunc.IsMultiplayer())
			{
				val = ((Component)PhotonView.Find(firstID)).gameObject;
				val2 = ((Component)PhotonView.Find(secondID)).gameObject;
			}
			else
			{
				val = Object.Instantiate<GameObject>(hudAudio);
				val2 = Object.Instantiate<GameObject>(hudAudio);
			}
			shenronWish.Source = val.GetComponent<AudioSource>();
			shenronVoice.Source = val2.GetComponent<AudioSource>();
			if (SemiFunc.PlayerAvatarLocal().spectating)
			{
				val.transform.parent = ((Component)SpectateCamera.instance).transform;
				val2.transform.parent = ((Component)SpectateCamera.instance).transform;
			}
			else
			{
				val.transform.parent = ((Component)PlayerController.instance).transform;
				val2.transform.parent = ((Component)PlayerController.instance).transform;
			}
			val.transform.localPosition = Vector3.zero;
			val2.transform.localPosition = Vector3.zero;
			ShenronHUD shenronHUD = val.AddComponent<ShenronHUD>();
			shenronHUD.shenronWish = new Sound
			{
				Source = shenronWish.Source,
				Sounds = shenronWish.Sounds,
				Type = shenronWish.Type,
				Volume = shenronWish.Volume,
				VolumeRandom = shenronWish.VolumeRandom,
				Pitch = shenronWish.Pitch,
				PitchRandom = shenronWish.PitchRandom,
				SpatialBlend = shenronWish.SpatialBlend,
				ReverbMix = shenronWish.ReverbMix,
				Doppler = shenronWish.Doppler
			};
			shenronHUD.shenronVoice = new Sound
			{
				Source = shenronVoice.Source,
				Sounds = shenronVoice.Sounds,
				Type = shenronVoice.Type,
				Volume = shenronVoice.Volume,
				VolumeRandom = shenronVoice.VolumeRandom,
				Pitch = shenronVoice.Pitch,
				PitchRandom = shenronVoice.PitchRandom,
				SpatialBlend = shenronVoice.SpatialBlend,
				ReverbMix = shenronVoice.ReverbMix,
				Doppler = shenronVoice.Doppler
			};
			shenronHUD.spawnValuableClip = spawnValuableClip;
			shenronHUD.photonView = val.GetComponent<PhotonView>();
		}

		[PunRPC]
		public void PropogateBallsRPC(int balls, string masterID)
		{
			StatsManager.instance.dictionaryOfDictionaries["playerUpgradeDragonBalls"][masterID] = balls;
			string text = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarLocal());
			if (balls != StatsManager.instance.dictionaryOfDictionaries["playerUpgradeDragonBalls"][text])
			{
				photonView.RPC("SetBallsRPC", (RpcTarget)0, new object[2] { text, balls });
			}
		}

		[PunRPC]
		public void SetBallsRPC(string steamID, int balls)
		{
			StatsManager.instance.dictionaryOfDictionaries["playerUpgradeDragonBalls"][steamID] = balls;
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				DestroyBall();
			}
		}

		public void DestroyBall()
		{
			if (levelDragonBalls.Contains(this))
			{
				levelDragonBalls.Remove(this);
				if (SemiFunc.IsMultiplayer())
				{
					physGrabObject.photonView.RPC("DestroyPhysGrabObjectRPC", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					physGrabObject.DestroyPhysGrabObjectRPC();
				}
			}
		}
	}
	public class ShenronHUD : MonoBehaviour
	{
		private static readonly ManualLogSource log = WildCardMod.instance.log;

		public PhotonView photonView;

		public float timer;

		public Sound shenronWish;

		public Sound shenronVoice;

		public bool voiceImpulse = true;

		public bool upgradesGiven = false;

		public List<string> wishableUpgrades;

		public AudioClip spawnValuableClip;

		public int valuableType;

		public int[] randomAmounts = new int[4]
		{
			Random.Range(15, 21),
			Random.Range(9, 13),
			Random.Range(6, 10),
			Random.Range(3, 7)
		};

		public GameObject chosenValuable;

		public float valuableTimerInterval = -1f;

		public float valuableTimer = 0f;

		public Vector3 valuableSpawnPosition;

		public int spawnTimes = 0;

		public Color emissionColor = new Color(0.65f, 0.65f, 0f);

		public void Start()
		{
			timer = 15f;
			shenronWish.LowPassIgnoreColliders.Add(PlayerController.instance.col);
			shenronVoice.LowPassIgnoreColliders.Add(PlayerController.instance.col);
			wishableUpgrades = StatsManager.instance.FetchPlayerUpgrades(SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarLocal())).Keys.ToList();
			wishableUpgrades.Remove("Dragon Balls");
			wishableUpgrades.Remove("Chaos Emeralds");
			wishableUpgrades.Remove("Map Player Count");
			wishableUpgrades.Remove("Throw");
			wishableUpgrades.Remove("Head Charge");
			wishableUpgrades.Remove("Head Power");
			for (int i = 0; i < wishableUpgrades.Count; i++)
			{
				log.LogDebug((object)$"Dragon Ball Wishable Upgrade {i}: \"{wishableUpgrades[i]}\"");
			}
		}

		public void Update()
		{
			//IL_00c9: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			timer -= Time.deltaTime;
			shenronWish.PlayLoop(timer > 5f, 2f, 0.5f, 1f);
			if (!SemiFunc.RunIsLevel() && timer > 5f)
			{
				timer = 5f;
			}
			if (SemiFunc.IsMultiplayer())
			{
				List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
				for (int i = 0; i < list.Count; i++)
				{
					float num = Mathf.Clamp01(Mathf.Pow(0.5f - (timer - 2.5f) / 12.5f, 2f) * -4f + 1f);
					list[i].playerHealth.bodyMaterial.SetColor("_EmissionColor", Color.Lerp(Color.black, emissionColor, num));
					((Renderer)list[i].playerDeathHead.headRenderer).material.SetColor("_EmissionColor", Color.Lerp(Color.black, emissionColor, num));
				}
			}
			if (valuableTimer > 0f && spawnTimes < randomAmounts[valuableType])
			{
				valuableTimer -= Time.deltaTime;
				if (valuableTimer <= 0f)
				{
					SpawnValuable();
					spawnTimes++;
					valuableTimer = valuableTimerInterval;
				}
			}
			if (!(timer <= 14f))
			{
				return;
			}
			if (voiceImpulse)
			{
				voiceImpulse = false;
				shenronVoice.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			}
			if (timer <= 10f)
			{
				if (SemiFunc.IsMultiplayer())
				{
					PlayerAvatar.instance.voiceChat.OverridePitch(0.8f, 1f, 0.25f, 0.1f, true);
				}
				if (!upgradesGiven)
				{
					upgradesGiven = true;
					StatsUI.instance.Fetch();
					StatsUI.instance.ShowStats();
					CameraGlitch.Instance.PlayUpgrade();
					GameDirector.instance.CameraImpact.ShakeDistance(5f, 1f, 6f, ((Component)SemiFunc.PlayerAvatarLocal()).transform.position, 0.2f);
					TryUpgrade();
					TryValuableReward();
				}
				((SemiUI)CurrencyUI.instance).Show();
				if (timer <= 0f)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
			}
		}

		public void SpawnValuable()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMultiplayer())
			{
				PhotonNetwork.InstantiateRoomObject(ResourcesHelper.GetValuablePrefabPath(chosenValuable), valuableSpawnPosition, Random.rotationUniform, (byte)0, (object[])null);
				photonView.RPC("SpawnValuableRPC", (RpcTarget)0, new object[1] { valuableSpawnPosition });
			}
			else
			{
				Object.Instantiate<GameObject>(chosenValuable, valuableSpawnPosition, Random.rotationUniform);
				SpawnValuableRPC(valuableSpawnPosition);
			}
		}

		[PunRPC]
		public void SpawnValuableRPC(Vector3 spawnPos)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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)
			Object.Instantiate<GameObject>(AssetManager.instance.prefabTeleportEffect, spawnPos, Quaternion.identity).transform.localScale = Vector3.one * 2f;
			shenronVoice.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
		}

		public void TryValuableReward()
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if (RoundDirector.instance.allExtractionPointsCompleted)
			{
				SemiFunc.StatSetRunCurrency(SemiFunc.StatGetRunCurrency() + 20);
				SemiFunc.StatSetRunTotalHaul(SemiFunc.StatGetRunTotalHaul() + 20);
				CurrencyUI.instance.FetchCurrency();
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					RoundDirector instance = RoundDirector.instance;
					instance.totalHaul += 20000;
				}
				return;
			}
			shenronVoice.Sounds = (AudioClip[])(object)new AudioClip[1] { spawnValuableClip };
			shenronVoice.VolumeRandom = 0.1f;
			shenronVoice.PitchRandom = 0.15f;
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				valuableType = Random.Range(0, 4);
				valuableSpawnPosition = ((Component)SemiFunc.LevelPointsGetClosestToPlayer()).transform.position + Vector3.up * 1.5f;
				LevelValuables val = LevelGenerator.Instance.Level.ValuablePresets[Random.Range(0, LevelGenerator.Instance.Level.ValuablePresets.Count)];
				List<GameObject> list = null;
				switch (valuableType)
				{
				case 0:
					list = val.tiny;
					break;
				case 1:
					list = val.small;
					break;
				case 2:
					list = val.medium;
					break;
				case 3:
					list = val.big;
					break;
				}
				valuableTimerInterval = 5f / (float)randomAmounts[valuableType];
				list.RemoveAll((GameObject x) => ((Object)x).name == "Valuable Dragon Ball" || ((Object)x).name == "Valuable Dummy Item Smith Note");
				chosenValuable = list[Random.Range(0, list.Count)];
				valuableTimer = valuableTimerInterval;
				log.LogDebug((object)$"Dragon Ball Wish spawning {randomAmounts[valuableType]} {((Object)chosenValuable).name}s!");
			}
		}

		public void TryUpgrade()
		{
			if (!SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			if (SemiFunc.IsMultiplayer())
			{
				List<string> list = wishableUpgrades;
				List<PlayerAvatar> list2 = SemiFunc.PlayerGetAll();
				for (int i = 0; i < list2.Count; i++)
				{
					list2[i].playerHealth.MaterialEffectOverride((Effect)0);
					if (list.Count == 0)
					{
						list = wishableUpgrades;
					}
					if (list.Count == 0)
					{
						log.LogWarning((object)"Something went wrong with the Dragon Balls upgrades system, no upgrades were available!");
						break;
					}
					int index = Random.Range(0, list.Count);
					MegaUpgrade(SemiFunc.PlayerGetSteamID(list2[i]), list[index]);
					list.RemoveAt(index);
				}
			}
			else
			{
				MegaUpgrade(SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarLocal()), wishableUpgrades[Random.Range(0, wishableUpgrades.Count)]);
			}
		}

		public void MegaUpgrade(string steamID, string upgrade)
		{
			log.LogDebug((object)("Dragon Ball Mega Upgrading: \"" + upgrade + "\""));
			switch (upgrade)
			{
			case "Health":
				if (WildCardMod.instance.oldSharedUpgradesPresent)
				{
					List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
					for (int i = 0; i < list.Count; i++)
					{
						for (int j = 0; j < 6; j++)
						{
							PunManager.instance.UpgradePlayerHealth(SemiFunc.PlayerGetSteamID(list[i]));
						}
					}
				}
				else
				{
					for (int k = 0; k < 6; k++)
					{
						PunManager.instance.UpgradePlayerHealth(steamID);
					}
				}
				return;
			case "Stamina":
				if (WildCardMod.instance.oldSharedUpgradesPresent)
				{
					List<PlayerAvatar> list6 = SemiFunc.PlayerGetAll();
					for (int num10 = 0; num10 < list6.Count; num10++)
					{
						for (int num11 = 0; num11 < 6; num11++)
						{
							PunManager.instance.UpgradePlayerEnergy(SemiFunc.PlayerGetSteamID(list6[num10]));
						}
					}
				}
				else
				{
					for (int num12 = 0; num12 < 6; num12++)
					{
						PunManager.instance.UpgradePlayerEnergy(steamID);
					}
				}
				return;
			case "Launch":
				if (WildCardMod.instance.oldSharedUpgradesPresent)
				{
					List<PlayerAvatar> list7 = SemiFunc.PlayerGetAll();
					for (int num13 = 0; num13 < list7.Count; num13++)
					{
						for (int num14 = 0; num14 < 6; num14++)
						{
							PunManager.instance.UpgradePlayerTumbleLaunch(SemiFunc.PlayerGetSteamID(list7[num13]));
						}
					}
				}
				else
				{
					for (int num15 = 0; num15 < 6; num15++)
					{
						PunManager.instance.UpgradePlayerTumbleLaunch(steamID);
					}
				}
				return;
			case "Speed":
				if (WildCardMod.instance.oldSharedUpgradesPresent)
				{
					List<PlayerAvatar> list3 = SemiFunc.PlayerGetAll();
					for (int num = 0; num < list3.Count; num++)
					{
						for (int num2 = 0; num2 < 6; num2++)
						{
							PunManager.instance.UpgradePlayerSprintSpeed(SemiFunc.PlayerGetSteamID(list3[num]));
						}
					}
				}
				else
				{
					for (int num3 = 0; num3 < 6; num3++)
					{
						PunManager.instance.UpgradePlayerSprintSpeed(steamID);
					}
				}
				return;
			case "Strength":
				if (WildCardMod.instance.oldSharedUpgradesPresent)
				{
					List<PlayerAvatar> list2 = SemiFunc.PlayerGetAll();
					for (int l = 0; l < list2.Count; l++)
					{
						for (int m = 0; m < 6; m++)
						{
							PunManager.instance.UpgradePlayerGrabStrength(SemiFunc.PlayerGetSteamID(list2[l]));
						}
					}
				}
				else
				{
					for (int n = 0; n < 6; n++)
					{
						PunManager.instance.UpgradePlayerGrabStrength(steamID);
					}
				}
				return;
			case "Range":
				if (WildCardMod.instance.oldSharedUpgradesPresent)
				{
					List<PlayerAvatar> list4 = SemiFunc.PlayerGetAll();
					for (int num4 = 0; num4 < list4.Count; num4++)
					{
						for (int num5 = 0; num5 < 6; num5++)
						{
							PunManager.instance.UpgradePlayerGrabRange(SemiFunc.PlayerGetSteamID(list4[num4]));
						}
					}
				}
				else
				{
					for (int num6 = 0; num6 < 6; num6++)
					{
						PunManager.instance.UpgradePlayerGrabRange(steamID);
					}
				}
				return;
			case "Extra Jump":
				if (WildCardMod.instance.oldSharedUpgradesPresent)
				{
					List<PlayerAvatar> list5 = SemiFunc.PlayerGetAll();
					for (int num7 = 0; num7 < list5.Count; num7++)
					{
						for (int num8 = 0; num8 < 6; num8++)
						{
							PunManager.instance.UpgradePlayerExtraJump(SemiFunc.PlayerGetSteamID(list5[num7]));
						}
					}
				}
				else
				{
					for (int num9 = 0; num9 < 6; num9++)
					{
						PunManager.instance.UpgradePlayerExtraJump(steamID);
					}
				}
				return;
			}
			if (WildCardMod.instance.moreUpgradesPresent)
			{
				MoreUpgradesUpgrade(steamID, upgrade);
				return;
			}
			log.LogWarning((object)("Dragon Ball wish for upgrade: " + upgrade + " failed, retrying..."));
			wishableUpgrades.Remove(upgrade);
			if (wishableUpgrades.Count == 0)
			{
				wishableUpgrades = StatsManager.instance.FetchPlayerUpgrades(steamID).Keys.ToList();
				wishableUpgrades.Remove("Dragon Balls");
				wishableUpgrades.Remove("Chaos Emeralds");
				wishableUpgrades.Remove("Map Player Count");
				wishableUpgrades.Remove("Throw");
				wishableUpgrades.Remove("Head Charge");
				wishableUpgrades.Remove("Head Power");
			}
			MegaUpgrade(steamID, wishableUpgrades[Random.Range(0, wishableUpgrades.Count)]);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		public void MoreUpgradesUpgrade(string steamID, string upgrade)
		{
			if (Plugin.instance.upgradeItems.Find((UpgradeItem x) => x.name == upgrade) == null)
			{
				log.LogWarning((object)("Dragon Ball wish upgrade tried to use MoreUpgrades' \"" + upgrade + "\" but something went wrong"));
				return;
			}
			log.LogDebug((object)("Using MoreUpgrades to upgrade \"" + upgrade + "\"!"));
			if (WildCardMod.instance.oldSharedUpgradesPresent)
			{
				List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
				for (int i = 0; i < list.Count; i++)
				{
					MoreUpgradesManager.instance.Upgrade(upgrade, SemiFunc.PlayerGetSteamID(list[i]), 5);
				}
			}
			else
			{
				MoreUpgradesManager.instance.Upgrade(upgrade, steamID, 5);
			}
		}

		public void OnDestroy()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			List<PlayerAvatar> list = SemiFunc.PlayerGetAll();
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].playerHealth.bodyMaterial.GetColor("_EmissionColor") != Color.black)
				{
					list[i].playerHealth.bodyMaterial.SetColor("_EmissionColor", Color.black);
					((Renderer)list[i].playerDeathHead.headRenderer).material.SetColor("_EmissionColor", Color.black);
				}
			}
		}
	}
	public class DummyValuable : MonoBehaviour
	{
		private readonly ManualLogSource log = WildCardMod.instance.log;

		public ScriptableObject script;

		public void Awake()
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				ScriptableObject val = script;
				ScriptableObject val2 = val;
				Item val3 = (Item)(object)((val2 is Item) ? val2 : null);
				if (val3 != null)
				{
					val3 = StatsManager.instance.itemDictionary[val3.itemAssetName];
					log.LogDebug((object)("Spawning " + val3.itemName + " from dummy!"));
					GameObject val4 = Items.SpawnItem(val3, ((Component)this).transform.position, ((Component)this).transform.rotation);
					val4.SetActive(true);
					log.LogDebug((object)("Spawned " + ((Object)val4).name + "!"));
				}
				else
				{
					log.LogWarning((object)(((Object)this).name + " was unable to spawn!"));
				}
				ValuableDirector instance = ValuableDirector.instance;
				instance.totalMaxAmount++;
				ValuableDirector instance2 = ValuableDirector.instance;
				instance2.valuableTargetAmount--;
			}
		}

		public void Start()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				((Component)((Component)this).transform).GetComponent<PhysGrabObject>().DestroyPhysGrabObject();
			}
		}
	}
	public class FixatedNoseTrap : Trap
	{
		private readonly ManualLogSource log = WildCardMod.instance.log;

		public ParticleScriptExplosion explodeScript;

		public PhysicMaterial physMat;

		public Animator animator;

		public override void Start()
		{
			((Trap)this).Start();
			base.physGrabObject.OverrideMaterial(physMat, -123f);
		}

		public override void Update()
		{
			((Trap)this).Update();
			if (base.trapStart && SemiFunc.IsMasterClientOrSingleplayer())
			{
				base.physGrabObject.impactDetector.DestroyObject(true);
			}
		}

		public void ImpactSquish()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				float impactForce = base.physGrabObject.impactDetector.impactForce;
				if (GameManager.Multiplayer())
				{
					base.photonView.RPC("SquishRPC", (RpcTarget)0, new object[1] { impactForce });
				}
				else
				{
					SquishRPC(impactForce);
				}
				if (!base.physGrabObject.impactDetector.inCart && !base.physGrabObject.roomVolumeCheck.inExtractionPoint)
				{
					((Trap)this).TrapStart();
				}
			}
		}

		[PunRPC]
		public void SquishRPC(float force)
		{
			animator.SetLayerWeight(1, Mathf.Clamp01(force / 150f));
			animator.SetTrigger("Squish");
		}

		public void NoseExplode()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (Vector3.Distance(((Component)this).transform.position, ((Component)PlayerAvatar.instance).transform.position) < 10f)
			{
				CameraGlitch.Instance.PlayShort();
			}
			log.LogDebug((object)(((Object)((Component)this).gameObject).name + " is exploding!"));
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				base.enemyInvestigate = true;
				base.enemyInvestigateRange = 10f;
				float value = Random.value;
				if (SemiFunc.IsMultiplayer())
				{
					base.photonView.RPC("ExplosionRPC", (RpcTarget)0, new object[1] { value });
				}
				else
				{
					ExplosionRPC(value);
				}
			}
		}

		[PunRPC]
		public void ExplosionRPC(float random)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if (random < 0.9f)
			{
				explodeScript.Spawn(((Component)this).transform.position, 0.245f, 5, 5, 2.5f, false, false, 1f);
			}
			else
			{
				explodeScript.Spawn(((Component)this).transform.position, 2f, 20, 20, 5f, false, false, 1f);
			}
		}
	}
	public class GiwiWormValuable : MonoBehaviour
	{
		private readonly ManualLogSource log = WildCardMod.instance.log;

		public GiwiRigidbody[] giwiRigidbodies;

		public Sound giwiSounds;

		public PhysGrabObject physGrabObject;

		public PhotonView photonView;

		public Animator animator;

		public float animTimer = 0f;

		public float animLerp;

		public float startTime = 0.5f;

		public float targetTime = 0.5f;

		public float animSpeed;

		public float dropTimer;

		public float overrideStrength = 15f;

		public void Start()
		{
			if (SemiFunc.IsMultiplayer())
			{
				if (!SemiFunc.IsMasterClient())
				{
					for (int i = 0; i < giwiRigidbodies.Length; i++)
					{
						giwiRigidbodies[i].rb.collisionDetectionMode = (CollisionDetectionMode)0;
					}
				}
			}
			else
			{
				PhotonTransformView[] componentsInChildren = ((Component)((Component)this).transform).GetComponentsInChildren<PhotonTransformView>();
				for (int j = 0; j < componentsInChildren.Length; j++)
				{
					((Behaviour)componentsInChildren[j]).enabled = false;
				}
			}
		}

		public void Update()
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if (!LevelGenerator.Instance.Generated)
			{
				return;
			}
			if (physGrabObject.grabbed)
			{
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					physGrabObject.OverrideGrabStrength(overrideStrength, 0.1f);
				}
				if (!giwiSounds.Source.isPlaying)
				{
					EnemyDirector.instance.SetInvestigate(((Component)this).transform.position, 10f);
					giwiSounds.Play(((Component)giwiRigidbodies[10].rb).transform.position, 1f, 1f, 1f, 1f);
					log.LogDebug((object)(((Object)giwiSounds.Source.clip).name ?? ""));
				}
			}
			else if (giwiSounds.Source.isPlaying)
			{
				giwiSounds.Stop();
			}
			if (animTimer <= 0f)
			{
				animLerp = 0f;
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					animTimer = Random.Range(0.5f, 2f);
					float num = Mathf.Max(Random.value, 0.125f) * 2f;
					float value = Random.value;
					if (GameManager.Multiplayer())
					{
						photonView.RPC("TargetTimeRPC", (RpcTarget)0, new object[4] { value, targetTime, num, animTimer });
					}
					else
					{
						TargetTimeRPC(value, targetTime, num, animTimer);
					}
				}
			}
			else if (animLerp < 1f)
			{
				animator.SetFloat("Motion Time", Mathf.Lerp(startTime, targetTime, Mathf.Clamp01(animLerp)));
				animLerp += Time.deltaTime * animSpeed;
			}
			else
			{
				animTimer -= Time.deltaTime;
			}
		}

		public void FixedUpdate()
		{
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			if (!LevelGenerator.Instance.Generated || !SemiFunc.IsMasterClientOrSingleplayer())
			{
				return;
			}
			if (physGrabObject.grabbed || dropTimer > 0f)
			{
				Vector3 val = default(Vector3);
				for (int i = 1; i < giwiRigidbodies.Length; i++)
				{
					giwiRigidbodies[i].newDirTimer -= Time.fixedDeltaTime;
					if (giwiRigidbodies[i].newDirTimer <= 0f)
					{
						if (physGrabObject.grabbed)
						{
							((Vector3)(ref val))..ctor(1f, 3f, 1f);
						}
						else
						{
							((Vector3)(ref val))..ctor(1f, 0.1f, 1f);
						}
						giwiRigidbodies[i].direction = Vector3.Scale(Random.onUnitSphere, val);
						giwiRigidbodies[i].newDirTimer = Random.Range(0.05f, 0.25f);
					}
					giwiRigidbodies[i].Wiggle(Random.Range(4f, 10f) * ((float)Mathf.Max(i, 3) / 1.5f), Random.Range(3f, 8f) * -1f);
				}
				if (physGrabObject.grabbed && dropTimer != 5f)
				{
					dropTimer = 5f;
				}
			}
			if (!physGrabObject.grabbed)
			{
				dropTimer -= Time.fixedDeltaTime;
			}
		}

		[PunRPC]
		public void TargetTimeRPC(float tTime, float sTime, float speed, float animTime)
		{
			targetTime = tTime;
			startTime = sTime;
			animSpeed = speed;
			animTimer = animTime;
		}
	}
	[Serializable]
	public class GiwiRigidbody
	{
		public Rigidbody rb;

		public Vector3 direction;

		public float newDirTimer;

		public void Wiggle(float forceIntensity, float torqueIntensity)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: 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_0025: Unknown result type (might be due to invalid IL or missing references)
			rb.AddForce(direction * forceIntensity);
			rb.AddTorque(Random.onUnitSphere * torqueIntensity);
		}
	}
	public class Hellgato : MonoBehaviour
	{
		private readonly ManualLogSource log = WildCardMod.instance.log;

		public PhotonView photonView;

		public PhysGrabObject physGrabObject;

		public ValuableObject valuableObject;

		public PhysGrabObjectImpactDetector impactDetector;

		public ParticleScriptExplosion explodeScript;

		public ParticleSystem particleSystem;

		public PropLight propLight;

		public Sound crackleLoop;

		public float loopTimer;

		public bool playLoop;

		public Transform floatPoint;

		public Animator animator;

		public float blinkTimer;

		public float earTimer;

		public float pawTimer;

		public bool lightTrigger;

		public AnimationCurve lightPulseCurve;

		public float lightPulseTimer;

		public bool wasGrabbed;

		public float alterTimer;

		public float balanceForce = 4f;

		public float floatHeight = 0.75f;

		public float floatPower = 5f;

		public float glidePower = 0.5f;

		public void Awake()
		{
			valuableObject.dollarValueOverride = Mathf.Max(1000, Mathf.RoundToInt(Random.Range(valuableObject.valuePreset.valueMin, valuableObject.valuePreset.valueMax) / 1000f) * 1000);
		}

		public void FixedUpdate()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_0079: 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_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: 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_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			if (LevelGenerator.Instance.Generated && SemiFunc.IsMasterClientOrSingleplayer())
			{
				Quaternion val = Quaternion.FromToRotation(((Component)this).transform.up, Vector3.up);
				physGrabObject.rb.AddTorque(new Vector3(val.x, val.y, val.z) * balanceForce);
				RaycastHit val2 = default(RaycastHit);
				if (Physics.Raycast(floatPoint.position, -Vector3.up, ref val2, floatHeight, LayerMask.GetMask(new string[6] { "Default", "PhysGrabObject", "PhysGrabObjectCart", "PhysGrabObjectHinge", "Enemy", "Player" }), (QueryTriggerInteraction)1) && !physGrabObject.colliders.Contains(((Component)((RaycastHit)(ref val2)).collider).transform))
				{
					physGrabObject.rb.AddForce(((Component)this).transform.up * (floatPower / ((RaycastHit)(ref val2)).distance) * (1.1f - Quaternion.Angle(Quaternion.identity, val) / 360f));
				}
				else
				{
					physGrabObject.rb.AddForce(((Component)this).transform.up * floatPower * glidePower * (1.1f - Quaternion.Angle(Quaternion.identity, val) / 360f));
				}
			}
		}

		public void Update()
		{
			if (!LevelGenerator.Instance.Generated)
			{
				return;
			}
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				physGrabObject.OverrideIndestructible(0.1f);
				if (blinkTimer > 0f)
				{
					blinkTimer -= Time.deltaTime;
				}
				else
				{
					blinkTimer = Random.Range(1f, 3f);
					AnimTrigger("Blink");
				}
				if (earTimer > 0f)
				{
					earTimer -= Time.deltaTime;
				}
				else
				{
					earTimer = Random.Range(4f, 9f);
					AnimTrigger("Ear Flick", "Ear Side", Random.Range(0, 2));
				}
				if (pawTimer > 0f)
				{
					pawTimer -= Time.deltaTime;
				}
				else
				{
					pawTimer = Random.Range(3f, 7f);
					AnimTrigger("Paw Twitch", "Paw Side", Random.Range(0, 4));
				}
			}
			if (loopTimer > 0f)
			{
				loopTimer -= Time.deltaTime;
			}
			else
			{
				loopTimer = Random.Range(1f, 5f);
				playLoop = !playLoop;
			}
			crackleLoop.PlayLoop(playLoop, 1f, 1f, Mathf.Clamp(((Vector3)(ref physGrabObject.rbVelocity)).magnitude / 1.5f, 1f, 1.5f));
			animator.SetLayerWeight(3, Mathf.Clamp(Mathf.Abs(physGrabObject.rbVelocity.y / 2f), 0.1f, 1f));
			if (physGrabObject.grabbedLocal)
			{
				if (!wasGrabbed)
				{
					wasGrabbed = true;
					alterTimer = 1f;
				}
				if (alterTimer <= 0f)
				{
					alterTimer = 1f;
					ValueChange(!PhysGrabber.instance.isRotating);
				}
				alterTimer -= Time.deltaTime;
			}
			else if (wasGrabbed)
			{
				wasGrabbed = false;
			}
			if (lightTrigger)
			{
				particleSystem.Play();
				lightTrigger = false;
				lightPulseTimer = 1f;
			}
			if (lightPulseTimer > 0f)
			{
				propLight.lightComponent.intensity = lightPulseCurve.Evaluate(1f - lightPulseTimer);
				lightPulseTimer -= Time.deltaTime;
			}
		}

		public void ValueChange(bool healPlayer)
		{
			if (healPlayer)
			{
				if (PlayerAvatar.instance.playerHealth.health <= PlayerAvatar.instance.playerHealth.maxHealth - 10)
				{
					Break(1000f);
					PlayerAvatar.instance.playerHealth.HealOther(10, true);
				}
			}
			else if (PlayerAvatar.instance.playerHealth.health >= 11)
			{
				Break(-1000f);
				PlayerAvatar.instance.playerHealth.Hurt(10, true, -1);
			}
		}

		public void Break(float value)
		{
			//IL_0067: 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)
			if (SemiFunc.IsMultiplayer())
			{
				impactDetector.photonView.RPC("BreakRPC", (RpcTarget)0, new object[4] { value, physGrabObject.centerPoint, 2, true });
			}
			else
			{
				impactDetector.BreakRPC(value, physGrabObject.centerPoint, 2, true);
			}
		}

		public void BreakEffect()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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)
			lightTrigger = true;
			int num = Random.Range(0, 3);
			Sound val = null;
			switch (num)
			{
			case 0:
				val = valuableObject.audioPreset.impactLight;
				break;
			case 1:
				val = valuableObject.audioPreset.impactMedium;
				break;
			case 2:
				val = valuableObject.audioPreset.impactHeavy;
				break;
			}
			val.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f);
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				physGrabObject.rb.AddForce(Random.insideUnitSphere * 2f, (ForceMode)1);
				physGrabObject.rb.AddTorque(Random.insideUnitSphere * 3.5f, (ForceMode)1);
			}
		}

		public void AnimTrigger(string trigger, string randomiser = "", int value = -1)
		{
			if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC("AnimTriggerRPC", (RpcTarget)0, new object[3] { trigger, randomiser, value });
			}
			else
			{
				AnimTriggerRPC(trigger, randomiser, value);
			}
		}

		[PunRPC]
		public void AnimTriggerRPC(string trigger, string randomiser, int value)
		{
			if (randomiser != "" && value > -1)
			{
				animator.SetInteger(randomiser, value);
			}
			animator.SetTrigger(trigger);
		}

		public void ImpactSquish()
		{
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				float impactForce = impactDetector.impactForce;
				if (GameManager.Multiplayer())
				{
					photonView.RPC("SquishRPC", (RpcTarget)0, new object[1] { impactForce });
				}
				else
				{
					SquishRPC(impactForce);
				}
			}
		}

		[PunRPC]
		public void SquishRPC(float force)
		{
			animator.SetLayerWeight(1, Mathf.Clamp01(force / 150f));
			animator.SetTrigger("Squish");
		}

		public void DestroyEffect()
		{
			//IL_000c: 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)
			EnemyDirector.instance.SetInvestigate(physGrabObject.centerPoint, float.MaxValue);
			explodeScript.Spawn(physGrabObject.centerPoint, 1f, 5, 10, 0.75f, false, false, 1f);
		}
	}
	public class MarioDice : MonoBehaviour
	{
		private readonly ManualLogSource log = WildCardMod.instanc