using System;
using System.Collections;
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 GameNetcodeStuff;
using HarmonyLib;
using LC_API.BundleAPI;
using LC_API.Networking;
using Newtonsoft.Json;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("PlayerDogModel")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A mod to replace Player models with a dog for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3")]
[assembly: AssemblyProduct("PlayerDogModel")]
[assembly: AssemblyTitle("PlayerDogModel")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.0")]
[module: UnverifiableCode]
namespace PlayerDogModel;
internal static class Networking
{
public const string ModelSwitchMessageName = "modelswitch";
public const string ModelInfoMessageName = "modelinfo";
public static void Initialize()
{
Network.RegisterMessage<PlayerModelReplacer.ToggleData>("modelswitch", false, (Action<ulong, PlayerModelReplacer.ToggleData>)HandleModelSwitchMessage);
Network.RegisterMessage("modelinfo", false, (Action<ulong>)HandleModelInfoMessage);
}
private static void HandleModelSwitchMessage(ulong senderId, PlayerModelReplacer.ToggleData toggleData)
{
Debug.Log((object)(string.Format("Got {0} network message from {1}: {{ ", "modelswitch", senderId) + string.Format("{0} = {1}, ", "playerClientId", toggleData.playerClientId) + string.Format("{0} = {1}, ", "playAudio", toggleData.playAudio) + string.Format("{0} = {1} ", "isDog", toggleData.isDog) + "}}"));
PlayerModelReplacer playerModelReplacer = null;
GameObject[] allPlayerObjects = StartOfRound.Instance.allPlayerObjects;
for (int i = 0; i < allPlayerObjects.Length; i++)
{
PlayerModelReplacer component = allPlayerObjects[i].GetComponent<PlayerModelReplacer>();
if ((Object)(object)component != (Object)null && component.PlayerClientId == toggleData.playerClientId)
{
playerModelReplacer = component;
break;
}
}
if ((Object)(object)playerModelReplacer == (Object)null)
{
Debug.LogWarning((object)string.Format("{0} message from client {1} will be ignored because replacer with this ID is not registered", "modelswitch", senderId));
return;
}
if (!playerModelReplacer.IsValid)
{
Debug.LogError((object)"Dog encountered an error when it was initialized and it can't be toggled. Check the log for more info.");
return;
}
Debug.Log((object)$"Received dog={toggleData.isDog} for {playerModelReplacer.PlayerClientId} ({playerModelReplacer.PlayerUsername}).");
if (toggleData.isDog)
{
playerModelReplacer.EnableDogModel(toggleData.playAudio);
}
else
{
playerModelReplacer.EnableHumanModel(toggleData.playAudio);
}
}
private static void HandleModelInfoMessage(ulong senderId)
{
Debug.Log((object)string.Format("Got {0} network message from {1}", "modelinfo", senderId));
GameObject[] allPlayerObjects = StartOfRound.Instance.allPlayerObjects;
for (int i = 0; i < allPlayerObjects.Length; i++)
{
PlayerModelReplacer component = allPlayerObjects[i].GetComponent<PlayerModelReplacer>();
if ((Object)(object)component != (Object)null)
{
component.BroadcastSelectedModel(playAudio: false);
}
}
}
}
[DefaultExecutionOrder(-1)]
public class PlayerModelReplacer : MonoBehaviour
{
[JsonObject]
internal class ToggleData
{
[JsonProperty]
public ulong playerClientId { get; set; }
[JsonProperty]
public bool isDog { get; set; }
[JsonProperty]
public bool playAudio { get; set; }
}
public static PlayerModelReplacer LocalReplacer;
private static bool loaded;
private static string exceptionMessage;
private static Exception exception;
private PlayerControllerB playerController;
private GameObject dogGameObject;
private GameObject[] humanGameObjects;
private SkinnedMeshRenderer[] dogRenderers;
private Transform dogTorso;
private PositionConstraint torsoConstraint;
private static AudioClip humanClip;
private static AudioClip dogClip;
private Vector3 humanCameraPosition;
private Transform localItemAnchor;
private Transform serverItemAnchor;
private static Image healthFill;
private static Image healthOutline;
private static Sprite humanFill;
private static Sprite humanOutline;
private static Sprite dogFill;
private static Sprite dogOutline;
private bool isDogActive;
public ulong PlayerClientId
{
get
{
if (!((Object)(object)playerController != (Object)null))
{
return ulong.MaxValue;
}
return playerController.playerClientId;
}
}
public string PlayerUsername
{
get
{
if (!((Object)(object)playerController != (Object)null))
{
return "";
}
return playerController.playerUsername;
}
}
public bool IsValid => (Object)(object)dogGameObject != (Object)null;
public bool IsDog => isDogActive;
private void Awake()
{
if (!loaded)
{
loaded = true;
LoadImageResources();
((MonoBehaviour)this).StartCoroutine(LoadAudioResources());
}
}
private void Start()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
playerController = ((Component)this).GetComponent<PlayerControllerB>();
if (((NetworkBehaviour)playerController).IsOwner)
{
LocalReplacer = this;
}
humanCameraPosition = ((Component)playerController.gameplayCamera).transform.localPosition;
Debug.Log((object)$"Adding PlayerModelReplacer on {playerController.playerUsername} ({((NetworkBehaviour)playerController).IsOwner})");
SpawnDogModel();
EnableHumanModel(playAudio: false);
}
private void Update()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: 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_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_0189: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: 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)
if (!string.IsNullOrEmpty(exceptionMessage))
{
return;
}
Vector3 val = humanCameraPosition;
if (isDogActive && !playerController.inTerminalMenu && !playerController.inSpecialInteractAnimation)
{
if (!playerController.isCrouching)
{
((Vector3)(ref val))..ctor(0f, -1.1f, 0.3f);
}
else
{
((Vector3)(ref val))..ctor(0f, -0.5f, 0.3f);
}
}
((Component)playerController.gameplayCamera).transform.localPosition = Vector3.MoveTowards(((Component)playerController.gameplayCamera).transform.localPosition, val, Time.deltaTime * 2f);
if (playerController.isCrouching)
{
torsoConstraint.weight = Mathf.MoveTowards(torsoConstraint.weight, 0.5f, Time.deltaTime * 3f);
}
else
{
torsoConstraint.weight = Mathf.MoveTowards(torsoConstraint.weight, 1f, Time.deltaTime * 3f);
}
if (playerController.isClimbingLadder)
{
dogTorso.localRotation = Quaternion.RotateTowards(dogTorso.localRotation, Quaternion.Euler(90f, 0f, 0f), Time.deltaTime * 360f);
}
else
{
dogTorso.localRotation = Quaternion.RotateTowards(dogTorso.localRotation, Quaternion.Euler(180f, 0f, 0f), Time.deltaTime * 360f);
}
}
private void LateUpdate()
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)localItemAnchor == (Object)null) && !((Object)(object)serverItemAnchor == (Object)null))
{
if (isDogActive)
{
playerController.localItemHolder.position = localItemAnchor.position;
playerController.serverItemHolder.position = serverItemAnchor.position;
}
if (((Renderer)dogRenderers[0]).shadowCastingMode != ((Renderer)playerController.thisPlayerModel).shadowCastingMode)
{
Debug.Log((object)$"Dog model is on the wrong shadow casting mode. ({((Renderer)dogRenderers[0]).shadowCastingMode} instead of {((Renderer)playerController.thisPlayerModel).shadowCastingMode})");
((Renderer)dogRenderers[0]).shadowCastingMode = ((Renderer)playerController.thisPlayerModel).shadowCastingMode;
}
if (((Component)dogRenderers[0]).gameObject.layer != ((Component)playerController.thisPlayerModel).gameObject.layer)
{
Debug.Log((object)("Dog model is on the wrong layer. (" + LayerMask.LayerToName(((Component)dogRenderers[0]).gameObject.layer) + " instead of " + LayerMask.LayerToName(((Component)playerController.thisPlayerModel).gameObject.layer) + ")"));
((Component)dogRenderers[0]).gameObject.layer = ((Component)playerController.thisPlayerModel).gameObject.layer;
}
}
}
private void SpawnDogModel()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: 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_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0311: Unknown result type (might be due to invalid IL or missing references)
//IL_0329: Unknown result type (might be due to invalid IL or missing references)
//IL_032e: Unknown result type (might be due to invalid IL or missing references)
//IL_035f: Unknown result type (might be due to invalid IL or missing references)
//IL_037a: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: Unknown result type (might be due to invalid IL or missing references)
//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0412: Unknown result type (might be due to invalid IL or missing references)
//IL_041d: Unknown result type (might be due to invalid IL or missing references)
//IL_0443: Unknown result type (might be due to invalid IL or missing references)
//IL_045e: Unknown result type (might be due to invalid IL or missing references)
//IL_0469: 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_04aa: Unknown result type (might be due to invalid IL or missing references)
//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
try
{
GameObject loadedAsset = BundleLoader.GetLoadedAsset<GameObject>("assets/Dog.fbx");
dogGameObject = Object.Instantiate<GameObject>(loadedAsset, ((Component)this).transform);
dogGameObject.transform.position = ((Component)this).transform.position;
dogGameObject.transform.eulerAngles = ((Component)this).transform.eulerAngles;
Transform transform = dogGameObject.transform;
transform.localScale *= 2f;
}
catch (Exception ex)
{
exceptionMessage = "Failed to spawn dog model.";
exception = ex;
Debug.LogError((object)exceptionMessage);
Debug.LogException(exception);
}
dogRenderers = dogGameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
UpdateMaterial();
try
{
LODGroup val = dogGameObject.AddComponent<LODGroup>();
val.fadeMode = (LODFadeMode)0;
LOD val2 = default(LOD);
val2.screenRelativeTransitionHeight = 0.4564583f;
val2.renderers = (Renderer[])(object)new Renderer[1] { (Renderer)dogRenderers[0] };
val2.fadeTransitionWidth = 0f;
LOD val3 = val2;
val2 = default(LOD);
val2.screenRelativeTransitionHeight = 0.1795709f;
val2.renderers = (Renderer[])(object)new Renderer[1] { (Renderer)dogRenderers[1] };
val2.fadeTransitionWidth = 0f;
LOD val4 = val2;
val2 = default(LOD);
val2.screenRelativeTransitionHeight = 0.009000001f;
val2.renderers = (Renderer[])(object)new Renderer[1] { (Renderer)dogRenderers[2] };
val2.fadeTransitionWidth = 0.435f;
LOD val5 = val2;
val.SetLODs((LOD[])(object)new LOD[3] { val3, val4, val5 });
}
catch (Exception ex2)
{
exceptionMessage = "Failed to set up the LOD.";
exception = ex2;
Debug.LogError((object)exceptionMessage);
Debug.LogException(exception);
}
try
{
dogTorso = dogGameObject.transform.Find("Armature").Find("torso");
Transform val6 = dogTorso.Find("head");
Transform val7 = dogTorso.Find("arm.L");
Transform val8 = dogTorso.Find("arm.R");
Transform val9 = dogTorso.Find("butt").Find("leg.L");
Transform val10 = dogTorso.Find("butt").Find("leg.R");
Transform val11 = ((Component)this).transform.Find("ScavengerModel").Find("metarig").Find("spine");
Transform sourceTransform = val11.Find("spine.001").Find("spine.002").Find("spine.003")
.Find("spine.004");
Transform sourceTransform2 = val11.Find("thigh.L");
Transform sourceTransform3 = val11.Find("thigh.R");
try
{
torsoConstraint = ((Component)dogTorso).gameObject.AddComponent<PositionConstraint>();
PositionConstraint obj = torsoConstraint;
ConstraintSource val12 = default(ConstraintSource);
((ConstraintSource)(ref val12)).sourceTransform = val11;
((ConstraintSource)(ref val12)).weight = 1f;
obj.AddSource(val12);
torsoConstraint.translationAtRest = dogTorso.localPosition;
torsoConstraint.translationOffset = dogTorso.InverseTransformPoint(val11.position);
torsoConstraint.constraintActive = true;
torsoConstraint.locked = true;
RotationConstraint obj2 = ((Component)val6).gameObject.AddComponent<RotationConstraint>();
val12 = default(ConstraintSource);
((ConstraintSource)(ref val12)).sourceTransform = sourceTransform;
((ConstraintSource)(ref val12)).weight = 1f;
obj2.AddSource(val12);
obj2.rotationAtRest = val6.localEulerAngles;
obj2.constraintActive = true;
obj2.locked = true;
RotationConstraint obj3 = ((Component)val7).gameObject.AddComponent<RotationConstraint>();
val12 = default(ConstraintSource);
((ConstraintSource)(ref val12)).sourceTransform = sourceTransform3;
((ConstraintSource)(ref val12)).weight = 1f;
obj3.AddSource(val12);
obj3.rotationAtRest = val7.localEulerAngles;
obj3.constraintActive = true;
obj3.locked = true;
RotationConstraint obj4 = ((Component)val8).gameObject.AddComponent<RotationConstraint>();
val12 = default(ConstraintSource);
((ConstraintSource)(ref val12)).sourceTransform = sourceTransform2;
((ConstraintSource)(ref val12)).weight = 1f;
obj4.AddSource(val12);
obj4.rotationAtRest = val8.localEulerAngles;
obj4.constraintActive = true;
obj4.locked = true;
RotationConstraint obj5 = ((Component)val9).gameObject.AddComponent<RotationConstraint>();
val12 = default(ConstraintSource);
((ConstraintSource)(ref val12)).sourceTransform = sourceTransform2;
((ConstraintSource)(ref val12)).weight = 1f;
obj5.AddSource(val12);
obj5.rotationAtRest = val9.localEulerAngles;
obj5.constraintActive = true;
obj5.locked = true;
RotationConstraint obj6 = ((Component)val10).gameObject.AddComponent<RotationConstraint>();
val12 = default(ConstraintSource);
((ConstraintSource)(ref val12)).sourceTransform = sourceTransform3;
((ConstraintSource)(ref val12)).weight = 1f;
obj6.AddSource(val12);
obj6.rotationAtRest = val10.localEulerAngles;
obj6.constraintActive = true;
obj6.locked = true;
}
catch (Exception ex3)
{
exceptionMessage = "Failed to set up the constraints.";
exception = ex3;
Debug.LogError((object)exceptionMessage);
Debug.LogException(exception);
}
serverItemAnchor = val6.Find("serverItem");
localItemAnchor = val6.Find("localItem");
}
catch (Exception ex4)
{
exceptionMessage = "Failed to retrieve bones. What the hell?";
exception = ex4;
Debug.LogError((object)exceptionMessage);
Debug.LogException(exception);
}
humanGameObjects = (GameObject[])(object)new GameObject[6];
humanGameObjects[0] = ((Component)playerController.thisPlayerModel).gameObject;
humanGameObjects[1] = ((Component)playerController.thisPlayerModelLOD1).gameObject;
humanGameObjects[2] = ((Component)playerController.thisPlayerModelLOD2).gameObject;
humanGameObjects[3] = ((Component)playerController.thisPlayerModelArms).gameObject;
humanGameObjects[4] = ((Component)playerController.playerBetaBadgeMesh).gameObject;
humanGameObjects[5] = ((Component)((Component)playerController.playerBetaBadgeMesh).transform.parent.Find("LevelSticker")).gameObject;
}
public void EnableHumanModel(bool playAudio = true)
{
isDogActive = false;
dogGameObject.SetActive(false);
GameObject[] array = humanGameObjects;
for (int i = 0; i < array.Length; i++)
{
array[i].SetActive(true);
}
if (playAudio)
{
playerController.movementAudio.PlayOneShot(humanClip);
}
if (((NetworkBehaviour)playerController).IsOwner && Object.op_Implicit((Object)(object)healthFill))
{
healthFill.sprite = humanFill;
healthOutline.sprite = humanOutline;
}
}
public void EnableDogModel(bool playAudio = true)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
isDogActive = true;
dogGameObject.SetActive(true);
((Renderer)dogRenderers[0]).shadowCastingMode = ((Renderer)playerController.thisPlayerModel).shadowCastingMode;
GameObject[] array = humanGameObjects;
for (int i = 0; i < array.Length; i++)
{
array[i].SetActive(false);
}
if (playAudio)
{
playerController.movementAudio.PlayOneShot(dogClip);
}
if (((NetworkBehaviour)playerController).IsOwner)
{
if (!Object.op_Implicit((Object)(object)healthFill))
{
healthFill = ((Component)HUDManager.Instance.selfRedCanvasGroup).GetComponent<Image>();
healthOutline = ((Component)((Component)HUDManager.Instance.selfRedCanvasGroup).transform.parent.Find("Self")).GetComponent<Image>();
humanFill = healthFill.sprite;
humanOutline = healthOutline.sprite;
}
healthFill.sprite = dogFill;
healthOutline.sprite = dogOutline;
}
}
public void UpdateMaterial()
{
if (dogRenderers == null)
{
Debug.LogWarning((object)"Skipping material replacement on dog because there was an error earlier.");
return;
}
SkinnedMeshRenderer[] array = dogRenderers;
for (int i = 0; i < array.Length; i++)
{
((Renderer)array[i]).material = ((Renderer)playerController.thisPlayerModel).material;
}
}
public void ToggleAndBroadcast(bool playAudio = true)
{
if (isDogActive)
{
EnableHumanModel();
}
else
{
EnableDogModel();
}
BroadcastSelectedModel(playAudio);
}
public void BroadcastSelectedModel(bool playAudio)
{
Debug.Log((object)$"Sent dog={isDogActive} on {playerController.playerClientId} ({playerController.playerUsername}).");
ToggleData toggleData = new ToggleData
{
playerClientId = PlayerClientId,
isDog = isDogActive,
playAudio = playAudio
};
Network.Broadcast<ToggleData>("modelswitch", toggleData);
}
public static void RequestSelectedModelBroadcast()
{
Network.Broadcast("modelinfo");
}
private static void LoadImageResources()
{
//IL_0024: 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_006b: 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)
try
{
Texture2D loadedAsset = BundleLoader.GetLoadedAsset<Texture2D>("assets/TPoseFilled.png");
dogFill = Sprite.Create(loadedAsset, new Rect(0f, 0f, (float)((Texture)loadedAsset).width, (float)((Texture)loadedAsset).height), new Vector2(0.5f, 0.5f), 100f);
Texture2D loadedAsset2 = BundleLoader.GetLoadedAsset<Texture2D>("assets/TPoseOutline.png");
dogOutline = Sprite.Create(loadedAsset2, new Rect(0f, 0f, (float)((Texture)loadedAsset2).width, (float)((Texture)loadedAsset2).height), new Vector2(0.5f, 0.5f), 100f);
}
catch (Exception ex)
{
exceptionMessage = "Failed to retrieve images.";
exception = ex;
Debug.LogError((object)exceptionMessage);
Debug.LogException(exception);
}
}
private static IEnumerator LoadAudioResources()
{
string fullPath2 = GetAssemblyFullPath("ChangeSuitToHuman.wav");
UnityWebRequest request2 = UnityWebRequestMultimedia.GetAudioClip(fullPath2, (AudioType)20);
yield return request2.SendWebRequest();
if (request2.error == null)
{
humanClip = DownloadHandlerAudioClip.GetContent(request2);
((Object)humanClip).name = Path.GetFileName(fullPath2);
}
fullPath2 = GetAssemblyFullPath("ChangeSuitToDog.wav");
request2 = UnityWebRequestMultimedia.GetAudioClip(fullPath2, (AudioType)20);
yield return request2.SendWebRequest();
if (request2.error == null)
{
dogClip = DownloadHandlerAudioClip.GetContent(request2);
((Object)dogClip).name = Path.GetFileName(fullPath2);
}
}
private static string GetAssemblyFullPath(string additionalPath)
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
return Path.GetFullPath((additionalPath != null) ? Path.Combine(directoryName, ".\\" + additionalPath) : directoryName);
}
}
public class PlayerModelSwitcher : MonoBehaviour
{
private void Start()
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: 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_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
GameObject obj = Object.Instantiate<GameObject>(BundleLoader.GetLoadedAsset<GameObject>("assets/Helmets.fbx"), ((Component)this).transform);
obj.transform.localPosition = Vector3.zero;
obj.transform.localRotation = Quaternion.identity;
obj.transform.localScale = Vector3.one * 0.75f;
Renderer component = obj.GetComponent<Renderer>();
Material[] materials = component.materials;
for (int i = 0; i < StartOfRound.Instance.unlockablesList.unlockables.Count; i++)
{
if (Object.op_Implicit((Object)(object)StartOfRound.Instance.unlockablesList.unlockables[0].suitMaterial))
{
materials[0] = StartOfRound.Instance.unlockablesList.unlockables[0].suitMaterial;
break;
}
}
materials[1] = ((Component)this).GetComponent<Renderer>().material;
component.materials = materials;
GameObject gameObject = ((Component)Object.Instantiate<ScanNodeProperties>(Object.FindObjectOfType<ScanNodeProperties>())).gameObject;
gameObject.transform.parent = ((Component)this).transform;
gameObject.transform.localPosition = new Vector3(0.75f, 0f, 0.8f);
ScanNodeProperties component2 = gameObject.GetComponent<ScanNodeProperties>();
component2.headerText = "Dog equipment";
component2.subText = "Switch to the dog model here.";
InteractTrigger obj2 = Object.Instantiate<InteractTrigger>(((Component)GameObject.Find("SpeakerAudio").transform.parent).GetComponentInChildren<InteractTrigger>());
((Component)obj2).transform.position = ((Component)this).transform.TransformPoint(new Vector3(0.75f, 0f, 0.9f));
((Component)obj2).transform.localScale = new Vector3(0.3f, 0.7f, 0.3f);
obj2.hoverTip = "Switch model";
obj2.interactable = true;
obj2.cooldownTime = 1f;
((UnityEventBase)obj2.onCancelAnimation).RemoveAllListeners();
((UnityEventBase)obj2.onInteractEarly).RemoveAllListeners();
((UnityEventBase)obj2.onStopInteract).RemoveAllListeners();
((UnityEventBase)obj2.onInteract).RemoveAllListeners();
((UnityEvent<PlayerControllerB>)(object)obj2.onInteract).AddListener((UnityAction<PlayerControllerB>)Interacted);
}
private void Interacted(PlayerControllerB player)
{
((Component)player).GetComponentInChildren<PlayerModelReplacer>().ToggleAndBroadcast();
}
}
[BepInPlugin("PlayerDogModel", "PlayerDogModel", "1.0.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("Lethal Company.exe")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(PlayerControllerB))]
internal class PlayerControllerBPatch
{
[HarmonyPatch("SpawnPlayerAnimation")]
[HarmonyPostfix]
public static void SpawnPlayerAnimationPatch(ref PlayerControllerB __instance)
{
GameObject[] allPlayerObjects = StartOfRound.Instance.allPlayerObjects;
foreach (GameObject val in allPlayerObjects)
{
if (!Object.op_Implicit((Object)(object)val.GetComponent<PlayerModelReplacer>()))
{
val.gameObject.AddComponent<PlayerModelReplacer>();
}
}
PlayerModelReplacer.RequestSelectedModelBroadcast();
}
}
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch
{
[HarmonyPatch("PositionSuitsOnRack")]
[HarmonyPostfix]
public static void PositionSuitsOnRackPatch(ref StartOfRound __instance)
{
if (!Object.op_Implicit((Object)(object)Object.FindObjectOfType<PlayerModelSwitcher>()))
{
GameObject.Find("NurbsPath.002").AddComponent<PlayerModelSwitcher>();
}
}
}
[HarmonyPatch(typeof(UnlockableSuit))]
internal class UnlockableSuitPatch
{
[HarmonyPatch("SwitchSuitForPlayer")]
[HarmonyPostfix]
public static void SwitchSuitForPlayerPatch(PlayerControllerB player, int suitID, bool playAudio = true)
{
PlayerModelReplacer component = ((Component)player).GetComponent<PlayerModelReplacer>();
if (Object.op_Implicit((Object)(object)component))
{
component.UpdateMaterial();
}
}
}
[HarmonyPatch(typeof(DeadBodyInfo))]
internal class DeadBodyPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void StartPatch(ref DeadBodyInfo __instance)
{
//IL_00ec: 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_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0265: Unknown result type (might be due to invalid IL or missing references)
//IL_027f: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0317: Unknown result type (might be due to invalid IL or missing references)
//IL_0322: Unknown result type (might be due to invalid IL or missing references)
if (((Component)__instance.playerScript).GetComponent<PlayerModelReplacer>().IsDog)
{
SkinnedMeshRenderer component = ((Component)__instance).GetComponent<SkinnedMeshRenderer>();
((Renderer)component).enabled = false;
Material material = ((Renderer)component).material;
Transform obj = ((Component)__instance).transform.Find("spine.001");
Transform sourceTransform = obj.Find("spine.002").Find("spine.003").Find("spine.004");
Transform sourceTransform2 = obj.Find("spine.002").Find("spine.003").Find("shoulder.L")
.Find("arm.L_upper");
Transform sourceTransform3 = obj.Find("spine.002").Find("spine.003").Find("shoulder.R")
.Find("arm.R_upper");
Transform sourceTransform4 = obj.Find("thigh.L");
Transform sourceTransform5 = obj.Find("thigh.R");
GameObject val = Object.Instantiate<GameObject>(BundleLoader.GetLoadedAsset<GameObject>("assets/DogRagdoll.fbx"), ((Component)__instance).transform);
val.transform.position = ((Component)__instance).transform.position;
val.transform.eulerAngles = ((Component)__instance).transform.eulerAngles;
Transform transform = val.transform;
transform.localScale *= 1.8f;
SkinnedMeshRenderer[] componentsInChildren = val.GetComponentsInChildren<SkinnedMeshRenderer>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
((Renderer)componentsInChildren[i]).material = material;
}
Transform obj2 = val.transform.Find("Armature").Find("torso");
Transform val2 = obj2.Find("head");
Transform val3 = obj2.Find("arm.L");
Transform val4 = obj2.Find("arm.R");
Transform val5 = obj2.Find("butt").Find("leg.L");
Transform val6 = obj2.Find("butt").Find("leg.R");
RotationConstraint obj3 = ((Component)val2).gameObject.AddComponent<RotationConstraint>();
ConstraintSource val7 = default(ConstraintSource);
((ConstraintSource)(ref val7)).sourceTransform = sourceTransform;
((ConstraintSource)(ref val7)).weight = 1f;
obj3.AddSource(val7);
obj3.rotationAtRest = val2.localEulerAngles;
obj3.constraintActive = true;
obj3.locked = true;
RotationConstraint obj4 = ((Component)val3).gameObject.AddComponent<RotationConstraint>();
val7 = default(ConstraintSource);
((ConstraintSource)(ref val7)).sourceTransform = sourceTransform3;
((ConstraintSource)(ref val7)).weight = 1f;
obj4.AddSource(val7);
obj4.rotationAtRest = val3.localEulerAngles;
obj4.constraintActive = true;
obj4.locked = true;
RotationConstraint obj5 = ((Component)val4).gameObject.AddComponent<RotationConstraint>();
val7 = default(ConstraintSource);
((ConstraintSource)(ref val7)).sourceTransform = sourceTransform2;
((ConstraintSource)(ref val7)).weight = 1f;
obj5.AddSource(val7);
obj5.rotationAtRest = val4.localEulerAngles;
obj5.constraintActive = true;
obj5.locked = true;
RotationConstraint obj6 = ((Component)val5).gameObject.AddComponent<RotationConstraint>();
val7 = default(ConstraintSource);
((ConstraintSource)(ref val7)).sourceTransform = sourceTransform4;
((ConstraintSource)(ref val7)).weight = 1f;
obj6.AddSource(val7);
obj6.rotationAtRest = val5.localEulerAngles;
obj6.constraintActive = true;
obj6.locked = true;
RotationConstraint obj7 = ((Component)val6).gameObject.AddComponent<RotationConstraint>();
val7 = default(ConstraintSource);
((ConstraintSource)(ref val7)).sourceTransform = sourceTransform5;
((ConstraintSource)(ref val7)).weight = 1f;
obj7.AddSource(val7);
obj7.rotationAtRest = val6.localEulerAngles;
obj7.constraintActive = true;
obj7.locked = true;
}
}
}
public static Harmony _harmony;
private void Awake()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
_harmony = new Harmony("PlayerDogModel");
_harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"PlayerDogModel loaded");
Networking.Initialize();
BundleLoader.LoadAssetBundle(GetAssemblyFullPath("playerdog"), true);
}
private static string GetAssemblyFullPath(string additionalPath)
{
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
return Path.GetFullPath((additionalPath != null) ? Path.Combine(directoryName, ".\\" + additionalPath) : directoryName);
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "PlayerDogModel";
public const string PLUGIN_NAME = "PlayerDogModel";
public const string PLUGIN_VERSION = "1.0.3";
}