using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering.HighDefinition;
[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: AssemblyCompany("LethalNardo")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Increase the max players in Lethal Company")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+8531a322b8aa5cec1b6378acc252d5697a30b402")]
[assembly: AssemblyProduct("LethalNardo")]
[assembly: AssemblyTitle("LethalNardo")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace CreatureModels
{
public class LethalCreature
{
public class CreatureController : MonoBehaviour
{
private GameObject lethalyeenObj = null;
private void Start()
{
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: 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_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_0270: Expected O, but got Unknown
//IL_0296: Unknown result type (might be due to invalid IL or missing references)
//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
//IL_02ad: Expected O, but got Unknown
//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Expected O, but got Unknown
//IL_0310: Unknown result type (might be due to invalid IL or missing references)
//IL_0320: Unknown result type (might be due to invalid IL or missing references)
//IL_0327: Expected O, but got Unknown
//IL_034d: Unknown result type (might be due to invalid IL or missing references)
((Component)this).gameObject.GetComponentInChildren<LODGroup>().enabled = false;
SkinnedMeshRenderer[] componentsInChildren = ((Component)this).gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
SkinnedMeshRenderer[] array = componentsInChildren;
foreach (SkinnedMeshRenderer val in array)
{
((Renderer)val).enabled = false;
}
AssetHandler.TryLoadAssets();
if ((Object)(object)lethalyeenObj == (Object)null)
{
lethalyeenObj = Object.Instantiate<GameObject>(AssetHandler.lethalyeen);
}
lethalyeenObj.transform.localScale = Vector3.one;
Transform val2 = ((Component)this).gameObject.transform.Find("ScavengerModel/metarig");
Transform parent = val2.Find("spine/spine.001");
lethalyeenObj.transform.SetParent(parent);
lethalyeenObj.transform.localPosition = Vector3.zero;
lethalyeenObj.transform.localRotation = Quaternion.identity;
SkinnedMeshRenderer thisPlayerModel = ((Component)this).gameObject.GetComponent<PlayerControllerB>().thisPlayerModel;
Shader shader = ((Renderer)thisPlayerModel).material.shader;
SkinnedMeshRenderer componentInChildren = lethalyeenObj.GetComponentInChildren<SkinnedMeshRenderer>();
MaterialAssembler.UpdateMaterial(ref ((Renderer)componentInChildren).materials[0], ref shader, ref AssetHandler.TexBase01);
HDMaterial.ValidateMaterial(((Renderer)componentInChildren).materials[0]);
Animator componentInChildren2 = lethalyeenObj.GetComponentInChildren<Animator>();
componentInChildren2.runtimeAnimatorController = AssetHandler.animController;
IKController iKController = lethalyeenObj.AddComponent<IKController>();
Transform val3 = val2.Find("spine").Find("thigh.L");
Transform val4 = val2.Find("spine").Find("thigh.R");
Transform val5 = val3.Find("shin.L");
Transform val6 = val4.Find("shin.R");
Transform val7 = val5.Find("foot.L");
Transform val8 = val6.Find("foot.R");
Transform val9 = val2.Find("spine").Find("spine.001").Find("spine.002")
.Find("spine.003");
Transform val10 = val9.Find("shoulder.L");
Transform val11 = val9.Find("shoulder.R");
Transform val12 = val10.Find("arm.L_upper");
Transform val13 = val11.Find("arm.R_upper");
Transform val14 = val12.Find("arm.L_lower");
Transform val15 = val13.Find("arm.R_lower");
Transform val16 = val14.Find("hand.L");
Transform val17 = val15.Find("hand.R");
GameObject val18 = new GameObject("IK Offset");
val18.transform.SetParent(val7, false);
val18.transform.localPosition = new Vector3(0f, 0f, 0f);
GameObject val19 = new GameObject("IK Offset");
val19.transform.SetParent(val8, false);
val19.transform.localPosition = new Vector3(0f, 0f, 0f);
GameObject val20 = new GameObject("IK Offset");
val20.transform.SetParent(val16, false);
val20.transform.localPosition = new Vector3(0f, 0f, 0f);
GameObject val21 = new GameObject("IK Offset");
val21.transform.SetParent(val17, false);
val21.transform.localPosition = new Vector3(0f, 0f, 0f);
iKController.leftLegTarget = val18.transform;
iKController.rightLegTarget = val19.transform;
iKController.leftHandTarget = val20.transform;
iKController.rightHandTarget = val21.transform;
iKController.ikActive = true;
}
private void LateUpdate()
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)lethalyeenObj != (Object)null)
{
lethalyeenObj.transform.localPosition = new Vector3(0f, 0.1f, 0f);
Transform val = ((Component)this).gameObject.transform.Find("ScavengerModel/metarig");
Transform val2 = val.Find("spine/spine.001/spine.002/spine.003");
lethalyeenObj.transform.Find("Armature/Hips/Spine/Chest").localRotation = val2.localRotation;
}
}
}
}
public static class AssetHandler
{
public static Texture TexBase01;
public static Texture TexBase02;
public static Texture TexBase03;
public static Texture TexBase04;
public static Texture AddsuitRed;
public static Texture AddsuitPurple;
public static Texture AddsuitPink;
public static Texture AddsuitWhite;
public static Texture AddsuitBlack;
public static GameObject lethalyeen;
public static RuntimeAnimatorController animController;
public static bool resourcesLoaded = false;
public static Dictionary<int, Dictionary<int, Texture>> BaseTextures = new Dictionary<int, Dictionary<int, Texture>>();
private static string texturePrefix = "assets/textures/lc";
public static string[] animalNames = new string[1] { "hyena" };
public static int[] animalIds;
public static string[] suits = new string[4] { "red", "green", "hazard", "pajama" };
public static AssetBundle bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "hazmatnardobundle"));
public static void TryLoadAssets()
{
if (animalIds == null)
{
animalIds = new int[animalNames.Length];
for (int i = 0; i < animalIds.Length; i++)
{
animalIds[i] = animalNames[i].GetStableHashCode();
}
}
if (BaseTextures.Count == 0)
{
for (int j = 0; j < animalIds.Length; j++)
{
Dictionary<int, Texture> value = new Dictionary<int, Texture>();
BaseTextures[animalIds[j]] = value;
}
}
if (!resourcesLoaded)
{
lethalyeen = bundle.LoadAsset<GameObject>("assets/hazmatnardo.fbx");
TexBase01 = bundle.LoadAsset<Texture>("assets/textures/defaultcolor.png");
TexBase02 = bundle.LoadAsset<Texture>("assets/textures/2_green_suit.png");
TexBase03 = bundle.LoadAsset<Texture>("assets/textures/1_yellow_suit.png");
TexBase04 = bundle.LoadAsset<Texture>("assets/textures/3_blue_suit.png");
animController = bundle.LoadAsset<RuntimeAnimatorController>("assets/nardocontroller.controller");
resourcesLoaded = true;
}
}
}
public static class MaterialAssembler
{
public static void UpdateMaterial(ref Material mat, ref Shader shader, ref Texture baseTexture)
{
mat.shader = shader;
mat.SetTexture("_BaseColorMap", baseTexture);
mat.SetFloat("_Smoothness", 0.3f);
}
}
public static class Utilities
{
public static int GetStableHashCode(this string str)
{
int num = 5381;
int num2 = num;
for (int i = 0; i < str.Length && str[i] != 0; i += 2)
{
num = ((num << 5) + num) ^ str[i];
if (i == str.Length - 1 || str[i + 1] == '\0')
{
break;
}
num2 = ((num2 << 5) + num2) ^ str[i + 1];
}
return num + num2 * 1566083941;
}
}
public class IKController : MonoBehaviour
{
protected Animator animator;
public bool ikActive = false;
public Transform leftLegTarget = null;
public Transform rightLegTarget = null;
public Transform leftHandTarget = null;
public Transform rightHandTarget = null;
private void Start()
{
animator = ((Component)this).GetComponent<Animator>();
}
private void OnAnimatorIK()
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
if (!Object.op_Implicit((Object)(object)animator))
{
return;
}
if (ikActive)
{
if ((Object)(object)leftLegTarget != (Object)null)
{
animator.SetIKPositionWeight((AvatarIKGoal)0, 1f);
animator.SetIKPosition((AvatarIKGoal)0, leftLegTarget.position);
animator.SetIKRotation((AvatarIKGoal)0, leftLegTarget.rotation);
}
if ((Object)(object)rightLegTarget != (Object)null)
{
animator.SetIKPositionWeight((AvatarIKGoal)1, 1f);
animator.SetIKPosition((AvatarIKGoal)1, rightLegTarget.position);
animator.SetIKRotation((AvatarIKGoal)1, rightLegTarget.rotation);
}
if ((Object)(object)leftHandTarget != (Object)null)
{
animator.SetIKPositionWeight((AvatarIKGoal)2, 1f);
animator.SetIKPosition((AvatarIKGoal)2, leftHandTarget.position);
animator.SetIKRotation((AvatarIKGoal)2, leftHandTarget.rotation);
}
if ((Object)(object)rightHandTarget != (Object)null)
{
animator.SetIKPositionWeight((AvatarIKGoal)3, 1f);
animator.SetIKPosition((AvatarIKGoal)3, rightHandTarget.position);
animator.SetIKRotation((AvatarIKGoal)3, rightHandTarget.rotation);
}
}
else
{
animator.SetIKPositionWeight((AvatarIKGoal)0, 0f);
animator.SetIKRotationWeight((AvatarIKGoal)0, 0f);
animator.SetIKPositionWeight((AvatarIKGoal)1, 0f);
animator.SetIKRotationWeight((AvatarIKGoal)1, 0f);
animator.SetIKPositionWeight((AvatarIKGoal)2, 0f);
animator.SetIKRotationWeight((AvatarIKGoal)2, 0f);
animator.SetIKPositionWeight((AvatarIKGoal)3, 0f);
animator.SetIKRotationWeight((AvatarIKGoal)3, 0f);
}
}
}
[BepInPlugin("anotherwilson.lethalnardo", "Nardoragon for Lethal Company", "1.1.0")]
public class Plugin : BaseUnityPlugin
{
public const string Version = "1.1.0";
public const string ModName = "Nardoragon for Lethal Company";
public const string GUID = "anotherwilson.lethalnardo";
public const string assetBundleName = "hazmatnardobundle";
public static Harmony _harmony = new Harmony("anotherwilson.lethalnardo");
public static ManualLogSource Log;
private void Awake()
{
_harmony.PatchAll();
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"NardoSnoot");
Log.LogInfo((object)"LethalNardo loaded");
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "LethalNardo";
public const string PLUGIN_NAME = "LethalNardo";
public const string PLUGIN_VERSION = "1.0.2";
}
}
namespace CreatureModels.Patches
{
[HarmonyPatch]
internal class PlayerObjects
{
public static void InitModels()
{
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
Debug.Log((object)((Object)((Component)localPlayerController).gameObject).name);
PlayerControllerB[] array = Object.FindObjectsOfType<PlayerControllerB>();
PlayerControllerB[] array2 = array;
foreach (PlayerControllerB val in array2)
{
if (!((Object)(object)val == (Object)(object)localPlayerController))
{
SkinnedMeshRenderer val2 = ((Component)val).gameObject.GetComponentsInChildren<SkinnedMeshRenderer>().ToList().Find((SkinnedMeshRenderer x) => ((Object)x).name.Contains("Body"));
if (!((Object)(object)val2 != (Object)null))
{
((Component)val).gameObject.AddComponent<LethalCreature.CreatureController>();
}
}
}
}
[HarmonyPatch(typeof(PlayerControllerB), "SpawnPlayerAnimation")]
[HarmonyPostfix]
public static void InitModel(ref PlayerControllerB __instance)
{
InitModels();
}
[HarmonyPatch(typeof(PlayerControllerB), "DisablePlayerModel")]
[HarmonyPostfix]
public static void DisablePlayerModel(ref PlayerControllerB __instance, GameObject playerObject)
{
PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
playerObject.gameObject.GetComponentInChildren<LODGroup>().enabled = false;
SkinnedMeshRenderer[] componentsInChildren = playerObject.gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
SkinnedMeshRenderer[] array = componentsInChildren;
foreach (SkinnedMeshRenderer val in array)
{
if (!(((Object)val).name == "Body"))
{
((Renderer)val).enabled = false;
}
}
}
}
[HarmonyPatch(typeof(UnlockableSuit))]
internal class UnlockableSuitPatch
{
[HarmonyPatch("SwitchSuitForPlayer")]
[HarmonyPrefix]
private static void SwitchSuitForPlayerPatch(PlayerControllerB player, int suitID, bool playAudio = true)
{
Texture val = (Texture)(suitID switch
{
0 => AssetHandler.TexBase01,
1 => AssetHandler.TexBase02,
2 => AssetHandler.TexBase03,
3 => AssetHandler.TexBase04,
_ => AssetHandler.TexBase01,
});
SkinnedMeshRenderer[] componentsInChildren = ((Component)player).gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
Debug.Log((object)"Looking for meshes...");
SkinnedMeshRenderer[] array = componentsInChildren;
foreach (SkinnedMeshRenderer val2 in array)
{
Debug.Log((object)("Found a mesh: " + ((Object)val2).name));
((Renderer)val2).materials[0].SetTexture("_BaseColorMap", val);
}
}
}
}