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.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using Photon.Voice.Unity;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Networking;
using Zorro.Core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.EMOKaMi.Mimic")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.6.5.0")]
[assembly: AssemblyInformationalVersion("0.6.5")]
[assembly: AssemblyProduct("com.EMOKaMi.Mimic")]
[assembly: AssemblyTitle("Mimic")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.6.5.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace Mimic
{
[BepInPlugin("com.emokami.mimic", "Mimic Mod", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Log { get; private set; }
public static Plugin Instance { get; private set; }
private void Awake()
{
Instance = this;
Log = ((BaseUnityPlugin)this).Logger;
try
{
Harmony.CreateAndPatchAll(typeof(Plugin).Assembly, (string)null);
Log.LogInfo((object)"Mimic 1.0.0 - Final Release.");
PhotonNetwork.MaxResendsBeforeDisconnect = 20;
PhotonNetwork.SerializationRate = 20;
}
catch (Exception arg)
{
Log.LogError((object)$"Harmony Error: {arg}");
}
if (!Object.op_Implicit((Object)(object)((Component)this).gameObject.GetComponent<MimicManager>()))
{
((Component)this).gameObject.AddComponent<MimicManager>();
}
}
private void Update()
{
if (PhotonNetwork.IsMasterClient)
{
if (Input.GetKeyDown((KeyCode)292))
{
MimicManager.Instance?.ToggleSettings();
}
if (Input.GetKeyDown((KeyCode)290))
{
MimicManager.Instance?.SpawnMimic();
}
if (Input.GetKeyDown((KeyCode)289))
{
MimicManager.Instance?.TestPlayVoice();
}
}
if (Input.GetKeyDown((KeyCode)288))
{
MimicManager.Instance?.DebugPlayLastClip();
}
}
public static void SafeShake(GamefeelHandler handler, float amount, float duration, float scale, Component source)
{
if ((Object)(object)source != (Object)null)
{
if ((Object)(object)source.GetComponent<MimicController>() != (Object)null)
{
return;
}
Character component = source.GetComponent<Character>();
if (component != null && component.isBot)
{
return;
}
}
if ((Object)(object)handler != (Object)null)
{
handler.AddPerlinShake(amount, duration, scale);
}
}
}
public class MimicManager : MonoBehaviourPunCallbacks
{
public struct VoiceClip
{
public float[] samples;
public int sampleRate;
}
public static MimicManager Instance;
public Dictionary<int, List<VoiceClip>> VoiceDataBank = new Dictionary<int, List<VoiceClip>>();
public List<VoiceClip> CustomClips = new List<VoiceClip>();
public bool AutoSpawnEnabled = true;
public int MaxMimicCount = 2;
public int MaxClipsPerPlayer = 100;
public float MinSpawnTime = 30f;
public float MaxSpawnTime = 60f;
public float DespawnDistance = 80f;
public float TalkDistance = 12f;
public float MinTalkInterval = 5f;
public float MaxTalkInterval = 15f;
public float MinDisguiseTime = 60f;
public float MaxDisguiseTime = 180f;
private float nextSpawnTime;
private List<MimicController> activeMimics = new List<MimicController>();
private bool showSettings;
private Rect settingsRect = new Rect(50f, 50f, 300f, 650f);
public bool isCapturingLocal;
public AudioMixerGroup VoiceMixer;
private float[] lastRecordedClip;
private float[] localMicBuffer = new float[384000];
private float[] localPreBuffer = new float[9600];
private int localMicPtr;
private int localPrePtr;
private bool isRecordingLocal;
private float localSilenceTimer;
private void Awake()
{
Instance = this;
}
private void Start()
{
((MonoBehaviour)this).StartCoroutine(LoadCustomClips());
nextSpawnTime = Time.time + Random.Range(5f, 15f);
}
private void Update()
{
if (!PhotonNetwork.IsMasterClient || !AutoSpawnEnabled || (Object)(object)RunManager.Instance == (Object)null || RunManager.Instance.timeSinceRunStarted < 5f)
{
return;
}
activeMimics.RemoveAll((MimicController x) => (Object)(object)x == (Object)null);
if (Time.time > nextSpawnTime)
{
if (activeMimics.Count < MaxMimicCount)
{
AttemptAutoSpawn();
}
nextSpawnTime = Time.time + Random.Range(MinSpawnTime, MaxSpawnTime);
}
}
private void AttemptAutoSpawn()
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
Vector3? smartSpawnPosition = GetSmartSpawnPosition();
if (smartSpawnPosition.HasValue)
{
SpawnMimicAt(smartSpawnPosition.Value);
}
}
private Vector3? GetSmartSpawnPosition()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: 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_0093: 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_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//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_00de: 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)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: 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_0121: 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_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: 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_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
Player[] playerList = PhotonNetwork.PlayerList;
if (playerList.Length == 0)
{
return null;
}
List<Character> list = new List<Character>();
Vector3 val = Vector3.zero;
Player[] array = playerList;
foreach (Player val2 in array)
{
Character playerCharacter = PlayerHandler.GetPlayerCharacter(val2);
if ((Object)(object)playerCharacter != (Object)null && !playerCharacter.data.dead)
{
list.Add(playerCharacter);
val += playerCharacter.Center;
}
}
if (list.Count == 0)
{
return null;
}
val /= (float)list.Count;
RaycastHit val5 = default(RaycastHit);
for (int j = 0; j < 10; j++)
{
Vector2 insideUnitCircle = Random.insideUnitCircle;
Vector2 val3 = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(10f, 30f);
Vector3 val4 = val + new Vector3(val3.x, 10f, val3.y);
if (!Physics.Raycast(val4, Vector3.down, ref val5, 50f, LayerMask.op_Implicit(HelperFunctions.terrainMapMask)))
{
continue;
}
Vector3 point = ((RaycastHit)(ref val5)).point;
bool flag = false;
foreach (Character item in list)
{
Vector3 val6 = point - item.Head;
Vector3 normalized = ((Vector3)(ref val6)).normalized;
if (Vector3.Angle(((Component)item.refs.head).transform.forward, normalized) < 80f && !Physics.Linecast(item.Head, point + Vector3.up, LayerMask.op_Implicit(HelperFunctions.terrainMapMask)))
{
flag = true;
break;
}
}
if (!flag)
{
return point;
}
}
return val + Vector3.up * 25f;
}
public void SpawnMimic()
{
AttemptAutoSpawn();
}
public void SpawnMimicAt(Vector3 position)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
Player[] playerList = PhotonNetwork.PlayerList;
if (playerList.Length != 0)
{
int num = Random.Range(0, playerList.Length);
int actorNumber = playerList[num].ActorNumber;
GameObject val = PhotonNetwork.Instantiate("MushroomZombie_Player", position, Quaternion.identity, (byte)0, new object[3] { "Mimic", actorNumber, actorNumber });
if (Object.op_Implicit((Object)(object)val))
{
MimicController mimicController = val.GetComponent<MimicController>() ?? val.AddComponent<MimicController>();
mimicController.LookActorNumber = actorNumber;
mimicController.VoiceActorNumber = actorNumber;
val.GetComponent<PhotonView>().RPC("RPC_MimicArise", (RpcTarget)3, new object[3] { actorNumber, "A", actorNumber });
activeMimics.Add(mimicController);
}
}
}
private IEnumerator LoadCustomClips()
{
string path = Path.Combine(Paths.PluginPath, "Mimic", "CustomAudio");
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
yield break;
}
string[] array = (from f in Directory.GetFiles(path, "*.*", SearchOption.TopDirectoryOnly)
where f.EndsWith(".wav") || f.EndsWith(".mp3") || f.EndsWith(".ogg")
select f).ToArray();
string[] array2 = array;
foreach (string text in array2)
{
UnityWebRequest uwr = UnityWebRequestMultimedia.GetAudioClip("file://" + text, (AudioType)0);
try
{
yield return uwr.SendWebRequest();
if ((int)uwr.result != 1)
{
continue;
}
AudioClip content = DownloadHandlerAudioClip.GetContent(uwr);
if (!Object.op_Implicit((Object)(object)content))
{
continue;
}
float[] array3 = new float[content.samples * content.channels];
content.GetData(array3, 0);
if (content.channels > 1)
{
float[] array4 = new float[content.samples];
for (int j = 0; j < content.samples; j++)
{
float num = 0f;
for (int k = 0; k < content.channels; k++)
{
num += array3[j * content.channels + k];
}
array4[j] = num / (float)content.channels;
}
array3 = array4;
}
CustomClips.Add(new VoiceClip
{
samples = array3,
sampleRate = content.frequency
});
}
finally
{
((IDisposable)uwr)?.Dispose();
}
}
}
public void ProcessLocalMic(float[] data, int sampleRate, int channels)
{
isCapturingLocal = true;
int num = data.Length / channels;
float[] array = new float[num];
for (int i = 0; i < num; i++)
{
float num2 = 0f;
for (int j = 0; j < channels; j++)
{
num2 += data[i * channels + j];
}
array[i] = num2 / (float)channels;
}
float num3 = 0f;
for (int k = 0; k < num; k++)
{
num3 += array[k] * array[k];
}
float num4 = Mathf.Sqrt(num3 / (float)num);
if (!isRecordingLocal)
{
for (int l = 0; l < num; l++)
{
localPreBuffer[localPrePtr] = array[l];
localPrePtr = (localPrePtr + 1) % localPreBuffer.Length;
}
}
if (num4 > 0.02f)
{
if (!isRecordingLocal)
{
isRecordingLocal = true;
localMicPtr = 0;
for (int m = 0; m < localPreBuffer.Length; m++)
{
localMicBuffer[localMicPtr++] = localPreBuffer[(localPrePtr + m) % localPreBuffer.Length];
}
}
localSilenceTimer = 0f;
}
if (!isRecordingLocal)
{
return;
}
for (int n = 0; n < num; n++)
{
if (localMicPtr < localMicBuffer.Length)
{
localMicBuffer[localMicPtr++] = array[n];
}
}
if (num4 <= 0.02f)
{
localSilenceTimer += (float)num / (float)sampleRate;
}
else
{
localSilenceTimer = 0f;
}
if (localSilenceTimer > 1.5f || localMicPtr >= localMicBuffer.Length - 1024)
{
if ((float)localMicPtr > (float)sampleRate * 0.5f)
{
float[] array2 = new float[localMicPtr];
Array.Copy(localMicBuffer, 0, array2, 0, localMicPtr);
Player localPlayer = PhotonNetwork.LocalPlayer;
StoreClip((localPlayer != null) ? localPlayer.ActorNumber : (-1), array2, sampleRate);
}
isRecordingLocal = false;
localMicPtr = 0;
}
}
public void StoreClip(int actorNumber, float[] samples, int rate)
{
if (samples == null || (float)samples.Length < (float)rate * 0.4f)
{
return;
}
float num = 0f;
foreach (float num2 in samples)
{
float num3 = Mathf.Abs(num2);
if (num3 > num)
{
num = num3;
}
}
if (num > 0.01f)
{
float num4 = 0.95f / num;
for (int j = 0; j < samples.Length; j++)
{
samples[j] = Mathf.Clamp(samples[j] * num4, -1f, 1f);
}
}
Player localPlayer = PhotonNetwork.LocalPlayer;
if (actorNumber == ((localPlayer != null) ? localPlayer.ActorNumber : (-1)))
{
lastRecordedClip = samples;
}
if (!VoiceDataBank.ContainsKey(actorNumber))
{
VoiceDataBank[actorNumber] = new List<VoiceClip>();
}
VoiceDataBank[actorNumber].Add(new VoiceClip
{
samples = samples,
sampleRate = rate
});
if (VoiceDataBank[actorNumber].Count > MaxClipsPerPlayer)
{
VoiceDataBank[actorNumber].RemoveAt(0);
}
}
public void ToggleSettings()
{
showSettings = !showSettings;
Cursor.lockState = (CursorLockMode)((!showSettings) ? 1 : 0);
Cursor.visible = showSettings;
}
private void OnGUI()
{
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Expected O, but got Unknown
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
Player localPlayer = PhotonNetwork.LocalPlayer;
int num = ((localPlayer != null) ? localPlayer.ActorNumber : (-1));
int num2 = ((num != -1 && VoiceDataBank.ContainsKey(num)) ? VoiceDataBank[num].Count : 0);
string text = (isCapturingLocal ? "green" : "red");
GUI.Label(new Rect((float)(Screen.width - 400), 20f, 400f, 80f), string.Format("<color={0}>[Mimic v0.7.2]</color>\nClips: {1}\nCustom: {2}\nAutoSpawn: {3}", text, num2, CustomClips.Count, AutoSpawnEnabled ? "ON" : "OFF"));
if (showSettings)
{
settingsRect = GUI.Window(999004, settingsRect, new WindowFunction(SettingsWindow), "Mimic Config");
}
}
private void SettingsWindow(int id)
{
GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
AutoSpawnEnabled = GUILayout.Toggle(AutoSpawnEnabled, "Enable Auto Spawn", Array.Empty<GUILayoutOption>());
GUILayout.Label($"Max Mimics: {MaxMimicCount}", Array.Empty<GUILayoutOption>());
MaxMimicCount = (int)GUILayout.HorizontalSlider((float)MaxMimicCount, 1f, 10f, Array.Empty<GUILayoutOption>());
GUILayout.Label($"Max Clips Per Player: {MaxClipsPerPlayer}", Array.Empty<GUILayoutOption>());
MaxClipsPerPlayer = (int)GUILayout.HorizontalSlider((float)MaxClipsPerPlayer, 10f, 500f, Array.Empty<GUILayoutOption>());
GUILayout.Label($"Min Spawn Time (s): {MinSpawnTime:F0}", Array.Empty<GUILayoutOption>());
MinSpawnTime = GUILayout.HorizontalSlider(MinSpawnTime, 10f, 300f, Array.Empty<GUILayoutOption>());
GUILayout.Label($"Max Spawn Time (s): {MaxSpawnTime:F0}", Array.Empty<GUILayoutOption>());
MaxSpawnTime = GUILayout.HorizontalSlider(MaxSpawnTime, MinSpawnTime, 600f, Array.Empty<GUILayoutOption>());
GUILayout.Label($"Despawn Distance (m): {DespawnDistance:F0}", Array.Empty<GUILayoutOption>());
DespawnDistance = GUILayout.HorizontalSlider(DespawnDistance, 30f, 200f, Array.Empty<GUILayoutOption>());
GUILayout.Space(5f);
GUILayout.Label($"Voice Trigger Distance: {TalkDistance:F0}m", Array.Empty<GUILayoutOption>());
TalkDistance = GUILayout.HorizontalSlider(TalkDistance, 5f, 50f, Array.Empty<GUILayoutOption>());
GUILayout.Label($"Min Talk Interval: {MinTalkInterval:F1}s", Array.Empty<GUILayoutOption>());
MinTalkInterval = GUILayout.HorizontalSlider(MinTalkInterval, 1f, 30f, Array.Empty<GUILayoutOption>());
GUILayout.Label($"Max Talk Interval: {MaxTalkInterval:F1}s", Array.Empty<GUILayoutOption>());
MaxTalkInterval = GUILayout.HorizontalSlider(MaxTalkInterval, MinTalkInterval, 60f, Array.Empty<GUILayoutOption>());
GUILayout.Space(5f);
GUILayout.Label($"Min Disguise Time: {MinDisguiseTime:F0}s", Array.Empty<GUILayoutOption>());
MinDisguiseTime = GUILayout.HorizontalSlider(MinDisguiseTime, 10f, 600f, Array.Empty<GUILayoutOption>());
GUILayout.Label($"Max Disguise Time: {MaxDisguiseTime:F0}s", Array.Empty<GUILayoutOption>());
MaxDisguiseTime = GUILayout.HorizontalSlider(MaxDisguiseTime, MinDisguiseTime, 1200f, Array.Empty<GUILayoutOption>());
if (GUILayout.Button("Close", Array.Empty<GUILayoutOption>()))
{
ToggleSettings();
}
GUILayout.EndVertical();
GUI.DragWindow();
}
public void TestPlayVoice()
{
if (VoiceDataBank.Count == 0 && CustomClips.Count == 0)
{
return;
}
int actorNumber = -1;
if (CustomClips.Count > 0 && Random.value < 0.3f)
{
actorNumber = -999;
}
else if (VoiceDataBank.Count > 0)
{
actorNumber = VoiceDataBank.Keys.ElementAt(Random.Range(0, VoiceDataBank.Count));
}
foreach (MimicController activeMimic in activeMimics)
{
if (Object.op_Implicit((Object)(object)activeMimic))
{
activeMimic.PrepareAndSendVoice(actorNumber);
}
}
}
public void DebugPlayLastClip()
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Expected O, but got Unknown
if (lastRecordedClip != null && lastRecordedClip.Length != 0)
{
GameObject val = new GameObject("ReplaySource");
AudioSource val2 = val.AddComponent<AudioSource>();
AudioClip val3 = AudioClip.Create("Replay", lastRecordedClip.Length, 1, AudioSettings.outputSampleRate, false);
val3.SetData(lastRecordedClip, 0);
val2.clip = val3;
val2.Play();
Object.Destroy((Object)(object)val, 10f);
}
}
}
public class MimicController : MonoBehaviourPun, IPunObservable
{
public int LookActorNumber;
public int VoiceActorNumber;
public Character character;
public MushroomZombie zombieAI;
public AudioSource voiceSource;
public bool isHostile;
private float attackTimer;
private float talkCooldown;
private Character? currentFollowTarget;
private Vector3 currentNavTarget;
private float collisionPauseTimer;
private float nextRandomPointTime;
private int visualForceCounter;
private AnimatedMouth cachedMouth;
public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info)
{
//IL_00e2: 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_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
if (stream.IsWriting)
{
stream.SendNext((object)LookActorNumber);
stream.SendNext((object)VoiceActorNumber);
stream.SendNext((object)isHostile);
stream.SendNext((object)character.input.movementInput);
stream.SendNext((object)character.input.sprintIsPressed);
stream.SendNext((object)character.data.lookValues);
return;
}
int lookActorNumber = LookActorNumber;
bool flag = isHostile;
LookActorNumber = (int)stream.ReceiveNext();
VoiceActorNumber = (int)stream.ReceiveNext();
isHostile = (bool)stream.ReceiveNext();
character.input.movementInput = (Vector2)stream.ReceiveNext();
character.input.sprintIsPressed = (bool)stream.ReceiveNext();
character.data.lookValues = (Vector2)stream.ReceiveNext();
if (lookActorNumber != LookActorNumber || flag != isHostile)
{
ApplyIdentity();
}
}
private void Awake()
{
character = ((Component)this).GetComponent<Character>();
character.isBot = true;
zombieAI = ((Component)this).GetComponent<MushroomZombie>();
voiceSource = ((Component)this).gameObject.GetComponent<AudioSource>() ?? ((Component)this).gameObject.AddComponent<AudioSource>();
voiceSource.spatialBlend = 1f;
voiceSource.minDistance = 5f;
voiceSource.maxDistance = 55f;
voiceSource.playOnAwake = false;
voiceSource.dopplerLevel = 0f;
voiceSource.loop = false;
if ((Object)(object)MimicManager.Instance?.VoiceMixer != (Object)null)
{
voiceSource.outputAudioMixerGroup = MimicManager.Instance.VoiceMixer;
}
cachedMouth = ((Component)this).GetComponentInChildren<AnimatedMouth>();
if (Object.op_Implicit((Object)(object)cachedMouth))
{
((Behaviour)cachedMouth).enabled = false;
cachedMouth.mouthRenderer.material.SetInt("_UseTalkSprites", 0);
}
if ((Object)(object)((MonoBehaviourPun)this).photonView != (Object)null && !((MonoBehaviourPun)this).photonView.ObservedComponents.Contains((Component)(object)this))
{
((MonoBehaviourPun)this).photonView.ObservedComponents.Add((Component)(object)this);
}
}
[PunRPC]
public void RPC_MimicArise(int lookID, string type, int voiceID)
{
LookActorNumber = lookID;
VoiceActorNumber = voiceID;
isHostile = false;
if (Object.op_Implicit((Object)(object)character))
{
character.isZombie = false;
character.isBot = true;
character.data.passedOut = false;
}
if (Object.op_Implicit((Object)(object)zombieAI))
{
zombieAI.currentState = (State)2;
((Behaviour)zombieAI).enabled = false;
}
ApplyIdentity();
if (PhotonNetwork.IsMasterClient)
{
attackTimer = Time.time + Random.Range(MimicManager.Instance.MinDisguiseTime, MimicManager.Instance.MaxDisguiseTime);
PickNewTarget();
talkCooldown = Time.time + 2f;
}
}
[PunRPC]
public void RPC_MimicDirectTalk(byte[] rawData, int rate)
{
if (rawData != null && rawData.Length != 0)
{
int num = rawData.Length / 2;
float[] array = new float[num];
for (int i = 0; i < num; i++)
{
short num2 = (short)(rawData[i * 2] | (rawData[i * 2 + 1] << 8));
array[i] = (float)num2 / 32768f;
}
AudioClip val = AudioClip.Create("MimicVoice", array.Length, 1, rate, false);
val.SetData(array, 0);
voiceSource.pitch = 1f;
voiceSource.clip = val;
voiceSource.Play();
}
}
[PunRPC]
public void RPC_PlayTransitionVFX()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
GameUtils.instance.RPC_SpawnResourceAtPosition("VFX_SporeExploExploEdibleSpawn_NoKnockback", character.Center);
}
public void ApplyIdentity()
{
if (((Component)this).gameObject.activeInHierarchy)
{
((MonoBehaviour)this).StartCoroutine(SyncAppearanceRoutine());
}
}
private IEnumerator SyncAppearanceRoutine()
{
for (int attempt = 0; attempt < 15; attempt++)
{
Player player = PhotonNetwork.CurrentRoom.GetPlayer(LookActorNumber, false);
if (player != null)
{
PersistentPlayerData playerData = GameHandler.GetService<PersistentPlayerDataService>().GetPlayerData(player);
CharacterCustomization val = character?.refs.customization;
if ((Object)(object)val != (Object)null && playerData != null)
{
character.isZombie = isHostile;
val.isDead = false;
val.isPassedOut = false;
AccessTools.Method(typeof(CharacterCustomization), "OnPlayerDataChange", (Type[])null, (Type[])null)?.Invoke(val, new object[1] { playerData });
val.overridePhotonPlayer = player;
Character playerCharacter = PlayerHandler.GetPlayerCharacter(player);
Texture val2 = null;
if ((Object)(object)playerCharacter != (Object)null && (Object)(object)playerCharacter.refs.customization != (Object)null)
{
object? obj = AccessTools.Field(typeof(CharacterCustomization), "CurrentEyeTexture")?.GetValue(playerCharacter.refs.customization);
val2 = (Texture)((obj is Texture) ? obj : null);
}
if ((Object)(object)val2 == (Object)null)
{
val2 = Singleton<Customization>.Instance.eyes[CharacterCustomization.GetEyesIndex(playerData)].texture;
}
if (val.refs.EyeRenderers != null)
{
Renderer[] eyeRenderers = val.refs.EyeRenderers;
foreach (Renderer val3 in eyeRenderers)
{
if (Object.op_Implicit((Object)(object)val3))
{
val3.material.SetTexture(CharacterCustomization.MainTex, val2);
val3.material.SetInt("_Spin", 0);
}
}
}
AccessTools.Field(typeof(CharacterCustomization), "CurrentEyeTexture")?.SetValue(val, val2);
if (Object.op_Implicit((Object)(object)zombieAI) && zombieAI.mushroomVisuals != null)
{
foreach (GameObject mushroomVisual in zombieAI.mushroomVisuals)
{
if (Object.op_Implicit((Object)(object)mushroomVisual))
{
mushroomVisual.SetActive(isHostile);
}
}
}
val.ShowAllRenderers();
break;
}
}
yield return (object)new WaitForSeconds(1f);
}
}
private void Update()
{
//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
//IL_0585: Unknown result type (might be due to invalid IL or missing references)
//IL_058a: Unknown result type (might be due to invalid IL or missing references)
//IL_05ef: Unknown result type (might be due to invalid IL or missing references)
//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
//IL_045f: Unknown result type (might be due to invalid IL or missing references)
//IL_0464: Unknown result type (might be due to invalid IL or missing references)
//IL_0468: Unknown result type (might be due to invalid IL or missing references)
//IL_047c: Unknown result type (might be due to invalid IL or missing references)
//IL_0481: Unknown result type (might be due to invalid IL or missing references)
//IL_048a: Unknown result type (might be due to invalid IL or missing references)
//IL_048f: Unknown result type (might be due to invalid IL or missing references)
//IL_049b: Unknown result type (might be due to invalid IL or missing references)
//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
//IL_056e: Unknown result type (might be due to invalid IL or missing references)
//IL_0555: Unknown result type (might be due to invalid IL or missing references)
//IL_055a: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)character))
{
character.isZombie = isHostile;
character.data.passedOut = false;
character.data.fallSeconds = 0f;
}
if (!isHostile)
{
visualForceCounter++;
if (visualForceCounter % 20 == 0)
{
CharacterCustomization val = character?.refs.customization;
if ((Object)(object)val != (Object)null)
{
val.isDead = false;
val.isPassedOut = false;
object? obj = AccessTools.Field(typeof(CharacterCustomization), "CurrentEyeTexture")?.GetValue(val);
Texture val2 = (Texture)((obj is Texture) ? obj : null);
if ((Object)(object)val2 != (Object)null && val.refs.EyeRenderers != null)
{
Renderer[] eyeRenderers = val.refs.EyeRenderers;
foreach (Renderer val3 in eyeRenderers)
{
if (Object.op_Implicit((Object)(object)val3) && (Object)(object)val3.material.GetTexture(CharacterCustomization.MainTex) != (Object)(object)val2)
{
val3.material.SetTexture(CharacterCustomization.MainTex, val2);
}
}
}
if (Object.op_Implicit((Object)(object)zombieAI) && zombieAI.mushroomVisuals != null)
{
foreach (GameObject mushroomVisual in zombieAI.mushroomVisuals)
{
if (Object.op_Implicit((Object)(object)mushroomVisual) && mushroomVisual.activeSelf)
{
mushroomVisual.SetActive(false);
}
}
}
}
}
}
else
{
if (Object.op_Implicit((Object)(object)zombieAI) && !((Behaviour)zombieAI).enabled)
{
((Behaviour)zombieAI).enabled = true;
zombieAI.currentState = (State)3;
}
if (Object.op_Implicit((Object)(object)zombieAI) && zombieAI.mushroomVisuals != null)
{
foreach (GameObject mushroomVisual2 in zombieAI.mushroomVisuals)
{
if (Object.op_Implicit((Object)(object)mushroomVisual2) && !mushroomVisual2.activeSelf)
{
mushroomVisual2.SetActive(true);
}
}
}
}
if (Object.op_Implicit((Object)(object)cachedMouth))
{
if (voiceSource.isPlaying)
{
cachedMouth.mouthRenderer.material.SetInt("_UseTalkSprites", 1);
float[] array = new float[256];
voiceSource.GetOutputData(array, 0);
float num = 0f;
for (int j = 0; j < array.Length; j++)
{
num += array[j] * array[j];
}
float num2 = Mathf.Sqrt(num / (float)array.Length);
int num3 = cachedMouth.mouthTextures.Length;
int num4 = Mathf.Clamp((int)(num2 * 50f), 0, num3 - 1);
if (!isHostile && num4 >= num3 - 1)
{
num4 = num3 - 2;
}
cachedMouth.mouthRenderer.material.SetTexture("_TalkSprite", (Texture)(object)cachedMouth.mouthTextures[num4]);
}
else
{
cachedMouth.mouthRenderer.material.SetInt("_UseTalkSprites", 0);
}
}
if (!PhotonNetwork.IsMasterClient)
{
return;
}
if (Object.op_Implicit((Object)(object)character) && (Object)(object)character.input != (Object)null)
{
character.input.ResetInput();
}
if ((Object)(object)voiceSource != (Object)null)
{
voiceSource.pitch = 1f;
}
bool flag = false;
Player[] playerList = PhotonNetwork.PlayerList;
foreach (Player val4 in playerList)
{
Character playerCharacter = PlayerHandler.GetPlayerCharacter(val4);
if ((Object)(object)playerCharacter != (Object)null && Vector3.Distance(character.Center, playerCharacter.Center) < MimicManager.Instance.DespawnDistance)
{
flag = true;
break;
}
}
if (!flag)
{
PhotonNetwork.Destroy(((Component)this).gameObject);
return;
}
if (!isHostile)
{
if ((Object)(object)currentFollowTarget == (Object)null || currentFollowTarget.data.dead)
{
PickNewTarget();
}
if ((Object)(object)currentFollowTarget != (Object)null)
{
if (Time.time > nextRandomPointTime)
{
Vector2 insideUnitCircle = Random.insideUnitCircle;
Vector2 val5 = ((Vector2)(ref insideUnitCircle)).normalized * Random.Range(2f, 6f);
currentNavTarget = currentFollowTarget.Center + new Vector3(val5.x, 0f, val5.y);
nextRandomPointTime = Time.time + Random.Range(3f, 6f);
}
RaycastHit val6 = default(RaycastHit);
if (Physics.Raycast(character.Head, ((Component)character.refs.head).transform.forward, ref val6, 1f))
{
Character componentInParent = ((Component)((RaycastHit)(ref val6)).collider).GetComponentInParent<Character>();
if ((Object)(object)componentInParent != (Object)null && !componentInParent.isBot && (Object)(object)componentInParent != (Object)(object)character)
{
collisionPauseTimer = Time.time + Random.Range(1f, 3f);
character.input.movementInput = Vector2.zero;
}
}
if (Time.time > collisionPauseTimer)
{
SmartWalkTowards(currentNavTarget);
}
}
else
{
character.input.movementInput = Vector2.zero;
}
if (Time.time > attackTimer)
{
TurnHostile();
}
}
else
{
Character closestPlayer = GetClosestPlayer();
if ((Object)(object)closestPlayer != (Object)null)
{
zombieAI.currentTarget = closestPlayer;
}
}
if (Time.time > talkCooldown && (isHostile || ((Object)(object)GetClosestPlayer() != (Object)null && Vector3.Distance(character.Center, GetClosestPlayer().Center) < MimicManager.Instance.TalkDistance)))
{
PrepareAndSendVoice(VoiceActorNumber);
talkCooldown = Time.time + (isHostile ? Random.Range(2f, 5f) : Random.Range(MimicManager.Instance.MinTalkInterval, MimicManager.Instance.MaxTalkInterval));
}
}
private void SmartWalkTowards(Vector3 targetPos)
{
//IL_0000: 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_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: 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_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: 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)
//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)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: 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)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: 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_009a: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = targetPos - character.Center;
Vector3 normalized = ((Vector3)(ref val)).normalized;
normalized.y = 0f;
if (normalized != Vector3.zero)
{
Vector2 val2 = Vector2.op_Implicit(HelperFunctions.DirectionToLook(normalized));
character.data.lookValues = Vector2.MoveTowards(character.data.lookValues, val2, Time.deltaTime * 360f);
}
float num = Vector3.Distance(character.Center, targetPos);
if (num < 1.5f)
{
character.input.movementInput = Vector2.zero;
return;
}
character.input.movementInput = new Vector2(0f, 1f);
character.input.sprintIsPressed = num > 15f;
if (num > 3f)
{
character.refs.climbing.TryClimb(1f);
}
}
private void PickNewTarget()
{
List<Character> list = (from p in PhotonNetwork.PlayerList
select PlayerHandler.GetPlayerCharacter(p) into c
where (Object)(object)c != (Object)null && !c.data.dead && !c.isBot
select c).ToList();
if (list.Count == 0)
{
currentFollowTarget = null;
return;
}
List<Character> list2 = list.Where((Character c) => ((MonoBehaviourPun)c).photonView.OwnerActorNr != LookActorNumber).ToList();
currentFollowTarget = ((list2.Count > 0) ? list2[Random.Range(0, list2.Count)] : list[Random.Range(0, list.Count)]);
}
private Character GetClosestPlayer()
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
Character result = null;
float num = float.MaxValue;
Player[] playerList = PhotonNetwork.PlayerList;
foreach (Player val in playerList)
{
Character playerCharacter = PlayerHandler.GetPlayerCharacter(val);
if ((Object)(object)playerCharacter != (Object)null && !playerCharacter.data.dead && !playerCharacter.isBot)
{
float num2 = Vector3.Distance(character.Center, playerCharacter.Center);
if (num2 < num)
{
num = num2;
result = playerCharacter;
}
}
}
return result;
}
public void PrepareAndSendVoice(int actorNumber)
{
if (!PhotonNetwork.IsMasterClient || ((Object)(object)character != (Object)null && character.data.dead))
{
return;
}
MimicManager.VoiceClip voiceClip = default(MimicManager.VoiceClip);
bool flag = false;
List<MimicManager.VoiceClip> value;
if (actorNumber == -999)
{
if (MimicManager.Instance.CustomClips.Count > 0)
{
voiceClip = MimicManager.Instance.CustomClips[Random.Range(0, MimicManager.Instance.CustomClips.Count)];
flag = true;
}
}
else if (MimicManager.Instance.VoiceDataBank.TryGetValue(actorNumber, out value) && value.Count > 0)
{
voiceClip = value[Random.Range(0, value.Count)];
flag = true;
}
if (flag)
{
int num = 12000;
float num2 = (float)voiceClip.sampleRate / (float)num;
int num3 = (int)((float)num * 3.5f);
int num4 = Mathf.Min(num3, (int)((float)voiceClip.samples.Length / num2));
byte[] array = new byte[num4 * 2];
for (int i = 0; i < num4; i++)
{
float num5 = voiceClip.samples[(int)((float)i * num2)];
short num6 = (short)Mathf.Clamp(num5 * 32767f, -32768f, 32767f);
array[i * 2] = (byte)((uint)num6 & 0xFFu);
array[i * 2 + 1] = (byte)((uint)(num6 >> 8) & 0xFFu);
}
((MonoBehaviourPun)this).photonView.RPC("RPC_MimicDirectTalk", (RpcTarget)0, new object[2] { array, num });
}
}
private void TurnHostile()
{
if (isHostile)
{
return;
}
isHostile = true;
if (Object.op_Implicit((Object)(object)character))
{
character.isZombie = true;
character.data.passedOut = false;
}
if (Object.op_Implicit((Object)(object)zombieAI))
{
((Behaviour)zombieAI).enabled = true;
zombieAI.currentState = (State)3;
if (zombieAI.mushroomVisuals != null)
{
foreach (GameObject mushroomVisual in zombieAI.mushroomVisuals)
{
if (Object.op_Implicit((Object)(object)mushroomVisual))
{
mushroomVisual.SetActive(true);
}
}
}
}
((MonoBehaviourPun)this).photonView.RPC("RPC_PlayTransitionVFX", (RpcTarget)0, Array.Empty<object>());
character.refs.customization.ShowAllRenderers();
}
}
public class VoiceSampler : MonoBehaviour
{
public int ActorID;
private float[] buffer = new float[480000];
private float[] preBuffer = new float[12000];
private int ptr;
private int prePtr;
private bool recording;
private float silence;
private int rate;
private void Start()
{
rate = AudioSettings.outputSampleRate;
}
private void OnAudioFilterRead(float[] data, int channels)
{
if ((Object)(object)MimicManager.Instance == (Object)null)
{
return;
}
int num = data.Length / channels;
if (!recording)
{
for (int i = 0; i < data.Length; i += channels)
{
float num2 = 0f;
for (int j = 0; j < channels; j++)
{
num2 += data[i + j];
}
preBuffer[prePtr] = num2 / (float)channels;
prePtr = (prePtr + 1) % preBuffer.Length;
}
}
float num3 = 0f;
for (int k = 0; k < data.Length; k++)
{
num3 += data[k] * data[k];
}
float num4 = Mathf.Sqrt(num3 / (float)data.Length);
if (num4 > 0.02f)
{
if (!recording)
{
recording = true;
ptr = 0;
for (int l = 0; l < preBuffer.Length; l++)
{
buffer[ptr++] = preBuffer[(prePtr + l) % preBuffer.Length];
}
}
silence = 0f;
}
if (!recording)
{
return;
}
for (int m = 0; m < data.Length; m += channels)
{
float num5 = 0f;
for (int n = 0; n < channels; n++)
{
num5 += data[m + n];
}
if (ptr < buffer.Length)
{
buffer[ptr++] = num5 / (float)channels;
}
}
if (num4 <= 0.02f)
{
silence += (float)num / (float)rate;
}
else
{
silence = 0f;
}
if (silence > 1.5f || ptr >= buffer.Length - 2048)
{
if ((float)ptr > (float)rate * 0.5f)
{
float[] array = new float[ptr];
Array.Copy(buffer, 0, array, 0, ptr);
MimicManager.Instance.StoreClip(ActorID, array, rate);
}
recording = false;
ptr = 0;
}
}
}
[HarmonyPatch(typeof(UIPlayerNames), "UpdateName")]
public static class Global_Hide_Names_Patch
{
public static bool Prefix()
{
return false;
}
}
[HarmonyPatch(typeof(MicWrapper), "Read")]
public static class Mic_Hook
{
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Expected O, but got Unknown
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Expected O, but got Unknown
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Expected O, but got Unknown
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected O, but got Unknown
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Expected O, but got Unknown
//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
MethodInfo methodInfo = AccessTools.Method(typeof(MicrophoneRelay), "SendMic", (Type[])null, (Type[])null);
for (int i = 0; i < list.Count; i++)
{
if (CodeInstructionExtensions.Calls(list[i], methodInfo))
{
List<CodeInstruction> list2 = new List<CodeInstruction>();
list2.Add(new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(MimicManager), "Instance")));
list2.Add(new CodeInstruction(OpCodes.Ldarg_1, (object)null));
list2.Add(new CodeInstruction(OpCodes.Ldarg_0, (object)null));
list2.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(MicWrapper), "SamplingRate")));
list2.Add(new CodeInstruction(OpCodes.Ldarg_0, (object)null));
list2.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.PropertyGetter(typeof(MicWrapper), "Channels")));
list2.Add(new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MimicManager), "ProcessLocalMic", (Type[])null, (Type[])null)));
list.InsertRange(i, list2);
break;
}
}
return list;
}
}
[HarmonyPatch(typeof(MushroomZombie))]
public static class Global_Zombie_Override
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
public static void Awake_Postfix(MushroomZombie __instance)
{
object[] instantiationData = ((MonoBehaviourPun)__instance).photonView.InstantiationData;
if (instantiationData != null && instantiationData.Length != 0 && instantiationData[0] as string == "Mimic")
{
MimicController mimicController = ((Component)__instance).gameObject.GetComponent<MimicController>() ?? ((Component)__instance).gameObject.AddComponent<MimicController>();
if (instantiationData.Length >= 2)
{
mimicController.LookActorNumber = (int)instantiationData[1];
}
if (instantiationData.Length >= 3)
{
mimicController.VoiceActorNumber = (int)instantiationData[2];
}
mimicController.ApplyIdentity();
}
}
[HarmonyPatch("Update")]
[HarmonyPrefix]
public static bool Update_Prefix(MushroomZombie __instance)
{
if ((Object)(object)((Component)__instance).GetComponent<MimicController>() != (Object)null)
{
MimicController component = ((Component)__instance).GetComponent<MimicController>();
if (!component.isHostile)
{
__instance.character.data.passedOut = false;
__instance.character.data.fallSeconds = 0f;
return false;
}
}
return true;
}
}
[HarmonyPatch(typeof(CharacterClimbing))]
public static class No_Mimic_Climb_Shake
{
[HarmonyPatch("Update")]
[HarmonyPatch("RPCA_ClimbJump")]
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
MethodInfo methodInfo = AccessTools.Method(typeof(GamefeelHandler), "AddPerlinShake", (Type[])null, (Type[])null);
MethodInfo operand = AccessTools.Method(typeof(Plugin), "SafeShake", (Type[])null, (Type[])null);
for (int i = 0; i < list.Count; i++)
{
if (CodeInstructionExtensions.Calls(list[i], methodInfo))
{
list.Insert(i, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
list[i + 1].operand = operand;
i++;
}
}
return list;
}
}
[HarmonyPatch(typeof(CharacterMovement), "RaycastGroundCheck")]
public static class No_Mimic_Landing_Shake
{
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
MethodInfo methodInfo = AccessTools.Method(typeof(GamefeelHandler), "AddPerlinShake", (Type[])null, (Type[])null);
MethodInfo operand = AccessTools.Method(typeof(Plugin), "SafeShake", (Type[])null, (Type[])null);
for (int i = 0; i < list.Count; i++)
{
if (CodeInstructionExtensions.Calls(list[i], methodInfo))
{
list.Insert(i, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
list[i + 1].operand = operand;
i++;
}
}
return list;
}
}
[HarmonyPatch(typeof(Character), "RPCA_FallWithScreenShake")]
public static class No_Mimic_Fall_Shake
{
[HarmonyTranspiler]
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Expected O, but got Unknown
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
MethodInfo methodInfo = AccessTools.Method(typeof(GamefeelHandler), "AddPerlinShake", (Type[])null, (Type[])null);
MethodInfo operand = AccessTools.Method(typeof(Plugin), "SafeShake", (Type[])null, (Type[])null);
for (int i = 0; i < list.Count; i++)
{
if (CodeInstructionExtensions.Calls(list[i], methodInfo))
{
list.Insert(i, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
list[i + 1].operand = operand;
i++;
}
}
return list;
}
}
[HarmonyPatch(typeof(CharacterVoiceHandler), "Start")]
public static class Voice_Injection_Patch
{
public static void Postfix(CharacterVoiceHandler __instance)
{
Character componentInParent = ((Component)__instance).gameObject.GetComponentInParent<Character>();
if (!((Object)(object)componentInParent != (Object)null) || !componentInParent.isBot)
{
if ((Object)(object)((Component)__instance).GetComponent<AudioSource>() != (Object)null && (Object)(object)MimicManager.Instance != (Object)null)
{
MimicManager.Instance.VoiceMixer = ((Component)__instance).GetComponent<AudioSource>().outputAudioMixerGroup;
}
VoiceSampler voiceSampler = ((Component)__instance).gameObject.AddComponent<VoiceSampler>();
voiceSampler.ActorID = ((MonoBehaviourPun)componentInParent).photonView.OwnerActorNr;
}
}
}
[HarmonyPatch(typeof(RunManager), "StartRun")]
public static class Run_Start_Patch
{
public static void Postfix()
{
MimicManager.Instance?.VoiceDataBank.Clear();
}
}
[HarmonyPatch(typeof(MushroomZombie), "RPC_PlaySFX")]
public static class Silence_Disguised_Zombie
{
public static bool Prefix(MushroomZombie __instance)
{
MimicController component = ((Component)__instance).GetComponent<MimicController>();
if ((Object)(object)component != (Object)null && !component.isHostile)
{
return false;
}
return true;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}