Decompiled source of MipaPlayerModel v1.3.0

BepInEx/plugins/Mipa.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using DigitalRuby.ThunderAndLightning;
using Dissonance;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mipa;
using ModelReplacement;
using ModelReplacement.Monobehaviors.Enemies;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("Mipa")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Mipa")]
[assembly: AssemblyTitle("Mipa")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
public class MaskedEnemyModelLink : MonoBehaviour
{
	public MaskedPlayerEnemy m_MaskedComponent;
}
public class MipaSkinInstance
{
	public string m_SkinName = "Default";

	public Texture2D m_EyesDefault = null;

	public Texture2D m_EyesBlink = null;

	public Texture2D m_EyesClosed = null;

	public Texture2D m_MouthDefault = null;

	public Texture2D m_DrunkMouth = null;

	public Texture2D m_DrunkEyes = null;

	public Texture2D m_LowHPMouth = null;

	public List<Texture2D> m_MouthTalking = new List<Texture2D>();

	public Material m_FaceMaterial = null;

	public Material m_BodyMaterial = null;

	public Material m_ChestMaterial = null;

	[ColorUsage(true, true)]
	public Color m_EmmissionColor = Color.white;
}
public class SkinApply : MonoBehaviour
{
	private enum BlinkState
	{
		Open,
		HalfClosed,
		Closesd
	}

	private enum FaceOverrideState
	{
		None,
		LowHealth,
		Hurt,
		Drunk
	}

	public PlayerControllerB m_Player;

	public VoicePlayerState m_VoiceState;

	public string m_SkinName = "None";

	public MipaSkinInstance m_Skin;

	public SkinnedMeshRenderer m_FaceMesh;

	public SkinnedMeshRenderer m_ChestMesh;

	public bool m_IsTalking = false;

	private bool m_IsLastTalking = false;

	public List<SkinnedMeshRenderer> m_Body = new List<SkinnedMeshRenderer>();

	public bool m_ReApplySkin = false;

	public bool m_ForceSkin = false;

	public bool m_IsDead = false;

	public float m_TimeUnderWater = 0f;

	public float m_NextSparkTime = 0f;

	public static GameObject m_SparkingPrefab;

	private float NextBlinkTime = 0f;

	private float BlinkingPerioud = 10f;

	private float BlinkingAnimationFrameTime = 0.1f;

	private BlinkState CurrentBlinkState = BlinkState.Open;

	private FaceOverrideState CurrentFaceOverrideState = FaceOverrideState.None;

	private int MouthTalkingIndex = 0;

	private float TalkingAnimationFrameTime = 0.2f;

	private float NextTalkTime = 0f;

	private AudioSource s_MimicLastAudioSource = null;

	private void Start()
	{
		AssignMeshes();
		Default();
	}

	public void AssignMeshes()
	{
		m_FaceMesh = ((Component)((Component)this).transform.GetChild(0).GetChild(1)).GetComponent<SkinnedMeshRenderer>();
		m_ChestMesh = ((Component)((Component)this).transform.GetChild(1).GetChild(7)).GetComponent<SkinnedMeshRenderer>();
		SkinnedMeshRenderer[] componentsInChildren = ((Component)((Component)this).transform).GetComponentsInChildren<SkinnedMeshRenderer>();
		foreach (SkinnedMeshRenderer val in componentsInChildren)
		{
			if ((Object)(object)val != (Object)(object)m_FaceMesh && (Object)(object)val != (Object)(object)m_ChestMesh)
			{
				m_Body.Add(val);
			}
		}
	}

	public void DoSparking()
	{
		//IL_0226: 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)
		if ((Object)(object)m_SparkingPrefab == (Object)null)
		{
			Debug.Log((object)"m_SparkingPrefab, not exist, creating one.");
			GameObject val = GameObject.Find("Terminal");
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			Debug.Log((object)"Found terminal obj");
			Terminal componentInChildren = val.GetComponentInChildren<Terminal>();
			if (!Object.op_Implicit((Object)(object)componentInChildren))
			{
				return;
			}
			Debug.Log((object)"Found terminal script");
			GameObject val2 = null;
			if (!Object.op_Implicit((Object)(object)componentInChildren))
			{
				return;
			}
			foreach (SpawnableEnemyWithRarity daytimeEnemy in componentInChildren.moonsCatalogueList[0].DaytimeEnemies)
			{
				if (daytimeEnemy.enemyType.enemyName == "Red Locust Bees")
				{
					val2 = daytimeEnemy.enemyType.enemyPrefab;
					break;
				}
			}
			if (!Object.op_Implicit((Object)(object)val2))
			{
				return;
			}
			Debug.Log((object)"Found RedLocustBees prefab");
			RedLocustBees component = val2.GetComponent<RedLocustBees>();
			if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.lightningComponent))
			{
				return;
			}
			Debug.Log((object)"RedLocustBees has essential components");
			GameObject val3 = Object.Instantiate<GameObject>(((Component)component.lightningComponent).gameObject);
			if (Object.op_Implicit((Object)(object)val3))
			{
				Sparking sparking = val3.AddComponent<Sparking>();
				if (Object.op_Implicit((Object)(object)sparking))
				{
					sparking.m_VisualFX = val3.GetComponent<LightningBoltPathScript>();
					sparking.m_AudioClips = ((EnemyAI)component).enemyType.audioClips;
					GameObject val4 = Object.Instantiate<GameObject>(((Component)component.beeZapAudio).gameObject, val3.transform);
					sparking.m_AudioSource = val4.GetComponent<AudioSource>();
				}
				Debug.Log((object)"m_SparkingPrefab created and ready!");
				Object.DontDestroyOnLoad((Object)(object)val3);
				val3.SetActive(false);
				m_SparkingPrefab = val3;
			}
			return;
		}
		Debug.Log((object)"Going to use m_SparkingPrefab!");
		Transform val5 = m_Player.bodyParts[Random.Range(0, m_Player.bodyParts.Length)];
		if (Object.op_Implicit((Object)(object)val5))
		{
			GameObject val6 = Object.Instantiate<GameObject>(m_SparkingPrefab, val5.position, Quaternion.identity);
			if (Object.op_Implicit((Object)(object)val6))
			{
				val6.SetActive(true);
				Sparking component2 = val6.GetComponent<Sparking>();
				component2.DoFX();
			}
		}
	}

	public void Default()
	{
		//IL_0094: 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_0184: Unknown result type (might be due to invalid IL or missing references)
		if (m_Skin == null)
		{
			return;
		}
		if (Object.op_Implicit((Object)(object)m_FaceMesh))
		{
			((Renderer)m_FaceMesh).material = m_Skin.m_FaceMaterial;
			((Renderer)m_FaceMesh).material.SetTexture("_Eyes", (Texture)(object)m_Skin.m_EyesDefault);
			((Renderer)m_FaceMesh).material.SetTexture("_Mouth", (Texture)(object)m_Skin.m_MouthDefault);
			((Renderer)m_FaceMesh).material.SetColor("_EmissionColor", m_Skin.m_EmmissionColor);
			if (m_IsDead)
			{
				((Renderer)m_FaceMesh).material = Assets.GetMaterial("MipaFaceDead");
			}
		}
		if (Object.op_Implicit((Object)(object)m_ChestMesh))
		{
			((Renderer)m_ChestMesh).material = m_Skin.m_ChestMaterial;
			((Renderer)m_ChestMesh).material.SetColor("_EmissionColor", m_Skin.m_EmmissionColor);
			if (m_IsDead)
			{
				((Renderer)m_ChestMesh).material = Assets.GetMaterial("Chest_Dead");
			}
		}
		foreach (SkinnedMeshRenderer item in m_Body)
		{
			((Renderer)item).material = m_Skin.m_BodyMaterial;
			if (m_IsDead)
			{
				((Renderer)item).material.SetColor("_EmissiveColor", new Color(0f, 0f, 0f));
			}
		}
	}

	public void SetEyesTexture(Texture2D Tex)
	{
		if (m_Skin != null && Object.op_Implicit((Object)(object)m_FaceMesh))
		{
			((Renderer)m_FaceMesh).material.SetTexture("_Eyes", (Texture)(object)Tex);
		}
	}

	public void SetMouthTexture(Texture2D Tex)
	{
		if (m_Skin != null && Object.op_Implicit((Object)(object)m_FaceMesh))
		{
			((Renderer)m_FaceMesh).material.SetTexture("_Mouth", (Texture)(object)Tex);
		}
	}

	private void UpdateTalking()
	{
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		MaskedEnemyModelLink component = ((Component)this).GetComponent<MaskedEnemyModelLink>();
		if ((Object)(object)component == (Object)null)
		{
			if (!Object.op_Implicit((Object)(object)m_Player))
			{
				return;
			}
			if (m_VoiceState == null)
			{
				StartOfRound.Instance.RefreshPlayerVoicePlaybackObjects();
				m_VoiceState = m_Player.voicePlayerState;
				if (m_VoiceState == null && (Object)(object)m_Player == (Object)StartOfRound.Instance.localPlayerController)
				{
					m_VoiceState = StartOfRound.Instance.voiceChatModule.FindPlayer(StartOfRound.Instance.voiceChatModule.LocalPlayerName);
				}
			}
			else
			{
				m_IsTalking = m_VoiceState.IsSpeaking;
			}
			return;
		}
		AudioSource val = s_MimicLastAudioSource;
		if ((Object)(object)val == (Object)null)
		{
			Transform val2 = ((Component)component.m_MaskedComponent).transform.Find("SpatializedPlaybackPrefabModified(Clone)");
			if (Object.op_Implicit((Object)(object)val2))
			{
				val = ((Component)val2).GetComponent<AudioSource>();
				s_MimicLastAudioSource = val;
			}
		}
		else
		{
			if (!((Object)(object)s_MimicLastAudioSource.clip != (Object)null))
			{
				return;
			}
			float num = 0.009f;
			float num2 = 0f;
			int num3 = 64;
			int num4 = s_MimicLastAudioSource.timeSamples - num3;
			if (num4 > 0)
			{
				float[] array = new float[num3];
				s_MimicLastAudioSource.clip.GetData(array, num4);
				float[] array2 = array;
				foreach (float num5 in array2)
				{
					num2 += Mathf.Abs(num5);
				}
				num2 /= (float)num3;
				m_IsTalking = num2 > num;
			}
			m_IsTalking = s_MimicLastAudioSource.isPlaying;
		}
	}

	public bool GetIsDead()
	{
		MaskedEnemyModelLink component = ((Component)this).GetComponent<MaskedEnemyModelLink>();
		if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.m_MaskedComponent))
		{
			return ((EnemyAI)component.m_MaskedComponent).isEnemyDead;
		}
		if (Object.op_Implicit((Object)(object)m_Player))
		{
			return m_Player.isPlayerDead;
		}
		return m_IsDead;
	}

	public float GetHealth()
	{
		MaskedEnemyModelLink component = ((Component)this).GetComponent<MaskedEnemyModelLink>();
		if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.m_MaskedComponent))
		{
			float num = ((EnemyAI)component.m_MaskedComponent).enemyHP;
			if (num >= 4f)
			{
				return 100f;
			}
			if (num < 4f && num > 1f)
			{
				return 70f;
			}
			if (num > 0f)
			{
				return 5f;
			}
			return 0f;
		}
		if (Object.op_Implicit((Object)(object)m_Player))
		{
			return m_Player.health;
		}
		return 0f;
	}

	public bool ShouldSpark()
	{
		if (Object.op_Implicit((Object)(object)m_Player) && !GetIsDead() && m_Player.isFaceUnderwaterOnServer && m_TimeUnderWater >= 5f && m_NextSparkTime < Time.time)
		{
			m_NextSparkTime = Time.time + 1f;
			return true;
		}
		return false;
	}

	private void FixedUpdate()
	{
		if (Object.op_Implicit((Object)(object)m_Player))
		{
			MaskedPlayerEnemy component = ((Component)this).GetComponent<MaskedPlayerEnemy>();
			bool isDead = GetIsDead();
			if (m_IsDead != isDead)
			{
				m_IsDead = isDead;
				Default();
			}
			if (!m_IsDead)
			{
				UpdateTalking();
			}
			else
			{
				m_IsTalking = false;
			}
		}
	}

	public void FaceUpdates()
	{
		if (m_Skin == null)
		{
			return;
		}
		float health = GetHealth();
		float num = 0f;
		if (Object.op_Implicit((Object)(object)m_Player) && (Object)(object)((Component)this).GetComponent<MaskedEnemyModelLink>() == (Object)null)
		{
			num = m_Player.drunkness;
		}
		if (health > 0f)
		{
			if (num > 0f)
			{
				if (CurrentFaceOverrideState != FaceOverrideState.Drunk)
				{
					SetMouthTexture(m_Skin.m_DrunkMouth);
					SetEyesTexture(m_Skin.m_DrunkEyes);
					CurrentFaceOverrideState = FaceOverrideState.Drunk;
				}
			}
			else if (health < 20f)
			{
				if (CurrentFaceOverrideState != FaceOverrideState.LowHealth)
				{
					SetEyesTexture(m_Skin.m_EyesClosed);
					SetMouthTexture(m_Skin.m_LowHPMouth);
					CurrentFaceOverrideState = FaceOverrideState.LowHealth;
				}
			}
			else if (health < 80f)
			{
				if (CurrentFaceOverrideState != FaceOverrideState.Hurt)
				{
					SetEyesTexture(m_Skin.m_EyesBlink);
					SetMouthTexture(m_Skin.m_LowHPMouth);
					CurrentFaceOverrideState = FaceOverrideState.Hurt;
				}
			}
			else if (CurrentFaceOverrideState != 0)
			{
				SetEyesTexture(m_Skin.m_EyesDefault);
				SetMouthTexture(m_Skin.m_MouthDefault);
				CurrentFaceOverrideState = FaceOverrideState.None;
			}
		}
		if (m_IsLastTalking != m_IsTalking)
		{
			m_IsLastTalking = m_IsTalking;
			if (!m_IsTalking)
			{
				if (CurrentFaceOverrideState == FaceOverrideState.None)
				{
					SetMouthTexture(m_Skin.m_MouthDefault);
				}
				else if (CurrentFaceOverrideState == FaceOverrideState.Drunk)
				{
					SetMouthTexture(m_Skin.m_DrunkMouth);
				}
				else if (CurrentFaceOverrideState == FaceOverrideState.LowHealth || CurrentFaceOverrideState == FaceOverrideState.Hurt)
				{
					SetMouthTexture(m_Skin.m_LowHPMouth);
				}
			}
		}
		if ((CurrentFaceOverrideState == FaceOverrideState.None || CurrentFaceOverrideState == FaceOverrideState.Hurt) && Time.time > NextBlinkTime)
		{
			if (CurrentBlinkState == BlinkState.Open)
			{
				NextBlinkTime = Time.time + BlinkingAnimationFrameTime;
				SetEyesTexture(m_Skin.m_EyesBlink);
				CurrentBlinkState = BlinkState.HalfClosed;
			}
			else if (CurrentBlinkState == BlinkState.HalfClosed)
			{
				NextBlinkTime = Time.time + BlinkingAnimationFrameTime;
				SetEyesTexture(m_Skin.m_EyesClosed);
				CurrentBlinkState = BlinkState.Closesd;
			}
			else if (CurrentBlinkState == BlinkState.Closesd)
			{
				NextBlinkTime = Time.time + BlinkingPerioud;
				if (CurrentFaceOverrideState == FaceOverrideState.None)
				{
					SetEyesTexture(m_Skin.m_EyesDefault);
					CurrentBlinkState = BlinkState.Open;
				}
				else
				{
					SetEyesTexture(m_Skin.m_EyesBlink);
					CurrentBlinkState = BlinkState.HalfClosed;
				}
			}
		}
		if (!(Time.time > NextTalkTime))
		{
			return;
		}
		if (m_IsTalking)
		{
			SetMouthTexture(m_Skin.m_MouthTalking[MouthTalkingIndex]);
			if (MouthTalkingIndex == m_Skin.m_MouthTalking.Count - 1)
			{
				MouthTalkingIndex = 0;
			}
			else
			{
				MouthTalkingIndex++;
			}
		}
		NextTalkTime = Time.time + TalkingAnimationFrameTime;
	}

	private void Update()
	{
		if (m_Skin == null && !string.IsNullOrEmpty(m_SkinName))
		{
			m_Skin = MipaSkinManager.GetSkin(m_SkinName);
			if (m_Skin == null)
			{
				m_Skin = MipaSkinManager.GetSkin("Default");
			}
			Default();
		}
		if (!m_IsDead)
		{
			FaceUpdates();
			if (Object.op_Implicit((Object)(object)m_Player))
			{
				if (m_Player.isFaceUnderwaterOnServer && (Object)(object)((Component)this).GetComponent<MaskedEnemyModelLink>() == (Object)null)
				{
					m_TimeUnderWater += Time.deltaTime;
				}
				else
				{
					m_TimeUnderWater = 0f;
				}
			}
		}
		if (m_ReApplySkin)
		{
			m_ReApplySkin = false;
			Default();
		}
		if (ShouldSpark())
		{
			DoSparking();
		}
	}
}
public class Sparking : MonoBehaviour
{
	public LightningBoltPathScript m_VisualFX;

	public AudioClip[] m_AudioClips;

	public AudioSource m_AudioSource;

	private bool s_Finished = false;

	private bool s_SkipOne = true;

	private bool s_Begin = false;

	public void DoFX()
	{
		if (Object.op_Implicit((Object)(object)m_VisualFX))
		{
			((LightningBoltScript)m_VisualFX).Camera = StartOfRound.Instance.activeCamera;
		}
		if (Object.op_Implicit((Object)(object)m_AudioSource))
		{
			m_AudioSource.PlayOneShot(m_AudioClips[Random.Range(0, m_AudioClips.Length)]);
		}
		s_Begin = true;
	}

	public void FixedUpdate()
	{
		if (s_Begin)
		{
			if (s_SkipOne)
			{
				s_SkipOne = false;
			}
			else if (Object.op_Implicit((Object)(object)m_VisualFX) && !s_Finished)
			{
				((LightningBoltPrefabScriptBase)m_VisualFX).Trigger(0.3f);
				s_Finished = true;
				Object.Destroy((Object)(object)((Component)this).gameObject, 1f);
			}
		}
	}
}
namespace Mipa
{
	public class MRMIPA_PLAYER_MODEL : BodyReplacementBase
	{
		public List<AudioClip> m_Footsteps = new List<AudioClip>();

		public AudioClip m_LandingClip;

		public AudioClip m_JumpingClip;

		protected override void Start()
		{
			if (m_Footsteps.Count == 0)
			{
				for (int i = 0; i <= 3; i++)
				{
					m_Footsteps.Add(Assets.GetAudioClip("FemRobotStep" + i));
				}
			}
			m_LandingClip = Assets.GetAudioClip("MetalLand0");
			m_JumpingClip = Assets.GetAudioClip("TileStep0");
		}

		public AudioClip GetFootstepClip()
		{
			if (m_Footsteps.Count != 0)
			{
				return m_Footsteps[Random.Range(0, m_Footsteps.Count)];
			}
			return null;
		}

		protected override GameObject LoadAssetsAndReturnModel()
		{
			string text = "MIPA_Player_Model";
			return Assets.GetAssetBundle().LoadAsset<GameObject>(text);
		}

		protected override void OnDamageTaken(bool dead)
		{
			SkinApply component = base.replacementModel.GetComponent<SkinApply>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.DoSparking();
			}
		}

		protected override void OnDeath()
		{
			SkinApply component = base.replacementModel.GetComponent<SkinApply>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.DoSparking();
			}
		}

		public virtual string GetSkin()
		{
			return "Default";
		}

		protected override void AddModelScripts()
		{
			MipaSkinInstance skin = MipaSkinManager.GetSkin(GetSkin());
			SkinApply skinApply = base.replacementModel.AddComponent<SkinApply>();
			skinApply.m_Skin = skin;
			skinApply.m_SkinName = GetSkin();
			skinApply.m_Player = ((BodyReplacementBase)this).controller;
		}
	}
	public class MR_MIPA_PLAYER_MODEL_HAZARD : MRMIPA_PLAYER_MODEL
	{
		public override string GetSkin()
		{
			return "Hazard";
		}
	}
	public class MR_MIPA_PLAYER_MODEL_ANOMALY : MRMIPA_PLAYER_MODEL
	{
		public override string GetSkin()
		{
			return "Anomaly";
		}
	}
	public class MR_MIPA_PLAYER_MODEL_PHANTASY : MRMIPA_PLAYER_MODEL
	{
		public override string GetSkin()
		{
			return "Phantasy";
		}
	}
	public class MR_MIPA_PLAYER_MODEL_PLACEHOLDER : MRMIPA_PLAYER_MODEL
	{
		public override string GetSkin()
		{
			return "Placeholder";
		}
	}
	[BepInPlugin("Mipa", "Mipa", "1.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public static ConfigFile config;

		private static void InitConfig()
		{
		}

		private void Awake()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			config = ((BaseUnityPlugin)this).Config;
			InitConfig();
			Assets.LoadBundle("mipa");
			MipaSkinManager.Init();
			ModelReplacementAPI.RegisterSuitModelReplacement("Mipa", typeof(MRMIPA_PLAYER_MODEL));
			ModelReplacementAPI.RegisterSuitModelReplacement("Mipa_Hazard", typeof(MR_MIPA_PLAYER_MODEL_HAZARD));
			ModelReplacementAPI.RegisterSuitModelReplacement("Mipa_Anomaly", typeof(MR_MIPA_PLAYER_MODEL_ANOMALY));
			ModelReplacementAPI.RegisterSuitModelReplacement("Mipa_Phantasy", typeof(MR_MIPA_PLAYER_MODEL_PHANTASY));
			Harmony val = new Harmony("Mipa");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Mipa is loaded!");
		}
	}
	public class MipaSkinManager
	{
		public static Dictionary<string, MipaSkinInstance> s_Skins = new Dictionary<string, MipaSkinInstance>();

		public static MipaSkinInstance GetSkinTemplate(string NewSkinName)
		{
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			MipaSkinInstance mipaSkinInstance = new MipaSkinInstance();
			mipaSkinInstance.m_SkinName = NewSkinName;
			mipaSkinInstance.m_FaceMaterial = Assets.GetMaterial("MipaFace");
			mipaSkinInstance.m_BodyMaterial = Assets.GetMaterial("Default_Body");
			mipaSkinInstance.m_ChestMaterial = Assets.GetMaterial("Default_Chest");
			mipaSkinInstance.m_EyesDefault = Assets.GetTexture("EyesDefault");
			mipaSkinInstance.m_EyesBlink = Assets.GetTexture("EyesHalfClosed");
			mipaSkinInstance.m_EyesClosed = Assets.GetTexture("EyesClosed");
			mipaSkinInstance.m_DrunkEyes = Assets.GetTexture("EyesDrunk");
			mipaSkinInstance.m_LowHPMouth = Assets.GetTexture("MouthHurt");
			mipaSkinInstance.m_DrunkMouth = Assets.GetTexture("MouthDrunk");
			mipaSkinInstance.m_MouthDefault = Assets.GetTexture("MouthDefault");
			mipaSkinInstance.m_MouthTalking = new List<Texture2D>
			{
				Assets.GetTexture("MouthTalk1"),
				Assets.GetTexture("MouthTalk2")
			};
			mipaSkinInstance.m_EmmissionColor = new Color(0f, 0.5957293f, 0.945426f, 1f);
			return mipaSkinInstance;
		}

		public static void Init()
		{
			//IL_0039: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			MipaSkinInstance skinTemplate = GetSkinTemplate("Default");
			AddSkin(skinTemplate.m_SkinName, skinTemplate);
			MipaSkinInstance skinTemplate2 = GetSkinTemplate("Anomaly");
			skinTemplate2.m_EmmissionColor = new Color(1f, 0.6954004f, 0f, 1f);
			skinTemplate2.m_BodyMaterial = Assets.GetMaterial("Anomaly_Body");
			skinTemplate2.m_ChestMaterial = Assets.GetMaterial("Anomaly_Chest");
			AddSkin(skinTemplate2.m_SkinName, skinTemplate2);
			MipaSkinInstance skinTemplate3 = GetSkinTemplate("Hazard");
			skinTemplate3.m_EmmissionColor = new Color(1f, 0.9136026f, 0f, 1f);
			skinTemplate3.m_BodyMaterial = Assets.GetMaterial("Hazard_Body");
			skinTemplate3.m_ChestMaterial = Assets.GetMaterial("HazardSkin_Chest");
			AddSkin(skinTemplate3.m_SkinName, skinTemplate3);
			MipaSkinInstance skinTemplate4 = GetSkinTemplate("Phantasy");
			skinTemplate4.m_EmmissionColor = new Color(0.5990566f, 0.9292454f, 1f, 1f);
			skinTemplate4.m_BodyMaterial = Assets.GetMaterial("Phantasy_Body");
			skinTemplate4.m_ChestMaterial = Assets.GetMaterial("Phantasy_Chest");
			AddSkin(skinTemplate4.m_SkinName, skinTemplate4);
			MipaSkinInstance skinTemplate5 = GetSkinTemplate("Placeholder");
			skinTemplate5.m_BodyMaterial = Assets.GetMaterial("Placeholder_Body");
			skinTemplate5.m_ChestMaterial = Assets.GetMaterial("Placeholder_Chest");
			skinTemplate5.m_EyesDefault = Assets.GetTexture("EyesDefaultPlaceholder");
			skinTemplate5.m_EyesBlink = Assets.GetTexture("EyesHalfClosedPlaceholder");
			skinTemplate5.m_EyesClosed = Assets.GetTexture("EyesClosedPlaceholder");
			skinTemplate5.m_MouthDefault = Assets.GetTexture("MouthDefaultPlaceholder");
			skinTemplate5.m_MouthTalking = new List<Texture2D>
			{
				Assets.GetTexture("MouthTalk1Placeholder"),
				Assets.GetTexture("MouthTalk2Placeholder")
			};
			AddSkin(skinTemplate5.m_SkinName, skinTemplate5);
		}

		public static MipaSkinInstance GetSkin(string SkinName)
		{
			if (s_Skins.TryGetValue(SkinName, out MipaSkinInstance value))
			{
				return value;
			}
			return null;
		}

		public static void AddSkin(string SkinName, MipaSkinInstance Instance)
		{
			if (!s_Skins.ContainsKey(SkinName))
			{
				s_Skins.Add(SkinName, Instance);
			}
		}
	}
	public static class Assets
	{
		public static AssetBundle Bundle;

		private static string GetAssemblyName()
		{
			return Assembly.GetExecutingAssembly().GetName().Name.Replace(" ", "_");
		}

		public static Texture2D GetTexture(string TextureName)
		{
			return GetAssetBundle().LoadAsset<Texture2D>(TextureName);
		}

		public static Material GetMaterial(string MaterialName)
		{
			return GetAssetBundle().LoadAsset<Material>(MaterialName);
		}

		public static AudioClip GetAudioClip(string ClipName)
		{
			return GetAssetBundle().LoadAsset<AudioClip>(ClipName);
		}

		public static Sprite GetSprite(string SpriteName)
		{
			return GetAssetBundle().LoadAsset<Sprite>(SpriteName);
		}

		public static void LoadBundle(string bundlename)
		{
			if (!((Object)(object)Bundle == (Object)null))
			{
				return;
			}
			Console.WriteLine(GetAssemblyName() + "." + bundlename);
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + "." + bundlename);
			Bundle = AssetBundle.LoadFromStream(stream);
			if (Object.op_Implicit((Object)(object)Bundle))
			{
				Console.WriteLine("--------------------------------------------");
				Console.WriteLine("Loaded asset bundle with name " + bundlename);
				Console.WriteLine("--------------------------------------------");
			}
			else
			{
				Console.WriteLine("--------------------------------------------");
				Console.WriteLine("Wasn't able to locate bundle " + bundlename);
				Console.WriteLine("--------------------------------------------");
			}
		}

		public static AssetBundle GetAssetBundle()
		{
			return Bundle;
		}
	}
	[HarmonyPatch(typeof(PlayerControllerB))]
	internal class PlayerControllerBPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch("SetFaceUnderwaterFilters")]
		public static void SetFaceUnderwaterFilters(PlayerControllerB __instance)
		{
			if (!__instance.isPlayerDead && Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<MRMIPA_PLAYER_MODEL>()) && StartOfRound.Instance.drowningTimer <= 0.3f)
			{
				HUDManager.Instance.DisplayStatusEffect("Wetness level critical!");
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("DropBlood")]
		public static bool DropBlood(PlayerControllerB __instance, Vector3 direction = default(Vector3), bool leaveBlood = true, bool leaveFootprint = false)
		{
			if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<MRMIPA_PLAYER_MODEL>()))
			{
				return false;
			}
			return true;
		}

		[HarmonyPrefix]
		[HarmonyPatch("AddBloodToBody")]
		public static bool AddBloodToBody(PlayerControllerB __instance)
		{
			if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<MRMIPA_PLAYER_MODEL>()))
			{
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch("PlayFootstepSound")]
		public static void PlayFootstepSound(PlayerControllerB __instance)
		{
			//IL_003c: 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)
			MRMIPA_PLAYER_MODEL component = ((Component)__instance).GetComponent<MRMIPA_PLAYER_MODEL>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				return;
			}
			AudioClip footstepClip = component.GetFootstepClip();
			if (Object.op_Implicit((Object)(object)footstepClip))
			{
				bool num;
				if (((NetworkBehaviour)__instance).IsOwner)
				{
					num = __instance.isSprinting;
				}
				else
				{
					AnimatorStateInfo currentAnimatorStateInfo = __instance.playerBodyAnimator.GetCurrentAnimatorStateInfo(0);
					num = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).IsTag("Sprinting");
				}
				bool flag = num;
				float num2 = 0.09f;
				if (!flag)
				{
					num2 = 0.06f;
				}
				__instance.movementAudio.PlayOneShot(footstepClip, num2);
				WalkieTalkie.TransmitOneShotAudio(__instance.movementAudio, footstepClip, num2);
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("PlayJumpAudio")]
		public static bool PlayJumpAudio(PlayerControllerB __instance)
		{
			MRMIPA_PLAYER_MODEL component = ((Component)__instance).GetComponent<MRMIPA_PLAYER_MODEL>();
			if (Object.op_Implicit((Object)(object)component))
			{
				__instance.movementAudio.PlayOneShot(component.m_JumpingClip, 0.56f);
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		[HarmonyPatch("PlayerHitGroundEffects")]
		public static void PlayerHitGroundEffects(PlayerControllerB __instance)
		{
			MRMIPA_PLAYER_MODEL component = ((Component)__instance).GetComponent<MRMIPA_PLAYER_MODEL>();
			if (Object.op_Implicit((Object)(object)component))
			{
				__instance.movementAudio.Stop(true);
				__instance.movementAudio.PlayOneShot(component.m_LandingClip, 0.56f);
			}
		}
	}
	[HarmonyPatch(typeof(MaskedReplacementBase))]
	internal class MaskedReplacementBasePatches
	{
		[HarmonyPostfix]
		[HarmonyPatch("SetReplacement")]
		public static void SetReplacement(MaskedReplacementBase __instance, PlayerControllerB mimicking)
		{
			if (Object.op_Implicit((Object)(object)__instance.replacementModel))
			{
				MaskedEnemyModelLink maskedEnemyModelLink = __instance.replacementModel.AddComponent<MaskedEnemyModelLink>();
				maskedEnemyModelLink.m_MaskedComponent = ((Component)__instance).GetComponent<MaskedPlayerEnemy>();
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager))]
	internal class HUDManagerPatches
	{
		public const string OriginalSystemOnlineText = "SYSTEMS ONLINE";

		public const string MipaSystemOnlineText = "MIPA: ONLINE";

		public static TextMeshProUGUI s_SystemOnline;

		public const string OriginalCriticalInjuryText = "CRITICAL INJURY";

		public const string MipaCriticalInjuryText = "CRITICAL DAMAGE";

		public static TextMeshProUGUI s_CriticalInjury;

		public const string OriginalLifeSupportOfflineText = "[LIFE SUPPORT: OFFLINE]";

		public const string MipaLifeSupportOfflineText = "[SYSTEMS: SHUTDOWN]";

		public static TextMeshProUGUI s_LifeSupportOffline;

		public static Image s_SelfIndicator;

		public static Sprite s_SelfIndicatorOriginalTexture;

		public static Sprite s_SelfIndicatorMipaTexture;

		public static Image s_SelfIndicatorFilled;

		public static Sprite s_SelfIndicatorFilledOriginalTexture;

		public static Sprite s_SelfIndicatorFilledMipaTexture;

		public static bool m_LastIsMipa;

		private static bool s_FoundElements;

		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		public static void Start(HUDManager __instance)
		{
			Transform val = ((Component)__instance.HUDAnimator).transform.Find("BottomMiddle/SystemsOnline/TipLeft1");
			if (Object.op_Implicit((Object)(object)val))
			{
				s_SystemOnline = ((Component)val).GetComponent<TextMeshProUGUI>();
			}
			val = ((Component)__instance.HUDAnimator).transform.Find("SpecialHUDGraphics/CriticalInjury/TipLeft1");
			if (Object.op_Implicit((Object)(object)val))
			{
				s_CriticalInjury = ((Component)val).GetComponent<TextMeshProUGUI>();
			}
			val = ((Component)__instance.gameOverAnimator).transform.Find("GameOverText");
			if (Object.op_Implicit((Object)(object)val))
			{
				s_LifeSupportOffline = ((Component)val).GetComponent<TextMeshProUGUI>();
			}
			val = ((Component)__instance.HUDAnimator).transform.Find("TopLeftCorner/Self");
			if (Object.op_Implicit((Object)(object)val))
			{
				Debug.Log((object)"Found TopLeftCorner/Self");
				s_SelfIndicator = ((Component)val).GetComponent<Image>();
				s_SelfIndicatorOriginalTexture = s_SelfIndicator.sprite;
			}
			val = ((Component)__instance.HUDAnimator).transform.Find("TopLeftCorner/SelfRed");
			if (Object.op_Implicit((Object)(object)val))
			{
				Debug.Log((object)"Found TopLeftCorner/SelfRed");
				s_SelfIndicatorFilled = ((Component)val).GetComponent<Image>();
				s_SelfIndicatorFilledOriginalTexture = s_SelfIndicator.sprite;
			}
			s_SelfIndicatorMipaTexture = Assets.GetSprite("MipaTPoseOutline");
			s_SelfIndicatorFilledMipaTexture = Assets.GetSprite("MipaTPoseFilled");
			s_FoundElements = true;
		}

		[HarmonyPostfix]
		[HarmonyPatch("Update")]
		public static void Update(HUDManager __instance)
		{
			if (!Object.op_Implicit((Object)(object)StartOfRound.Instance) || !Object.op_Implicit((Object)(object)StartOfRound.Instance.localPlayerController))
			{
				return;
			}
			bool flag = (Object)(object)((Component)StartOfRound.Instance.localPlayerController).GetComponent<MRMIPA_PLAYER_MODEL>() != (Object)null;
			if (m_LastIsMipa != flag)
			{
				m_LastIsMipa = flag;
				if (s_FoundElements)
				{
					((TMP_Text)s_SystemOnline).text = (flag ? "MIPA: ONLINE" : "SYSTEMS ONLINE");
					((TMP_Text)s_LifeSupportOffline).text = (flag ? "[SYSTEMS: SHUTDOWN]" : "[LIFE SUPPORT: OFFLINE]");
					((TMP_Text)s_CriticalInjury).text = (flag ? "CRITICAL DAMAGE" : "CRITICAL INJURY");
					s_SelfIndicator.sprite = (flag ? s_SelfIndicatorMipaTexture : s_SelfIndicatorOriginalTexture);
					s_SelfIndicatorFilled.sprite = (flag ? s_SelfIndicatorFilledMipaTexture : s_SelfIndicatorFilledOriginalTexture);
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}