Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LethalCawmpany v0.1.5
LethalCawmpanyProj.dll
Decompiled 2 years agousing 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.Configuration; using CrowModelReplacement; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using ModelReplacement; using ModelReplacement.AvatarBodyUpdater; using ModelReplacement.Scripts.Player; 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-CSharp")] [assembly: AssemblyCompany("LethalCawmpanyProj")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("LethalCawmpanyProj")] [assembly: AssemblyTitle("LethalCawmpanyProj")] [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 ModelReplacement.AvatarBodyUpdater { public class CrowAvatarUpdater : ViewModelUpdater { protected SkinnedMeshRenderer viewModelRenderer = null; protected Animator replacementViewAnimator = null; protected Vector3 firstPersonRootPositionOffset; protected bool hasUpperChest; private PlayerControllerB controller; private static Dictionary<string, HumanBodyBones> pModelToAvatarBone = new Dictionary<string, HumanBodyBones> { { "spine", (HumanBodyBones)0 }, { "spine.001", (HumanBodyBones)7 }, { "shoulder.L", (HumanBodyBones)11 }, { "arm.L_upper", (HumanBodyBones)13 }, { "arm.L_lower", (HumanBodyBones)15 }, { "hand.L", (HumanBodyBones)17 }, { "finger5.L", (HumanBodyBones)36 }, { "finger5.L.001", (HumanBodyBones)37 }, { "finger4.L", (HumanBodyBones)33 }, { "finger4.L.001", (HumanBodyBones)34 }, { "finger3.L", (HumanBodyBones)30 }, { "finger3.L.001", (HumanBodyBones)31 }, { "finger2.L", (HumanBodyBones)27 }, { "finger2.L.001", (HumanBodyBones)28 }, { "finger1.L", (HumanBodyBones)24 }, { "finger1.L.001", (HumanBodyBones)26 }, { "shoulder.R", (HumanBodyBones)12 }, { "arm.R_upper", (HumanBodyBones)14 }, { "arm.R_lower", (HumanBodyBones)16 }, { "hand.R", (HumanBodyBones)18 }, { "finger5.R", (HumanBodyBones)51 }, { "finger5.R.001", (HumanBodyBones)52 }, { "finger4.R", (HumanBodyBones)48 }, { "finger4.R.001", (HumanBodyBones)49 }, { "finger3.R", (HumanBodyBones)45 }, { "finger3.R.001", (HumanBodyBones)46 }, { "finger2.R", (HumanBodyBones)42 }, { "finger2.R.001", (HumanBodyBones)43 }, { "finger1.R", (HumanBodyBones)39 }, { "finger1.R.001", (HumanBodyBones)41 }, { "spine.004", (HumanBodyBones)10 }, { "thigh.L", (HumanBodyBones)1 }, { "shin.L", (HumanBodyBones)3 }, { "foot.L", (HumanBodyBones)5 }, { "toe.L", (HumanBodyBones)19 }, { "thigh.R", (HumanBodyBones)2 }, { "shin.R", (HumanBodyBones)4 }, { "foot.R", (HumanBodyBones)6 }, { "toe.R", (HumanBodyBones)20 } }; public override void AssignViewModelReplacement(GameObject player, GameObject replacementViewModel) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_00a1: 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_00b7: 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) controller = player.GetComponent<PlayerControllerB>(); viewModelRenderer = (Object.op_Implicit((Object)(object)controller) ? controller.thisPlayerModelArms : null); if ((Object)(object)viewModelRenderer == (Object)null) { ModelReplacementAPI.Instance.Logger.LogFatal((object)"Failed to start CrowAvatarUpdater"); return; } replacementViewAnimator = replacementViewModel.GetComponentInChildren<Animator>(); base.replacementViewModel = replacementViewModel; Vector3 localScale = replacementViewModel.transform.localScale; float num = 0.5f; replacementViewModel.transform.localScale = localScale * num; firstPersonRootPositionOffset = new Vector3(0f, -0.1f, -0.1f); replacementViewModel.transform.localScale = replacementViewModel.transform.localScale * 2.75f; Transform boneTransform = replacementViewAnimator.GetBoneTransform((HumanBodyBones)54); hasUpperChest = (Object)(object)boneTransform != (Object)null; replacementViewModel.SetActive(true); } protected override void UpdateViewModel() { //IL_009e: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) Transform[] bones = viewModelRenderer.bones; foreach (Transform val in bones) { Transform viewAvatarTransformFromBoneName = GetViewAvatarTransformFromBoneName(((Object)val).name); if (!((Object)(object)viewAvatarTransformFromBoneName == (Object)null)) { viewAvatarTransformFromBoneName.rotation = val.rotation; RotationOffset component = ((Component)viewAvatarTransformFromBoneName).GetComponent<RotationOffset>(); if (Object.op_Implicit((Object)(object)component)) { viewAvatarTransformFromBoneName.rotation *= component.offset; } } } Transform viewAvatarTransformFromBoneName2 = GetViewAvatarTransformFromBoneName("spine.003"); Transform fPPlayerTransformFromBoneName = GetFPPlayerTransformFromBoneName("spine.003"); viewAvatarTransformFromBoneName2.position = fPPlayerTransformFromBoneName.position + fPPlayerTransformFromBoneName.TransformVector(firstPersonRootPositionOffset); } private Transform GetViewAvatarTransformFromBoneName(string boneName) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) if (boneName == "spine.002") { return hasUpperChest ? replacementViewAnimator.GetBoneTransform((HumanBodyBones)8) : null; } if (boneName == "spine.003") { return hasUpperChest ? replacementViewAnimator.GetBoneTransform((HumanBodyBones)54) : replacementViewAnimator.GetBoneTransform((HumanBodyBones)8); } if (boneName.Contains("PlayerRagdoll")) { return replacementViewAnimator.GetBoneTransform((HumanBodyBones)0); } HumanBodyBones value; return pModelToAvatarBone.TryGetValue(boneName, out value) ? replacementViewAnimator.GetBoneTransform(value) : null; } public Transform GetFPPlayerTransformFromBoneName(string boneName) { string boneName2 = boneName; IEnumerable<Transform> source = viewModelRenderer.bones.Where((Transform x) => ((Object)x).name == boneName2); if (source.Any()) { return source.First(); } if (boneName2 == "spine") { IEnumerable<Transform> source2 = viewModelRenderer.bones.Where((Transform x) => ((Object)x).name.Contains("PlayerRagdoll")); return source2.Any() ? source2.First() : null; } return null; } public void MoveUp(float amount) { //IL_0003: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) firstPersonRootPositionOffset += new Vector3(0f, 0f, amount); Plugin.ShowMessage("Offset is now " + ((object)(Vector3)(ref firstPersonRootPositionOffset)).ToString()); } public void MoveDown(float amount) { //IL_0003: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) firstPersonRootPositionOffset -= new Vector3(0f, 0f, amount); Plugin.ShowMessage("Offset is now " + ((object)(Vector3)(ref firstPersonRootPositionOffset)).ToString()); } } } namespace CrowModelReplacement { public class CrowBodyReplacement : BodyReplacementBase { private CrowAvatarUpdater customUpdater = null; private Vector3 originalHatSize; private Vector3 originalHatSizeLocal; private Vector3 originalLowerTorsoSize; private bool originalSizesSet; protected override void Awake() { GameObject val = LoadAssetsAndReturnModelHack("crowmate"); if ((Object)(object)val == (Object)null) { ModelReplacementAPI.Instance.Logger.LogFatal((object)"LoadAssetsAndReturnModel() returned null. Verify that your assetbundle works and your asset name is correct. "); } else { Animator componentInChildren = val.GetComponentInChildren<Animator>(); OffsetBuilder component = ((Component)componentInChildren).gameObject.GetComponent<OffsetBuilder>(); component.GenerateViewModel = Plugin.replaceHands.Value; } val = LoadAssetsAndReturnModelHack("crowmatebee"); if ((Object)(object)val == (Object)null) { ModelReplacementAPI.Instance.Logger.LogFatal((object)"LoadAssetsAndReturnModel() returned null. Verify that your assetbundle works and your asset name is correct. "); } else { Animator componentInChildren2 = val.GetComponentInChildren<Animator>(); OffsetBuilder component2 = ((Component)componentInChildren2).gameObject.GetComponent<OffsetBuilder>(); component2.GenerateViewModel = Plugin.replaceHands.Value; } val = LoadAssetsAndReturnModelHack("crowmatebunny"); if ((Object)(object)val == (Object)null) { ModelReplacementAPI.Instance.Logger.LogFatal((object)"LoadAssetsAndReturnModel() returned null. Verify that your assetbundle works and your asset name is correct. "); } else { Animator componentInChildren3 = val.GetComponentInChildren<Animator>(); OffsetBuilder component3 = ((Component)componentInChildren3).gameObject.GetComponent<OffsetBuilder>(); component3.GenerateViewModel = Plugin.replaceHands.Value; } originalSizesSet = false; ((BodyReplacementBase)this).Awake(); } protected override GameObject LoadAssetsAndReturnModel() { string text = "crowmate"; string text2 = "crowmatebee"; string text3 = "crowmatebunny"; GameObject val; switch (StartOfRound.Instance.unlockablesList.unlockables[((BodyReplacementBase)this).controller.currentSuitID].unlockableName) { case "Bee Suit": case "Bee suit": case "CABee": HideAccessories(); val = Assets.MainAssetBundle.LoadAsset<GameObject>(text2); break; case "Bunny Suit": case "Bunny suit": case "CABunny": HideAccessories(); val = Assets.MainAssetBundle.LoadAsset<GameObject>(text3); break; default: RestoreAccessories(); val = Assets.MainAssetBundle.LoadAsset<GameObject>(text); break; } Material material; switch (StartOfRound.Instance.unlockablesList.unlockables[((BodyReplacementBase)this).controller.currentSuitID].unlockableName) { case "Green suit": case "CAGreen": material = Assets.MainAssetBundle.LoadAsset<Material>("CrowmateGreen"); break; case "Hazard suit": case "CAHaz": material = Assets.MainAssetBundle.LoadAsset<Material>("CrowmateHazard"); break; case "CAPajam": case "Pajama suit": material = Assets.MainAssetBundle.LoadAsset<Material>("CrowmatePajama"); break; case "Purple Suit": case "CAPurp": material = Assets.MainAssetBundle.LoadAsset<Material>("CrowmatePurple"); break; case "CABee": case "Bee Suit": case "Bee suit": material = Assets.MainAssetBundle.LoadAsset<Material>("CrowmateBee"); break; case "Bunny Suit": case "Bunny suit": case "CABunny": material = Assets.MainAssetBundle.LoadAsset<Material>("CrowmateBunny"); break; default: material = Assets.MainAssetBundle.LoadAsset<Material>("CrowmateOrange"); break; } SkinnedMeshRenderer[] componentsInChildren = val.GetComponentsInChildren<SkinnedMeshRenderer>(); SkinnedMeshRenderer[] array = componentsInChildren; foreach (SkinnedMeshRenderer val2 in array) { ((Renderer)val2).SetMaterial(material); } return val; } private void HideAccessories() { //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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (!originalSizesSet) { originalHatSize = ((BodyReplacementBase)this).controller.headCostumeContainer.localScale; originalHatSizeLocal = ((BodyReplacementBase)this).controller.headCostumeContainerLocal.localScale; originalLowerTorsoSize = ((BodyReplacementBase)this).controller.lowerTorsoCostumeContainer.localScale; originalSizesSet = true; } ((BodyReplacementBase)this).controller.headCostumeContainer.localScale = Vector3.zero; ((BodyReplacementBase)this).controller.headCostumeContainerLocal.localScale = Vector3.zero; ((BodyReplacementBase)this).controller.lowerTorsoCostumeContainer.localScale = Vector3.zero; } private void RestoreAccessories() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if (!originalSizesSet) { originalHatSize = ((BodyReplacementBase)this).controller.headCostumeContainer.localScale; originalHatSizeLocal = ((BodyReplacementBase)this).controller.headCostumeContainerLocal.localScale; originalLowerTorsoSize = ((BodyReplacementBase)this).controller.lowerTorsoCostumeContainer.localScale; originalSizesSet = true; } ((BodyReplacementBase)this).controller.headCostumeContainer.localScale = originalHatSize; ((BodyReplacementBase)this).controller.headCostumeContainerLocal.localScale = originalHatSizeLocal; ((BodyReplacementBase)this).controller.lowerTorsoCostumeContainer.localScale = originalLowerTorsoSize; } protected override void OnEmoteStart(int emoteId) { if (emoteId == 2) { ((BodyReplacementBase)this).controller.movementAudio.PlayOneShot(Assets.GetRandomCaw(), Plugin.cawVolume.Value); } } protected GameObject LoadAssetsAndReturnModelHack(string modelName) { return Assets.MainAssetBundle.LoadAsset<GameObject>(modelName); } protected override ViewModelUpdater GetViewModelUpdater() { if (Plugin.replaceHands.Value) { customUpdater = new CrowAvatarUpdater(); return (ViewModelUpdater)(object)customUpdater; } return ((BodyReplacementBase)this).GetViewModelUpdater(); } } [BepInPlugin("com.moopmantis.lethalcawmpany", "Lethal Cawmpany", "0.1.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public static ConfigFile config; public static ConfigEntry<bool> defaultToCrow { get; private set; } public static ConfigEntry<float> cawVolume { get; private set; } public static ConfigEntry<bool> replaceHands { get; private set; } public static Plugin Instance { get; private set; } private static void InitConfig() { defaultToCrow = config.Bind<bool>("Suit Replacement Settings", "Default to crow model", false, "If true, non-vanilla suits (e.g. from MoreSuits) will show as the orange crow model instead."); replaceHands = config.Bind<bool>("Suit Replacement Settings", "Replace first person hands", true, "If true, replaces the employee's hands in first person with those big dumb feather hands."); cawVolume = config.Bind<float>("Audio Settings", "Caw Volume", 0.3f, "Adjust the volulme of caw sounds when pointing."); } private void Awake() { //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown config = ((BaseUnityPlugin)this).Config; InitConfig(); if ((Object)(object)Instance == (Object)null) { Instance = this; } Assets.PopulateAssets(); ModelReplacementAPI.RegisterSuitModelReplacement("Default", typeof(CrowBodyReplacement)); ModelReplacementAPI.RegisterSuitModelReplacement("Orange suit", typeof(CrowBodyReplacement)); ModelReplacementAPI.RegisterSuitModelReplacement("Green suit", typeof(CrowBodyReplacement)); ModelReplacementAPI.RegisterSuitModelReplacement("Hazard suit", typeof(CrowBodyReplacement)); ModelReplacementAPI.RegisterSuitModelReplacement("Pajama suit", typeof(CrowBodyReplacement)); ModelReplacementAPI.RegisterSuitModelReplacement("Purple suit", typeof(CrowBodyReplacement)); ModelReplacementAPI.RegisterSuitModelReplacement("Bee suit", typeof(CrowBodyReplacement)); ModelReplacementAPI.RegisterSuitModelReplacement("Bunny suit", typeof(CrowBodyReplacement)); if (defaultToCrow.Value) { ModelReplacementAPI.RegisterModelReplacementDefault(typeof(CrowBodyReplacement)); } Harmony val = new Harmony("com.moopmantis.lethalcawmpany"); val.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.moopmantis.lethalcawmpany is loaded!"); } public static void ShowMessage(string s) { ((BaseUnityPlugin)Instance).Logger.LogMessage((object)s); } } public static class Assets { private static int CAW_COUNT = 2; private static Random random = null; public static string mainAssetBundleName = "crowbundle"; public static AssetBundle MainAssetBundle = null; public static AudioClip[] cawSounds = null; public static AudioClip GetAudioClipFromName(string name) { Object obj = MainAssetBundle.LoadAsset(name); return (AudioClip)(object)((obj is AudioClip) ? obj : 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); } cawSounds = (AudioClip[])(object)new AudioClip[CAW_COUNT]; random = new Random(); for (int i = 0; i < CAW_COUNT; i++) { cawSounds[i] = GetAudioClipFromName("caw" + (i + 1)); } } public static AudioClip GetRandomCaw() { return cawSounds[random.Next(cawSounds.Length)]; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }