using System;
using System.Collections;
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 BepInEx.Logging;
using Dissonance;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModelReplacement;
using ModelReplacement.AvatarBodyUpdater;
using RuntimeNetcodeRPCValidator;
using TerminalApi;
using TerminalApi.Classes;
using Unity.Netcode;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("SealModelReplacement")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SealModelReplacement")]
[assembly: AssemblyTitle("SealModelReplacement")]
[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;
}
}
}
namespace SealModelReplacement
{
public class MRSAMSEAL_NEW : BodyReplacementBase
{
[Serializable]
public class RestPair
{
public Transform key;
public Quaternion value;
}
[Serializable]
public class TransformPair
{
public Transform key;
public Transform value;
public Quaternion offset;
public bool copyTransform;
public Quaternion rest = Quaternion.identity;
}
private int[] usedBlendShapes = new int[12]
{
23, 29, 41, 42, 43, 44, 46, 47, 49, 50,
58, 110
};
private int danceNumber = 0;
private int previousDanceNumber = 0;
private PlayerMicVolume playerMicVolume;
private SkinnedMeshRenderer sealBody;
internal GameObject sealArms;
private List<TransformPair> pairedTransforms = new List<TransformPair>();
private List<RestPair> defaultRotations = new List<RestPair>();
internal string hoodieColor = "white";
private float armAnimBlend = 0.1f;
private bool wasJump = false;
protected override void Awake()
{
//IL_00d5: 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)
((BodyReplacementBase)this).Awake();
if ((Object)(object)Plugin.localController != (Object)null && ((BodyReplacementBase)this).controller.playerClientId == Plugin.localController.playerClientId)
{
Plugin.localReplacement = this;
}
playerMicVolume = base.replacementModel.AddComponent<PlayerMicVolume>();
playerMicVolume.controller = ((BodyReplacementBase)this).controller;
sealBody = ((Component)base.replacementModel.transform.Find("Body")).GetComponent<SkinnedMeshRenderer>();
Transform[] componentsInChildren = base.replacementModel.GetComponentsInChildren<Transform>();
foreach (Transform val in componentsInChildren)
{
if (((Object)val).name.Contains("upper_arm"))
{
Plugin.PluginLogger.LogInfo((object)((Object)val).name);
defaultRotations.Add(new RestPair
{
key = val,
value = val.localRotation
});
}
}
if ((Object)(object)Plugin.localController != (Object)null && ((BodyReplacementBase)this).controller.playerClientId == Plugin.localController.playerClientId)
{
enableArms();
}
}
protected override void OnDestroy()
{
((BodyReplacementBase)this).OnDestroy();
Object.Destroy((Object)(object)sealArms);
sealArms = null;
((Component)((BodyReplacementBase)this).controller.thisPlayerModelArms).gameObject.SetActive(true);
}
internal void enableArms()
{
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_009f: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
((Component)((BodyReplacementBase)this).controller.thisPlayerModelArms).gameObject.SetActive(false);
sealArms = Object.Instantiate<GameObject>(LoadArmAsset());
sealArms.transform.parent = ((Component)((BodyReplacementBase)this).controller.thisPlayerModelArms).transform.parent.FindChild("metarig");
sealArms.transform.localPosition = Vector3.zero;
sealArms.transform.localScale = Vector3.one;
sealArms.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
((Renderer)((Component)sealArms.transform.Find("HoodieArms")).GetComponent<SkinnedMeshRenderer>()).material = ((Renderer)((Component)base.replacementModel.transform.Find("Hoodie")).GetComponent<SkinnedMeshRenderer>()).material;
Transform[] componentsInChildren = ((Component)((Component)((BodyReplacementBase)this).controller.thisPlayerModelArms).transform.parent).GetComponentsInChildren<Transform>();
RotationOffset[] componentsInChildren2 = sealArms.GetComponentsInChildren<RotationOffset>();
foreach (RotationOffset val in componentsInChildren2)
{
Transform[] array = componentsInChildren;
foreach (Transform val2 in array)
{
if (((Object)((Component)val2).gameObject).name == ((Object)((Component)val).gameObject).name)
{
if (((Object)((Component)val2).gameObject).name.Contains("finger"))
{
pairedTransforms.Add(new TransformPair
{
key = ((Component)val).transform,
value = val2,
offset = val.offset,
copyTransform = false,
rest = ((Component)val).transform.localRotation
});
}
else
{
pairedTransforms.Add(new TransformPair
{
key = ((Component)val).transform,
value = val2,
offset = val.offset,
copyTransform = true
});
}
break;
}
}
}
}
protected override GameObject LoadAssetsAndReturnModel()
{
string text = "SamSeal_LC";
return Assets.MainAssetBundle.LoadAsset<GameObject>(text);
}
private GameObject LoadArmAsset()
{
return Assets.MainAssetBundle.LoadAsset<GameObject>("SamArmsOnlyTake2");
}
private void ChangeExpression(Dictionary<int, float> blendShapes)
{
int[] array = usedBlendShapes;
foreach (int num in array)
{
if (!blendShapes.ContainsKey(num))
{
((MonoBehaviour)this).StartCoroutine(FadeToBlendShape(num, 0f, sealBody));
}
}
foreach (KeyValuePair<int, float> blendShape in blendShapes)
{
((MonoBehaviour)this).StartCoroutine(FadeToBlendShape(blendShape.Key, blendShape.Value, sealBody));
}
}
protected override void OnDeath()
{
//IL_0060: 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)
SkinnedMeshRenderer component = ((Component)base.replacementDeadBody.transform.Find("Body")).GetComponent<SkinnedMeshRenderer>();
component.SetBlendShapeWeight(45, 47.5f);
component.SetBlendShapeWeight(52, 59.4f);
component.SetBlendShapeWeight(102, 39.1f);
((Renderer)component).materials[0].SetColor("_EmissiveColor", ((Renderer)component).materials[0].GetColor("_EmissiveColor") * new Color(0.24f, 0.24f, 0.24f, 1f));
((Component)base.replacementDeadBody.transform.Find("Armature").Find("hips").Find("TailFloorCollider")).gameObject.SetActive(false);
}
protected void OnEmoteChange(int emoteId)
{
switch (emoteId)
{
case 1:
ChangeExpression(new Dictionary<int, float>
{
{ 47, 100f },
{ 50, 100f }
});
break;
case 2:
ChangeExpression(new Dictionary<int, float> { { 43, 31.9f } });
break;
case 3:
ChangeExpression(new Dictionary<int, float>
{
{ 29, 50.2f },
{ 110, 70.9f }
});
break;
case 4:
ChangeExpression(new Dictionary<int, float> { { 46, 87.6f } });
break;
case 5:
ChangeExpression(new Dictionary<int, float> { { 41, 34.6f } });
break;
case 6:
ChangeExpression(new Dictionary<int, float> { { 50, 100f } });
break;
case 7:
ChangeExpression(new Dictionary<int, float>
{
{ 42, 100f },
{ 49, 100f }
});
break;
case 8:
ChangeExpression(new Dictionary<int, float> { { 44, 100f } });
break;
case 9:
ChangeExpression(new Dictionary<int, float>
{
{ 23, 29.9f },
{ 58, 100f }
});
break;
case 1010:
ChangeExpression(new Dictionary<int, float>
{
{ 23, 29.9f },
{ 50, 62.9f }
});
break;
default:
ChangeExpression(new Dictionary<int, float>());
break;
}
}
protected override void OnEmoteEnd()
{
ChangeExpression(new Dictionary<int, float>());
}
protected void Update()
{
//IL_00fd: 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_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
previousDanceNumber = danceNumber;
danceNumber = ((BodyReplacementBase)this).controller.playerBodyAnimator.GetInteger("emoteNumber");
if (previousDanceNumber != danceNumber)
{
OnEmoteChange(danceNumber);
}
if ((Object)(object)playerMicVolume != (Object)null)
{
sealBody.SetBlendShapeWeight(0, playerMicVolume.detectedVolumeAmplitude * 75f);
}
if (!((Object)(object)sealArms != (Object)null))
{
return;
}
if (((Renderer)((BodyReplacementBase)this).controller.thisPlayerModelArms).enabled != sealArms.activeSelf)
{
sealArms.SetActive(((Renderer)((BodyReplacementBase)this).controller.thisPlayerModelArms).enabled);
}
foreach (TransformPair pairedTransform in pairedTransforms)
{
pairedTransform.key.rotation = pairedTransform.value.rotation * pairedTransform.offset;
if (pairedTransform.copyTransform)
{
pairedTransform.key.position = pairedTransform.value.position;
}
else if (danceNumber == 1)
{
pairedTransform.key.localRotation = Quaternion.Lerp(pairedTransform.rest, pairedTransform.key.localRotation, 0.7f);
}
}
}
public override void LateUpdate()
{
//IL_002a: 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_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
((BodyReplacementBase)this).LateUpdate();
defaultRotations[0].key.localRotation = Quaternion.Lerp(defaultRotations[0].key.localRotation, defaultRotations[0].value, armAnimBlend);
if (!((BodyReplacementBase)this).controller.isHoldingObject)
{
defaultRotations[1].key.localRotation = Quaternion.Lerp(defaultRotations[1].key.localRotation, defaultRotations[1].value, armAnimBlend);
}
bool @bool = ((BodyReplacementBase)this).controller.playerBodyAnimator.GetBool("Jumping");
if (wasJump != @bool)
{
if (@bool)
{
ChangeExpression(new Dictionary<int, float> { { 50, 100f } });
}
else
{
ChangeExpression(new Dictionary<int, float> { { 50, 0f } });
}
wasJump = @bool;
}
}
private IEnumerator FadeToBlendShape(int index, float value, SkinnedMeshRenderer skinnedMeshRenderer)
{
float timeElapsed = 0f;
float duration = 0.1f;
float startValue = skinnedMeshRenderer.GetBlendShapeWeight(index);
while (timeElapsed < duration)
{
skinnedMeshRenderer.SetBlendShapeWeight(index, Mathf.Lerp(startValue, value, timeElapsed / duration));
timeElapsed += Time.deltaTime;
yield return null;
}
skinnedMeshRenderer.SetBlendShapeWeight(index, Mathf.Lerp(startValue, value, timeElapsed / duration));
}
public void ToggleSealHoodie(string option = "toggle")
{
if (((Component)base.replacementModel.transform.Find("Hoodie")).gameObject.activeInHierarchy)
{
((Component)base.replacementModel.transform.Find("Hoodie")).gameObject.SetActive(false);
sealBody.SetBlendShapeWeight(33, 0f);
sealBody.SetBlendShapeWeight(34, 0f);
sealBody.SetBlendShapeWeight(131, 0f);
sealBody.SetBlendShapeWeight(132, 0f);
if ((Object)(object)sealArms != (Object)null)
{
((Component)sealArms.transform.Find("HoodieArms")).gameObject.SetActive(false);
((Component)sealArms.transform.Find("HoodieArms")).GetComponent<SkinnedMeshRenderer>().SetBlendShapeWeight(0, 0f);
}
}
else
{
((Component)base.replacementModel.transform.Find("Hoodie")).gameObject.SetActive(true);
sealBody.SetBlendShapeWeight(33, 100f);
sealBody.SetBlendShapeWeight(34, 100f);
sealBody.SetBlendShapeWeight(131, 100f);
sealBody.SetBlendShapeWeight(132, 100f);
if ((Object)(object)sealArms != (Object)null)
{
((Component)sealArms.transform.Find("HoodieArms")).gameObject.SetActive(true);
((Component)sealArms.transform.Find("HoodieArms")).GetComponent<SkinnedMeshRenderer>().SetBlendShapeWeight(0, 100f);
}
}
}
public void SetSealHoodieActive(bool active = false)
{
if ((Object)(object)sealArms != (Object)null)
{
((Component)sealArms.transform.Find("HoodieArms")).gameObject.SetActive(active);
}
((Component)base.replacementModel.transform.Find("Hoodie")).gameObject.SetActive(active);
if (active)
{
sealBody.SetBlendShapeWeight(33, 100f);
sealBody.SetBlendShapeWeight(34, 100f);
sealBody.SetBlendShapeWeight(131, 100f);
sealBody.SetBlendShapeWeight(132, 100f);
if ((Object)(object)sealArms != (Object)null)
{
((Component)sealArms.transform.Find("HoodieArms")).GetComponent<SkinnedMeshRenderer>().SetBlendShapeWeight(0, 100f);
}
}
else
{
sealBody.SetBlendShapeWeight(33, 0f);
sealBody.SetBlendShapeWeight(34, 0f);
sealBody.SetBlendShapeWeight(131, 0f);
sealBody.SetBlendShapeWeight(132, 0f);
if ((Object)(object)sealArms != (Object)null)
{
((Component)sealArms.transform.Find("HoodieArms")).GetComponent<SkinnedMeshRenderer>().SetBlendShapeWeight(0, 0f);
}
}
}
public bool IsHoodieActive()
{
return ((Component)base.replacementModel.transform.Find("Hoodie")).gameObject.activeInHierarchy;
}
public void ColorSealHoodie(string color = "darkblue")
{
//IL_002b: 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_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)
//IL_01b1: 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_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_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: 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_00f9: 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_0104: 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_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: 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_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0163: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: 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_0181: 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_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
Color val = default(Color);
((Color)(ref val))..ctor(0.5566037f, 0.5566037f, 0.5566037f, 1f);
switch (color)
{
case "red":
val *= Color.red;
break;
case "orange":
((Color)(ref val))..ctor(0.517647f, 0.2156862f, 0f);
break;
case "yellow":
((Color)(ref val))..ctor(1f, 0.89f, 0f);
break;
case "green":
val *= Color.green;
break;
case "cyan":
val *= new Color(0f, 0.89f, 1f, 1f);
break;
case "blue":
val *= Color.blue;
break;
case "darkblue":
val *= new Color(0.06274508f, 0.117647f, 0.3372549f, 1f);
break;
case "purple":
val *= new Color(0.66f, 0f, 1f, 1f);
break;
case "black":
val *= Color.black;
break;
}
((Renderer)((Component)base.replacementModel.transform.Find("Hoodie")).gameObject.GetComponent<SkinnedMeshRenderer>()).material.color = val;
hoodieColor = color;
}
}
public class ExampleNetworkHandler : NetworkBehaviour
{
public static ExampleNetworkHandler Instance { get; private set; }
public static event Action<string> LevelEvent;
private void Start()
{
Instance = this;
}
[ServerRpc(RequireOwnership = false)]
internal void RequestHoodieDataServerRpc(ulong localPlayerID)
{
Plugin.PluginLogger.LogInfo((object)"Server is requesting hoodie data");
SendHoodieDataClientRpc(localPlayerID, 666uL);
}
[ServerRpc(RequireOwnership = false)]
internal void RequestHoodieDataFromPlayerServerRpc(ulong localPlayerID, ulong requestedPlayerID)
{
Plugin.PluginLogger.LogInfo((object)"Player {localPlayerID} is requesting hoodie data from Player{requestedPlayerID}");
SendHoodieDataClientRpc(localPlayerID, 666uL);
}
[ClientRpc]
internal void SendHoodieDataClientRpc(ulong requesterID, ulong requestedPlayerID = 666uL)
{
if (requestedPlayerID == 666 || Plugin.localController.playerClientId == requestedPlayerID)
{
Plugin.PluginLogger.LogInfo((object)("Sending hoodie data to server for Player " + requesterID));
Plugin.PluginLogger.LogInfo((object)$"Plugin.localController: {(Object)(object)Plugin.localController == (Object)null}, Plugin.localReplacement: {(Object)(object)Plugin.localReplacement == (Object)null}");
ReceiveHoodieDataServerRpc(Plugin.localController.playerClientId, hoodieEnabled: true, Plugin.localReplacement.hoodieColor, requesterID);
}
}
[ServerRpc(RequireOwnership = false)]
internal void ReceiveHoodieDataServerRpc(ulong playerID, bool hoodieEnabled, string hoodieColor, ulong requesterID)
{
Plugin.PluginLogger.LogInfo((object)("Server has received hoodie data from Player " + playerID + " and is sending it to Player " + requesterID));
ReceiveHoodieDataClientRpc(playerID, hoodieEnabled, hoodieColor, requesterID);
}
[ServerRpc(RequireOwnership = false)]
internal void SendAllSealInfoServerRpc(ulong recipient)
{
Plugin.PluginLogger.LogInfo((object)$"Sending all seal data to Player {recipient}.");
for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
{
PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i];
if (val.playerClientId != recipient && val.isPlayerControlled)
{
MRSAMSEAL_NEW component = ((Component)val.thisPlayerBody).gameObject.GetComponent<MRSAMSEAL_NEW>();
if ((Object)(object)component != (Object)null)
{
ReceiveHoodieDataClientRpc(val.playerClientId, ((Component)((BodyReplacementBase)component).replacementModel.transform.Find("Hoodie")).gameObject.activeInHierarchy, component.hoodieColor, recipient);
}
}
}
}
[ClientRpc]
private void ReceiveHoodieDataClientRpc(ulong playerID, bool hoodieEnabled, string hoodieColor, ulong requesterID)
{
if (Plugin.localController.playerClientId == requesterID)
{
Plugin.PluginLogger.LogInfo((object)$"Received data of Player {playerID}, hoodieEnabled {hoodieEnabled}, hoodieColor {hoodieColor}");
Plugin.Instance.UpdateSeal(playerID, isColor: true, hoodieColor);
Plugin.Instance.UpdateSeal(playerID, isColor: false, hoodieEnabled.ToString());
}
}
public void UpdateHoodieForOthers(ulong playerID, bool isColor, string value)
{
if (((NetworkBehaviour)Plugin.localController).IsOwner && Plugin.localController.isPlayerControlled)
{
HoodieDataServerRpc(playerID, isColor, value);
}
}
[ServerRpc(RequireOwnership = false)]
internal void HoodieDataServerRpc(ulong playerID, bool isColor, string value)
{
Plugin.PluginLogger.LogInfo((object)("ServerRpc Hoodie: " + playerID));
HoodieDataClientRpc(playerID, isColor, value);
}
[ClientRpc]
private void HoodieDataClientRpc(ulong playerID, bool isColor, string value)
{
Plugin.PluginLogger.LogInfo((object)("ClientRpc Hoodie: " + playerID));
Plugin.Instance.UpdateSeal(playerID, isColor, value);
}
}
public class PlayerMicVolume : MonoBehaviour
{
public bool useDissonanceForMicDetection = true;
[Space(3f)]
private DissonanceComms comms;
public float detectedVolumeAmplitude;
private AudioClip _clipRecord;
private int _sampleWindow = 128;
public PlayerControllerB controller;
private float LevelMax()
{
float num = 0f;
float[] array = new float[_sampleWindow];
int num2 = Microphone.GetPosition(IngamePlayerSettings.Instance.settings.micDevice) - (_sampleWindow + 1);
if (num2 < 0)
{
return 0f;
}
_clipRecord.GetData(array, num2);
for (int i = 0; i < _sampleWindow; i++)
{
float num3 = array[i] * array[i];
if (num < num3)
{
num = num3;
}
}
return num;
}
private void Update()
{
if (((NetworkBehaviour)controller).IsLocalPlayer)
{
Plugin.PluginLogger.LogInfo((object)"IsLocal");
detectedVolumeAmplitude = 0f;
if (!IngamePlayerSettings.Instance.settings.micEnabled || (IngamePlayerSettings.Instance.settings.pushToTalk && !IngamePlayerSettings.Instance.playerInput.actions.FindAction("VoiceButton", false).IsPressed() && !GameNetworkManager.Instance.localPlayerController.speakingToWalkieTalkie))
{
return;
}
if (useDissonanceForMicDetection && (Object)(object)NetworkManager.Singleton != (Object)null)
{
if ((Object)(object)comms == (Object)null)
{
comms = Object.FindObjectOfType<DissonanceComms>();
}
Plugin.PluginLogger.LogInfo((object)("Playername: " + comms.LocalPlayerName));
detectedVolumeAmplitude = Mathf.Clamp(comms.FindPlayer(comms.LocalPlayerName).Amplitude * 35f, 0f, 1f);
}
else
{
detectedVolumeAmplitude = Mathf.Clamp(LevelMax() * 300f, 0f, 1f);
}
if (detectedVolumeAmplitude < 0.25f)
{
detectedVolumeAmplitude = 0f;
}
}
else if (controller.voicePlayerState != null)
{
detectedVolumeAmplitude = Mathf.Clamp(controller.voicePlayerState.Amplitude * 35f, 0f, 1f);
}
}
private void Awake()
{
if (!useDissonanceForMicDetection)
{
_clipRecord = AudioClip.Create("newClip", 44100, 1, 2000, true);
}
}
}
[BepInPlugin("julian0555.SealModelReplacement", "SealModelReplacement", "1.0.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency("NicholaScott.BepInEx.RuntimeNetcodeRPCValidator", "0.2.5")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
public static ConfigFile config;
public static ManualLogSource PluginLogger;
public static PlayerControllerB localController;
public static MRSAMSEAL_NEW localReplacement;
public static ConfigEntry<bool> enableModelForAllSuits { get; private set; }
public static ConfigEntry<bool> enableModelAsDefault { get; private set; }
public static ConfigEntry<string> suitNamesToEnableModel { get; private set; }
public static Plugin Instance { get; private set; }
private static void InitConfig()
{
enableModelForAllSuits = config.Bind<bool>("Suits to Replace Settings", "Enable Model for all Suits", false, "Enable to model replace every suit. Set to false to specify suits");
enableModelAsDefault = config.Bind<bool>("Suits to Replace Settings", "Enable Model as default", false, "Enable to model replace every suit that hasn't been otherwise registered.");
suitNamesToEnableModel = config.Bind<string>("Suits to Replace Settings", "Suits to enable Model for", "Seal", "Enter a comma separated list of suit names.(Additionally, [Default,Orange suit,Green suit,Pajama suit,Hazard suit])");
}
private void Awake()
{
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Expected O, but got Unknown
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Expected O, but got Unknown
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: 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_012f: Expected O, but got Unknown
//IL_0135: 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_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Expected O, but got Unknown
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: 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)
//IL_01b7: Expected O, but got Unknown
//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Expected O, but got Unknown
//IL_0201: 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)
//IL_022c: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Expected O, but got Unknown
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Expected O, but got Unknown
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Expected O, but got Unknown
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
//IL_030b: Expected O, but got Unknown
//IL_0311: Unknown result type (might be due to invalid IL or missing references)
//IL_0316: Unknown result type (might be due to invalid IL or missing references)
//IL_033c: Unknown result type (might be due to invalid IL or missing references)
//IL_034f: Expected O, but got Unknown
//IL_0355: Unknown result type (might be due to invalid IL or missing references)
//IL_035a: Unknown result type (might be due to invalid IL or missing references)
//IL_0380: Unknown result type (might be due to invalid IL or missing references)
//IL_0393: Expected O, but got Unknown
//IL_0399: Unknown result type (might be due to invalid IL or missing references)
//IL_039e: Unknown result type (might be due to invalid IL or missing references)
//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
//IL_03d7: Expected O, but got Unknown
config = ((BaseUnityPlugin)this).Config;
InitConfig();
Assets.PopulateAssets();
if (enableModelForAllSuits.Value)
{
ModelReplacementAPI.RegisterModelReplacementOverride(typeof(MRSAMSEAL_NEW));
}
if (enableModelAsDefault.Value)
{
ModelReplacementAPI.RegisterModelReplacementDefault(typeof(MRSAMSEAL_NEW));
}
string[] array = suitNamesToEnableModel.Value.Split(',');
string[] array2 = array;
foreach (string text in array2)
{
ModelReplacementAPI.RegisterSuitModelReplacement(text, typeof(MRSAMSEAL_NEW));
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin julian0555.SealModelReplacement is loaded!");
Harmony val = new Harmony("julian0555.SealModelReplacement");
val.PatchAll();
NetcodePatcher();
PluginLogger = ((BaseUnityPlugin)this).Logger;
NetcodeValidator val2 = new NetcodeValidator("julian0555.SealModelReplacement");
val2.PatchAll();
val2.BindToPreExistingObjectByBehaviour<ExampleNetworkHandler, StartOfRound>();
TerminalApi.AddCommand("hoodie", new CommandInfo
{
DisplayTextSupplier = delegate
{
ExampleNetworkHandler.Instance.UpdateHoodieForOthers(localController.playerClientId, isColor: false, "");
return "no way chat.";
},
Category = "Other"
}, (string)null, true);
TerminalApi.AddCommand("hoodie red", new CommandInfo
{
DisplayTextSupplier = delegate
{
ExampleNetworkHandler.Instance.UpdateHoodieForOthers(localController.playerClientId, isColor: true, "red");
return "red hoodie!";
},
Category = "Other"
}, (string)null, true);
TerminalApi.AddCommand("hoodie orange", new CommandInfo
{
DisplayTextSupplier = delegate
{
ExampleNetworkHandler.Instance.UpdateHoodieForOthers(localController.playerClientId, isColor: true, "orange");
return "orange hoodie!";
},
Category = "Other"
}, (string)null, true);
TerminalApi.AddCommand("hoodie yellow", new CommandInfo
{
DisplayTextSupplier = delegate
{
ExampleNetworkHandler.Instance.UpdateHoodieForOthers(localController.playerClientId, isColor: true, "yellow");
return "yellow hoodie!";
},
Category = "Other"
}, (string)null, true);
TerminalApi.AddCommand("hoodie green", new CommandInfo
{
DisplayTextSupplier = delegate
{
ExampleNetworkHandler.Instance.UpdateHoodieForOthers(localController.playerClientId, isColor: true, "green");
return "green hoodie!";
},
Category = "Other"
}, (string)null, true);
TerminalApi.AddCommand("hoodie cyan", new CommandInfo
{
DisplayTextSupplier = delegate
{
ExampleNetworkHandler.Instance.UpdateHoodieForOthers(localController.playerClientId, isColor: true, "cyan");
return "cyan hoodie!";
},
Category = "Other"
}, (string)null, true);
TerminalApi.AddCommand("hoodie blue", new CommandInfo
{
DisplayTextSupplier = delegate
{
ExampleNetworkHandler.Instance.UpdateHoodieForOthers(localController.playerClientId, isColor: true, "blue");
return "blue hoodie!";
},
Category = "Other"
}, (string)null, true);
TerminalApi.AddCommand("hoodie darkblue", new CommandInfo
{
DisplayTextSupplier = delegate
{
ExampleNetworkHandler.Instance.UpdateHoodieForOthers(localController.playerClientId, isColor: true, "darkblue");
return "dark blue hoodie!";
},
Category = "Other"
}, (string)null, true);
TerminalApi.AddCommand("hoodie purple", new CommandInfo
{
DisplayTextSupplier = delegate
{
ExampleNetworkHandler.Instance.UpdateHoodieForOthers(localController.playerClientId, isColor: true, "purple");
return "purple hoodie!";
},
Category = "Other"
}, (string)null, true);
TerminalApi.AddCommand("hoodie black", new CommandInfo
{
DisplayTextSupplier = delegate
{
ExampleNetworkHandler.Instance.UpdateHoodieForOthers(localController.playerClientId, isColor: true, "black");
return "black hoodie!";
},
Category = "Other"
}, (string)null, true);
TerminalApi.AddCommand("hoodie white", new CommandInfo
{
DisplayTextSupplier = delegate
{
ExampleNetworkHandler.Instance.UpdateHoodieForOthers(localController.playerClientId, isColor: true, "white");
return "white hoodie!";
},
Category = "Other"
}, (string)null, true);
Instance = this;
}
private static void NetcodePatcher()
{
Type[] types = Assembly.GetExecutingAssembly().GetTypes();
Type[] array = types;
foreach (Type type in array)
{
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
MethodInfo[] array2 = methods;
foreach (MethodInfo methodInfo in array2)
{
object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
if (customAttributes.Length != 0)
{
methodInfo.Invoke(null, null);
}
}
}
}
public void UpdateSeal(ulong playerID, bool isColor, string value)
{
for (int i = 0; i < StartOfRound.Instance.allPlayerScripts.Length; i++)
{
PlayerControllerB val = StartOfRound.Instance.allPlayerScripts[i];
if (val.playerClientId != playerID)
{
continue;
}
MRSAMSEAL_NEW component = ((Component)val.thisPlayerBody).gameObject.GetComponent<MRSAMSEAL_NEW>();
if ((Object)(object)component != (Object)null)
{
if (isColor)
{
component.ColorSealHoodie(value);
}
else if (value == "")
{
component.ToggleSealHoodie();
}
else
{
component.SetSealHoodieActive(Convert.ToBoolean(value));
}
}
break;
}
}
}
public static class Assets
{
public static string mainAssetBundleName = "sealbundle";
public static AssetBundle MainAssetBundle = null;
public static AssetBundle NetworkAssetBundle = null;
private static string GetAssemblyName()
{
return Assembly.GetExecutingAssembly().GetName().Name.Replace(" ", "_");
}
public static void PopulateAssets()
{
if ((Object)(object)MainAssetBundle == (Object)null)
{
Console.WriteLine(GetAssemblyName() + "." + mainAssetBundleName);
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(GetAssemblyName() + "." + mainAssetBundleName);
MainAssetBundle = AssetBundle.LoadFromStream(stream);
}
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerBPatch
{
[HarmonyPatch("ConnectClientToPlayerObject")]
[HarmonyPostfix]
private static void ConnectClientToPlayerObjectPatch(ref PlayerControllerB __instance)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
Plugin.localController = GameNetworkManager.Instance.localPlayerController;
MRSAMSEAL_NEW component = ((Component)__instance).gameObject.GetComponent<MRSAMSEAL_NEW>();
if ((Object)(object)component != (Object)null)
{
if ((Object)(object)Plugin.localReplacement == (Object)null)
{
Plugin.localReplacement = component;
}
if ((Object)(object)component.sealArms == (Object)null)
{
component.enableArms();
}
}
if (!((NetworkBehaviour)ExampleNetworkHandler.Instance).IsHost)
{
ExampleNetworkHandler.Instance.SendAllSealInfoServerRpc(Plugin.localController.playerClientId);
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}